Java Code Examples for org.hl7.fhir.dstu3.model.Observation#setValue()
The following examples show how to use
org.hl7.fhir.dstu3.model.Observation#setValue() .
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: ObservationStatsBuilder.java From org.hl7.fhir.core with Apache License 2.0 | 7 votes |
private static void addAge(Bundle b, int y, int m, String v) throws FHIRException { Observation obs = new Observation(); obs.setId("obs-example-age-weight-"+Integer.toString(y)+"-"+Integer.toString(m)); obs.setSubject(new Reference().setReference("Patient/123")); obs.setStatus(ObservationStatus.FINAL); Calendar when = Calendar.getInstance(); when.add(Calendar.YEAR, -y); when.add(Calendar.MONTH, m); obs.setEffective(new DateTimeType(when)); obs.getCode().addCoding().setCode("29463-7").setSystem("http://loinc.org"); obs.setValue(new Quantity()); obs.getValueQuantity().setCode("kg"); obs.getValueQuantity().setSystem("http://unitsofmeasure.org"); obs.getValueQuantity().setUnit("kg"); obs.getValueQuantity().setValue(new BigDecimal(v)); b.addEntry().setFullUrl("http://hl7.org/fhir/Observation/"+obs.getId()).setResource(obs); }
Example 2
Source File: ArgonautConverter.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
private void processSocialHistorySection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception { scanSection("Social History", section); int i = 0; for (Element c : cda.getChildren(section, "entry")) { Element o = cda.getChild(c, "observation"); Observation obs = new Observation(); obs.setId(context.baseId+"-smoking-"+(i == 0 ? "" : Integer.toString(i))); obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-smokingstatus-dafsmokingstatus"); i++; obs.setSubject(context.subjectRef); obs.setContext(new Reference().setReference("Encounter/"+context.encounter.getId())); obs.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "code")), new Coding().setSystem("http://loinc.org").setCode("72166-2"))); boolean found = false; for (Element e : cda.getChildren(o, "id")) { Identifier id = convert.makeIdentifierFromII(e); obs.getIdentifier().add(convert.makeIdentifierFromII(e)); } if (!found) { obs.setStatus(ObservationStatus.FINAL); obs.setEffective(convert.makeDateTimeFromTS(cda.getChild(o, "effectiveTime"))); obs.setValue(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "value")), null)); saveResource(obs, "-sh"); } } }
Example 3
Source File: TestData.java From bunsen with Apache License 2.0 | 6 votes |
/** * Returns a FHIR Observation for testing purposes. */ public static Observation newObservation() { // Observation based on https://www.hl7.org/FHIR/observation-example-bloodpressure.json.html 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); Quantity quantity = new Quantity(); quantity.setValue(new java.math.BigDecimal("123.45")); quantity.setUnit("mm[Hg]"); observation.setValue(quantity); return observation; }
Example 4
Source File: Example34_ContainedResources.java From fhirstarters with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void main(String[] args) { // Create an Observation Observation obs = new Observation(); obs.setStatus(Observation.ObservationStatus.FINAL); obs.setValue(new StringType("This is a value")); // Create a Patient Patient pat = new Patient(); pat.addName().setFamily("Simpson").addGiven("Homer"); // Assign the Patient to the Observation obs.getSubject().setResource(pat); FhirContext ctx = FhirContext.forDstu3(); String output = ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs); System.out.println(output); }
Example 5
Source File: ArgonautConverter.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
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 6
Source File: CCDAConverter.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
protected String processVitalSignsObservation(Element comp, ListResource list) throws Exception { Element observation = cda.getChild(comp, "observation"); cda.checkTemplateId(observation, "2.16.840.1.113883.10.20.22.4.27"); checkNoNegationOrNullFlavor(observation, "Vital Signs Observation"); checkNoSubject(observation, "Vital Signs Observation"); Observation obs = new Observation(); // SHALL contain at least one [1..*] id (CONF:7300). for (Element e : cda.getChildren(observation, "id")) obs.getIdentifier().add(convert.makeIdentifierFromII(e)); // SHALL contain exactly one [1..1] code, which SHOULD be selected from ValueSet Vital Sign Result Value Set 2.16.840.1.113883.3.88.12.80.62 DYNAMIC (CONF:7301). obs.setCode(convert.makeCodeableConceptFromCD(cda.getChild(observation, "code"))); // all loinc codes // SHOULD contain zero or one [0..1] text (CONF:7302). // The text, if present, SHOULD contain zero or one [0..1] reference (CONF:15943). // The reference, if present, SHOULD contain zero or one [0..1] @value (CONF:15944). // This reference/@value SHALL begin with a '#' and SHALL point to its corresponding narrative (using the approach defined in CDA Release 2, section 4.3.5.1) (CONF:15945). // todo: put this in narrative if it exists? // SHALL contain exactly one [1..1] statusCode (CONF:7303). This statusCode SHALL contain exactly one [1..1] @code="completed" Completed (CodeSystem: ActStatus 2.16.840.1.113883.5.14 STATIC) (CONF:19119). // ignore // SHALL contain exactly one [1..1] effectiveTime (CONF:7304). obs.setEffective(convert.makeMatchingTypeFromIVL(cda.getChild(observation, "effectiveTime"))); // SHALL contain exactly one [1..1] value with @xsi:type="PQ" (CONF:7305). obs.setValue(convert.makeQuantityFromPQ(cda.getChild(observation, "value"))); // MAY contain zero or one [0..1] interpretationCode (CONF:7307). obs.setInterpretation(convert.makeCodeableConceptFromCD(cda.getChild(observation, "interpretationCode"))); // MAY contain zero or one [0..1] methodCode (CONF:7308). obs.setMethod(convert.makeCodeableConceptFromCD(cda.getChild(observation, "methodCode"))); // MAY contain zero or one [0..1] targetSiteCode (CONF:7309). obs.setBodySite(convert.makeCodeableConceptFromCD(cda.getChild(observation, "targetSiteCode"))); // MAY contain zero or one [0..1] author (CONF:7310). if (cda.getChild(observation, "author") != null) obs.getPerformer().add(makeReferenceToPractitionerForAssignedEntity(cda.getChild(observation, "author"), composition)); // make a contained practitioner String n = nextRef(); obs.setId(n); list.getContained().add(obs); return n; }
Example 7
Source File: TestData.java From bunsen with Apache License 2.0 | 5 votes |
/** * 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 8
Source File: ArgonautConverter.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
private void processVitalSignsSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception { scanSection("Vital Signs", section); ListResource list = new ListResource(); list.setId(context.baseId+"-list-vitalsigns"); //. list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafproblemlist"); no list list.setSubject(context.subjectRef); list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null)); list.setTitle(cda.getChild(section, "title").getTextContent()); list.setStatus(ListStatus.CURRENT); list.setMode(ListMode.SNAPSHOT); list.setDateElement(context.now); list.setSource(context.authorRef); buildNarrative(list, cda.getChild(section, "text")); int i = 0; for (Element c : cda.getChildren(section, "entry")) { Element org = cda.getChild(c, "organizer"); // problem concern act for (Element oc : cda.getChildren(org, "component")) { Element o = cda.getChild(oc, "observation"); // problem concern act Observation obs = new Observation(); obs.setId(context.baseId+"-vitals-"+Integer.toString(i)); obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-vitalsigns-dafvitalsigns"); i++; obs.setSubject(context.subjectRef); obs.setContext(new Reference().setReference("Encounter/"+context.encounter.getId())); obs.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "code")), null)); boolean found = false; for (Element e : cda.getChildren(o, "id")) { Identifier id = convert.makeIdentifierFromII(e); obs.getIdentifier().add(id); } if (!found) { list.addEntry().setItem(new Reference().setReference("Observation/"+obs.getId())); obs.setStatus(ObservationStatus.FINAL); obs.setEffective(convert.makeDateTimeFromTS(cda.getChild(o, "effectiveTime"))); String v = cda.getChild(o, "value").getAttribute("value"); if (!Utilities.isDecimal(v, true)) { obs.setDataAbsentReason(inspectCode(new CodeableConcept().setText(v), null)); } else obs.setValue(convert.makeQuantityFromPQ(cda.getChild(o, "value"))); saveResource(obs, "-vs"); } } } saveResource(list, "-vs"); }