Java Code Examples for org.hl7.fhir.dstu3.model.CodeableConcept

The following examples show how to use org.hl7.fhir.dstu3.model.CodeableConcept. These examples are extracted from open source projects. 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 Project: org.hl7.fhir.core   Source File: ArgonautConverter.java    License: 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 Project: org.hl7.fhir.core   Source File: ArgonautConverter.java    License: Apache License 2.0 6 votes vote down vote up
private void makeDocumentReference(CDAUtilities cda, Convert convert, Element doc, Context context) throws Exception {
	scanSection("document", doc);
	DocumentReference ref = new DocumentReference();
	ref.setId(context.baseId+"-document");
	ref.setMasterIdentifier(convert.makeIdentifierFromII(cda.getChild(doc, "id")));
	ref.setSubject(context.subjectRef);
	ref.setType(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(doc, "code")), null));
	ref.addAuthor(context.authorRef);
	ref.setCreatedElement(convert.makeDateTimeFromTS(cda.getChild(doc, "effectiveTime")));
	ref.setIndexedElement(InstantType.now());
	ref.setStatus(DocumentReferenceStatus.CURRENT);
	ref.addSecurityLabel(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(doc, "confidentialityCode")), null));
	DocumentReferenceContentComponent cnt = ref.addContent();
	cnt.getAttachment().setContentType("application/hl7-v3+xml").setUrl("Binary/"+context.baseId).setLanguage(convertLanguage(cda.getChild(doc, "language")));
	//		for (Element ti : cda.getChildren(doc, "templateId"))
	//			cnt.addFormat().setSystem("urn:oid:1.3.6.1.4.1.19376.1.2.3").setCode(value)("urn:oid:"+ti.getAttribute("root"));
	ref.setContext(new DocumentReferenceContextComponent());
	ref.getContext().setPeriod(convert.makePeriodFromIVL(cda.getChild(cda.getChild(doc, "serviceEvent"), "effectiveTime")));
	for (CodeableConcept cc : context.encounter.getType())
		ref.getContext().addEvent(cc);
	ref.setDescription(cda.getChild(doc, "title").getTextContent());
	ref.setCustodian(new Reference().setReference("Organization/"+processOrganization(cda.getDescendent(doc, "custodian/assignedCustodian/representedCustodianOrganization"), cda, convert, context).getId()));
	Practitioner p = processPerformer(cda, convert, context, cda.getChild(doc, "legalAuthenticator"), "assignedEntity", "assignedPerson");
	ref.setAuthenticator(new Reference().setReference("Practitioner/"+p.getId()).setDisplay(p.getUserString("display")));
	saveResource(ref);
}
 
Example 3
Source Project: org.hl7.fhir.core   Source File: ArgonautConverter.java    License: Apache License 2.0 6 votes vote down vote up
private CodeableConcept makeClassCode(CodeableConcept type, DocumentReference ref) throws Exception {
	CodeableConcept res = new CodeableConcept();
	String cs = type.getCoding().get(0).getCode();
	if (cs.equals("18842-5") || cs.equals("34133-9"))
		return type;
	else if (cs.equals("34111-5")) {
		ref.getFormatCommentsPre().add("The underlying CDA document has the code '34111-5: Evaluation and Management Note' which is incorrect (wrong display/code combination). The type has been preserved even though it's wrong");
		res.addCoding().setSystem("http://loinc.org").setCode("34109-9").setDisplay("Evaluation and management note");
	}
	//		else if (cs.equals("34111-5") || cs.equals("5666"))
	//		  res.addCoding().setSystem("http://loinc.org").setCode("LP173418-7").setDisplay("Note");
	else
		throw new Exception("Uncategorised document type code: "+cs+": "+type.getCoding().get(0).getDisplay());
	return res;

}
 
