Stream: mapping-framework
Topic: Transform unknown: qty
Corey Wen (Jun 04 2021 at 18:48):
I'm trying to use qty to transform a string into a Quantity resource. More generally I am trying to map a part in a QuestionnaireResponse (QR) to a quantity, specifically to Medication.strength.numerator. When I try to post my mapping to this URL it's successfully converts the mapping to a StructureMap.
The part in the mapping that uses qty is strength.numerator = qty(val)
, where val
is the answer as a string such as "5 mg".
When I POST the QR I get the error "Failed to call access method: java.lang.Error: Rule \"value\": Transform Unknown: qty".
I've also been trying to use evaluate and FHIRpath expressions,
I didn't fully understand the syntax described for evaluate, so any examples would be useful.
Eventually I tried evaluate(val, toQuantity)
in the mapping which was then converted to StructureMap w/ no errors, but when posting the QR I got the following error, where "val" in the QR == "23.4 mg"
"Failed to call access method: org.hl7.fhir.exceptions.FHIRException: Exception executing transform strength.numerator = evaluate(valtoQuantity) on Rule \"value\": Error @1, 2: Premature ExpressionNode termination at unexpected token \"mg\""
Joee Garcia (Jun 04 2021 at 19:35):
I was also getting that error when I tried using qty(val) so as a work-around, I just call create('Quantity') like below:
answerItem.answer as answer -> observation.value = create('Quantity') as newQty then {
answer.value as vs -> newQty.value = vs;
src -> newQty.unit = '/a';
src -> newQty.system = 'http://unitsofmeasure.org';
src -> newQty.code = '/a';
};
};
Corey Wen (Jun 04 2021 at 20:59):
Why is newQty .unit and .code set equal to '/a'
? Also, in your example, is answer.value a string or is it guaranteed to be a number?
In the case answer.value is "12.3 mg" how can the .value of Quantity be assigned? Is there a way to parse out the number and unit without the qty transform?
I believe qty accepts strings in the form [comparator]value[space]unit
which is why I've looking to use it.
Last updated: Apr 12 2022 at 19:14 UTC