Skip to content

Commit

Permalink
Merge pull request #234 from OHSUCMP/feature/issue232
Browse files Browse the repository at this point in the history
#232 - fix to edge-case Encounter Matcher bug
  • Loading branch information
mattStorer authored Dec 11, 2024
2 parents a0be030 + d7a0b9d commit 32ce2fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/main/java/edu/ohsu/cmp/coach/fhir/EncounterMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public boolean isHomeEncounter(Encounter e) {
}

private boolean encounterMatches(StringBuilder sb, Encounter e, List<Coding> classIn, List<Coding> classNotIn, List<Coding> typeIn, List<Coding> typeNotIn) {
if (classIn != null) {
if (classIn != null && ! classIn.isEmpty()) {
if (sb != null) sb.append("classInMatch? ");
boolean match = e.hasClass_() && inClass(sb, e.getClass_(), classIn);
if ( ! match ) {
Expand All @@ -70,12 +70,12 @@ private boolean encounterMatches(StringBuilder sb, Encounter e, List<Coding> cla
}
}

if (classNotIn != null) {
if (classNotIn != null && ! classNotIn.isEmpty()) {
if (sb != null) sb.append("classNotInMatch? ");
boolean match = ! e.hasClass_() || ! inClass(sb, e.getClass_(), classNotIn);
if ( ! match ) {
if (sb != null) sb.append("*NO* (class='")
.append(FhirUtil.toCodingString(e.getClass_()))
.append(toCodingDebugString(e.getClass_()))
.append("')");
return false;
} else if (sb != null) {
Expand All @@ -89,7 +89,7 @@ private boolean encounterMatches(StringBuilder sb, Encounter e, List<Coding> cla
}
}

if (typeIn != null) {
if (typeIn != null && ! typeIn.isEmpty()) {
if (sb != null) sb.append("typeInMatch? ");
boolean match = e.hasType() && inType(sb, e.getType(), typeIn);
if ( ! match ) {
Expand All @@ -100,7 +100,7 @@ private boolean encounterMatches(StringBuilder sb, Encounter e, List<Coding> cla
}
}

if (typeNotIn != null) {
if (typeNotIn != null && ! typeNotIn.isEmpty()) {
if (sb != null) sb.append("typeNotInMatch? ");
boolean match = ! e.hasType() || ! inType(sb, e.getType(), typeNotIn);
if ( ! match ) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/edu/ohsu/cmp/coach/util/FhirUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,9 @@ public static boolean codingMatches(Coding c, Coding spec, StringBuilder sb) {
if (spec.hasCode()) {
boolean codeMatches = c.hasCode() && c.getCode().equals(spec.getCode());
if (codeMatches) {
if (sb != null) sb.append("MATCH code='").append(spec.getSystem()).append("' ");
if (sb != null) sb.append("MATCH code='").append(spec.getCode()).append("' ");
} else {
if (sb != null) sb.append("DOES NOT MATCH code='").append(spec.getSystem()).append("' ");
if (sb != null) sb.append("DOES NOT MATCH code='").append(spec.getCode()).append("' ");
return false;
}
}
Expand All @@ -502,9 +502,9 @@ public static boolean codingMatches(Coding c, Coding spec, StringBuilder sb) {
if (spec.hasDisplay()) {
boolean displayMatches = c.hasDisplay() && c.getDisplay().equals(spec.getDisplay());
if (displayMatches) {
if (sb != null) sb.append("MATCH display='").append(spec.getSystem()).append("' ");
if (sb != null) sb.append("MATCH display='").append(spec.getDisplay()).append("' ");
} else {
if (sb != null) sb.append("DOES NOT MATCH display='").append(spec.getSystem()).append("' ");
if (sb != null) sb.append("DOES NOT MATCH display='").append(spec.getDisplay()).append("' ");
return false;
}
}
Expand Down

0 comments on commit 32ce2fb

Please sign in to comment.