Skip to content

Instantly share code, notes, and snippets.

View KevinMayfield's full-sized avatar

Kevin Mayfield KevinMayfield

  • Leeds, West Riding, UK
View GitHub Profile
<Condition>
...
<subject>
<reference value="https://demographics.spineservices.nhs.uk/STU3/Patient/9876543210"/>
<display value="Mike Meakin"/>
<identifier>
<system value="https://fhir.nhs.uk/Id/nhs-number"/>
<value value="9876543210"/>
<identifier>
</subject>
<Condition>
...
<subject>
<reference value="https://demographics.spineservices.nhs.uk/STU3/Patient/9876543210"/>
</subject>
....
</Condition>
<MedicationDispense>
...
<medicationReference>
<reference value="urn:uuid:9c7e61c3-5b92-4828-9ebc-21e74bcdbc96"/>
</medicationReference>
....
</MedicationDispense>
or
doc.getMeta().addProfile("https://fhir.nhs.uk/STU3/StructureDefinition/GPConnect-DocumentReference-1");
package uk.nhs.careconnect.hapiclient.App;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.client.api.IClientInterceptor;
import ca.uhn.fhir.rest.client.api.IHttpRequest;
import ca.uhn.fhir.rest.client.api.IHttpResponse;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
private void sendNRLS(Bundle bundle) {
for (Bundle.BundleEntryComponent entry : bundle.getEntry()) {
if (entry.getResource() instanceof DocumentReference) {
DocumentReference documentReference = (DocumentReference) entry.getResource();
documentReference.setSubject(new Reference("https://demographics.spineservices.nhs.uk/STU3/Patient/9658220169"));
documentReference.setAuthor(new ArrayList<>());
documentReference.addAuthor().setReference("https://directory.spineservices.nhs.uk/STU3/Organization/MHT01");
documentReference.setCustodian(new Reference("https://directory.spineservices.nhs.uk/STU3/Organization/MHT01"));
private void sendNRLS(Bundle bundle) {
for (Bundle.BundleEntryComponent entry : bundle.getEntry()) {
if (entry.getResource() instanceof DocumentReference) {
DocumentReference documentReference = (DocumentReference) entry.getResource();
documentReference.setSubject(new Reference("https://demographics.spineservices.nhs.uk/STU3/Patient/9658220169"));
documentReference.setAuthor(new ArrayList<>());
documentReference.addAuthor().setReference("https://directory.spineservices.nhs.uk/STU3/Organization/MHT01");
documentReference.setCustodian(new Reference("https://directory.spineservices.nhs.uk/STU3/Organization/MHT01"));
documentReference.setType(null);
MethodOutcome outcome = clientCCRI.create().resource(bundle).execute();
if (outcome.getCreated()) {
sendNRLS((Bundle) outcome.getResource());
}
}
private void sendNRLS(Bundle bundle) {
for (Bundle.BundleEntryComponent entry : bundle.getEntry()) {
if (entry.getResource() instanceof DocumentReference) {
Bundle bundle = new Bundle();
bundle.addEntry().setResource(doc).setFullUrl("urn:uuid:"+doc.getId());
bundle.addEntry().setResource(binary).setFullUrl("urn:uuid:"+binary.getId());
bundle.setType(Bundle.BundleType.COLLECTION);
System.out.println(FhirContext.forDstu3().newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
Bundle bundle = new Bundle();
bundle.addEntry().setResource(doc);
bundle.addEntry().setResource(binary);
System.out.println(FhirContext.forDstu3().newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));