diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java index 4f03d740b..92c208475 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java @@ -2977,10 +2977,10 @@ public class VersionConvertor_40_50 { return convertTime((org.hl7.fhir.r4.model.TimeType) src); if (src instanceof org.hl7.fhir.r4.model.UnsignedIntType) return convertUnsignedInt((org.hl7.fhir.r4.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.r4.model.UriType) - return convertUri((org.hl7.fhir.r4.model.UriType) src); if (src instanceof org.hl7.fhir.r4.model.UrlType) return convertUrl((org.hl7.fhir.r4.model.UrlType) src); + if (src instanceof org.hl7.fhir.r4.model.UriType) + return convertUri((org.hl7.fhir.r4.model.UriType) src); if (src instanceof org.hl7.fhir.r4.model.UuidType) return convertUuid((org.hl7.fhir.r4.model.UuidType) src); if (src instanceof org.hl7.fhir.r4.model.Extension) @@ -3103,10 +3103,10 @@ public class VersionConvertor_40_50 { return convertTime((org.hl7.fhir.r5.model.TimeType) src); if (src instanceof org.hl7.fhir.r5.model.UnsignedIntType) return convertUnsignedInt((org.hl7.fhir.r5.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.r5.model.UriType) - return convertUri((org.hl7.fhir.r5.model.UriType) src); if (src instanceof org.hl7.fhir.r5.model.UrlType) return convertUrl((org.hl7.fhir.r5.model.UrlType) src); + if (src instanceof org.hl7.fhir.r5.model.UriType) + return convertUri((org.hl7.fhir.r5.model.UriType) src); if (src instanceof org.hl7.fhir.r5.model.UuidType) return convertUuid((org.hl7.fhir.r5.model.UuidType) src); if (src instanceof org.hl7.fhir.r5.model.Extension) diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java index b98857e2f..2446eaff9 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java @@ -237,7 +237,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat throw new NotImplementedException("Not done yet (ValidatorHostServices.conformsToProfile), when item is element"); boolean ok = true; for (ValidationMessage v : valerrors) - ok = ok && v.getLevel().isError(); + ok = ok && !v.getLevel().isError(); return ok; } diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java index a1b4c8ebd..0caa647b7 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java @@ -125,25 +125,24 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour val.getContext().cacheResource(sd); } } + List errors = new ArrayList(); + if (name.startsWith("Json.")) + val.validate(null, errors, new FileInputStream(path), FhirFormat.JSON); + else + val.validate(null, errors, new FileInputStream(path), FhirFormat.XML); + checkOutcomes(errors, content); if (content.has("profile")) { - List errors = new ArrayList(); + List errorsProfile = new ArrayList(); JsonObject profile = content.getAsJsonObject("profile"); String filename = TestUtilities.resourceNameToFile("validation-examples", profile.get("source").getAsString()); String v = content.has("version") ? content.get("version").getAsString() : Constants.VERSION; StructureDefinition sd = loadProfile(filename, v); if (name.startsWith("Json.")) - val.validate(null, errors, new FileInputStream(path), FhirFormat.JSON, sd); + val.validate(null, errorsProfile, new FileInputStream(path), FhirFormat.JSON, sd); else - val.validate(null, errors, new FileInputStream(path), FhirFormat.XML, sd); - checkOutcomes(errors, profile); - } else { - List errors = new ArrayList(); - if (name.startsWith("Json.")) - val.validate(null, errors, new FileInputStream(path), FhirFormat.JSON); - else - val.validate(null, errors, new FileInputStream(path), FhirFormat.XML); - checkOutcomes(errors, content); - } + val.validate(null, errorsProfile, new FileInputStream(path), FhirFormat.XML, sd); + checkOutcomes(errorsProfile, profile); + } } public StructureDefinition loadProfile(String filename, String v) diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json b/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json index d181b8916..1005422ea 100644 --- a/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json @@ -388,6 +388,28 @@ "errorCount": 0, "warningCount": 1 }, + "patient-conform-profile.xml" : { + "errorCount": 0, + "warningCount": 1 + }, + "patient-bad-gender.xml" : { + "errorCount": 1, + "warningCount": 0, + "profile" : { + "source" : "patient-conform-profile.xml", + "errorCount": 2, + "warningCount": 0 + } + }, + "patient-warning-maritalstatus.xml" : { + "errorCount": 0, + "warningCount": 1, + "profile" : { + "source" : "patient-conform-profile.xml", + "errorCount": 0, + "warningCount": 1 + } + }, "document-good.xml" : { "errorCount": 0, "profiles" : ["document-section-library.xml"], diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/patient-bad-gender.xml b/org.hl7.fhir.validation/src/test/resources/validation-examples/patient-bad-gender.xml new file mode 100644 index 000000000..b1418a5d6 --- /dev/null +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/patient-bad-gender.xml @@ -0,0 +1,11 @@ + + + + +
+*FAILURE* validating ./examplesNonValid/patient/patient-error-gender.xml: error:1 warn:1 info:0 + Error @ Patient.gender (line 3, col34) : The value provided ('asdfafafafd') is not in the value set http://hl7.org/fhir/ValueSet/administrative-gender|4.0.0 (http://hl7.org/fhir/ValueSet/administrative-gender, and a code is required from this value set) (error message = Unknown Code org.hl7.fhir.r4.model.Coding@5ee34b1b in http://hl7.org/fhir/administrative-gender) +
+
+ +
\ No newline at end of file diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/patient-conform-profile.xml b/org.hl7.fhir.validation/src/test/resources/validation-examples/patient-conform-profile.xml new file mode 100644 index 000000000..23237668c --- /dev/null +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/patient-conform-profile.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/patient-warning-maritalstatus.xml b/org.hl7.fhir.validation/src/test/resources/validation-examples/patient-warning-maritalstatus.xml new file mode 100644 index 000000000..2e0fb74b7 --- /dev/null +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/patient-warning-maritalstatus.xml @@ -0,0 +1,17 @@ + + + + +
+Success...validating ./examplesNonValid/patient/patient-warning-maritalstatus.xml: error:0 warn:1 info:0 + Warning @ Patient.maritalStatus (line 9, col20) : None of the codes provided are in the value set http://hl7.org/fhir/ValueSet/marital-status (http://hl7.org/fhir/ValueSet/marital-status, and a code should come from this value set unless it has no suitable code) (codes = http://fhir.ch/whateversysstem#adfasfdf) +
+
+ + + + + + + +
\ No newline at end of file