FHIR Chat · FHIR resource validation using response interceptor in HA... · implementers

Stream: implementers

Topic: FHIR resource validation using response interceptor in HA...


view this post on Zulip Aditya (May 01 2019 at 16:40):

I am trying to validate outgoing FHIR resources using ResponseValidatingInterceptor but its not working. I followed all steps listed here : http://hapifhir.io/doc_rest_server_interceptor.html#_toc_requestresponse_validation

view this post on Zulip Lloyd McKenzie (May 01 2019 at 16:50):

Can you expand on "not working"?

view this post on Zulip Aditya (May 01 2019 at 17:02):

@Lloyd McKenzie

I have a code as shown in example where I am purposely not setting "status" which is required in Observation resource when http request is made to my server http://localhost:8080/context/fhir/resource/Observation?category=vital-signs&patient=abcdefgh

    Observation obs = new Observation();
    obs.getCode().addCoding().setSystem("http://loinc.org").setCode("12345-6");
    obs.setValue(new StringType("This is a value"));

Then I have following code in the service which extends RestfulServer :

    public void initialize() {

          //some code ...
          ResponseValidatingInterceptor responseInterceptor = new ResponseValidatingInterceptor();
      responseInterceptor.addValidatorModule(new FhirInstanceValidator());
      responseInterceptor.setFailOnSeverity(ResultSeverityEnum.ERROR);
      responseInterceptor.setAddResponseHeaderOnSeverity(ResultSeverityEnum.INFORMATION);
      responseInterceptor.setResponseHeaderValue("Validation on ${line}: ${message} ${severity}");
      responseInterceptor.setResponseHeaderValueNoIssues("No issues detected");
    }

Now at the output, I am getting "No issues detected" when ideally I should get validation error in header since observation has no status.
Thats my problem

My outgoing response in bundle through :

{
    "resourceType": "Bundle",
    "id": "uiehfkdhsfn-sdfjs-sdff-sdfs-yugrhfjbsdf",
    "meta": {
        "lastUpdated": "2019-05-01T14:11:26.390-04:00"
      },
    "language": "ENG",
    "type": "searchset",
    "total": 4,
    "link": [
        {
            "relation": "self",
            "url": "http://localhost:8080/context/fhir/resource/Observation?category=vital-signs&patient=abcdefgh"
        }
    ],
    "entry": [
        {
            "resource": {
                "resourceType": "Observation",
                "id": "adasdasdadasdasd.asdasdasdasdasdasd",
                "text": {
                    "status": "generated",
                    "div": "<table     xmlns=\"http://www.w3.org/1999/xhtml\"><thead><tr><th>Vital</th><th>Patient Control         No</th></tr></thead><tbody><tr><td>Blood Pressure Systolic:117 mm     Hg</td><td>9294</td></tr></tbody></table>"
                },
                "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": "8480-6",
                            "display": "blood pressure systolic"
                        }
                    ],
                    "text": "Blood Pressure Systolic"
                },
                "subject": {
                    "reference": "Patient/abcdefgh"
                },
                "effectiveDateTime": "2019-04-17",
                "valueQuantity": {
                    "value": 117,
                    "unit": "mm[Hg]",
                    "system": "http://unitsofmeasure.org",
                    "code": "mm[Hg]"
                }
            }
        }
    ]
}

view this post on Zulip Lloyd McKenzie (May 01 2019 at 17:27):

That's much better :) @James Agnew ? (Also, in the future, and if you don't get a timely response here, suggest raising on the #hapi stream.)

view this post on Zulip Aditya (May 01 2019 at 18:25):

Thanks @Lloyd McKenzie . I also added some more desription regarding the response I am sending out.

view this post on Zulip James Agnew (May 01 2019 at 20:28):

It doesn't look like you actually registered the interceptor in your code. You need to call registerInterceptor(responseInterceptor);


Last updated: Apr 12 2022 at 19:14 UTC