From 6b5ca97aa8c103753b930689955e3bc32d087400 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 15 Sep 2023 12:46:45 -0700 Subject: [PATCH] Fix error in Comparisons --- .../fhir/r5/comparison/ComparisonSession.java | 4 +-- .../StructureDefinitionComparer.java | 26 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonSession.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonSession.java index 6f905935f..3c05b67dc 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonSession.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonSession.java @@ -109,9 +109,9 @@ public class ComparisonSession { throw new FHIRException("Unable to compare resources of type "+left.fhirType()+" and "+right.fhirType()); } } catch (Throwable e) { -// if (debug) { + if (debug) { e.printStackTrace(); -// } + } ResourceComparer.PlaceHolderComparison csc = new ResourceComparer.PlaceHolderComparison(left, right, e); compares.put(key, csc); return csc; diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/StructureDefinitionComparer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/StructureDefinitionComparer.java index 8fbc6f7b4..a4874833e 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/StructureDefinitionComparer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/StructureDefinitionComparer.java @@ -906,10 +906,15 @@ public class StructureDefinitionComparer extends CanonicalResourceComparer imple } else if (derivesFrom(sdnw, sdex, ctxt)) { tfound = true; } else if (sdnw.getSnapshot().getElement().get(0).getPath().equals(sdex.getSnapshot().getElement().get(0).getPath())) { - ProfileComparison compP = (ProfileComparison) session.compare(sdex, sdnw); - if (compP.getUnion() != null) { - tfound = true; - ex.addTargetProfile("#"+compP.getId()); + ResourceComparison cmp = session.compare(sdex, sdnw); + if (cmp instanceof ProfileComparison) { + ProfileComparison compP = (ProfileComparison) cmp; + if (compP.getUnion() != null) { + tfound = true; + ex.addTargetProfile("#"+compP.getId()); + } + } else { + // ? } } } @@ -973,10 +978,15 @@ public class StructureDefinitionComparer extends CanonicalResourceComparer imple c.setProfile(r.getProfile()); pfound = true; } else if (sdl.getType().equals(sdr.getType())) { - ProfileComparison compP = (ProfileComparison) session.compare(sdl, sdr); - if (compP != null && compP.getIntersection() != null) { - pfound = true; - c.addProfile("#"+compP.getId()); + ResourceComparison cmp = session.compare(sdl, sdr); + if (cmp instanceof ProfileComparison) { + ProfileComparison compP = (ProfileComparison) cmp; + if (compP != null && compP.getIntersection() != null) { + pfound = true; + c.addProfile("#"+compP.getId()); + } + } else { + // not sure how to handle this error? } } }