SQL Store Procedure Output (String) into HL7 message
Hi,
I am afraid I am stuck again. I have ensemble connected with a MsSQL database and I have a service that calls a store procedure. All is working, and I can get strings from the database in the service. The problem is that the data the store procedure returns is suppose to be an HL7 message so I need to convert the string into HL7 format. I have been using the
I guess, is something to be with the structure of the HL7 message...it is a special one that contains multiple ORCs, OBRs, SPMs... it can be seen as the merge of multiple HL7 messages...the problem is that seems only the first part of the message is converted to. I have put a sentence to write the message into the log before being converted and after being converted and both looks different.
The code is as follow:
SET HL7msg = ##class(EnsLib.HL7.Message).ImportFromString(pInput.GetData(1)) $$$ThrowOnError(tSC)
SET tDocType=##class(EnsLib.HL7.Schema).ResolveSchemaTypeToDocType("2.5.1","ORU_R01", tSC) $$$ThrowOnError(tSC)
SET HL7msg.DocType=tDocType
$$$LOGINFO("HL7:" _ HL7msg.RawContent)
The structure of the incoming message is as follow (the one I am receiving fine):
PID|1||~
ORC|RE|2
OBR|1|20
NTE|1|L|
NTE|2|L|
OBX|1|NM
SPM|1|||
SPM|1|||
OBR|1|20
NTE|1|L|
OBX|2|NM
OBX|3|NM
OBX|4|NM
SPM|1|||
SPM|1|||
But once converted:
PID|1||~
ORC|RE|2
OBR|1|20
NTE|1|L|
NTE|2|L|
OBX|1|NM
SPM|1|||
Is it because the schema is not defined and then is converting using a standard HL7 version?
Thanks
Hi,
Your question is a bit confusing. Neither of those are valid HL7 messages. Do you mean that first $$$LOGINFO("Stream: " _ pInput.GetData(1)) is generating the first example message? In the first message you seem to only be getting back the first 8 characters from each line. Are there any limitations in the number of characters defined somewhere?
The second one is due to the Schema being a default Ensemble one. From your message it seems like you will need to define a custom schema type according to your HL7 specification.
Kind regards,
Alice
Thanks for your response. Maybe I was a little bit unclear...sorry about that.
I did not include the full message, just the first characters as an example of the structure of the message I am receiving.
Basically, I am receiving a message (string) from a database ( pInput As EnsLib.SQL.Snapshot), and converting that string into an HL7 message ( ##class(EnsLib.HL7.Message). ImportFromString(pInput.GetData(1))).
The string I am receiving is fine, nothing is missed, but when the string is converted into HL7, part of the message just dissapears. I cannot see any limitation on the number of characters, and if I check the size of the converted HL7 is not close to any round number as 2,000, 3,000...
I am going to try to change the schema to a custom one with the same structure I am receiving and check if that works...
Thanks
Found the issue.
The store procedure was adding extra breakline at the end of the first SPM segment and ensemble identify that as end of message.
All sorted now.
Thanks all for your help.