web stats
Difficulty adding contained resources - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-27-2018, 01:15 AM
seaston seaston is offline
OBX.3 Kenobi
 
Join Date: Feb 2010
Location: London, UK
Posts: 168
seaston is on a distinguished road
Default Difficulty adding contained resources

I'm wondering if I am going about this completely the wrong way as I cannot see how to add contained resources to the transaction bundle I am trying to build below using http://hapifhir.io/apidocs-dstu3/org...e-summary.html

Code:
var fhircontext = new Packages.ca.uhn.fhir.context.FhirContext.forDstu3();

// create bundle object and set its type:
var bundle = new org.hl7.fhir.dstu3.model.Bundle();
bundle.setType(org.hl7.fhir.dstu3.model.Bundle.BundleType.TRANSACTION);
// Add metadata to bundle:
var bundlemetadata = new org.hl7.fhir.dstu3.model.Meta();
bundlemetadata.addProfile("http://ihe.net/fhir/tag/iti-65");
bundle.setMeta(bundlemetadata);
// Build a document reference resource to add to the bundle:
var docref = new org.hl7.fhir.dstu3.model.DocumentReference();
docref.setStatus(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.CURRENT);
// Add Document Type
var codeableconcept = new org.hl7.fhir.dstu3.model.CodeableConcept();
var coding = new org.hl7.fhir.dstu3.model.Coding();
coding.setCode('101');
coding.setDisplay('Repatriation Document');
coding.setSystem('2.16.840.1.113883.2.1.3.46.1.2');  
codeableconcept.addCoding(coding);
docref.setType(codeableconcept);
// Add Document Class:
var codeableconcept = new org.hl7.fhir.dstu3.model.CodeableConcept();
var coding = new org.hl7.fhir.dstu3.model.Coding();
coding.setCode('163171000000105');
coding.setDisplay('Care professional documentation');
coding.setSystem('2.16.840.1.113883.2.1.3.2.4.15');  
codeableconcept.addCoding(coding);
docref.setClass_(codeableconcept);
// Set Indexed Date:
var currentDate = new java.util.Date(java.lang.System.currentTimeMillis());
docref.setIndexed(currentDate);

/*

References to one or more contained author Practitioner resources; one contained author Organization resource; and zero or one publishing system Device resource.
See resources defined below as:
DocumentReference.author(Practitioner)
DocumentReference.author(Organization)
DocumentReference.author(Device)

org.hl7.fhir.dstu3.model.Organization

*/
var organization = new org.hl7.fhir.dstu3.model.Organization();
organization.setName('Epsom and St Helier University Hospitals NHS Trust');
organization.addIdentifier(new org.hl7.fhir.dstu3.model.Identifier().setSystem('urn:oid:2.16.840.1.113883.2.1.3').setValue('urn:oid:2.16.840.1.113883.2.1.3'));
organization.setId('esth');
// Add security label:
var codeableconcept = new org.hl7.fhir.dstu3.model.CodeableConcept();
var coding = new org.hl7.fhir.dstu3.model.Coding();
coding.setCode('N');
coding.setDisplay('normal');
coding.setSystem('2.16.840.1.113883.5.25');  
codeableconcept.addCoding(coding);
docref.addSecurityLabel(codeableconcept);


// build document content: 
var documentcontent = new org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContentComponent();
var attachment = new org.hl7.fhir.dstu3.model.Attachment();
attachment.setContentType('application/pdf');
attachment.setLanguage('en-GB');
attachment.setUrl('fhirDocument0');
documentcontent.setAttachment(attachment);
// document format:
var coding = new org.hl7.fhir.dstu3.model.Coding();
coding.setCode('urn:ihe:iti:xds-sd:pdf:2008');
coding.setDisplay('PDF embedded in FHIR per XDS-SD profile');
coding.setSystem('urn:oid:1.3.6.1.4.1.19376.1.2.3');  
documentcontent.setFormat(coding);


docref.addContent(documentcontent);

// Add document Reference to the Bundle:
bundle.addEntry(new org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent().setResource(docref) );

var docmanifest = new org.hl7.fhir.dstu3.model.DocumentManifest();
var binary = new org.hl7.fhir.dstu3.model.Binary();

binary.setId('fhirDocument0');
binary.setContentType('application/pdf');
binary.setContentAsBase64(msg['OBX']['OBX.5']['OBX.5.5'].toString());

var binarycomponent = new org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent();
binarycomponent.setFullUrl('fhirDocument0');
bundle.addEntry(binarycomponent.setResource(binary));



msg = fhircontext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle);
Has anyone got some sample code they can share that will show me how to build a FHIR bundle, add resources etc including contained resources?
Reply With Quote
  #2  
Old 04-30-2018, 03:23 AM
seaston seaston is offline
OBX.3 Kenobi
 
Join Date: Feb 2010
Location: London, UK
Posts: 168
seaston is on a distinguished road
Default

Worked out where I was going wrong by looking here

http://hapifhir.io/doc_resource_references.html
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 05:53 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation