Stream: implementers
Topic: HAPI validation issue
Aditya Joshi (Jun 14 2018 at 13:58):
Hi All,
Need help on below issue.
For Observation resource (STU 3), there is one constraint mentioned -
https://www.hl7.org/implement/standards/fhir/observation.html
obs-7: If code is the same as a component code then the value element associated with the code SHALL NOT be present (expression : value.empty() or code!=component.code)
In my understanding it means if Observation.code (which means Observation.code.coding.code) is equal to component.code ( which means Observation.component.code.coding.code) then there must not be Observation.value element.
But when I try to validate this, I am not getting correct results.
Scenario 1: Error with HAPI code
Actual FHIR Json Resource:
{ "resourceType": "Observation", "identifier": [ { "system": "http://partners.org/schema/ABC/LabTest", "value": "45454545" } ], "status": "final", "category": [ { "coding": [ { "system": "http://hl7.org/fhir/observation-category", "code": "laboratory", "display": "Laboratory" } ] } ], "code": { "coding": [ { "system": "http://loinc.org", "code": "2823-3", "display": "Potassium [Moles/volume] in Serum or Plasma" } ], "text": "K" }, "effectiveDateTime": "2014-04-02T07:49:00+05:30", "valueQuantity": { "value": 100, "unit": "mmol/L" }, "specimen": { "identifier": { "system": "http://mysystem.org/schema/ABC/Specimen", "value": "4547667" } }, "referenceRange": [ { "text": "3.4-4.8" } ] }
HAPI code used:
FhirContext context = FhirContext.forDstu3();
FhirValidator validator = context.newValidator();
validator.setValidateAgainstStandardSchema(true);
validator.setValidateAgainstStandardSchematron(true);
Error Log:
ValidationResult{messageCount=1, isSuccessful=false, description='ERROR - [error] Observation @ /*:Observation[namespace-uri()='http://hl7.org/fhir'][1]; Test=not(exists(f:*[starts-with(local-name(.), 'value')])) or not(count(for $coding in f:code/f:coding return parent::*/f:component/f:code/f:coding[f:code/@value=$coding/f:code/@value and f:system/@value=$coding/f:system/@value])=0); Message=obs-7: If code is the same as a component code then the value element associated with the code SHALL NOT be present - Observation @ /*:Observation[namespace-uri()='http://hl7.org/fhir'][1]'}
Note- I tried above example to validate on below Public servers and did not get any error-
http://test.fhir.org/r4
http://fhir.hl7fundamentals.org/baseDstu3 (used $validate operation)
Scenario 2: Error Using some other public fhir test server and other Observation resource examples to compare how other test servers behaves for this issue
Observation Resource with only one component. This is giving error related to above constraint.
{ "resourceType": "Observation", "id": "blood-pressure", "meta": { "profile": [ "http://hl7.org/fhir/StructureDefinition/vitalsigns" ] }, "identifier": [ { "system": "urn:ietf:rfc:3986", "value": "urn:uuid:187e0c12-8dd2-67e2-99b2-bf273c878281" } ], "status": "final", "category": [ { "coding": [ { "system": "http://hl7.org/fhir/observation-category", "code": "vital-signs", "display": "Vital Signs" } ] } ], "code": { "coding": [ { "system": "http://loinc.org", "code": "85354-9", "display": "Bood pressure panel with all children optional" } ], "text": "Blood pressure systolic & diastolic" }, "subject": { "reference": "Patient/example" }, "effectiveDateTime": "2012-09-17", "valueQuantity": { "value": 60, "unit": "mmHg", "system": "http://unitsofmeasure.org", "code": "mm[Hg]" }, "component": [ { "code": { "coding": [ { "system": "http://loinc.org", "code": "8480-6", "display": "Systolic blood pressure" } ] }, "valueQuantity": { "value": 107, "unit": "mmHg", "system": "http://unitsofmeasure.org", "code": "mm[Hg]" } } ] }
I am validating resouce using $validate opeartion. Here is the query (using POST)-
http://fhir.hl7fundamentals.org/baseDstu3/Observation/$validate
Above resource in POST body.
But Observation.code is not equal to Observation.component.code in above case.
Server response- see the last error, rest warnings are fine, I do understand what they are
{ "resourceType": "OperationOutcome", "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">WARNING</td><td>[Observation]</td><td><pre>All observations should have a performer</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td style=\"font-weight: bold;\">INFORMATION</td>\n\t\t\t\t<td>[Observation]</td>\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t<td><pre>All observations should have a performer</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td style=\"font-weight: bold;\">ERROR</td>\n\t\t\t\t<td>[Observation]</td>\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t<td><pre>If code is the same as a component code then the value element associated with the code SHALL NOT be present [value.empty() or code!=component.code]</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t</table>\n\t</div>" }, "issue": [ { "severity": "warning", "code": "processing", "diagnostics": "All observations should have a performer", "location": [ "Observation" ] }, { "severity": "information", "code": "processing", "diagnostics": "All observations should have a performer", "location": [ "Observation" ] }, { "severity": "error", "code": "processing", "diagnostics": "If code is the same as a component code then the value element associated with the code SHALL NOT be present [value.empty() or code!=component.code]", "location": [ "Observation" ] } ] }
Note- I tried above example to validate on below Public servers and did not get any error-
http://test.fhir.org/r4
Scenario 3: When I use both components, error went away.
{ "resourceType": "Observation", "id": "blood-pressure", "meta": { "profile": [ "http://hl7.org/fhir/StructureDefinition/vitalsigns" ] }, "identifier": [ { "system": "urn:ietf:rfc:3986", "value": "urn:uuid:187e0c12-8dd2-67e2-99b2-bf273c878281" } ], "status": "final", "category": [ { "coding": [ { "system": "http://hl7.org/fhir/observation-category", "code": "vital-signs", "display": "Vital Signs" } ] } ], "code": { "coding": [ { "system": "http://loinc.org", "code": "85354-9", "display": "Bood pressure panel with all children optional" } ], "text": "Blood pressure systolic & diastolic" }, "subject": { "reference": "Patient/example" }, "effectiveDateTime": "2012-09-17", "valueQuantity": { "value": 60, "unit": "mmHg", "system": "http://unitsofmeasure.org", "code": "mm[Hg]" }, "component": [ { "code": { "coding": [ { "system": "http://loinc.org", "code": "8480-6", "display": "Systolic blood pressure" } ] }, "valueQuantity": { "value": 107, "unit": "mmHg", "system": "http://unitsofmeasure.org", "code": "mm[Hg]" } }, { "code": { "coding": [ { "system": "http://loinc.org", "code": "8462-4", "display": "Diastolic blood pressure" } ] }, "valueQuantity": { "value": 60, "unit": "mmHg", "system": "http://unitsofmeasure.org", "code": "mm[Hg]" } } ] }
Scenario 4: when no component, no error on baseDSTU3 server but error with HAPI code
I am really not clear on this constraint, what it really meant. and why I am getting error when there is one component but codes are different.
Thanks for your help.
Regards,
Aditya Joshi
Eric Haas (Jun 14 2018 at 18:40):
your interpretation is correct. if code = A and component.code = A then there is no value, component.values are allowed.
Aditya Joshi (Jun 14 2018 at 19:14):
Thanks Eric for confirmation. So, do you think that issue I have posted is due to HAPI validator. For the Json I have posted this issue must not come from validator.
Christiaan Knaap (Jul 04 2018 at 04:36):
For comparison you can also try to validate it using the .NET validator. You can use the .NET validator with the ValidationDemo or by invoking the $validate operation on Vonk (vonk.fire.ly)
Last updated: Apr 12 2022 at 19:14 UTC