Example 4
Source Project: org.hl7.fhir.core   Source File: Convert.java    License: Apache License 2.0 6 votes vote down vote up
public CodeableConcept makeCodeableConceptFromCD(Element cv) throws Exception {
		if (cv == null)
			return null;
		CodeableConcept cc = new CodeableConcept();
		cc.addCoding(makeCodingFromCV(cv));
		for (Element e : cda.getChildren(cv, "translation"))
			cc.addCoding(makeCodingFromCV(e));
		if (cda.getChild(cv, "originalText") != null) {
			Element ote = cda.getChild(cv, "originalText");
//			if (cda.getChild(ote, "reference") != null) {
//				if (cda.getChild(ote, "reference").getAttribute("value").startsWith("#")) {
//					Element t = cda.getByXmlId(cda.getChild(ote, "reference").getAttribute("value").substring(1));
//					String ot = t.getTextContent().trim();
//					cc.setText(Utilities.noString(ot) ? null : ot);
//				} else
//					throw new Exception("external references not handled yet "+cda.getChild(ote, "reference").getAttribute("value"));
//			} else {	  		
				String ot = ote.getTextContent().trim();
				cc.setText(Utilities.noString(ot) ? null : ot);
	  	//}  
	  }
	  return cc;
  }
 
Example 5
@Test
public void convertCondition20() throws IOException {
	// condition format of HAPI FHIR 2.0
	String oldContent = AllTests.getResourceAsString("/rsc/json/ConditionFormat20.json");
	assertFalse(FindingsFormatUtil.isCurrentFindingsFormat(oldContent));

	Optional<String> newContent = FindingsFormatUtil.convertToCurrentFindingsFormat(oldContent);
	assertTrue(newContent.isPresent());

	IBaseResource resource = AllTests.getJsonParser().parseResource(newContent.get());
	assertTrue(resource instanceof Condition);
	Condition condition = (Condition) resource;

	// category changed from diagnosis to problem-list-item
	List<CodeableConcept> category = condition.getCategory();
	assertFalse(category.isEmpty());
	CodeableConcept code = category.get(0);
	List<Coding> coding = code.getCoding();
	assertFalse(coding.isEmpty());
	assertTrue(coding.get(0).getCode().equals(ConditionCategory.PROBLEMLISTITEM.getCode()));
	// dateRecorded changed to assertedDate
	Date assertedDate = condition.getAssertedDate();
	assertNotNull(assertedDate);
}
 
Example 6
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());
    // also, populate the XPath variant
    StringType s = new StringType();
    s.setValue(Utilities.fhirPathToXPath(message.getLocation())+(message.getLine()>= 0 && message.getCol() >= 0 ? " (line "+Integer.toString(message.getLine())+", col"+Integer.toString(message.getCol())+")" : "") );
    issue.getLocation().add(s);
  }
  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 7
Source Project: org.hl7.fhir.core   Source File: BaseWorkerContext.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
private String describeValidationParameters(Parameters pin) {
  CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
  for (ParametersParameterComponent p : pin.getParameter()) {
    if (p.hasValue() && p.getValue() instanceof PrimitiveType) {
      b.append(p.getName() + "=" + ((PrimitiveType) p.getValue()).asStringValue());
    } else if (p.hasValue() && p.getValue() instanceof Coding) {
      b.append("system=" + ((Coding) p.getValue()).getSystem());
      b.append("code=" + ((Coding) p.getValue()).getCode());
      b.append("display=" + ((Coding) p.getValue()).getDisplay());
    } else if (p.hasValue() && p.getValue() instanceof CodeableConcept) {
      if (((CodeableConcept) p.getValue()).hasCoding()) {
        Coding c = ((CodeableConcept) p.getValue()).getCodingFirstRep();
        b.append("system=" + c.getSystem());
        b.append("code=" + c.getCode());
        b.append("display=" + c.getDisplay());
      } else if (((CodeableConcept) p.getValue()).hasText()) {
        b.append("text=" + ((CodeableConcept) p.getValue()).getText());
      }
    } else if (p.hasResource() && (p.getResource() instanceof ValueSet)) {
      b.append("valueset=" + getVSSummary((ValueSet) p.getResource()));
    }
  }
  return b.toString();
}
 
