use of org.hl7.fhir.r4.model.Quantity in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method parseQuantityString.
public Quantity parseQuantityString(String s) {
if (s == null) {
return null;
}
s = s.trim();
if (s.contains(" ")) {
String v = s.substring(0, s.indexOf(" ")).trim();
s = s.substring(s.indexOf(" ")).trim();
if (!Utilities.isDecimal(v, false)) {
return null;
}
if (s.startsWith("'") && s.endsWith("'")) {
return Quantity.fromUcum(v, s.substring(1, s.length() - 1));
}
if (s.equals("year") || s.equals("years")) {
return Quantity.fromUcum(v, "a");
} else if (s.equals("month") || s.equals("months")) {
return Quantity.fromUcum(v, "mo_s");
} else if (s.equals("week") || s.equals("weeks")) {
return Quantity.fromUcum(v, "wk");
} else if (s.equals("day") || s.equals("days")) {
return Quantity.fromUcum(v, "d");
} else if (s.equals("hour") || s.equals("hours")) {
return Quantity.fromUcum(v, "h");
} else if (s.equals("minute") || s.equals("minutes")) {
return Quantity.fromUcum(v, "min");
} else if (s.equals("second") || s.equals("seconds")) {
return Quantity.fromUcum(v, "s");
} else if (s.equals("millisecond") || s.equals("milliseconds")) {
return Quantity.fromUcum(v, "ms");
} else {
return null;
}
} else {
if (Utilities.isDecimal(s, true)) {
return new Quantity().setValue(new BigDecimal(s)).setSystem("http://unitsofmeasure.org").setCode("1");
} else {
return null;
}
}
}
use of org.hl7.fhir.r4.model.Quantity in project org.hl7.fhir.core by hapifhir.
the class FHIRToolingClientTest method generateObservation.
private Observation generateObservation() {
// Create an observation object
Observation observation = new Observation();
observation.getCode().addCoding().setSystem("http://loinc.org").setCode("789-8").setDisplay("Erythrocytes [#/volume] in Blood by Automated count");
observation.setValue(new Quantity().setValue(4.12).setUnit("10 trillion/L").setSystem("http://unitsofmeasure.org").setCode("10*12/L"));
return observation;
}
use of org.hl7.fhir.r4.model.Quantity in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method displayQuantity.
private String displayQuantity(Quantity q) {
StringBuilder s = new StringBuilder();
s.append("(system = '").append(describeSystem(q.getSystem())).append("' code ").append(q.getCode()).append(" = '").append(lookupCode(q.getSystem(), q.getCode())).append("')");
return s.toString();
}
use of org.hl7.fhir.r4.model.Quantity in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeSupplyDeliverySupplyDeliverySuppliedItemComponent.
protected void composeSupplyDeliverySupplyDeliverySuppliedItemComponent(Complex parent, String parentType, String name, SupplyDelivery.SupplyDeliverySuppliedItemComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "suppliedItem", name, element, index);
if (element.hasQuantity())
composeQuantity(t, "SupplyDelivery", "quantity", element.getQuantity(), -1);
if (element.hasItem())
composeType(t, "SupplyDelivery", "item", element.getItem(), -1);
}
use of org.hl7.fhir.r4.model.Quantity in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeExplanationOfBenefitAddedItemDetailComponent.
protected void composeExplanationOfBenefitAddedItemDetailComponent(Complex parent, String parentType, String name, ExplanationOfBenefit.AddedItemDetailComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "detail", name, element, index);
if (element.hasProductOrService())
composeCodeableConcept(t, "ExplanationOfBenefit", "productOrService", element.getProductOrService(), -1);
for (int i = 0; i < element.getModifier().size(); i++) composeCodeableConcept(t, "ExplanationOfBenefit", "modifier", element.getModifier().get(i), i);
if (element.hasQuantity())
composeQuantity(t, "ExplanationOfBenefit", "quantity", element.getQuantity(), -1);
if (element.hasUnitPrice())
composeMoney(t, "ExplanationOfBenefit", "unitPrice", element.getUnitPrice(), -1);
if (element.hasFactorElement())
composeDecimal(t, "ExplanationOfBenefit", "factor", element.getFactorElement(), -1);
if (element.hasNet())
composeMoney(t, "ExplanationOfBenefit", "net", element.getNet(), -1);
for (int i = 0; i < element.getNoteNumber().size(); i++) composePositiveInt(t, "ExplanationOfBenefit", "noteNumber", element.getNoteNumber().get(i), i);
for (int i = 0; i < element.getAdjudication().size(); i++) composeExplanationOfBenefitAdjudicationComponent(t, "ExplanationOfBenefit", "adjudication", element.getAdjudication().get(i), i);
for (int i = 0; i < element.getSubDetail().size(); i++) composeExplanationOfBenefitAddedItemDetailSubDetailComponent(t, "ExplanationOfBenefit", "subDetail", element.getSubDetail().get(i), i);
}
Aggregations