How can I add two values in a segment field separated by ~
I am updating the PV1 segment with values from the database but when I get two values back I dont know how to separate them with a tilde and insert. Any advice for me on that?
so if I get two values returned
my PV1.7 segment should be :
My current code is as below: It works fine for one value, but when there are more than 2 values returned I need to find a way to include it
Set sc=res.Prepare(sqlstring,,conn)
{
s RET = res.GetData(2)
}
s sc=res.Close()
Set sc=conn.Disconnect()
//create a copy of the request
s newREQ = pRequest.%ConstructClone()
//now we use the copy for manipulation
s PV1 = newREQ.FindSegment("PV1")
set res = PV1.SetValueAt(RET,3.1)
Quit request
https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...
Try replacing your while loop with this:
Thank you David, this worked for me.
You should need only to iterate over the result set and populate the repetition of the PV1 field. Note that you reference PV1.7 (attending provider) in your narrative, but your code references PV1.3 (assigned patient location), so adjust the below as needed to identify the proper field:
The appropriate repetition delimiters as defined within the message schema (in this case "~") are automatically inserted.
Note that the SetValueAt() method has been modified with the assumption that you're using a consistent HL7 schema across all messages and know the correct path to the PV1 field in question. In that case the FindSegment() method should not be necessary.
Thank you Jeff, as always a clear explanation and detailed.