Example 8
Source Project: synthea   Source File: FhirStu3.java    License: 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 9
public static void main(String[] theArgs) {
Patient pat = new Patient();
pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("J");

// Add an extension on the resource
pat.addExtension()
		.setUrl("http://hl7.org/fhir/StructureDefinition/patient-importance")
		.setValue(new CodeableConcept().setText("Patient is a VIP"));

// Add an extension on a primitive
pat.getBirthDateElement().setValueAsString("1955-02-22");
pat.getBirthDateElement().addExtension()
		.setUrl("http://hl7.org/fhir/StructureDefinition/patient-birthTime")
		.setValue(new TimeType("23:30"));

    IParser parser = FhirContext.forDstu3().newJsonParser().setPrettyPrint(true);
    System.out.println(parser.encodeResourceToString(pat));
 }
 
Example 10
Source Project: elexis-3-core   Source File: ObservationAccessor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public void setCategory(DomainResource resource, ObservationCategory category){
	org.hl7.fhir.dstu3.model.Observation fhirObservation =
		(org.hl7.fhir.dstu3.model.Observation) resource;
	CodeableConcept categoryCode = new CodeableConcept();
	if (category.name().startsWith("SOAP_")) {
		// elexis soap categories
		categoryCode.setCoding(
			Collections.singletonList(new Coding(IdentifierSystem.ELEXIS_SOAP.getSystem(),
				category.getCode(), category.getLocalized())));
	} else {
		org.hl7.fhir.dstu3.model.codesystems.ObservationCategory fhirCategoryCode =
			(org.hl7.fhir.dstu3.model.codesystems.ObservationCategory) categoryMapping
				.getFhirEnumValueByEnum(category);
		if (fhirCategoryCode != null) {
			// lookup matching fhir category
			categoryCode
				.setCoding(Collections.singletonList(new Coding(fhirCategoryCode.getSystem(),
					fhirCategoryCode.toCode(), fhirCategoryCode.getDisplay())));
		} else {
			throw new IllegalStateException("Unknown observation category " + category);
		}
	}
	if (!categoryCode.getCoding().isEmpty()) {
		fhirObservation.setCategory(Collections.singletonList(categoryCode));
	}
}
 
Example 11
Source Project: elexis-3-core   Source File: ObservationAccessor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public List<ObservationComponent> getComponents(DomainResource resource){
	org.hl7.fhir.dstu3.model.Observation fhirObservation =
		(org.hl7.fhir.dstu3.model.Observation) resource;
	List<ObservationComponent> components = new ArrayList<>();
	
	for (ObservationComponentComponent o : fhirObservation.getComponent()) {
		ObservationComponent component = new ObservationComponent(o.getId());
		CodeableConcept codeableConcept = o.getCode();
		if (codeableConcept != null) {
			component.setCoding(ModelUtil.getCodingsFromConcept(codeableConcept));
			component.setExtensions(getExtensions(o));
			
			if (o.hasValueQuantity()) {
				Quantity quantity = (Quantity) o.getValue();
				component.setNumericValue(quantity.getValue());
				component.setNumericValueUnit(quantity.getUnit());
			} else if (o.hasValueStringType()) {
				StringType stringType = (StringType) o.getValue();
				component.setStringValue(stringType.getValue());
			}
		}
		components.add(component);
	}
	return components;
}
 
