String patientId = patient.getIdentifier().get(0).getValue(); String familyName = patient.getName().get(0).getFamily().get(0).getValue(); String gender = patient.getGender();
/** * 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()); }
/** * Sets the MRN criterion. * * @param mrn MRN. */ public void setMRN(String mrn) { this.mrn = new IdentifierDt(); this.mrn.setType(IdentifierTypeCodesEnum.MR); this.mrn.setValue(mrn); }
@SuppressWarnings("unused") public static void main(String[] args) throws DataFormatException, IOException { Patient patient = new Patient(); patient.addIdentifier().setUse(IdentifierUseEnum.OFFICIAL).setSystem("urn:fake:mrns").setValue("7000135"); patient.addIdentifier().setUse(IdentifierUseEnum.SECONDARY).setSystem("urn:fake:otherids").setValue("3287486"); patient.addName().addFamily("Smith").addGiven("John").addGiven("Q").addSuffix("Junior"); patient.setGender(AdministrativeGenderEnum.MALE); FhirContext ctx = FhirContext.forDstu2(); String xmlEncoded = ctx.newXmlParser().encodeResourceToString(patient); String jsonEncoded = ctx.newJsonParser().encodeResourceToString(patient); MyClientInterface client = ctx.newRestfulClient(MyClientInterface.class, "http://foo/fhir"); IdentifierDt searchParam = new IdentifierDt("urn:someidentifiers", "7000135"); List<Patient> clients = client.findPatientsByIdentifier(searchParam); }
@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
/** * 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); }
/** * Sets the SSN criterion. * * @param ssn SSN. */ public void setSSN(String ssn) { this.ssn = new IdentifierDt(); this.ssn.setType(IdentifierTypeCodesEnum.SS); this.ssn.setValue(ssn); this.ssn.setSystem("http://hl7.org/fhir/sid/us-ssn"); }
public static int compareProblemIDs(String id1, String id2) { IdentifierDt ed1 = PCCUtil.parseProblemID(id1); IdentifierDt ed2 = PCCUtil.parseProblemID(id2); int i = ed1.getType().getCodingFirstRep().getCode().compareToIgnoreCase(ed2.getType().getCodingFirstRep().getCode()); if (i == 0) { int v1 = NumberUtils.toInt(ed1.getValue()); int v2 = NumberUtils.toInt(ed2.getValue()); i = v1 == v2 ? 0 : v1 > v2 ? 1 : -1; } return i; }
if (nextValue.isEmpty()) { continue; String system = StringUtils.defaultIfBlank(nextValue.getSystemElement().getValueAsString(), null); String value = nextValue.getValueElement().getValue(); if (isNotBlank(value)) { systems.add(system); if (isNotBlank(nextValue.getType().getText())) { addStringParam(theEntity, retVal, nextSpDef, nextValue.getType().getText());
/** * Sets the SSN criterion. * * @param ssn SSN. */ public void setSSN(String ssn) { this.ssn = new IdentifierDt("http://hl7.org/fhir/sid/us-ssn", ssn); this.ssn.setType(IdentifierTypeCodesEnum.SS); }
/** * Sets the identifier's type. This is a workaround for HAPI-FHIR's restrictive setter for this * property. * * @param identifier The identifier whose type is to be set. * @param code The identifier type. */ @SuppressWarnings("unchecked") public static void setIdentifierType(IdentifierDt identifier, CodeableConceptDt code) { identifier.setType((BoundCodeableConceptDt<IdentifierTypeCodesEnum>) code); }
public static IdentifierDt getIdentifier(List<IdentifierDt> list, IdentifierTypeCodesEnum... types) { for (IdentifierTypeCodesEnum type : types) { for (IdentifierDt id : list) { for (CodingDt coding : id.getType().getCoding()) { if (coding.getSystem().equals(type.getSystem()) && coding.getCode().equals(type.getCode())) { return id; } } } } return null; }
/** * Gets the value(s) for <b>system</b> (). * creating it if it does * not exist. This method may return <code>null</code>. * * <p> * <b>Definition:</b> * Establishes the namespace in which set of possible id values is unique. * </p> */ public String getSystem() { return getSystemElement().getValue(); }
public void fluent() throws DataFormatException { FhirContext ctx = new FhirContext(Patient.class, Observation.class); String encoded; //START SNIPPET: encodeMsgFluent Patient patient = new Patient(); patient.addIdentifier().setSystem("http://example.com/fictitious-mrns").setValue("MRN001"); patient.addName().setUse(NameUseEnum.OFFICIAL).addFamily("Tester").addGiven("John").addGiven("Q"); encoded = ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient); System.out.println(encoded); //END SNIPPET: encodeMsgFluent }
/** * 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); }
/** * Sets the value(s) for <b>type</b> () * * <p> * <b>Definition:</b> * A coded type for the identifier that can be used to determine which identifier to use for a specific purpose * </p> */ public IdentifierDt setType(IdentifierTypeCodesEnum theValue) { setType(new BoundCodeableConceptDt<IdentifierTypeCodesEnum>(IdentifierTypeCodesEnum.VALUESET_BINDER, theValue)); /* getType().setValueAsEnum(theValue); */ return this; }
/** * Adds and returns a new value for <b>identifier</b> (id) * * <p> * <b>Definition:</b> * Id for specimen * </p> */ public IdentifierDt addIdentifier() { IdentifierDt newType = new IdentifierDt(); getIdentifier().add(newType); return newType; }
vs.setId(StringUtils.defaultString(nextVs.getIdentifier().getValue())); vs.setClassName(toClassName(nextVs.getName()));
/** * 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; }
/** * Sets the DEA criterion. * * @param dea DEA. */ @SuppressWarnings("unchecked") public void setDEA(String dea) { this.dea = new IdentifierDt(); CodeableConceptDt type = new CodeableConceptDt(null, "DEA"); this.dea.setType((BoundCodeableConceptDt<IdentifierTypeCodesEnum>) type); this.dea.setValue(dea); }