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"


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

request = cREQ
Quit request


0 6 71 3



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


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?

Could you please provide a HL7 example?

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"

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.

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