User bio
404 bio not found
Member since Apr 27, 2017
Replies:

The HS.FHIRModel.R4.Patient class in  IRIS directly represents the FHIR R4 Patient resource as defined. When a FHIR Bundle is loaded using HS.FHIRModel.R4.Bundle.fromDao(), each resource in the bundle's entry.resource is automatically mapped to the correct HS.FHIRModel.R4.* subclass (e.g., Patient, Encounter, AllergyIntolerance) based on its resourceType. There’s no need for manual casting — the object model handles the typing internally.

here is the sample code

Set bundle={"resourceType":"Bundle","type":"searchset","total":3,"entry":[{"fullUrl":"https://example.org/fhir/Patient/patient-1","resource":{"resourceType":"Patient","id":"patient-1","name":[{"family":"Doe","given":["John"]}],"gender":"male","birthDate":"1985-02-15"},"search":{"mode":"match"}},{"fullUrl":"https://example.org/fhir/Encounter/encounter-1","resource":{"resourceType":"Encounter","id":"encounter-1","status":"finished","class":{"system":"http://terminology.hl7.org/CodeSystem/v3-ActCode","code":"AMB","display":"ambulatory"},"subject":{"reference":"Patient/patient-1"},"period":{"start":"2023-07-01T10:00:00Z","end":"2023-07-01T10:30:00Z"}},"search":{"mode":"include"}},{"fullUrl":"https://example.org/fhir/AllergyIntolerance/allergy-1","resource":{"resourceType":"AllergyIntolerance","id":"allergy-1","clinicalStatus":{"coding":[{"system":"http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical","code":"active"}]},"verificationStatus":{"coding":[{"system":"http://terminology.hl7.org/CodeSystem/allergyintolerance-verification","code":"confirmed"}]},"type":"allergy","category":["food"],"criticality":"high","code":{"coding":[{"system":"http://snomed.info/sct","code":"227493005","display":"Cashew nuts"}],"text":"Allergy to cashews"},"patient":{"reference":"Patient/patient-1"},"reaction":[{"manifestation":[{"coding":[{"system":"http://snomed.info/sct","code":"271807003","display":"Skin rash"}]}],"severity":"moderate"}]},"search":{"mode":"include"}}]}                                                                                             
set fhirModelBundle = ##class(HS.FHIRModel.R4.Bundle).fromDao(bundle)  
;
Zwrite fhirModelBundle.entry.list.size()
3
;
Zwrite fhirModelBundle.entry.list.get(0).toDao() ; patient
{"fullUrl":"https://example.org/fhir/Patient/patient-1","resource":{"resourceType":"Patient","id":"patient-1","name":[{"family":"Doe","given":["John"]}],"gender":"male","birthDate":"1985-02-15"},"search":{"mode":"match"}}  ; <DYNAMIC OBJECT>                        
;
Zwrite fhirModelBundle.entry.list.get(1).toDao() ; encounter
{"fullUrl":"https://example.org/fhir/Encounter/encounter-1","resource":{"resourceType":"Encounter","id":"encounter-1","status":"finished","class":{"system":"http://terminology.hl7.org/CodeSystem/v3-ActCode","code":"AMB","display":"ambulatory"},"subject":{"reference":"Patient/patient-1"},"period":{"start":"2023-07-01T10:00:00Z","end":"2023-07-01T10:30:00Z"}},"search":{"mode":"include"}}  ; <DYNAMIC OBJECT>                                                                                                                         
;
Zwrite fhirModelBundle.entry.list.get(2).toDao() ; Allergy
{"fullUrl":"https://example.org/fhir/AllergyIntolerance/allergy-1","resource":{"resourceType":"AllergyIntolerance","id":"allergy-1","clinicalStatus":{"coding":[{"system":"http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical","code":"active"}]},"verificationStatus":{"coding":[{"system":"http://terminology.hl7.org/CodeSystem/allergyintolerance-verification","code":"confirmed"}]},"type":"allergy","category":["food"],"criticality":"high","code":{"coding":[{"system":"http://snomed.info/sct","code":"227493005","display":"Cashew nuts"}],"text":"Allergy to cashews"},"patient":{"reference":"Patient/patient-1"},"reaction":[{"manifestation":[{"coding":[{"system":"http://snomed.info/sct","code":"271807003","display":"Skin rash"}]}],"severity":"moderate"}]},"search":{"mode":"include"}}  ; <DYNAMIC OBJECT>

Hello @Scott Roth 

I directly import JSON via fromDao method and It works for me. Did you get any errors while importing?

Set patient = {"resourceType":"Patient","id":"example","text":{"status":"generated","div":"<div xmlns=\"http://www.w3.org/1999/xhtml\">John Doe</div>"},"identifier":[{"use":"usual","type":{"coding":[{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"MR","display":"Medical Record Number"}]},"system":"http://hospital.smarthealth.org","value":"123456"}],"active":true,"name":[{"use":"official","family":"Doe","given":["John"]}],"telecom":[{"system":"phone","value":"+1 555-123-4567","use":"mobile"},{"system":"email","value":"john.doe@example.com","use":"home"}],"gender":"male","birthDate":"1980-01-01","address":[{"use":"home","line":["123 Main Street"],"city":"Anytown","state":"CA","postalCode":"90210","country":"USA"}]}
Set r4Patient = ##class(HS.FHIRModel.R4.Patient).fromDao(patient)
Write r4Patient.toString()
Open Exchange applications:
Certifications & Credly badges:
Ashok Kumar has no Certifications & Credly badges yet.
Global Masters badges:
Followers:
Following: