Java Code Examples for org.hl7.fhir.r4.model.CodeableConcept#setText()

The following examples show how to use org.hl7.fhir.r4.model.CodeableConcept#setText() . 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: OperationOutcomeUtilities.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
public static OperationOutcomeIssueComponent convertToIssue(ValidationMessage message, OperationOutcome op) {
  OperationOutcomeIssueComponent issue = new OperationOutcome.OperationOutcomeIssueComponent();
  issue.setCode(convert(message.getType()));
  
  if (message.getLocation() != null) {
    // message location has a fhirPath in it. We need to populate the expression
    issue.addExpression(message.getLocation());
  }
  // pass through line/col if they're present
  if (message.getLine() != 0)
    issue.addExtension().setUrl(ToolingExtensions.EXT_ISSUE_LINE).setValue(new IntegerType(message.getLine()));
  if (message.getCol() != 0)
    issue.addExtension().setUrl(ToolingExtensions.EXT_ISSUE_COL).setValue(new IntegerType(message.getCol()));
  issue.setSeverity(convert(message.getLevel()));
  CodeableConcept c = new CodeableConcept();
  c.setText(message.getMessage());
  issue.setDetails(c);
  if (message.getSource() != null) {
    issue.getExtension().add(ToolingExtensions.makeIssueSource(message.getSource()));
  }
  return issue;
}
 
Example 2
Source File: FhirR4.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 3
Source File: ObjectConverter.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static CodeableConcept readAsCodeableConcept(Element element) {
  CodeableConcept cc = new CodeableConcept();
  List<Element> list = new ArrayList<Element>();
  element.getNamedChildren("coding", list);
  for (Element item : list)
    cc.addCoding(readAsCoding(item));
  cc.setText(element.getNamedChildValue("text"));
  return cc;
}
 
Example 4
Source File: LoincToDEConvertor.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private CodeableConcept makeUnits(String text, String ucum) {
	if (Utilities.noString(text) && Utilities.noString(ucum))
		return null;
	CodeableConcept cc = new CodeableConcept();
	cc.setText(text);
	cc.getCoding().add(new Coding().setCode(ucum).setSystem("http://unitsofmeasure.org"));
	return cc;
}
 
Example 5
Source File: TestData.java    From bunsen with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a FHIR medication request for testing purposes.
 */
public static MedicationRequest newMedRequest() {

  MedicationRequest medReq = new MedicationRequest();

  medReq.setId("test-med");

  // Medication code
  CodeableConcept med = new CodeableConcept();
  med.addCoding()
      .setSystem("http://www.nlm.nih.gov/research/umls/rxnorm")
      .setCode("582620")
      .setDisplay("Nizatidine 15 MG/ML Oral Solution [Axid]");

  med.setText("Nizatidine 15 MG/ML Oral Solution [Axid]");

  medReq.setMedication(med);

  Annotation annotation = new Annotation();

  annotation.setText("Test medication note.");

  annotation.setAuthor(
      new Reference("Provider/example")
          .setDisplay("Example provider."));

  medReq.addNote(annotation);

  return medReq;
}