Skip to content

Commit

Permalink
minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pnrobinson committed Aug 23, 2023
1 parent 43f378b commit b744f70
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class TimePointParser {


/** gets 2 dats before presentation, Two days before presentation etc.*/
private final Pattern pattern1 = Pattern.compile("\\b\\w+\\b\\s+(hours?|days?|weeks?|months?|years?|decades?) before presentation",Pattern.CASE_INSENSITIVE);
private final Pattern pattern1 = Pattern.compile("\\b\\w+\\b\\s+(hours?|days?|weeks?|months?|years?|decades?) before (the current )?presentation",Pattern.CASE_INSENSITIVE);

private final Pattern pattern2 = Pattern.compile("\\b\\w+\\b\\s+(hours?|days?|weeks?|months?|years?|decades?) earlier",Pattern.CASE_INSENSITIVE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ private String stripFamilyHistoryAndPmh(String originalSeg) {
for (var line : lines) {
if (line.toLowerCase().contains("family history")) continue;
if (line.toLowerCase().contains("medical history")) continue;
if (line.toLowerCase().contains(" mother ")) continue; // e.g. the patient's mother had
if (line.toLowerCase().contains(" father ")) continue;
validLines.add(line);
}
return String.join(". ", validLines);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ protected String getPhenopacketTextWithManualAdditions() {
vignette = vignette.substring(ii + 1);
List<TimePoint> timePointList = timePointParser.getTimePoints(vignette);



try {
Map<String, String> timeSegments = timeSegments(vignette, timePointList);
for (var entry : timeSegments.entrySet()) {
Expand All @@ -85,6 +83,7 @@ protected String getPhenopacketTextWithManualAdditions() {
.append("\n");
}
if (familyHistory.size() > 0) {
sb.append("The family history was notable for the following. ");
for (String item: familyHistory) {
sb.append(item).append("\n");
}
Expand Down Expand Up @@ -150,8 +149,9 @@ protected String getPhenopacketBasedQuerySegmentWithAdditions(String presentatio
capitalizedTimepoint = presentationTimeDescription.substring(0, 1).toUpperCase() + presentationTimeDescription.substring(1);
}

sb.append(capitalizedTimepoint);
sb.append(capitalizedTimepoint).append(" ");
boolean observedEmpty = true;
boolean needEmpty = true;
if (!observed_terms.isEmpty()) {
observedEmpty = false;
if (capitalizedTimepoint.isEmpty()) {
Expand All @@ -166,20 +166,23 @@ protected String getPhenopacketBasedQuerySegmentWithAdditions(String presentatio
sb.append(observedSymptoms).append(" \n");
}
if (!excluded_terms.isEmpty()) {
if (needEmpty) { sb.append(" "); needEmpty = false; }
String excludededSymptoms = getOxfordCommaList(excluded_terms);
if (observedEmpty) {
sb.append(", the following signs and symptoms were excluded: ");
sb.append("The following signs and symptoms were excluded: ");
} else {
sb.append("The following signs and symptoms were excluded: ");
}
sb.append(excludededSymptoms).append("\n");
}
if (! diagnostics.isEmpty()) {
if (needEmpty) { sb.append(" "); needEmpty = false; }
sb.append("The following diagnostic observations were made: ");
sb.append(getOxfordCommaList(diagnostics));
sb.append("\n");
}
if (! treatment.isEmpty()) {
if (needEmpty) { sb.append(" "); needEmpty = false; }
sb.append("The following treatments were administered: ");
sb.append(getOxfordCommaList(treatment));
sb.append("\n");
Expand Down

0 comments on commit b744f70

Please sign in to comment.