Cache Query for HL7 NACK
I would like to capture any NACK's that is sent back to the Operation. The Operation is already setup to "Save Replies/IndexNotOK's", but I would like to see if we can query Cache and pull those NACK's into an extract.
Is this possible?
Thanks
Scott
Product version: Caché 2018.1
$ZV: Cache for UNIX (IBM AIX for System Power System-64) 2018.1.3 (Build 414U) Mon Oct 28 2019 11:24:02 EDT
I've written a query for HL7Spy's SQL Loader that extracts ACKs/NAKs from the IOLog:
Here's the SQL in text form. The method HICG.GetMsg() is an ObjectScript stored procedure written specifically for HL7Spy that returns the message body as a stream for delivery via ODBC. You could adapt the SQL for use with the %SQL.Statement class to return a result set containing the message body IDs, Next() your way through that, open each message with %OpenId() and write it out to a file. Getting just the NAKs will require a bit of message parsing.
Thanks the query is very helpful.
You wouldn't happen to have an example of how to create the query as a Stored Procedure within Cache? I know how to do it in MS SQL, I am just looking for an example on how to do it in Cache.
There are a number of examples at Defining and Using Stored Procedures | Using InterSystems SQL | InterSystems IRIS Data Platform 2021.2. The SP I wrote for fetching the message body using its object ID probably won't be much help, since it doesn't actually execute an SQL query ... it's just an ObjectScript classmethod that returns a string, and it's called for every row returned in the containing query. It's available at https://hl7spy.ca/downloads/HICG_HL7.xml if you want to look at it.
Not sure if this has any value, its pretty primitive.
You might be able to do simple query operation and write the RawContent out to a file.
Rough sql sample
SELECT top 10 *
FROM EnsLib_HL7.Message
where DocType like '%ACK%'
and RawContent like '%MSA|AE%'