Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: HDISVAP1

HDISVAP1.m

Go to the documentation of this file.
  1. HDISVAP1 ;BPFO/JRP - Application Programmer API(s);03/07/12 07:37
  1. ;;1.0;HEALTH DATA & INFORMATICS;**7**;Feb 22, 2005;Build 33
  1. ;
  1. LABXCPT(ARRAY,TASKIT) ;Transmit Lab SNOMED CT exceptions
  1. ; Input: ARRAY - Array containing information about the exception
  1. ; (FULL GLOBAL REFERENCE)
  1. ; @ARRAY@(ETC, n) = Transaction number ^ Time stamp
  1. ; @ARRAY@(ETC, n, [x, y, ...]) = Exception specific nodes
  1. ;
  1. ; ETC is a code denoting the type of exception to report
  1. ; 1 = Load Exception
  1. ; 2 = Reference Lab
  1. ; 3 = Add/Edit by Site
  1. ;
  1. ; Time Stamp is in FileMan format
  1. ; TASKIT - Flag denoting if the work this API does should
  1. ; be queued to run
  1. ; 1 = Queue to run
  1. ; 0 = Run now (DEFAULT)
  1. ;
  1. ;Output: None
  1. ; : The node @ARRAY@("XMZ") will be set equal to the message
  1. ; number of the generated message. A value of zero (0) will
  1. ; be used when the message could not be generated.
  1. ; : The node @ARRAY@("ZTSK") will be set equal to the task number
  1. ; assigned if the TASKIT variable is set to one (1). A value
  1. ; of zero (0) will be used if queuing of this API's work was
  1. ; not requested.
  1. ; : The node @ARRAY@("ERROR", ETC) will be set equal to error
  1. ; text for input exception type codes that are not supported.
  1. ; : The node @ARRAY@("ERROR", ETC, n) will be set to error
  1. ; text if the exception could not be handled. This is
  1. ; typically set because of a missing input node. This node
  1. ; will not be set for unsupported exception type codes.
  1. ;
  1. ; Notes: If this is not a production system the generated message
  1. ; will be sent to the currently defined user (i.e. DUZ)
  1. ; : The node @ARRAY@("ERROR") will be KILLed on input
  1. ; : A pipe (|) is used as the delimiter for the "SA" and "SB"
  1. ; nodes. This is because they mirror the layout of the SNOMED
  1. ; CT extract already implemented by the Lab package.
  1. ; : A pipe (|) is used as the delimiter for the "RD" node. This
  1. ; is because it mirrors the layout of the resolution data being
  1. ; transmitted by ERT to the Lab package for loading.
  1. ; : The following text lists the nodes for each exception type
  1. ;
  1. ; Exception Type Code 1: Load Exception
  1. ; =====================================
  1. ; @ARRAY@(1, n) = Transaction number ^ Time stamp
  1. ; @ARRAY@(1, n, "TXT") = Text to describe why the exception was
  1. ; generated. Contents is up to the
  1. ; discretion of the Lab package.
  1. ; @ARRAY@(1, n, "SA") = The pipe delimited row of data for the
  1. ; entry that would be generated by the LR
  1. ; LAB SERVER when fulfilling a SNOMED extract
  1. ; report
  1. ; @ARRAY@(1, n, "RD") = The pipe delimited row of data received
  1. ; from STS that the Lab package attempted
  1. ; to load
  1. ;
  1. ; Exception Type Code 2: Reference Lab
  1. ; ====================================
  1. ; @ARRAY@(2, n) = Transaction number ^ Time stamp
  1. ; @ARRAY@(2, n, "TXT") = Text to describe why the exception was
  1. ; generated. Contents is up to the
  1. ; discretion of the Lab package.
  1. ; @ARRAY@(2, n, "SA") = The pipe delimited row of data for the
  1. ; entry that would be generated by the LR
  1. ; LAB SERVER when fulfilling a SNOMED extract
  1. ; report
  1. ; @ARRAY@(2, n, "RL") = Location type code ^ Location number ^
  1. ; Location name
  1. ; @ARRAY@(2, n, "EC") = Encoding characters from HL-7 message
  1. ; @ARRAY@(2, n, "OBX", 3) = Sequence 3 of received OBX segment
  1. ; @ARRAY@(2, n, "OBX", 5) = Sequence 5 of received OBX segment
  1. ;
  1. ; Location Type Code:
  1. ; 1 = DoD 4 = IHS
  1. ; 2 = VA 5 = Other
  1. ; 3 = Non-government 6 = Unknown
  1. ;
  1. ; Exception Type Code 3: Add/Edit by Site
  1. ; =======================================
  1. ; @ARRAY@(3, n) = Transaction number ^ Time stamp
  1. ; @ARRAY@(3, n, "TXT") = Text to describe why the exception was
  1. ; generated. Contents is up to the
  1. ; discretion of the Lab package.
  1. ; @ARRAY@(3, n, "SA") = The pipe delimited row of data for the
  1. ; entry that would be generated by the LR
  1. ; LAB SERVER when fulfilling a SNOMED extract
  1. ; report
  1. ; @ARRAY@(3, n, "SB") = Same definition as the SA node except the
  1. ; values prior to the add/edit are used.
  1. ; Node not present for additions.
  1. ;
  1. ;
  1. ; Alternate Array Format
  1. ; ======================
  1. ; Array nodes that are delimited pieces of data can also be broken
  1. ; out into their individual pieces of data. The only node that
  1. ; CAN NOT be broken out in this manner is the main node for the
  1. ; exception.
  1. ;
  1. ; Using exception type code 1 (Load Exception) as an example, the
  1. ; alternate array format would be:
  1. ;
  1. ; @ARRAY@(1, n) = Transaction number ^ Time stamp
  1. ; @ARRAY@(1, n, "TXT") = Some kind of text
  1. ; @ARRAY@(1, n, "SA", 1..N) = Piece N of the SA node
  1. ; @ARRAY@(1, n, "RD", 1..N) = Piece N of the RD node
  1. ;
  1. ; Note that the primary and alternate formats can not be used at
  1. ; the same time for the same node. If this is done, the data will
  1. ; be ignored and the error node for the exception will be set.
  1. ;
  1. ;Initialize XMZ & ZTSK output nodes
  1. SET @ARRAY@("XMZ")=0
  1. SET @ARRAY@("ZTSK")=0
  1. SET TASKIT=+$GET(TASKIT)
  1. ;Queue running ?
  1. IF TASKIT DO QUIT
  1. .;API asked to queue it's running
  1. .NEW ZTRTN,ZTDESC,ZTDTH,ZTIO,ZTSAVE,ZTSK,TMP
  1. .SET ZTRTN="TASKIT^HDISVAP1"
  1. .SET ZTDESC="Transmit Lab SNOMED CT exceptions"
  1. .SET ZTDTH=$HOROLOG
  1. .SET ZTIO=""
  1. .SET ZTSAVE("TASKIT")=1
  1. .KILL ^TMP("HDISVAP1-TASK",$JOB)
  1. .MERGE ^TMP("HDISVAP1-TASK",$JOB)=@ARRAY
  1. .SET ZTSAVE("ARRAY")="^TMP(""HDISVAP1-TASK"",$JOB)"
  1. .SET ZTSAVE("^TMP(""HDISVAP1-TASK"",$JOB,")=""
  1. .DO ^%ZTLOAD
  1. .KILL ^TMP("HDISVAP1-TASK",$JOB)
  1. .SET @ARRAY@("ZTSK")=$GET(ZTSK)
  1. .QUIT
  1. TASKIT ;Entry point used when API is asked to queue itself
  1. NEW XMLDOC,SUMTXT,ENCODED,LINE,SUBJ,LOOP
  1. ;Initialize
  1. SET XMLDOC=$NAME(^TMP("HDISVAP1",$JOB,"XMLDOC"))
  1. SET SUMTXT=$NAME(^TMP("HDISVAP1",$JOB,"SUMTXT"))
  1. SET ENCODED=$NAME(^TMP("HDISVAP1",$JOB,"ENCODED"))
  1. KILL @XMLDOC,@SUMTXT,@ENCODED,@ARRAY@("ERROR")
  1. ;Build XML document & summary text - quit if nothing to encode/send
  1. IF ('$$BUILD^HDISVAP2(ARRAY,XMLDOC,SUMTXT)) DO QUIT
  1. .KILL @XMLDOC,@SUMTXT,@ENCODED
  1. .QUIT
  1. ;UUEncode array containing XML document
  1. SET @XMLDOC@(0)=$$FILENAME^HDISVAP3()
  1. DO ENCODE^HDISVM03(XMLDOC,ENCODED,1)
  1. ;Combine UUEncoded array and summary text
  1. SET LINE=0
  1. FOR SET LINE=+$ORDER(@SUMTXT@(LINE)) QUIT:('LINE) DO
  1. .SET @ENCODED@(LINE*.000001)=@SUMTXT@(LINE,0)
  1. ;Build & send message
  1. SET SUBJ="Lab Exception(s): "_$GET(@SUMTXT@(0))
  1. IF ($LENGTH(SUBJ)>64) DO
  1. .FOR LOOP=$LENGTH(SUBJ,","):-1 DO QUIT:($LENGTH(SUBJ)<59)
  1. ..SET SUBJ=$PIECE(SUBJ,",",1,LOOP-1)
  1. .SET SUBJ=SUBJ_", ..."
  1. SET @ARRAY@("XMZ")=$$SENDMSG^HDISVAP3(ENCODED,SUBJ)
  1. ;Clean up
  1. KILL @XMLDOC,@SUMTXT,@ENCODED
  1. ;Checked for tasked use
  1. IF $DATA(ZTQUEUED) DO
  1. .;Delete task & input/output array
  1. .SET ZTREQ="@"
  1. .KILL @ARRAY
  1. .QUIT
  1. QUIT