Stream: mapping-framework
Topic: split operation in mapping rules
amit bodhwani (Jul 15 2021 at 11:36):
Hello all,
In am trying to create Immunization resource using mapping rules.
In Immunization resource doseQuantity is of data type SimpleQuantity.
In my input json i have a field called dose which has both value an unit separated by a space between.
For E.g. "dose" : "<Some Value> <Unit> ", here before writing the mapping rule, I want to split the field "dose" from input json based on space and get the value and unit.
Is it possible to split any field based on a character/string in mapping rules.
Lloyd McKenzie (Jul 15 2021 at 14:21):
@Joee Garcia
Oliver Egger (Jul 15 2021 at 14:24):
yes, but you would need to split it in the target, e.g. you can use the fhirPath functions substring and indexOf, see an example here
amit bodhwani (Jul 16 2021 at 06:27):
Oliver Egger said:
yes, but you would need to split it in the target, e.g. you can use the fhirPath functions substring and indexOf, see an example here
Hello @Oliver Egger ,
Thank You for quick response , i tried this , but it is not working.
src->tgt.doseQuantity = create('SimpleQuantity') as doseQuantity then{
src.dose as dose->doseQuantity.value = dose.substring(0,dose.indexOf(' ') -1) "value";
src.dose as dose->doseQuantity.unit = dose.substring(dose.indexOf(' ')) "unit";
}"doseQuantity";
Input : "dose" : "0.5 ml"
Oliver Egger (Jul 16 2021 at 08:10):
@amit bodhwani try to use the evaluate() function or the shortcut () of it, e.g: doseQuantity.value = (%dose.substring(0,%dose.indexOf(' ') -1)) "value";
amit bodhwani (Jul 16 2021 at 08:30):
Oliver Egger said:
amit bodhwani try to use the evaluate() function or the shortcut () of it, e.g: doseQuantity.value = (%dose.substring(0,%dose.indexOf(' ') -1)) "value";
Thank you for quick response @Oliver Egger , it works using shortcut operator.
Carl Leitner (Feb 09 2022 at 14:08):
on a slightly off topic/related question, is there any effort to pull together common FML helper functions (e.g. split() ) into a library?
Last updated: Apr 12 2022 at 19:14 UTC