/** * The main method here will directly call an open FHIR server and retrieve a * list of resources matching a given criteria, then load a linked resource. */ public static void main(String[] args) throws IOException { // Create a client factory FhirContext ctx = FhirContext.forDstu2(); // Create the client String serverBase = "http://fhir.healthintersections.com.au/open"; ClientInterface client = ctx.newRestfulClient(ClientInterface.class, serverBase); // Invoke the client to search for patient List<Patient> patients = client.findPatientsForMrn(new IdentifierDt("urn:oid:1.2.36.146.595.217.0.1", "12345")); System.out.println("Found " + patients.size() + " patients"); // Print a value from the loaded resource Patient patient = patients.get(0); System.out.println("Patient Last Name: " + patient.getName().get(0).getFamily().get(0).getValue()); // Load a referenced resource ResourceReferenceDt managingRef = patient.getManagingOrganization(); Organization org = (Organization) managingRef.loadResource(client); // Print organization name System.out.println(org.getName()); }
@Search private List<IBaseResource> searchForPatients() { // Create an organization Organization org = new Organization(); org.setId("Organization/65546"); org.setName("Test Organization"); // Create a patient Patient patient = new Patient(); patient.setId("Patient/1333"); patient.addIdentifier().setSystem("urn:mrns").setValue("253345"); patient.getManagingOrganization().setResource(org); // Here we return only the patient object, which has links to other resources List<IBaseResource> retVal = new ArrayList<IBaseResource>(); retVal.add(patient); return retVal; } // END SNIPPET: addIncludes
public static void manualContained() { // START SNIPPET: manualContained // Create an organization, and give it a local ID Organization org = new Organization(); org.setId("#localOrganization"); org.getNameElement().setValue("Contained Test Organization"); // Create a patient Patient patient = new Patient(); patient.setId("Patient/1333"); patient.addIdentifier().setSystem("urn:mrns").setValue("253345"); // Set the reference, and manually add the contained resource patient.getManagingOrganization().setReference("#localOrganization"); patient.getContained().getContainedResources().add(org); String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient); System.out.println(encoded); // END SNIPPET: manualContained }
public void onClick$btnAddNote() { String note = AddNoteController.execute(); if (note == null || note.isEmpty()) { return; } ProblemNote pn = new ProblemNote(); IUser user = UserContext.getActiveUser(); pn.setAuthor(user.getFullName()); pn.setFacility((Organization) PatientContext.getActivePatient().getManagingOrganization().getResource()); pn.setNumber("*"); pn.setNarrative(note); pn.setDateAdded(new FMDate(DateUtil.stripTime(new Date()))); changedNotes.add(pn); renderNote(pn); } }
Organization institution = (Organization) patient.getManagingOrganization().getResource(); String sNum = "1".equals(sRpc) ? "" : txtID.getValue(); // Pass only if changed