Java Code Examples for org.hl7.fhir.dstu3.model.Patient#setGender()

The following examples show how to use org.hl7.fhir.dstu3.model.Patient#setGender() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FhirSearchTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void searchTest() {
    Patient one = new Patient();
    one.setId("one");
    one.setGender(Enumerations.AdministrativeGender.UNKNOWN);
    Patient two = new Patient();
    two.setId("two");
    two.setGender(Enumerations.AdministrativeGender.UNKNOWN);

    Bundle bundle = new Bundle();
    bundle.getEntry().add(new Bundle.BundleEntryComponent().setResource(one));
    bundle.getEntry().add(new Bundle.BundleEntryComponent().setResource(two));

    stubFhirRequest(get(urlEqualTo("/Patient?gender=unknown&_format=xml")).willReturn(okXml(toXml(bundle))));

    FhirResourceQuery query = new FhirResourceQuery();
    query.setQuery("gender=unknown");

    String result = template.requestBody("direct:start", query, String.class);

    Assertions.assertThat(result).isEqualTo(
        "[<Patient xmlns=\"http://hl7.org/fhir\"><id value=\"one\"/><gender value=\"unknown\"/></Patient>, " +
        "<Patient xmlns=\"http://hl7.org/fhir\"><id value=\"two\"/><gender value=\"unknown\"/></Patient>]");
}
 
Example 2
Source File: Example09_Interceptors.java    From fhirstarters with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void main(String[] theArgs) {

		// Create a client
      IGenericClient client = FhirContext.forDstu3().newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3");

      // Register some interceptors
      client.registerInterceptor(new CookieInterceptor("mycookie=Chips Ahoy"));
      client.registerInterceptor(new LoggingInterceptor());

      // Read a Patient
      Patient patient = client.read().resource(Patient.class).withId("example").execute();

		// Change the gender
		patient.setGender(patient.getGender() == AdministrativeGender.MALE ? AdministrativeGender.FEMALE : AdministrativeGender.MALE);

		// Update the patient
		MethodOutcome outcome = client.update().resource(patient).execute();
		
		System.out.println("Now have ID: " + outcome.getId());
	}
 
Example 3
Source File: Example04_EncodeResource.java    From fhirstarters with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void main(String[] theArgs) {

		// Create a Patient
		Patient pat = new Patient();
		pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("J");
		pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("7000135");
		pat.addTelecom().setUse(ContactPointUse.HOME).setSystem(ContactPointSystem.PHONE).setValue("1 (416) 340-4800");
		pat.setGender(AdministrativeGender.MALE);

		// Create a context
		FhirContext ctx = FhirContext.forDstu3();

		// Create a JSON parser
		IParser parser = ctx.newJsonParser();
		parser.setPrettyPrint(true);

		String encode = parser.encodeResourceToString(pat);
		System.out.println(encode);

	}
 
Example 4
Source File: Example02_EnumeratedTypes.java    From fhirstarters with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] theArgs) {

      Patient pat = new Patient();

      pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("J");
      pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("7000135");

      // Enumerated types are provided for many coded elements
      ContactPoint contact = pat.addTelecom();
      contact.setUse(ContactPoint.ContactPointUse.HOME);
      contact.setSystem(ContactPoint.ContactPointSystem.PHONE);
      contact.setValue("1 (416) 340-4800");

      pat.setGender(Enumerations.AdministrativeGender.MALE);
   }
 
Example 5
Source File: Example02_EnumeratedTypes.java    From fhirstarters with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] theArgs) {

      Patient pat = new Patient();

      pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("J");
      pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("7000135");

      // Enumerated types are provided for many coded elements
      ContactPoint contact = pat.addTelecom();
      contact.setUse(ContactPoint.ContactPointUse.HOME);
      contact.setSystem(ContactPoint.ContactPointSystem.PHONE);
      contact.setValue("1 (416) 340-4800");

      pat.setGender(Enumerations.AdministrativeGender.MALE);
   }
 
Example 6
Source File: TestData.java    From bunsen with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a new Patient for testing.
 *
 * @return a FHIR Patient for testing.
 */
public static Patient newPatient() {

  Patient patient = new Patient();

  patient.setId("test-patient");
  patient.setGender(AdministrativeGender.MALE);
  patient.setActive(true);
  patient.setMultipleBirth(new IntegerType(1));

  patient.setBirthDateElement(new DateType("1945-01-02"));

  patient.addGeneralPractitioner().setReference("Practitioner/12345");

  Identifier practitionerIdentifier = new Identifier();
  practitionerIdentifier.setId("P123456");
  practitionerIdentifier.getAssigner().setReference("Organization/123456");
  patient.getGeneralPractitionerFirstRep().setIdentifier(practitionerIdentifier);

  Address address = patient.addAddress();
  address.addLine("123 Fake Street");
  address.setCity("Chicago");
  address.setState("IL");
  address.setDistrict("12345");

  Extension birthSex = patient.addExtension();

  birthSex.setUrl(US_CORE_BIRTHSEX);
  birthSex.setValue(new CodeType("M"));

  Extension ethnicity = patient.addExtension();
  ethnicity.setUrl(US_CORE_ETHNICITY);
  ethnicity.setValue(null);

  Coding ombCoding = new Coding();

  ombCoding.setSystem("urn:oid:2.16.840.1.113883.6.238");
  ombCoding.setCode("2135-2");
  ombCoding.setDisplay("Hispanic or Latino");

  // Add category to ethnicity extension
  Extension ombCategory = ethnicity.addExtension();

  ombCategory.setUrl("ombCategory");
  ombCategory.setValue(ombCoding);

  // Add multiple detailed sub-extension to ethnicity extension
  Coding detailedCoding1 = new Coding();
  detailedCoding1.setSystem("urn:oid:2.16.840.1.113883.6.238");
  detailedCoding1.setCode("2165-9");
  detailedCoding1.setDisplay("South American");

  Coding detailedCoding2 = new Coding();
  detailedCoding2.setSystem("urn:oid:2.16.840.1.113883.6.238");
  detailedCoding2.setCode("2166-7");
  detailedCoding2.setDisplay("Argentinean");

  final Extension detailed1 = ethnicity.addExtension();
  detailed1.setUrl("detailed");
  detailed1.setValue(detailedCoding1);

  final Extension detailed2 = ethnicity.addExtension();
  detailed2.setUrl("detailed");
  detailed2.setValue(detailedCoding2);

  // Add text display to ethnicity extension
  Extension ethnicityText = ethnicity.addExtension();
  ethnicityText.setUrl("text");
  ethnicityText.setValue(new StringType("Not Hispanic or Latino"));

  // Human Name
  HumanName humanName = new HumanName();
  humanName.setFamily("family_name");
  humanName.addGiven("given_name");
  humanName.addGiven("middle_name");
  patient.addName(humanName);

  return patient;
}