Question
· Apr 30, 2020

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.

Discussion (2)1
Log in or sign up to continue

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>