· Nov 2

Extracting FHIR resource data from a bundle

I am receiving a FHIR bundle and I need to extract data from it and wondered if there was an easier way of doing this rather than looping through the data as suggested in Working with FHIR Data | FHIR Support in InterSystems Products | InterSystems IRIS for Health 2023.2.

Ideally it would be great if there was a DTL the accept STU3 and then extract the data from there and I did try using the HS.FHIR.DTL.vSTU3.Model.Resource.Bundle class (depreciated) but that only allowed me to see the data at the bundle level and not the resources within it (entry). Is there a way to get that resource data perhaps with a subtransform-esq solution?

I'm new to FHIR so I’d really appreciate any tips/code on how to import and manipulate FHIR data within IRIS.

Below is the code I have so far:-

Set tSC = ..AuthoriseMe(.Token)
    //Set payload = ##class(%DynamicObject).%New()
    Set HTTPRequest = ##class(%Net.HttpRequest).%New()
    #DIM pHttpResponse As %Net.HttpResponse
    Set HTTPRequest.ContentType = "application/json"
    Do HTTPRequest.SetHeader("Accept","application/json")
    Do HTTPRequest.SetHeader("authorization","Bearer " _ Token)
    Do HTTPRequest.SetParam("patientId","1286259")

    Set tSC = ..Adapter.SendFormDataArray(.pHttpResponse, "GET", HTTPRequest)
    $$$TRACE(pHttpResponse.Data.Read()) //displays the bundle
    Do pHttpResponse.Data.Rewind()

    Set payload = ##class(%DynamicObject).%FromJSON(pHttpResponse.Data)

    if $isobject(payload.identifier) {
        Set identifierIterator = payload.entry.%GetIterator() $$$TRACE("identifierIterator = "_identifierIterator)
        While identifierIterator.%GetNext(.key,.value) {
               //$$$TRACE("key "_key_":value "_value)
                Set entryIter = value.%GetIterator()
                While entryIter.%GetNext(.entKey, .entVal){
                    //$$$TRACE("value "_entVal.resourceType)
                    If entVal.resourceType = "MedicationStatement"{
                           set a = entVal.%ToJSON() $$$TRACE("a = "_a)
                           Set MedicationStatementid =  //$$$TRACE(MedicationStatementid)                    
                            Set LastUpdated = entVal.meta.lastUpdated //$$$TRACE(LastUpdated)
                            Set status = entVal.text.status //$$$TRACE(status)
                           Set tSC=$CLASSMETHOD("TESTING.Transform.MedsStatement","Transform",entVal,.ConOut2)
                           Set tSC = ..SendRequestAsync(..TESTING,ConOut2,0) 


Thank you.

Product version: IRIS 2022.1
$ZV: IRIS for Windows (x86-64) 2022.1.2 (Build 574U) Fri Jan 13 2023 15:00:26 EST
Discussion (3)2
Log in or sign up to continue

Sorry, I mixed things up!

Classes in the package HS.FHIR.vSTU3.* are deprecated but HS.FHIR.DTL.vSTU3.* classes are not deprecated. At least to my knowledge. Why do you think they are deprecated?

When I read your post I assumed you referred to the deprecated HS.FHIR.vSTU3.* classes, in fact you mentioned HS.FHIR.DTL.vSTU3.Model.Resource.Bundle, so I got confused.

Set payload=##class(HS.FHIR.DTL.vSTU3.Model.Resource.Bundle).FromJSON(pHttpResponse.Data,"vSTU3")

You should be able to "convert" (import) the stream bundle to the corresponding classes and then "navigate" the bundle, including the resources within it, as a classic IRIS class.