Written by

Question ED Coder · Sep 17, 2020

Unable to set DG1 segment after cloning

My segment is not getting set with the new value though It goes into the if statement. Am I doing something wrong?

ClassMethod Clone(pRequest As EnsLib.HL7.Message) As EnsLib.HL7.Message [ Final ]

s cREQ = pRequest.%ConstructClone()

s DG1 = cREQ.FindSegment("DG1",.ind)

While (ind2 '="")

{
diag = DG1.GetValueAt(4.1)

if diag = "0"
{
tmp = "No code"
rc=DG1.SetValueAt(tmp,4.1)
}

}

DG1 = cREQ.FindSegment("DG1",.ind2)

request = cREQ
Quit request

}

Comments

Kurro Lopez · Sep 18, 2020

Hi,

One question... the third line is using ind variable, but you are evaluating ind2 variable, is it a mistake?

Regards,

Kurro Lopez

0
ED Coder  Sep 18, 2020 to Kurro Lopez

Hi Kurro, yes that is a typo, sorry. for some reason it isnt getting into the segment. Do you think I should first clear the segment and then set the value?

0
Kurro Lopez  Sep 18, 2020 to ED Coder

Could you please provide a HL7 example?

0
ED Coder  Sep 18, 2020 to Kurro Lopez

Hi Kurro, once I make the change, should I be updating the segment?

I am doing a findSegment again? is that wrong?

Below is an example of the HL7 we get, it comes as a 0 , I want to replace it with "No code"

0
Kurro Lopez  Sep 18, 2020 to ED Coder

I think the best approach to your goal is create a DTL and clone the message directly, then check the value of DG1:4.1 and set the value in target that you want. See below

You can call to the DTL and you'll have your new message.

Regards,
Kurro Lopez

0
Kurro Lopez  Sep 18, 2020 to Kurro Lopez

if you want to use the DTL programmatically....

ClassMethod Clone(pRequest As EnsLib.HL7.Message) As EnsLib.HL7.Message [ Final ]
{
    set sc=##class(Kurro.DTL.EDCoder).Transform(pRequest,.request)
    if $$$ISERR(sc) {do $system.Status.DisplayError(sc)}
    
    Quit request

}
0