Example 12
Source Project: org.hl7.fhir.core   Source File: ArgonautConverter.java    License: Apache License 2.0 5 votes vote down vote up
private Observation processObservation(CDAUtilities cda, Convert convert, Context context, Element o) throws Exception {
	Observation obs = new Observation();
	obs.setId(context.baseId+"-results-"+Integer.toString(context.obsId));
	context.obsId++;
	obs.setSubject(context.subjectRef);
	obs.setContext(new Reference().setReference("Encounter/"+context.encounter.getId()));
	obs.setStatus(ObservationStatus.FINAL);
	obs.setEffective(convert.makeDateTimeFromTS(cda.getChild(o, "effectiveTime")));
	obs.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "code")), null));
	obs.setInterpretation(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "interpretationCode")), null));
	Element rr = cda.getChild(o, "referenceRange");
	if (rr != null)
		obs.addReferenceRange().setText(cda.getChild(cda.getChild(rr, "observationRange"), "text").getTextContent());

	Element v = cda.getChild(o, "value");
	String type = v.getAttribute("xsi:type");
	if ("ST".equals(type)) {
		obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-results-dafresultobsother");
		obs.setValue(new StringType(v.getTextContent()));
	} else if ("CD".equals(type)) {
		obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-results-dafresultobscode");
		obs.setValue(inspectCode(convert.makeCodeableConceptFromCD(v), null));
	} else if ("PQ".equals(type)) {
		obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-results-dafresultobsquantity");
		String va = cda.getChild(o, "value").getAttribute("value");
		if (!Utilities.isDecimal(va, true)) {
			obs.setDataAbsentReason(inspectCode(new CodeableConcept().setText(va), null));
		} else
			obs.setValue(convert.makeQuantityFromPQ(cda.getChild(o, "value"), null));
	} else
		throw new Exception("Unknown type '"+type+"'");

	for (Element e : cda.getChildren(o, "id")) {
		Identifier id = convert.makeIdentifierFromII(e);
		obs.getIdentifier().add(id);
	}
	saveResource(obs, "-gen");
	return obs;
}
 
Example 13
Source Project: org.hl7.fhir.core   Source File: CCDAConverter.java    License: Apache License 2.0 5 votes vote down vote up
protected CodeableConcept processIndication(Element obs) throws Exception {
	Element v = cda.getChild(obs, "value");
	if (v == null) {
		// have to find it by ID
		Element o = cda.getById(cda.getChild(obs, "id"), "value");
		if (o != null)
			v = cda.getChild(obs, "value");
	}
	if (v != null)
		return convert.makeCodeableConceptFromCD(v);
	else
		return null;
}
 
Example 14
Source Project: org.hl7.fhir.core   Source File: CCDAConverter.java    License: Apache License 2.0 5 votes vote down vote up
protected void addToCodeableList(List<CodeableConcept> list, CodeableConcept code) throws Exception {
	for (CodeableConcept item : list) {
		if (Comparison.matches(item, code, null))
			Comparison.merge(item, code);
	}
	list.add(code);
}
 
Example 15
Source Project: org.hl7.fhir.core   Source File: ObjectConverter.java    License: 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 16
Source Project: org.hl7.fhir.core   Source File: LoincToDEConvertor.java    License: 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 17
Source Project: org.hl7.fhir.core   Source File: ProfileUtilities.java    License: Apache License 2.0 5 votes vote down vote up
private boolean hasDescription(Type fixed) {
  if (fixed instanceof Coding) {
    return ((Coding) fixed).hasDisplay();
  } else if (fixed instanceof CodeableConcept) {
    CodeableConcept cc = (CodeableConcept) fixed;
    if (cc.hasText())
      return true;
    for (Coding c : cc.getCoding())
      if (c.hasDisplay())
       return true;
  } // (fixed instanceof CodeType) || (fixed instanceof Quantity);
  return false;
}
 
Example 18
Source Project: org.hl7.fhir.core   Source File: ProfileUtilities.java    License: Apache License 2.0 5 votes vote down vote up
private String summarise(Type value) throws IOException {
  if (value instanceof Coding)
    return summariseCoding((Coding) value);
  else if (value instanceof CodeableConcept)
    return summariseCodeableConcept((CodeableConcept) value);
  else
    return buildJson(value);
}
 
Example 19
Source Project: org.hl7.fhir.core   Source File: ToolingExtensions.java    License: Apache License 2.0 5 votes vote down vote up
public static void setAllowableUnits(ElementDefinition eld, CodeableConcept cc) {
  for (Extension e : eld.getExtension()) 
    if (e.getUrl().equals(EXT_ALLOWABLE_UNITS)) {
      e.setValue(cc);
      return;
    }
  eld.getExtension().add(new Extension().setUrl(EXT_ALLOWABLE_UNITS).setValue(cc));
}
 
