/** * 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()); }
String familyName = patient.getName().get(0).getFamily().get(0).getValue(); String gender = patient.getGender();
/** * The "@Search" annotation indicates that this method supports the * search operation. You may have many different method annotated with * this annotation, to support many different search criteria. This * example searches by family name. * * @param theIdentifier * This operation takes one parameter which is the search criteria. It is * annotated with the "@Required" annotation. This annotation takes one argument, * a string containing the name of the search criteria. The datatype here * is StringDt, but there are other possible parameter types depending on the * specific search criteria. * @return * This method returns a list of Patients. This list may contain multiple * matching resources, or it may also be empty. */ @Search() public List<Patient> getPatient(@RequiredParam(name = Patient.SP_FAMILY) StringDt theFamilyName) { Patient patient = new Patient(); patient.addIdentifier(); patient.getIdentifier().get(0).setUse(IdentifierUseEnum.OFFICIAL); patient.getIdentifier().get(0).setSystem(new UriDt("urn:hapitest:mrns")); patient.getIdentifier().get(0).setValue("00001"); patient.addName(); patient.getName().get(0).addFamily("Test"); patient.getName().get(0).addGiven("PatientOne"); patient.setGender(AdministrativeGenderEnum.MALE); return Collections.singletonList(patient); }
/** * The "@Search" annotation indicates that this method supports the * search operation. You may have many different method annotated with * this annotation, to support many different search criteria. This * example searches by family name. * * @param theFamilyName * This operation takes one parameter which is the search criteria. It is * annotated with the "@Required" annotation. This annotation takes one argument, * a string containing the name of the search criteria. The datatype here * is StringParam, but there are other possible parameter types depending on the * specific search criteria. * @return * This method returns a list of Patients. This list may contain multiple * matching resources, or it may also be empty. */ @Search() public List<Patient> getPatient(@RequiredParam(name = Patient.SP_FAMILY) StringParam theFamilyName) { Patient patient = new Patient(); patient.addIdentifier(); patient.getIdentifier().get(0).setUse(IdentifierUseEnum.OFFICIAL); patient.getIdentifier().get(0).setSystem(new UriDt("urn:hapitest:mrns")); patient.getIdentifier().get(0).setValue("00001"); patient.addName(); patient.getName().get(0).addFamily(theFamilyName.getValue()); patient.getName().get(0).addGiven("PatientOne"); patient.setGender(AdministrativeGenderEnum.MALE); return Collections.singletonList(patient); }
/** * The "@Read" annotation indicates that this method supports the * read operation. It takes one argument, the Resource type being returned. * * @param theId * The read operation takes one parameter, which must be of type * IdDt and must be annotated with the "@Read.IdParam" annotation. * @return * Returns a resource matching this identifier, or null if none exists. */ @Read() public Patient getResourceById(@IdParam IdDt theId) { Patient patient = new Patient(); patient.addIdentifier(); patient.getIdentifier().get(0).setSystem(new UriDt("urn:hapitest:mrns")); patient.getIdentifier().get(0).setValue("00002"); patient.addName().addFamily("Test"); patient.getName().get(0).addGiven("PatientOne"); patient.setGender(AdministrativeGenderEnum.FEMALE); return patient; }
/** * The "@Read" annotation indicates that this method supports the * read operation. Read operations should return a single resource * instance. * * @param theId * The read operation takes one parameter, which must be of type * IdDt and must be annotated with the "@Read.IdParam" annotation. * @return * Returns a resource matching this identifier, or null if none exists. */ @Read() public Patient getResourceById(@IdParam IdDt theId) { Patient patient = new Patient(); patient.addIdentifier(); patient.getIdentifier().get(0).setSystem(new UriDt("urn:hapitest:mrns")); patient.getIdentifier().get(0).setValue("00002"); patient.addName().addFamily("Test"); patient.getName().get(0).addGiven("PatientOne"); patient.setGender(AdministrativeGenderEnum.FEMALE); return patient; }
public void testFindPatientWherePatientExists() { Patient thePatient = surgery.findPatient("Teddy"); assertEquals("Teddy", thePatient.getName()); } public void testFindPatientWherePatientDoesntExist() { assertNull(surgery.findPatient("I dont exist")); }
public int pAhead(String name) { Patient p; int patientsAhead = 0; for(int i= 0; i < list.size(); i++) { p = list.get(i); //get each object from array String n = p.getName(); if(name.equalsIgnoreCase(n)) { //if name passed is equal to object getName, than increase your counter patientsAhead = i; break; } } return list.size() - patientsAhead; }
public int pAhead(String name) { Patient p; int patientsAhead = 0; for(int i= 0; i < list.size(); i++) { p = list.get(i); //get each object from array String n = p.getName(); if(name.equalsIgnoreCase(n)) { //if name passed is equal to object getName, than increase your counter patientsAhead = i; } } return patientsAhead; }
for (Student student : S) { for (Patient patient : P) { if (student.getName().equals(patient.getName())) { count++; } } }
/** * Adds and returns a new value for <b>name</b> () * * <p> * <b>Definition:</b> * A name associated with the individual. * </p> */ public HumanNameDt addName() { HumanNameDt newType = new HumanNameDt(); getName().add(newType); return newType; }
HashMap<String, Patient> patients = objectMapper.readValue(new File("patients.json"), new TypeReference<HashMap<String,Patient>>() {}); Patient patientA = patients.get("A"); String patientAName = patientA.getName(); int pateintAAge = patientA.getAge();
for (Patient p : patients) { System.out.println(String.format(DATA_FORMAT, p.getMediacareNumber(), p.getName(), p.getDob(), p.getVisits())); }
// Create a client (only needed once) FhirContext ctx = new FhirContext(); IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/base"); // Invoke the client Bundle bundle = client.search() .forResource(Patient.class) .execute(); System.out.println("patients count=" + bundle.size()); List<Patient> list = bundle.getResources(Patient.class); for (Patient p : list) { System.out.println("name=" + p.getName()); }
/** * Update display for currently selected patient. * * @param refresh If true, force a refresh before returning. */ private void updatePatient(boolean refresh) { patient = PatientContext.getActivePatient(); radPatient.setLabel(patient == null ? Labels.getLabel("vistanotification.main.patient.not.selected") : FhirUtil .formatName(patient.getName())); if (refresh) { refresh(); } }
public void UpdateTable() { DefaultTableModel tableModel = (DefaultTableModel)TableName.getModel(); for(Patient k: PatientList) { int TableID = k.getAccountNumber(); String TableName = k.getName(); int TableAge = k.getAge(); String TableAddress = k.getAddress(); String TableSex = k.getSex(); String TablePhone = k.getPhone(); //Add row here. tableModel.addRow(new String[]{TableID,TableName,TableAge,TableAddress,TableSex,TablePhone }); } }
/** * Creates a CCOW context from the specified patient object. */ @Override public ContextItems toCCOWContext(Patient patient) { IdentifierDt mrn = FhirUtil.getIdentifier(patient.getIdentifier(), IdentifierTypeCodesEnum.MR); contextItems.setItem(CCOW_MRN, mrn == null ? null : mrn.getValue(), "MRN"); contextItems.setItem(CCOW_NAM, patient.getName()); contextItems.setItem(CCOW_SEX, patient.getGender()); contextItems.setItem(CCOW_DOB, patient.getBirthDate()); return contextItems; }
@Override protected void updateContext(ContextMap context) { Patient patient = PatientContext.getActivePatient(); if (patient != null) { context.put("full_name", FhirUtil.formatName(patient.getName())); context.put("id", patient.getId().getValue()); } }
@Test @Ignore public void marshalling() throws Exception { changePatientContext(); ContextMarshaller marshaller = contextManager.getContextMarshaller("keystore-test"); String ctx = marshaller.marshal(contextManager.getMarshaledContext()); String sig = marshaller.sign(ctx); PatientContext.changePatient(null); assertNull(PatientContext.getActivePatient()); marshaller.unmarshal(ctx, sig); Patient patient = PatientContext.getActivePatient(); assertTrue("Doe, Jane".equalsIgnoreCase(new HumanNameParser().toString(patient.getName().get(0)))); }