%DynamicObject (JSON) Response into Class Structure
Using the FHIR DEMO, I have pieced together how to make a FHIR Request using OAuth against an External FHIR Repository. When I execute the Patient search (HS.FHIRServer.Interop.Request), I get a HS.FHIRServer.Interop.Response that has a Quick Stream ID, which I then use to convert the Quick Stream to a JSON Dynamic Object. if I do a trace on the Raw JSON Object, I am able to pull out single elements, however I want to pull the raw JSON into a defined Class Structure.
I tried using fromDao(dao As %DynamicAbstractObject) As <HS.FHIRModel.R4 subclass> outlined within Working with FHIR Data
in my DTL when I would try...
Set cls = $CLASSMETHOD("HS.FHIR.DTL.vR4.Model.Resource.Patient","fromDao",dao)I would get...
|
ERROR <Ens>ErrBPTerminated: Terminating BP TEST_FHIR_PATIENT_SEARCH # due to error: ERROR #5002: ObjectScript error: <METHOD DOES NOT EXIST>Transform+18^osuwmc.FHIR.PatientResposneToFHIRObject.1 *fromDao,HS.FHIR.DTL.vR4.Model.Resource.Patient> ERROR #5002: ObjectScript error: <METHOD DOES NOT EXIST>Transform+18^osuwmc.FHIR.PatientResposneToFHIRObject.1 *fromDao,HS.FHIR.DTL.vR4.Model.Resource.Patient |
When I would try to transform the tRawJSONto HS.FHIR.DTL.vR4.Model.Resource.Patientusing fromDao.
What could I possibly doing wrong? I want to put the JSON into a Class Structure that could be passed back to an HL7 message if needed in the case we need more information that is available via FHIR but not through the standard HL7 interface.
Comments
As you noted, fromDao is in the HS.FHIRModel classes, but in the code you pasted you're actually using a class under HS.FHIR:
Set cls = $CLASSMETHOD("HS.FHIR.DTL.vR4.Model.Resource.Patient","fromDao",dao)I think you want to do this instead:
Set cls = $CLASSMETHOD("HS.FHIRModel.R4.Patient","fromDao",dao)https://docs.intersystems.com/irisforhealth20241/csp/documatic/%25CSP.D…
Using the following within a Code action I got no errors...
set tPatient = $CLASSMETHOD("HS.FHIRModel.R4.Patient","fromDao",tRawJSON)However as soon as I tried it within a Set action in the DTL I got errors...
.png)
| ERROR <Ens>ErrBPTerminated: Terminating BP TEST_FHIR_PATIENT_SEARCH # due to error: ERROR <Ens>ErrException: <UNDEFINED>%Construct+1 ^osuwmc.Demo.FHIRPlace.BPL.FHIRDataCollector.Context.1 *HS -- logged as '-' number - @' Set i%%Concurrency=$zu(115,10),i%%LastError=1,i%tPatient=HS.FHIRModel.R4.Patient' > ERROR <Ens>ErrException: <UNDEFINED>%Construct+1 ^osuwmc.Demo.FHIRPlace.BPL.FHIRDataCollector.Context.1 *HS -- logged as '-' number - @' Set i%%Concurrency=$zu(115,10),i%%LastError=1,i%tPatient=HS.FHIRModel.R4.Patient' |
if I go back to using the Code action, how can I guarantee that tPatient gets into the target?