diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e69de29bb..c1786be61 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -0,0 +1,14 @@ +Validator: +* Better validation of bad references (and fix NPE) +* Rework output to be more informative and cleaner +* Fix bugs in validation of nested bundles +* Fix bug loading package with no specified version +* fix bugs loading discovered packages on the fly +* Validator now supports logical models in XML wkith no namespaces + +Other code changes: +* Add version conversion for AllergyIntolerance (1.2 <-> 3.0 & 1.2 <-> 4.0) +* Add version conversion for MedicationRequest +* Fix rendering of documents +* fix for not rendering null values in patterns for must-support view + diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_30/AllergyIntolerance10_30.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_30/AllergyIntolerance10_30.java index 0baaa0f3f..fcb2bb778 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_30/AllergyIntolerance10_30.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_30/AllergyIntolerance10_30.java @@ -12,9 +12,9 @@ public class AllergyIntolerance10_30 { VersionConvertor_10_30.copyDomainResource(src, tgt); for (org.hl7.fhir.dstu2.model.Identifier identifier : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_30.convertIdentifier(identifier)); if (src.hasOnset()) - tgt.setOnset(new org.hl7.fhir.dstu3.model.DateTimeType(src.getOnset())); + tgt.setOnset(VersionConvertor_10_30.convertDateTime(src.getOnsetElement())); if (src.hasRecordedDate()) - tgt.setAssertedDate(src.getRecordedDate()); + tgt.setAssertedDateElement(VersionConvertor_10_30.convertDateTime(src.getRecordedDateElement())); if (src.hasRecorder()) tgt.setRecorder(VersionConvertor_10_30.convertReference(src.getRecorder())); if (src.hasPatient()) @@ -40,7 +40,7 @@ public class AllergyIntolerance10_30 { if (src.hasCategory()) tgt.addCategory(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.fromCode(src.getCategory().toCode())); if (src.hasLastOccurence()) - tgt.setLastOccurrence(src.getLastOccurence()); + tgt.setLastOccurrenceElement(VersionConvertor_10_30.convertDateTime(src.getLastOccurenceElement())); if (src.hasNote()) tgt.addNote(VersionConvertor_10_30.convertAnnotation(src.getNote())); for (org.hl7.fhir.dstu2.model.AllergyIntolerance.AllergyIntoleranceReactionComponent reaction : src.getReaction()) @@ -63,9 +63,9 @@ public class AllergyIntolerance10_30 { )); for (org.hl7.fhir.dstu2.model.CodeableConcept concept : src.getManifestation()) tgt.addManifestation(VersionConvertor_10_30.convertCodeableConcept(concept)); if (src.hasDescription()) - src.setDescription(src.getDescription()); + tgt.setDescriptionElement(VersionConvertor_10_30.convertString(src.getDescriptionElement())); if (src.hasOnset()) - tgt.setOnset(src.getOnset()); + tgt.setOnsetElement(VersionConvertor_10_30.convertDateTime(src.getOnsetElement())); if (src.hasSeverity()) tgt.setSeverity(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity.fromCode(src.getSeverity().toCode())); if (src.hasExposureRoute()) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/AllergyIntolerance10_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/AllergyIntolerance10_40.java index 0f9760ff9..e5c51c648 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/AllergyIntolerance10_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/AllergyIntolerance10_40.java @@ -13,7 +13,7 @@ public class AllergyIntolerance10_40 { if (src.hasOnset()) tgt.setOnset(VersionConvertor_10_40.convertType(src.getOnsetElement())); if (src.hasRecordedDate()) - tgt.setRecordedDate(src.getRecordedDate()); + tgt.setRecordedDateElement(VersionConvertor_10_40.convertDateTime(src.getRecordedDateElement())); if (src.hasRecorder()) tgt.setRecorder(VersionConvertor_10_40.convertReference(src.getRecorder())); if (src.hasPatient()) @@ -44,8 +44,8 @@ public class AllergyIntolerance10_40 { tgt.setType(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType.fromCode(src.getType().toCode())); if (src.hasCategory()) tgt.addCategory(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory.fromCode(src.getCategory().toCode())); - if (src.hasLastOccurence()) - tgt.setLastOccurrence(src.getLastOccurence()); + if (src.hasLastOccurenceElement()) + tgt.setLastOccurrenceElement(VersionConvertor_10_40.convertDateTime(src.getLastOccurenceElement())); if (src.hasNote()) tgt.addNote(VersionConvertor_10_40.convertAnnotation(src.getNote())); for (org.hl7.fhir.dstu2.model.AllergyIntolerance.AllergyIntoleranceReactionComponent reaction : src.getReaction()) @@ -68,9 +68,9 @@ public class AllergyIntolerance10_40 { )); for (org.hl7.fhir.dstu2.model.CodeableConcept concept : src.getManifestation()) tgt.addManifestation(VersionConvertor_10_40.convertCodeableConcept(concept)); if (src.hasDescription()) - src.setDescription(src.getDescription()); + tgt.setDescriptionElement(VersionConvertor_10_40.convertString(src.getDescriptionElement())); if (src.hasOnset()) - tgt.setOnset(src.getOnset()); + tgt.setOnsetElement(VersionConvertor_10_40.convertDateTime(src.getOnsetElement())); if (src.hasSeverity()) tgt.setSeverity(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceSeverity.fromCode(src.getSeverity().toCode())); if (src.hasExposureRoute()) diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_30/AllergyIntolerance10_30Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_30/AllergyIntolerance10_30Test.java index 920c0df9e..e2c5ab5fd 100644 --- a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_30/AllergyIntolerance10_30Test.java +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_30/AllergyIntolerance10_30Test.java @@ -36,6 +36,14 @@ public class AllergyIntolerance10_30Test { org.hl7.fhir.dstu3.formats.JsonParser stu_parser = new org.hl7.fhir.dstu3.formats.JsonParser(); org.hl7.fhir.dstu3.model.Resource stu_expected = stu_parser.parse(stu_exepected_input); + if (!stu_expected.equalsDeep(stu_actual)) { + System.out.println("Expected"); + System.out.println(stu_parser.composeString(stu_expected)); + System.out.println(); + System.out.println("Actual"); + System.out.println(stu_parser.composeString(stu_actual)); + } + Assertions.assertTrue(stu_expected.equalsDeep(stu_actual), "Failed comparing\n" + stu_parser.composeString(stu_actual) + "\nand\n" + stu_parser.composeString(stu_expected) ); diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/AllergyIntolerance10_40Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/AllergyIntolerance10_40Test.java index e1cf86214..6dc3cba82 100644 --- a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/AllergyIntolerance10_40Test.java +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/AllergyIntolerance10_40Test.java @@ -36,8 +36,14 @@ public class AllergyIntolerance10_40Test { org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser(); org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input); - Assertions.assertTrue(r4_expected.equalsDeep(r4_actual), - "Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected) + if (!r4_expected.equalsDeep(r4_actual)) { + System.out.println("Expected"); + System.out.println(r4_parser.composeString(r4_expected)); + System.out.println(); + System.out.println("Actual"); + System.out.println(r4_parser.composeString(r4_actual)); + } + Assertions.assertTrue(r4_expected.equalsDeep(r4_actual), "Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected) ); } } diff --git a/org.hl7.fhir.convertors/src/test/resources/0_allergy_intolerance_10.json b/org.hl7.fhir.convertors/src/test/resources/0_allergy_intolerance_10.json index 6289fa81f..7c008a863 100644 --- a/org.hl7.fhir.convertors/src/test/resources/0_allergy_intolerance_10.json +++ b/org.hl7.fhir.convertors/src/test/resources/0_allergy_intolerance_10.json @@ -1,20 +1,42 @@ -{"resourceType": "AllergyIntolerance", - "recordedDate": "2015-08-25T02:11:36", - "status": "confirmed", - "criticality": "CRITL", - "id": "TBwnNbrAqC0Qw5Ha7AFT-2AB", - "onset": "2012-11-07T00:00:00Z", - "recorder": {"display": "MOORE, NICK", - "reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/TItWfhjChtlo0pFh9nzctSQB"}, - "patient": {"display": "Jason Argonaut", - "reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB"}, - "substance": {"text": "PENICILLIN G", - "coding": [{"system": "http://www.nlm.nih.gov/research/umls/rxnorm", - "code": "7980", - "display": "PENICILLIN G"}, - {"system": "http://fdasis.nlm.nih.gov", - "code": "Q42T66VG0C", - "display": "PENICILLIN G"}]}, - "reaction": [{"certainty": "confirmed", - "onset": "2012-11-07T00:00:00Z", - "manifestation": [{"text": "Hives"}]}]} \ No newline at end of file +{ + "resourceType" : "AllergyIntolerance", + "recordedDate" : "2015-08-25T02:11:36", + "status" : "confirmed", + "criticality" : "CRITL", + "id" : "TBwnNbrAqC0Qw5Ha7AFT-2AB", + "onset" : "2012-11-07T00:00:00Z", + "recorder" : { + "display" : "MOORE, NICK", + "reference" : "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/TItWfhjChtlo0pFh9nzctSQB" + }, + "patient" : { + "display" : "Jason Argonaut", + "reference" : "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB" + }, + "substance" : { + "text" : "PENICILLIN G", + "coding" : [ + { + "system" : "http://www.nlm.nih.gov/research/umls/rxnorm", + "code" : "7980", + "display" : "PENICILLIN G" + }, + { + "system" : "http://fdasis.nlm.nih.gov", + "code" : "Q42T66VG0C", + "display" : "PENICILLIN G" + } + ] + }, + "reaction" : [ + { + "certainty" : "confirmed", + "onset" : "2012-11-07T00:00:00Z", + "manifestation" : [ + { + "text" : "Hives" + } + ] + } + ] +} diff --git a/org.hl7.fhir.convertors/src/test/resources/0_allergy_intolerance_30.json b/org.hl7.fhir.convertors/src/test/resources/0_allergy_intolerance_30.json index b163ced15..be78790a9 100644 --- a/org.hl7.fhir.convertors/src/test/resources/0_allergy_intolerance_30.json +++ b/org.hl7.fhir.convertors/src/test/resources/0_allergy_intolerance_30.json @@ -1,22 +1,48 @@ -{"resourceType": "AllergyIntolerance", - "id": "TBwnNbrAqC0Qw5Ha7AFT-2AB", - "clinicalStatus": "active", - "verificationStatus": "confirmed", - "criticality": "low", - "code": {"coding": [{"system": "http://www.nlm.nih.gov/research/umls/rxnorm", - "code": "7980", - "display": "PENICILLIN G"}, - {"system": "http://fdasis.nlm.nih.gov", - "code": "Q42T66VG0C", - "display": "PENICILLIN G"}], - "text": "PENICILLIN G"}, - "patient": {"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB", - "display": "Jason Argonaut"}, - "onsetDateTime": "2012-11-07T00:00:00", - "assertedDate": "2015-08-25T02:11:36", - "recorder": {"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/TItWfhjChtlo0pFh9nzctSQB", - "display": "MOORE, NICK"}, - "reaction": [{"extension": [{"url": "http://hl7.org/fhir/AllergyIntolerance-r2-certainty", - "valueString": "confirmed"}], - "manifestation": [{"text": "Hives"}], - "onset": "2012-11-07T00:00:00"}]} +{ + "resourceType" : "AllergyIntolerance", + "id" : "TBwnNbrAqC0Qw5Ha7AFT-2AB", + "clinicalStatus" : "active", + "verificationStatus" : "confirmed", + "criticality" : "low", + "code" : { + "coding" : [ + { + "system" : "http://www.nlm.nih.gov/research/umls/rxnorm", + "code" : "7980", + "display" : "PENICILLIN G" + }, + { + "system" : "http://fdasis.nlm.nih.gov", + "code" : "Q42T66VG0C", + "display" : "PENICILLIN G" + } + ], + "text" : "PENICILLIN G" + }, + "patient" : { + "reference" : "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB", + "display" : "Jason Argonaut" + }, + "onsetDateTime" : "2012-11-07T00:00:00Z", + "assertedDate" : "2015-08-25T02:11:36", + "recorder" : { + "reference" : "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/TItWfhjChtlo0pFh9nzctSQB", + "display" : "MOORE, NICK" + }, + "reaction" : [ + { + "extension" : [ + { + "url" : "http://hl7.org/fhir/AllergyIntolerance-r2-certainty", + "valueString" : "confirmed" + } + ], + "manifestation" : [ + { + "text" : "Hives" + } + ], + "onset" : "2012-11-07T00:00:00Z" + } + ] +} diff --git a/org.hl7.fhir.convertors/src/test/resources/0_allergy_intolerance_40.json b/org.hl7.fhir.convertors/src/test/resources/0_allergy_intolerance_40.json index 74030f0db..e02782189 100644 --- a/org.hl7.fhir.convertors/src/test/resources/0_allergy_intolerance_40.json +++ b/org.hl7.fhir.convertors/src/test/resources/0_allergy_intolerance_40.json @@ -1,23 +1,61 @@ -{"resourceType": "AllergyIntolerance", - "clinicalStatus": {"coding": [{"system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical", - "code": "confirmed"}]}, - "verificationStatus": {"coding": [{"system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", - "code": "confirmed"}]}, - "criticality": "low", - "code": {"coding": [{"system": "http://www.nlm.nih.gov/research/umls/rxnorm", - "code": "7980", - "display": "PENICILLIN G"}, - {"system": "http://fdasis.nlm.nih.gov", - "code": "Q42T66VG0C", - "display": "PENICILLIN G"}], - "text": "PENICILLIN G"}, - "patient": {"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB", - "display": "Jason Argonaut"}, - "onsetDateTime": "2012-11-07T00:00:00Z", - "recordedDate": "2015-08-25T02:11:36", - "recorder": {"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/TItWfhjChtlo0pFh9nzctSQB", - "display": "MOORE, NICK"}, - "reaction": [{"extension": [{"url": "http://hl7.org/fhir/AllergyIntolerance-r2-certainty", - "valueString": "confirmed"}], - "manifestation": [{"text": "Hives"}], - "onset": "2012-11-07T00:00:00"}]} \ No newline at end of file +{ + "resourceType" : "AllergyIntolerance", + "clinicalStatus" : { + "coding" : [ + { + "system" : "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical", + "code" : "confirmed" + } + ] + }, + "verificationStatus" : { + "coding" : [ + { + "system" : "http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", + "code" : "confirmed" + } + ] + }, + "criticality" : "low", + "code" : { + "coding" : [ + { + "system" : "http://www.nlm.nih.gov/research/umls/rxnorm", + "code" : "7980", + "display" : "PENICILLIN G" + }, + { + "system" : "http://fdasis.nlm.nih.gov", + "code" : "Q42T66VG0C", + "display" : "PENICILLIN G" + } + ], + "text" : "PENICILLIN G" + }, + "patient" : { + "reference" : "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB", + "display" : "Jason Argonaut" + }, + "onsetDateTime" : "2012-11-07T00:00:00Z", + "recordedDate" : "2015-08-25T02:11:36", + "recorder" : { + "reference" : "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/TItWfhjChtlo0pFh9nzctSQB", + "display" : "MOORE, NICK" + }, + "reaction" : [ + { + "extension" : [ + { + "url" : "http://hl7.org/fhir/AllergyIntolerance-r2-certainty", + "valueString" : "confirmed" + } + ], + "manifestation" : [ + { + "text" : "Hives" + } + ], + "onset" : "2012-11-07T00:00:00Z" + } + ] +} diff --git a/org.hl7.fhir.convertors/src/test/resources/1_allergy_intolerance_30.json b/org.hl7.fhir.convertors/src/test/resources/1_allergy_intolerance_30.json index 36324bff6..0e8ebd1fe 100644 --- a/org.hl7.fhir.convertors/src/test/resources/1_allergy_intolerance_30.json +++ b/org.hl7.fhir.convertors/src/test/resources/1_allergy_intolerance_30.json @@ -1,22 +1,48 @@ -{"resourceType": "AllergyIntolerance", - "id": "TKebKfLXzu6Sp.LY-IpvpmQB", - "clinicalStatus": "active", - "verificationStatus": "confirmed", - "criticality": "high", - "code": {"coding": [{"system": "http://www.nlm.nih.gov/research/umls/rxnorm", - "code": "892484", - "display": "STRAWBERRY"}, - {"system": "http://fdasis.nlm.nih.gov", - "code": "4J2TY8Y81V", - "display": "STRAWBERRY"}], - "text": "STRAWBERRY"}, - "patient": {"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB", - "display": "Jason Argonaut"}, - "onsetDateTime": "2014-03-07T00:00:00", - "assertedDate": "2015-11-07T22:56:34", - "recorder": {"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/TItWfhjChtlo0pFh9nzctSQB", - "display": "MOORE, NICK"}, - "reaction": [{"extension": [{"url": "http://hl7.org/fhir/AllergyIntolerance-r2-certainty", - "valueString": "confirmed"}], - "manifestation": [{"text": "Anaphylaxis"}], - "onset": "2014-03-07T00:00:00"}]} \ No newline at end of file +{ + "resourceType" : "AllergyIntolerance", + "id" : "TKebKfLXzu6Sp.LY-IpvpmQB", + "clinicalStatus" : "active", + "verificationStatus" : "confirmed", + "criticality" : "high", + "code" : { + "coding" : [ + { + "system" : "http://www.nlm.nih.gov/research/umls/rxnorm", + "code" : "892484", + "display" : "STRAWBERRY" + }, + { + "system" : "http://fdasis.nlm.nih.gov", + "code" : "4J2TY8Y81V", + "display" : "STRAWBERRY" + } + ], + "text" : "STRAWBERRY" + }, + "patient" : { + "reference" : "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB", + "display" : "Jason Argonaut" + }, + "onsetDateTime" : "2014-03-07T00:00:00Z", + "assertedDate" : "2015-11-07T22:56:34", + "recorder" : { + "reference" : "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/TItWfhjChtlo0pFh9nzctSQB", + "display" : "MOORE, NICK" + }, + "reaction" : [ + { + "extension" : [ + { + "url" : "http://hl7.org/fhir/AllergyIntolerance-r2-certainty", + "valueString" : "confirmed" + } + ], + "manifestation" : [ + { + "text" : "Anaphylaxis" + } + ], + "onset" : "2014-03-07T00:00:00Z" + } + ] +} diff --git a/org.hl7.fhir.convertors/src/test/resources/1_allergy_intolerance_40.json b/org.hl7.fhir.convertors/src/test/resources/1_allergy_intolerance_40.json index cbb724f7d..a38da25a8 100644 --- a/org.hl7.fhir.convertors/src/test/resources/1_allergy_intolerance_40.json +++ b/org.hl7.fhir.convertors/src/test/resources/1_allergy_intolerance_40.json @@ -1,23 +1,61 @@ -{"resourceType": "AllergyIntolerance", - "clinicalStatus": {"coding": [{"system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical", - "code": "confirmed"}]}, - "verificationStatus": {"coding": [{"system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", - "code": "confirmed"}]}, - "criticality": "high", - "code": {"coding": [{"system": "http://www.nlm.nih.gov/research/umls/rxnorm", - "code": "892484", - "display": "STRAWBERRY"}, - {"system": "http://fdasis.nlm.nih.gov", - "code": "4J2TY8Y81V", - "display": "STRAWBERRY"}], - "text": "STRAWBERRY"}, - "patient": {"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB", - "display": "Jason Argonaut"}, - "onsetDateTime": "2014-03-07T00:00:00Z", - "recordedDate": "2015-11-07T22:56:34", - "recorder": {"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/TItWfhjChtlo0pFh9nzctSQB", - "display": "MOORE, NICK"}, - "reaction": [{"extension": [{"url": "http://hl7.org/fhir/AllergyIntolerance-r2-certainty", - "valueString": "confirmed"}], - "manifestation": [{"text": "Anaphylaxis"}], - "onset": "2014-03-07T00:00:00"}]} +{ + "resourceType" : "AllergyIntolerance", + "clinicalStatus" : { + "coding" : [ + { + "system" : "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical", + "code" : "confirmed" + } + ] + }, + "verificationStatus" : { + "coding" : [ + { + "system" : "http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", + "code" : "confirmed" + } + ] + }, + "criticality" : "high", + "code" : { + "coding" : [ + { + "system" : "http://www.nlm.nih.gov/research/umls/rxnorm", + "code" : "892484", + "display" : "STRAWBERRY" + }, + { + "system" : "http://fdasis.nlm.nih.gov", + "code" : "4J2TY8Y81V", + "display" : "STRAWBERRY" + } + ], + "text" : "STRAWBERRY" + }, + "patient" : { + "reference" : "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB", + "display" : "Jason Argonaut" + }, + "onsetDateTime" : "2014-03-07T00:00:00Z", + "recordedDate" : "2015-11-07T22:56:34", + "recorder" : { + "reference" : "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/TItWfhjChtlo0pFh9nzctSQB", + "display" : "MOORE, NICK" + }, + "reaction" : [ + { + "extension" : [ + { + "url" : "http://hl7.org/fhir/AllergyIntolerance-r2-certainty", + "valueString" : "confirmed" + } + ], + "manifestation" : [ + { + "text" : "Anaphylaxis" + } + ], + "onset" : "2014-03-07T00:00:00Z" + } + ] +} diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java index 4e4fbecce..d258606dc 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java @@ -331,6 +331,7 @@ public class I18nConstants { public static final String REFERENCE_REF_NOTFOUND_BUNDLE = "Reference_REF_NotFound_Bundle"; public static final String REFERENCE_REF_NOTYPE = "Reference_REF_NoType"; public static final String REFERENCE_REF_RESOURCETYPE = "Reference_REF_ResourceType"; + public static final String REFERENCE_REF_SUSPICIOUS = "REFERENCE_REF_SUSPICIOUS"; public static final String REFERENCE_REF_WRONGTARGET = "Reference_REF_WrongTarget"; public static final String REFERENCE_TO__CANNOT_BE_RESOLVED = "reference_to__cannot_be_resolved"; public static final String REFERENCE__REFERS_TO_A__NOT_A_VALUESET = "Reference__refers_to_a__not_a_ValueSet"; diff --git a/org.hl7.fhir.utilities/src/main/resources/Messages.properties b/org.hl7.fhir.utilities/src/main/resources/Messages.properties index 481342e10..a72555b61 100644 --- a/org.hl7.fhir.utilities/src/main/resources/Messages.properties +++ b/org.hl7.fhir.utilities/src/main/resources/Messages.properties @@ -604,3 +604,4 @@ FHIRPATH_BAD_DATE = Unable to parse Date {0} FHIRPATH_NUMERICAL_ONLY = Error evaluating FHIRPath expression: The function {0} can only be used on integer, decimal or Quantity but found {1} FHIRPATH_DECIMAL_ONLY = Error evaluating FHIRPath expression: The function {0} can only be used on a decimal but found {1} FHIRPATH_FOCUS_PLURAL = Error evaluating FHIRPath expression: focus for {0} has more than one value +REFERENCE_REF_SUSPICIOUS = The syntax of the reference ''{0}'' looks incorrect, and it should be checked diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java index 48179bc5e..517b06b11 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java @@ -2398,6 +2398,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat // special known URLs that can't be validated but are known to be valid return; } + warning(errors, IssueType.STRUCTURE, element.line(), element.col(), path, !isSuspiciousReference(ref), I18nConstants.REFERENCE_REF_SUSPICIOUS, ref); ResolvedReference we = localResolve(ref, stack, errors, path, (Element) hostContext.getAppContext(), element); String refType; @@ -2439,10 +2440,11 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat } String ft; - if (we != null) + if (we != null) { ft = we.getType(); - else + } else { ft = tryParse(ref); + } if (reference.hasType()) { // R4 onwards... // the type has to match the specified @@ -2596,6 +2598,20 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat } } + private boolean isSuspiciousReference(String url) { + if (!assumeValidRestReferences || url == null || Utilities.isAbsoluteUrl(url)) { + return false; + } + String[] parts = url.split("\\/"); + if (parts.length == 2 && context.getResourceNames().contains(parts[0]) && Utilities.isValidId(parts[1])) { + return false; + } + if (parts.length == 4 && context.getResourceNames().contains(parts[0]) && Utilities.isValidId(parts[1]) && "_history".equals(parts[2]) && Utilities.isValidId(parts[3])) { + return false; + } + return true; + } + private String asListByUrl(Collection list) { CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); for (StructureDefinition sd : list) { @@ -4842,7 +4858,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat case 2: return checkResourceType(parts[0]); default: - if (parts[parts.length - 2].equals("_history")) + if (parts[parts.length - 2].equals("_history") && parts.length >= 4) return checkResourceType(parts[parts.length - 4]); else return checkResourceType(parts[parts.length - 2]);