Data transform: Using function set to change values but doesnt seem to work
Hi,
Would appreciate some guidance on this. I am creating a transform to replace values using a functionset. But for some reason the values arent getting replaced. What I want to do is to replace if the observation value [For Eg: if Migraine should replace with M1]
<assign value='##class(ClassName.FunctionSet).illnessConv(source.{OBX():ObservationValue})' property='target.{OBX():ObservationValue}' action='set' />
My function set class is as below:
ClassMethod illnesConv(observationValue As %String) As %String [ Final ]
{
set ret = ""
set ^TEST("observation") = observationValue
if observationValue = "Migraine"
{
set ret = "M1"
}
quit ret
}
Shouldnt this replace the value? Would appreciate some guidance on what I am doing wrong.
Comments
I believe you are missing parentheses for this particular field:
<assign value='##class(ClassName.FunctionSet).illnessConv(source.{OBX():ObservationValue()})' property='target.{OBX():ObservationValue()}' action='set' />Generally, I switch over the field names to numbers as that is easier for me to read:
<assign value='##class(ClassName.FunctionSet).illnessConv(source.{OBX():5})' property='target.{OBX():5}' action='set' />I'm not sure what schema you are using, but if you are using a schema with repeating OBR or OBX fields then you may also need to loop those as well, respectfully:
<foreach property='source.{OBXgrp()}' key='k1' >
<foreach property='source.{OBXgrp(k1).OBX()}' key='k2' >
<assign value='source.{OBXgrp(k1).OBX(k2):5}' property='target.{OBXgrp(k1).OBX(k2):5}' action='set' />
</foreach>
</foreach> Thank you so much Chris, I had to add the parentheses. Thank you for giving me the idea of referencing with the field number. I used to type the whole lot. This works faster.
Regards,
Eric