Merge pull request #10 from ahdis/oliveregger_conformsto
[GF#20482] FHIRPath conformsTo Validation of Warnings/Error handling
This commit is contained in:
commit
56d22bc2ee
|
@ -2977,10 +2977,10 @@ public class VersionConvertor_40_50 {
|
||||||
return convertTime((org.hl7.fhir.r4.model.TimeType) src);
|
return convertTime((org.hl7.fhir.r4.model.TimeType) src);
|
||||||
if (src instanceof org.hl7.fhir.r4.model.UnsignedIntType)
|
if (src instanceof org.hl7.fhir.r4.model.UnsignedIntType)
|
||||||
return convertUnsignedInt((org.hl7.fhir.r4.model.UnsignedIntType) src);
|
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)
|
if (src instanceof org.hl7.fhir.r4.model.UrlType)
|
||||||
return convertUrl((org.hl7.fhir.r4.model.UrlType) src);
|
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)
|
if (src instanceof org.hl7.fhir.r4.model.UuidType)
|
||||||
return convertUuid((org.hl7.fhir.r4.model.UuidType) src);
|
return convertUuid((org.hl7.fhir.r4.model.UuidType) src);
|
||||||
if (src instanceof org.hl7.fhir.r4.model.Extension)
|
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);
|
return convertTime((org.hl7.fhir.r5.model.TimeType) src);
|
||||||
if (src instanceof org.hl7.fhir.r5.model.UnsignedIntType)
|
if (src instanceof org.hl7.fhir.r5.model.UnsignedIntType)
|
||||||
return convertUnsignedInt((org.hl7.fhir.r5.model.UnsignedIntType) src);
|
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)
|
if (src instanceof org.hl7.fhir.r5.model.UrlType)
|
||||||
return convertUrl((org.hl7.fhir.r5.model.UrlType) src);
|
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)
|
if (src instanceof org.hl7.fhir.r5.model.UuidType)
|
||||||
return convertUuid((org.hl7.fhir.r5.model.UuidType) src);
|
return convertUuid((org.hl7.fhir.r5.model.UuidType) src);
|
||||||
if (src instanceof org.hl7.fhir.r5.model.Extension)
|
if (src instanceof org.hl7.fhir.r5.model.Extension)
|
||||||
|
|
|
@ -237,7 +237,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
throw new NotImplementedException("Not done yet (ValidatorHostServices.conformsToProfile), when item is element");
|
throw new NotImplementedException("Not done yet (ValidatorHostServices.conformsToProfile), when item is element");
|
||||||
boolean ok = true;
|
boolean ok = true;
|
||||||
for (ValidationMessage v : valerrors)
|
for (ValidationMessage v : valerrors)
|
||||||
ok = ok && v.getLevel().isError();
|
ok = ok && !v.getLevel().isError();
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,24 +125,23 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
|
||||||
val.getContext().cacheResource(sd);
|
val.getContext().cacheResource(sd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (content.has("profile")) {
|
|
||||||
List<ValidationMessage> errors = new ArrayList<ValidationMessage>();
|
|
||||||
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);
|
|
||||||
else
|
|
||||||
val.validate(null, errors, new FileInputStream(path), FhirFormat.XML, sd);
|
|
||||||
checkOutcomes(errors, profile);
|
|
||||||
} else {
|
|
||||||
List<ValidationMessage> errors = new ArrayList<ValidationMessage>();
|
List<ValidationMessage> errors = new ArrayList<ValidationMessage>();
|
||||||
if (name.startsWith("Json."))
|
if (name.startsWith("Json."))
|
||||||
val.validate(null, errors, new FileInputStream(path), FhirFormat.JSON);
|
val.validate(null, errors, new FileInputStream(path), FhirFormat.JSON);
|
||||||
else
|
else
|
||||||
val.validate(null, errors, new FileInputStream(path), FhirFormat.XML);
|
val.validate(null, errors, new FileInputStream(path), FhirFormat.XML);
|
||||||
checkOutcomes(errors, content);
|
checkOutcomes(errors, content);
|
||||||
|
if (content.has("profile")) {
|
||||||
|
List<ValidationMessage> errorsProfile = new ArrayList<ValidationMessage>();
|
||||||
|
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, errorsProfile, new FileInputStream(path), FhirFormat.JSON, sd);
|
||||||
|
else
|
||||||
|
val.validate(null, errorsProfile, new FileInputStream(path), FhirFormat.XML, sd);
|
||||||
|
checkOutcomes(errorsProfile, profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -388,6 +388,28 @@
|
||||||
"errorCount": 0,
|
"errorCount": 0,
|
||||||
"warningCount": 1
|
"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" : {
|
"document-good.xml" : {
|
||||||
"errorCount": 0,
|
"errorCount": 0,
|
||||||
"profiles" : ["document-section-library.xml"],
|
"profiles" : ["document-section-library.xml"],
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<Patient xmlns="http://hl7.org/fhir">
|
||||||
|
<id value="patient-error-gender"/>
|
||||||
|
<text>
|
||||||
|
<status value="generated"/>
|
||||||
|
<div xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
*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)
|
||||||
|
</div>
|
||||||
|
</text>
|
||||||
|
<gender value="asdfafafafd"/>
|
||||||
|
</Patient>
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<StructureDefinition xmlns="http://hl7.org/fhir">
|
||||||
|
<id value="patient-conform-profile" />
|
||||||
|
<url
|
||||||
|
value="http://hl7.org/fhir/StructureDefinition/patient-conform-profile" />
|
||||||
|
<name value="PatientConformProfile" />
|
||||||
|
<status value="draft" />
|
||||||
|
<description
|
||||||
|
value="Test profile to test if a patient with warning or errors in valdidation is conformant to a profile" />
|
||||||
|
<kind value="resource" />
|
||||||
|
<abstract value="false" />
|
||||||
|
<type value="Patient" />
|
||||||
|
<baseDefinition
|
||||||
|
value="http://hl7.org/fhir/StructureDefinition/Patient" />
|
||||||
|
<derivation value="constraint" />
|
||||||
|
<differential>
|
||||||
|
<element id="Patient">
|
||||||
|
<path value="Patient" />
|
||||||
|
<constraint>
|
||||||
|
<key value="conformsToCheck" />
|
||||||
|
<severity value="error" />
|
||||||
|
<human value="conformsToCheck" />
|
||||||
|
<expression
|
||||||
|
value="conformsTo('http://hl7.org/fhir/StructureDefinition/Patient')" />
|
||||||
|
</constraint>
|
||||||
|
</element>
|
||||||
|
</differential>
|
||||||
|
</StructureDefinition>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<Patient xmlns="http://hl7.org/fhir">
|
||||||
|
<id value="patient-warning-maritalstatus"/>
|
||||||
|
<text>
|
||||||
|
<status value="generated"/>
|
||||||
|
<div xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
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)
|
||||||
|
</div>
|
||||||
|
</text>
|
||||||
|
<maritalStatus>
|
||||||
|
<coding>
|
||||||
|
<system value="http://fhir.ch/whateversysstem"/>
|
||||||
|
<code value="adfasfdf"/>
|
||||||
|
<display value="I dont know what this value means"/>
|
||||||
|
</coding>
|
||||||
|
</maritalStatus>
|
||||||
|
</Patient>
|
Loading…
Reference in New Issue