go to post Adam Trahan · Nov 10, 2021 I ended up opening a WRC for this. We were able to resolve this by utilizing Enslib.HL7.Message's OutputToString and ImportFromString methods to just store the entire contents in a string that could then be manipulated directly. Including the entire method here, in case someone else stumbles upon this and needs it: ClassMethod Transform(pRequest As EnsLib.HL7.Message, Output pResponse As EnsLib.HL7.Message) As %Status{// Get the MSH values for logging purposesset MSHID = pRequest.GetValueAt("MSH:10")set MSHDT = pRequest.GetValueAt("MSH:7") // Save the whole HL7 message into a string so we can manipulate it set data = pRequest.OutputToString() // Loop through the string, replacing Non-ASCII characters with spaces until you don't find any moreset tEnd = 1 Set tLocation = $LOCATE(data,"[^\x09-\x0d\x20-\x7e]",,tEnd)While tLocation {set ^ASCIIStrip($NOW(),$INCREMENT(i))="Non-ASCII Character Found at Position " _ (tEnd-1) _ " in Msg ID " _ MSHID _ " with MSH Date " _ MSHDT// replace with a spaceSet $EXTRACT(data,tLocation,(tEnd-1)) = " "Set tEnd = 1Set tLocation = $LOCATE(data,"[^\x09-\x0d\x20-\x7e]",,tEnd)} // Save that modified string back into an HL7 messageset pResponse = pResponse.ImportFromString(data) // Manually set the DocType and MessageTypeCategory from the sourceset tSC = pResponse.PokeDocType(pRequest.DocType)set tSC = pResponse.PokeTypeCategory(pRequest.MessageTypeCategory) Quit 1}
go to post Adam Trahan · Nov 9, 2021 Thanks, that does help, but I still have the problem of figuring out how to address the entirety of the message. There is a RawContent property, but it's truncated.