Example 20
Source Project: org.hl7.fhir.core   Source File: ResourceUtilities.java    License: Apache License 2.0 5 votes vote down vote up
private static String renderDEUnits(Type units) {
  if (units == null || units.isEmpty())
    return "";
  if (units instanceof CodeableConcept)
    return renderCodeable((CodeableConcept) units);
  else
    return "<a href=\""+Utilities.escapeXml(((Reference) units).getReference())+"\">"+Utilities.escapeXml(((Reference) units).getReference())+"</a>";
    
}
 
Example 21
Source Project: org.hl7.fhir.core   Source File: ResourceUtilities.java    License: Apache License 2.0 5 votes vote down vote up
private static String renderCodeable(CodeableConcept units) {
  if (units == null || units.isEmpty())
    return "";
  String v = renderCoding(units.getCoding());
  if (units.hasText())
    v = v + " " +Utilities.escapeXml(units.getText());
  return v;
}
 
Example 22
Source Project: org.hl7.fhir.core   Source File: NarrativeGenerator.java    License: Apache License 2.0 5 votes vote down vote up
public String genType(Type type) throws DefinitionException {
  if (type instanceof Coding)
    return gen((Coding) type);
  if (type instanceof CodeableConcept)
    return displayCodeableConcept((CodeableConcept) type);
  if (type instanceof Quantity)
    return displayQuantity((Quantity) type);
  if (type instanceof Range)
    return displayRange((Range) type);
  return null;
}
 
Example 23
Source Project: org.hl7.fhir.core   Source File: NarrativeGenerator.java    License: Apache License 2.0 5 votes vote down vote up
public String gen(CodeableConcept code) {
	if (code == null)
  	return null;
	if (code.hasText())
		return code.getText();
	if (code.hasCoding())
		return gen(code.getCoding().get(0));
	return null;
}
 
Example 24
Source Project: org.hl7.fhir.core   Source File: BaseWorkerContext.java    License: Apache License 2.0 5 votes vote down vote up
private ValidationResult handleByCache(ValueSet vs, CodeableConcept concept, boolean tryCache) {
  String cacheId = cacheId(concept);
  Map<String, ValidationResult> cache = validationCache.get(vs.getUrl());
  if (cache == null) {
    cache = new HashMap<String, IWorkerContext.ValidationResult>();
    validationCache.put(vs.getUrl(), cache);
  }
  if (cache.containsKey(cacheId)) {
    return cache.get(cacheId);
  }

  if (validationCache.containsKey(vs.getUrl()) && validationCache.get(vs.getUrl())
    .containsKey(cacheId)) {
    return validationCache.get(vs.getUrl()).get(cacheId);
  }
  if (!tryCache) {
    return null;
  }
  if (!cacheValidation) {
    return null;
  }
  if (failed.contains(vs.getUrl())) {
    return null;
  }
  ValueSetExpansionOutcome vse = expandVS(vs, true, false);
  if (vse.getValueset() == null || notcomplete(vse.getValueset())) {
    failed.add(vs.getUrl());
    return null;
  }
  ValidationResult res = validateCode(concept, vse.getValueset());
  cache.put(cacheId, res);
  return res;
}
 
Example 25
Source Project: org.hl7.fhir.core   Source File: BaseWorkerContext.java    License: Apache License 2.0 5 votes vote down vote up
private String cacheId(CodeableConcept cc) {
  StringBuilder b = new StringBuilder();
  for (Coding c : cc.getCoding()) {
    b.append("#");
    b.append(cacheId(c));
  }
  return b.toString();
}
 
