Java Code Examples for org.hl7.fhir.dstu3.model.Coding#setDisplay()

The following examples show how to use org.hl7.fhir.dstu3.model.Coding#setDisplay() . 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: ArgonautConverter.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private CodeableConcept inspectCode(CodeableConcept cc, Coding def) {
	if (cc != null) {
		for (Coding c : cc.getCoding()) {
			if ("http://snomed.info/sct".equals(c.getSystem())) {
				if ("ASSERTION".equals(c.getCode()))
					c.setSystem("http://hl7.org/fhir/v3/ActCode");
			}
			if ("http://hl7.org/fhir/v3/ActCode".equals(c.getSystem()) && "ASSERTION".equals(c.getCode())) {
				if (def == null)
					throw new Error("need a default code");
				c.setSystem(def.getSystem());
				c.setVersion(def.getVersion());
				c.setCode(def.getCode());
				c.setDisplay(def.getDisplay());
			}
		}
	}
	return cc;
}
 
Example 2
Source File: Convert.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
public Coding makeCodingFromCV(Element cd) throws Exception {
if (cd == null || Utilities.noString(cd.getAttribute("code")))
	return null;
 Coding c = new Coding();
 c.setCode(cd.getAttribute("code"));
 c.setDisplay(cd.getAttribute("displayName"));
 String r = cd.getAttribute("codeSystem");
 String uri = getUriForOID(r);
 if (uri != null)
 	c.setSystem(uri);
 else if (isGuid(r)) 
	c.setSystem("urn:uuid:"+r);
else if (UriForOid(r) != null)
	c.setSystem(UriForOid(r));
else 
	c.setSystem("urn:oid:"+r);
 return c;
}
 
Example 3
Source File: FhirStu3.java    From synthea with Apache License 2.0 6 votes vote down vote up
/**
 * Helper function to convert a Code into a CodeableConcept. Takes an optional system, which
 * replaces the Code.system in the resulting CodeableConcept if not null.
 *
 * @param from The Code to create a CodeableConcept from.
 * @param system The system identifier, such as a URI. Optional; may be null.
 * @return The converted CodeableConcept
 */
private static CodeableConcept mapCodeToCodeableConcept(Code from, String system) {
  CodeableConcept to = new CodeableConcept();
  system = system == null ? null : ExportHelper.getSystemURI(system);
  from.system = ExportHelper.getSystemURI(from.system);

  if (from.display != null) {
    to.setText(from.display);
  }

  Coding coding = new Coding();
  coding.setCode(from.code);
  coding.setDisplay(from.display);
  if (from.system == null) {
    coding.setSystem(system);
  } else {
    coding.setSystem(from.system);
  }

  to.addCoding(coding);

  return to;
}
 
Example 4
Source File: ObjectConverter.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static Coding readAsCoding(Element item) {
  Coding c = new Coding();
  c.setSystem(item.getNamedChildValue("system"));
  c.setVersion(item.getNamedChildValue("version"));
  c.setCode(item.getNamedChildValue("code"));
  c.setDisplay(item.getNamedChildValue("display"));
  return c;
}
 
Example 5
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;
}