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
{
"resourceType": "Bundle",
"identifier": {
"system": "https://tools.ietf.org/html/rfc4122",
"value": "d124df3f-e966-46c7-9159-401af1974541"
},
"type": "document",
"entry": [
{
"fullUrl": "urn:uuid:37f316aa-94a7-4659-90fd-1d605095cf64",
<?xml version="1.0" encoding="ISO-8859-1"?><html xmlns="http://www.w3.org/1999/xhtml" xmlns:fhir="http://hl7.org/fhir">
<head>
<title>Patient Summary Care Record</title>
<style type="text/css">
body { color: #000000; font-size: 10pt; line-height: normal; font-family: Verdana, Arial, sans-serif; margin: 10px; }
h1 { font-size: 14pt; text-decoration: underline; font-weight: bold; color: #000000; margin-top: 25px; margin-bottom: 15px;}
h2 { font-size: 12pt; text-decoration: underline; font-weight: bold; color: #000000; margin-top: 25px; margin-bottom: 15px; }
h3 { font-size: 10pt; font-weight: bold; color: #000000; margin-top: 5px; margin-bottom: 15px; }
h4 { font-size: 10pt; font-weight: bold; text-decoration: underline; color: #000000; margin-top: 5px; margin-bottom: 15px; }
h5 { font-size: 10pt; font-weight: normal; text-decoration: underline; color: #000000; margin-top: 5px; margin-bottom: 15px; }
private DocumentReference getSimple() {
Binary binary = new Binary();
binary.setId(UUID.randomUUID().toString());
String dummyContent = "<!DOCTYPE html><html><body>SOME TEXT</body></html>";
binary.setContent (dummyContent.getBytes());
binary.setContentType("text/html");
//System.out.println(FhirContext.forDstu3().newJsonParser().setPrettyPrint(true).encodeResourceToString(binary));
DocumentReference doc = new DocumentReference();
IGenericClient clientODS = ctxFHIR.newRestfulGenericClient("https://directory.spineservices.nhs.uk/STU3/");
clientODS.setEncoding(EncodingEnum.XML);
Organization organization = clientODS
.read()
.resource(Organization.class)
.withId("RR8").execute();
organization.setId(UUID.randomUUID().toString());
Binary binary = new Binary();
binary.setId(UUID.randomUUID().toString());
String dummyContent = "<!DOCTYPE html><html><body>SOME TEXT</body></html>";
binary.setContent (dummyContent.getBytes());
binary.setContentType("text/html");
System.out.println(FhirContext.forDstu3().newJsonParser().setPrettyPrint(true).encodeResourceToString(binary));
DocumentReference doc = new DocumentReference();
doc.setId(UUID.randomUUID().toString());
doc.setSubject(new Reference("https://demographics.spineservices.nhs.uk/STU3/Patient/9658220169"));
DocumentReference doc = new DocumentReference();
doc.setSubject(new Reference("https://demographics.spineservices.nhs.uk/STU3/Patient/9658218881"));
doc.setStatus(Enumerations.DocumentReferenceStatus.CURRENT);
doc.getType().addCoding()
.setSystem("http://snomed.info/sct")
.setCode("734163000")
.setDisplay("Care Plan");
doc.addAuthor() .setReference("https://directory.spineservices.nhs.uk/STU3/Organization/RR8").setDisplay("LEEDS TEACHING HOSPITALS NHS TRUST");
doc.setIndexed(new Date());
Binary binary = new Binary();
String dummyContent = "<!DOCTYPE html><html><body>SOME TEXT</body></html>";
binary.setContent (dummyContent.getBytes());
binary.setContentType("text/html");
System.out.println(FhirContext.forDstu3().newJsonParser().setPrettyPrint(true).encodeResourceToString(binary));
Bundle bundle = new Bundle();
bundle.addEntry().setResource(doc);
bundle.addEntry().setResource(binary);
System.out.println(FhirContext.forDstu3().newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
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));