Example 26
Source Project: org.hl7.fhir.core   Source File: BaseWorkerContext.java    License: Apache License 2.0 5 votes vote down vote up
private ValidationResult verifyCodeExternal(ValueSet vs, CodeableConcept cc, boolean tryCache)
  throws Exception {
  ValidationResult res = handleByCache(vs, cc, tryCache);
  if (res != null) {
    return res;
  }
  Parameters pin = new Parameters();
  pin.addParameter().setName("codeableConcept").setValue(cc);
  pin.addParameter().setName("valueSet").setResource(vs);
  res = serverValidateCode(pin, false);
  Map<String, ValidationResult> cache = validationCache.get(vs.getUrl());
  cache.put(cacheId(cc), res);
  return res;
}
 
Example 27
Source Project: org.hl7.fhir.core   Source File: BaseWorkerContext.java    License: Apache License 2.0 5 votes vote down vote up
private ValidationResult verifyCodeInternal(ValueSet vs, CodeableConcept code) throws Exception {
  for (Coding c : code.getCoding()) {
    ValidationResult res = verifyCodeInternal(vs, c.getSystem(), c.getCode(), c.getDisplay());
    if (res.isOk()) {
      return res;
    }
  }
  if (code.getCoding().isEmpty()) {
    return new ValidationResult(IssueSeverity.ERROR, "None code provided");
  } else {
    return new ValidationResult(IssueSeverity.ERROR,
      "None of the codes are in the specified value set");
  }
}
 
Example 28
Source Project: elexis-3-core   Source File: ModelUtil.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public static List<ICoding> getCodingsFromConcept(CodeableConcept codeableConcept){
	ArrayList<ICoding> ret = new ArrayList<>();
	List<Coding> coding = codeableConcept.getCoding();
	for (Coding code : coding) {
		ret.add(new CodingWrapper(code));
	}
	return ret;
}
 
Example 29
Source Project: bunsen   Source File: TestData.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new Observation for testing.
 *
 * @return a FHIR Observation for testing.
 */
public static Observation newObservation() {
  Observation observation = new Observation();

  observation.setId("blood-pressure");

  Identifier identifier = observation.addIdentifier();
  identifier.setSystem("urn:ietf:rfc:3986");
  identifier.setValue("urn:uuid:187e0c12-8dd2-67e2-99b2-bf273c878281");

  observation.setStatus(Observation.ObservationStatus.FINAL);

  CodeableConcept obsCode = new CodeableConcept();

  observation.setCode(obsCode);

  Quantity quantity = new Quantity();
  quantity.setValue(new java.math.BigDecimal("123.45"));
  quantity.setUnit("mm[Hg]");
  quantity.setSystem("http://unitsofmeasure.org");
  observation.setValue(quantity);

  ObservationComponentComponent component = observation.addComponent();

  CodeableConcept code = new CodeableConcept()
      .addCoding(new Coding()
          .setCode("abc")
          .setSystem("PLACEHOLDER"));

  component.setCode(code);

  return observation;
}
 
Example 30
Source Project: bunsen   Source File: TestData.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new Medication for testing.
 *
 * @return a FHIR Medication for testing.
 */
public static Medication newMedication(String id) {

  Medication medication = new Medication();

  medication.setId(id);

  CodeableConcept itemCodeableConcept = new CodeableConcept();
  itemCodeableConcept.addCoding()
      .setSystem("http://www.nlm.nih.gov/research/umls/rxnorm")
      .setCode("103109")
      .setDisplay("Vitamin E 3 MG Oral Tablet [Ephynal]")
      .setUserSelected(true);

  MedicationIngredientComponent ingredientComponent = new MedicationIngredientComponent();
  ingredientComponent.setItem(itemCodeableConcept);

  medication.addIngredient(ingredientComponent);

  Reference itemReference = new Reference("test-item-reference");

  MedicationPackageContentComponent medicationPackageContentComponent =
      new MedicationPackageContentComponent();
  medicationPackageContentComponent.setItem(itemReference);

  MedicationPackageComponent medicationPackageComponent = new MedicationPackageComponent();
  medicationPackageComponent.addContent(medicationPackageContentComponent);

  medication.setPackage(medicationPackageComponent);

  return medication;
}