Skip to content

Instantly share code, notes, and snippets.

@KevinMayfield
Created December 7, 2018 16:09
Show Gist options
  • Save KevinMayfield/95ba821e17dad596b3c010cac7c79407 to your computer and use it in GitHub Desktop.
Save KevinMayfield/95ba821e17dad596b3c010cac7c79407 to your computer and use it in GitHub Desktop.
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);
documentReference.getType().addCoding()
.setSystem("http://snomed.info/sct")
.setDisplay("Mental Health Crisis Plan")
.setCode("736253002");
System.out.println(FhirContext.forDstu3().newJsonParser().setPrettyPrint(true).encodeResourceToString(documentReference));
IGenericClient clientNRLS = ctxFHIR.newRestfulGenericClient("https://data.developer.nhs.uk/nrls-ri/");
SSPInterceptor sspInterceptor = new SSPInterceptor();
clientNRLS.registerInterceptor(sspInterceptor);
clientNRLS.create().resource(documentReference).execute();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment