Search code examples
hl7-fhir

Can't get FHIR message to decode


I am trying to integrate with a service that provides FHIR ImageStudy messages in JSON format. Once I have the JSON message I need to convert the message to XML.

I am using the FHIR-net-api found here, https://github.com/ewoutkramer/fhir-net-api I posted earlier and got help using this library to parse standard image study messages. Here is a link to my earlier post, FHIR JSON to XML decoding in BizTalk

The service I am connecting to has added some extensions to the image study message and when I attempt to parse it I get an error that the parser failed line 1 character 1.

My understanding is that if the extension are done correctly the FHIR-net-api library should be able to parse the JSON to XML. Is this correct?

Can anyone identify if the test message below is compliant to the FHIR standard, if not what is wrong with it? I have shortened the message to only contain a single image study but the service returns multiple in a bundle. I have also removed identifying information. { "resourceType": "Bundle", "total": 15, "entry": [

  {"resource":       {
     "resourceType": "ImagingStudy",
     "id": "LALA.e1e6683d-f6d9-e311-ae0e-0050568f64",
     "contained":          [
                    {
           "resourceType": "Organization",
           "text": {"div": "LALA"},
           "name": "LALA"
        },
                    {
           "resourceType": "Procedure",
           "id": "Procedure1",
           "code": {"coding": [               {
              "code": "RAD-HANB",
              "display": "HANDS BIL"
           }]}
        }
     ],
     "extension": [         {
        "url": "https://someplace.org/fhir/extensions/imagingstudy-examstatus",
        "valueString": "Finalized"
     }],
     "started": "2013-12-03T12:30:00-08:00",
     "accession": {"value": "A12345BH"},
     "procedure": [{"reference": "#Procedure1"}],
     "series": [         {
        "modality":             {
           "system": "http://www.dicomlibrary.com/dicom/modality/",
           "code": "CR"
        },
        "bodySite": {"code": "UEX"},
        "instance":             [
           {"title": "DiagnosticReport"},
                          {
              "title": "DiagnosticImage",
              "content":                   [
                                      {
                    "url": "/fhir/Patient/91111/ImagingStudy?_query=imageUrl&_id=6683d-f6d9-e311-ae0e-0050568f6477&-mrn=12345T&-organization=lala&accession=tester&-status=F",
                    "title": "Something"
                 },
                                      {
                    "url": "/fhir/Patient/9111111/ImagingStudy?_query=html5Url&_id=e1e6683d-f6d9-e311-ae0e-0050568f6&-mrn=123345&-organization=lala&accession=testing&-status=F",
                    "title": "HTML5"
                 }
              ]
           }
        ]
     }]
  }}

] }


Solution

  • I suspect that you got a message like this: Error parsing XHTML: Incorrect document syntax. at line 1 row 1. source = " at line 8 col 13

    That's what I get once I clean up the instance a little bit to include only the resource and not the wrapper from the Bundle and check it against http://fhir2.healthintersections.com.au/open/.

    The first issue is that the narrative inside your div tag is not valid. It needs to look like this:

    "div": "<div>LALA</div>"
    

    However there are a bunch of others. The narrative is missing status. Narrative isn't actually allowed on contained resources, you're missing a bunch of mandatory elements, etc. Just go to the link above and paste your JSON into the "upload" box at the bottom of the page and select "validate". That will give you a full report of the issues. (Not all of those will necessarily impact your ability to convert between JSON and XML, but presumably you'll want to fix them regardless.)