In the previous Terminology & Profile Support blog post I introduced the HSPC Terminology Server and gave step-by-step instructions on some common use cases including:
...
Code Block |
---|
https://api-v5-stu3.hspconsortium.org/stu3/open/StructureDefinition?url=http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient |
Response
omitted due to size
Putting this all together, we can formulate the $validate
request as follows:
...
In the response we can see a list of issues, most of the classified as information
or warning
. The last two issues are error
level and are a result of deleting the LOINC smoking-status code, these indicate that the resource instance does not actually conform to the indicated profile.
Validating Resource Without "Parameters" Resource
If a user wants to validate a resource without embedding in it as a parameter in a Parameters FHIR resource, that is also an option. Here's an example of a heart rate Observation example:
Code Block | ||
---|---|---|
| ||
{ "resourceType": "Observation", "id": "heart-rate", "meta": { "profile": [ "http://hl7.org/fhir/StructureDefinition/heartrate" ] }, "status": "final", "category": [ { "coding": [ { "system": "http://hl7.org/fhir/observation-category", "code": "vital-signs", "display": "Vital Signs" } ], "text": "Vital Signs" } ], "code": { "coding": [ { "system": "http://loinc.org", "code": "8867-4", "display": "Heart rate" } ], "text": "Heart rate" }, "subject": { "reference": "Patient/example" }, "performer": { "reference": "Practitioner/example" }, "effectiveDateTime": "1999-07-02", "valueQuantity": { "value": 44, "unit": "beats/minute", "system": "http://unitsofmeasure.org", "code": "/minute" } } |
Limitations of HSPC Sandbox Validation
In the FHIR Validation spec, there is a mention of being able to pass a custom profile via the url (https://www.hl7.org/fhir/validation.html#op). The call would look something like this:
Code Block | ||
---|---|---|
| ||
POST [base]/Observation/$validate?profile=http://hl7.org/fhir/StructureDefinition/heartrate |
Although this approach would be convenient, HAPI, the FHIR server off of which the HSPC servers are built, does not support this functionality.
Another possible approach to adding a profile for validation is to implement a Parameters resource and to add a parameter in the list that states the profile url (https://www.hl7.org/fhir/operation-resource-validate.html):
Code Block | ||
---|---|---|
| ||
{
"resourceType": "Parameters",
"parameter": [
{
"name": "profile",
"valueUri": "http://hl7.org/fhir/StructureDefinition/heartrate"
},
{
"name": "resource",
"resource": {
... |
This, however, is also not supported by HAPI.
So for now, using the approaches described earlier (passing the profile url through the meta.profile parameter) are the only way to validate against custom profiles. We will update our documentation if/when either approach becomes available.
Conclusion
Validating instance data through a FHIR Terminology Service like the HSPC Terminology Server is a great way of ensuring data quality and interoperability. The example's we've shown have been for the us-core profiles, but should work equally well for any profiles built using the standard StructureDefinition
resources and loaded into the terminology service.
...