/** * 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 "@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; }
/** * 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; }
@SuppressWarnings("unused") public static void codes() { // START SNIPPET: codes Patient patient = new Patient(); // You can set this code using a String if you want. Note that // for "closed" valuesets (such as the one used for Patient.gender) // you must use one of the strings defined by the FHIR specification. // You must not define your own. patient.getGenderElement().setValue("male"); // HAPI also provides Java enumerated types which make it easier to // deal with coded values. This code achieves the exact same result // as the code above. patient.setGender(AdministrativeGenderEnum.MALE); // You can also retrieve coded values the same way String genderString = patient.getGenderElement().getValueAsString(); AdministrativeGenderEnum genderEnum = patient.getGenderElement().getValueAsEnum(); // The following is a shortcut to create patient.setMaritalStatus(MaritalStatusCodesEnum.M); // END SNIPPET: codes }
/** * Sets the value(s) for <b>gender</b> () * * <p> * <b>Definition:</b> * Administrative Gender - the gender that the patient is considered to have for administration and record keeping purposes. * </p> */ public Patient setGender(AdministrativeGenderEnum theValue) { setGender(new BoundCodeDt<AdministrativeGenderEnum>(AdministrativeGenderEnum.VALUESET_BINDER, theValue)); /* getGenderElement().setValueAsEnum(theValue); */ return this; }
@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); }
.addGiven("J") .addGiven("Jonah"); patient.setGender(AdministrativeGenderEnum.MALE);
patient.setGender(AdministrativeGenderEnum.FEMALE);
while (rs.next()) { /* Do Here */ Patient patient = new Patient(); patient.setId(rs.getString(1)); patient.setName(rs.getString(2)); patient.setLastName(rs.getString(3)); patient.setGender(rs.getString(4)); patient.setAge(rs.getString(5)); patient.setPhoneNumber(rs.getString(6)); patient.setAddress(rs.getString(7)); patient.setDisease(rs.getString(8)); patient.setCondition(rs.getString(9)); patient.setRoomType(rs.getString(10)); patient.setRoomNumber(rs.getString(11)); patient.setDate(rs.getString(12)); patients.add(patient); }