HDISVAP3 ;BPFO/JRP - Application Programmer API(s);03/07/12 07:56
;;1.0;HEALTH DATA & INFORMATICS;**7**;Feb 22, 2005;Build 33
;
; THIS IS A CONTINUATION OF LABXCPT^HDISVAP1
;
ADD(TEXT,TAGNAME,XMLDOC,XMLNODE) ;Add text to XML document
NEW ESCTEXT
IF (TAGNAME="") QUIT
;Check for NULL data - special denotion in XML
IF (TEXT="") DO QUIT
.SET @XMLDOC@(XMLNODE,0)="<"_TAGNAME_"/>"
.SET XMLNODE=XMLNODE+1
.QUIT
;Convert reserved XML characters to escape sequences
SET ESCTEXT=$$CHARCHK^XOBVLIB(TEXT)
;Add text
SET @XMLDOC@(XMLNODE,0)="<"_TAGNAME_">"_ESCTEXT_"</"_TAGNAME_">"
SET XMLNODE=XMLNODE+1
QUIT
;
ADDBEG(TAGNAME,XMLDOC,XMLNODE) ; Add beginning tag to XML document
SET @XMLDOC@(XMLNODE,0)="<"_TAGNAME_">"
SET XMLNODE=XMLNODE+1
QUIT
;
ADDEND(TAGNAME,XMLDOC,XMLNODE) ;Add ending tag to XML document
SET @XMLDOC@(XMLNODE,0)="</"_TAGNAME_">"
SET XMLNODE=XMLNODE+1
QUIT
;
SUMADD(TEXT,SUMTXT,SUMNODE) ;Add line of text to summary data
SET @SUMTXT@(SUMNODE,0)=TEXT
SET SUMNODE=SUMNODE+1
QUIT
;
SUMADMIN(SUMTXT,XCPTTYPE,DATA,SUMNODE) ;Administrative summary text
NEW TEXT
SET TEXT=" "
DO SUMADD(TEXT,SUMTXT,.SUMNODE)
SET TEXT=" Transaction Number: "_$GET(DATA(1))
DO SUMADD(TEXT,SUMTXT,.SUMNODE)
SET TEXT="Exception Type Code: "_$GET(XCPTTYPE)
DO SUMADD(TEXT,SUMTXT,.SUMNODE)
SET TEXT=" Time Stamp: "_$GET(DATA(2))
DO SUMADD(TEXT,SUMTXT,.SUMNODE)
SET TEXT=" "
DO SUMADD(TEXT,SUMTXT,.SUMNODE)
QUIT
;
SUMSNOMD(SUMTXT,DATA,SUMNODE) ;SNOMED summary text
NEW TEXT
SET TEXT="ID (Fac#-File#-IEN): "_$GET(DATA(1))
DO SUMADD(TEXT,SUMTXT,.SUMNODE)
SET TEXT=" SNOMED CT: "_$GET(DATA(5))
DO SUMADD(TEXT,SUMTXT,.SUMNODE)
SET TEXT=" SNOMED CT Term: "_$GET(DATA(6))
DO SUMADD(TEXT,SUMTXT,.SUMNODE)
SET TEXT=" Mapping Exception: "_$GET(DATA(7))
DO SUMADD(TEXT,SUMTXT,.SUMNODE)
SET TEXT=" Term Status: "_$GET(DATA(11))
DO SUMADD(TEXT,SUMTXT,.SUMNODE)
SET TEXT=" "
DO SUMADD(TEXT,SUMTXT,.SUMNODE)
QUIT
;
SUMRFLAB(SUMTXT,DATA,SUMNODE) ;Reference lab summary text
NEW TEXT
SET TEXT=" Location Type Code: "_$GET(DATA(1))
DO SUMADD(TEXT,SUMTXT,.SUMNODE)
SET TEXT=" Location Number: "_$GET(DATA(2))
DO SUMADD(TEXT,SUMTXT,.SUMNODE)
SET TEXT=" Location Name: "_$GET(DATA(3))
DO SUMADD(TEXT,SUMTXT,.SUMNODE)
SET TEXT=" "
DO SUMADD(TEXT,SUMTXT,.SUMNODE)
QUIT
;
SUMID(SUMTXT,SANODE) ;Add ID to list of IDs added to XML document
NEW TEXT,ARRTYPE,ID
SET ARRTYPE=$DATA(@SANODE)
IF ARRTYPE=0 QUIT
IF ARRTYPE=1 SET ID=$PIECE($GET(@SANODE),"|",1)
IF ARRTYPE=10 SET ID=$GET(@SANODE@(1))
SET TEXT=$GET(@SUMTXT@(0))
SET @SUMTXT@(0)=$SELECT(TEXT="":ID,1:TEXT_", "_ID)
QUIT
;
FILENAME() ;Returns fabricated file name
NEW TMP,OUT
SET OUT=$$FACNUM^HDISVF01()
SET TMP=$$HTE^XLFDT($HOROLOG,"7FS")
SET OUT=OUT_"-"_$TRANSLATE(TMP," @/:","0-")
SET OUT=OUT_".XML"
QUIT OUT
;
SENDMSG(MSGTXT,SUBJ) ;Build/send message
; Input: MSGTXT - Array containing message text
; (FULL GLOBAL REFERENCE)
; SUBJ - Message subject (optional)
;Output: Message number of generated message (aka XMZ)
; 0 is returned if the message could not be generated
; Notes: If this is a non-production system the message is sent
; to the current user
;
NEW HDISVTO,HDISVFLG,HDISVXMZ,XTYPE
;Default message subject
SET SUBJ=$GET(SUBJ)
IF (SUBJ="") DO
.NEW FACPTR,FACNUM
.;Get pointer to current location
.SET:('$$GETFAC^HDISVF07(,.FACPTR)) FACPTR=$$FACPTR^HDISVF01()
.;Get facility number of current location
.SET FACNUM=$PIECE($$NS^XUAF4(FACPTR),"^",2)
.IF (FACNUM="") SET FACNUM=$$FACNUM^HDISVF01()
.;Build message subject
.SET SUBJ="LAB EXCEPTION DATA FROM "_FACNUM
.QUIT
;Deliver to mail group on FORUM
SET HDISVTO("G.HDIS LAB EXCEPTIONS@DOMAIN.EXT")=""
;If this is a non-production system send message to current user
SET:('$$GETTYPE^HDISVF07(,.XTYPE)) XTYPE=$$PROD^XUPROD()
IF ('XTYPE) DO
.KILL HDISVTO
.SET HDISVTO(DUZ)=""
.QUIT
;Unrestricted addressing
SET HDISVFLG("ADDR FLAGS")="R"
;Message is info only
SET HDISVFLG("FLAGS")="I"
;Message sender
SET HDISVFLG("FROM")="Data Standardization Toolset"
;Send message (UUEncoded array is the message text)
DO SENDMSG^XMXAPI(DUZ,SUBJ,MSGTXT,.HDISVTO,.HDISVFLG,.HDISVXMZ)
IF $GET(XMERR) DO
.;Error sending message - log error text
.DO ERR2XTMP^HDISVU01("HDI-XM","Message sending",$NAME(^TMP("XMERR",$JOB)))
.KILL XMERR,^TMP("XMERR",$JOB)
.;Reset generated message number
.SET HDISVXMZ=0
.QUIT
;Done - return message number
QUIT HDISVXMZ
;
GETTAGS(TAGS) ;Build array of element names
NEW X,LINE
KILL @TAGS
FOR X=1:1 DO QUIT:('X)
.SET LINE=$PIECE($TEXT(TAGS+X),";;",2)
.IF (LINE="") SET X=0 QUIT
.SET @TAGS@(+$PIECE(LINE,"^",1))=$PIECE(LINE,"^",2)
.QUIT
QUIT
;
TAGS ;
;;1^Lab_Exceptions
;;2^Lab_Exception_Data
;;3^Administrative_Data
;;3.01^Exception_Station_Number
;;3.02^Exception_Station_Domain_IP
;;3.03^Exception_Station_System_Type
;;3.04^Exception_Type_Code
;;3.05^Exception_Transaction_Number
;;3.06^Exception_Time_Stamp
;;3.07^Lab_Package_Exception_Text
;;4^Lab_File_SNOMED_Data
;;4.01^FacilityNumber_FileNumber_IEN
;;4.02^Entry_Name
;;4.03^SNOMED_I
;;4.04^VUID
;;4.05^SNOMED_CT
;;4.06^SNOMED_CT_Term
;;4.07^Mapping_Exception
;;4.08^Related_Specimen
;;4.09^Related_Specimen_ID
;;4.10^Extract_Version
;;4.11^Term_Status
;;4.12^STS_Exception
;;4.13^STS_Exception_Reason
;;5^Mapping_Data_Being_Loaded
;;5.01^Mapping_Data_FacilityNumber_FileNumber_IEN
;;5.02^Mapping_Data_Entry_Name
;;5.03^Mapping_Data_SNOMED_I
;;5.04^Mapping_Data_STS_Further_Action
;;5.05^Mapping_Data_STS_SCT_ID
;;5.06^Mapping_Data_STS_Type_Of_Match
;;6^Reference_Lab_Data
;;6.01^Reference_Lab_Type_Code
;;6.02^Reference_Lab_Station_Number
;;6.03^Reference_Lab_Name
;;6.04^Reference_Lab_OBX-3
;;6.05^Reference_Lab_OBX-5
;;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHDISVAP3 6011 printed Oct 16, 2024@17:57:28 Page 2
HDISVAP3 ;BPFO/JRP - Application Programmer API(s);03/07/12 07:56
+1 ;;1.0;HEALTH DATA & INFORMATICS;**7**;Feb 22, 2005;Build 33
+2 ;
+3 ; THIS IS A CONTINUATION OF LABXCPT^HDISVAP1
+4 ;
ADD(TEXT,TAGNAME,XMLDOC,XMLNODE) ;Add text to XML document
+1 NEW ESCTEXT
+2 IF (TAGNAME="")
QUIT
+3 ;Check for NULL data - special denotion in XML
+4 IF (TEXT="")
Begin DoDot:1
+5 SET @XMLDOC@(XMLNODE,0)="<"_TAGNAME_"/>"
+6 SET XMLNODE=XMLNODE+1
+7 QUIT
End DoDot:1
QUIT
+8 ;Convert reserved XML characters to escape sequences
+9 SET ESCTEXT=$$CHARCHK^XOBVLIB(TEXT)
+10 ;Add text
+11 SET @XMLDOC@(XMLNODE,0)="<"_TAGNAME_">"_ESCTEXT_"</"_TAGNAME_">"
+12 SET XMLNODE=XMLNODE+1
+13 QUIT
+14 ;
ADDBEG(TAGNAME,XMLDOC,XMLNODE) ; Add beginning tag to XML document
+1 SET @XMLDOC@(XMLNODE,0)="<"_TAGNAME_">"
+2 SET XMLNODE=XMLNODE+1
+3 QUIT
+4 ;
ADDEND(TAGNAME,XMLDOC,XMLNODE) ;Add ending tag to XML document
+1 SET @XMLDOC@(XMLNODE,0)="</"_TAGNAME_">"
+2 SET XMLNODE=XMLNODE+1
+3 QUIT
+4 ;
SUMADD(TEXT,SUMTXT,SUMNODE) ;Add line of text to summary data
+1 SET @SUMTXT@(SUMNODE,0)=TEXT
+2 SET SUMNODE=SUMNODE+1
+3 QUIT
+4 ;
SUMADMIN(SUMTXT,XCPTTYPE,DATA,SUMNODE) ;Administrative summary text
+1 NEW TEXT
+2 SET TEXT=" "
+3 DO SUMADD(TEXT,SUMTXT,.SUMNODE)
+4 SET TEXT=" Transaction Number: "_$GET(DATA(1))
+5 DO SUMADD(TEXT,SUMTXT,.SUMNODE)
+6 SET TEXT="Exception Type Code: "_$GET(XCPTTYPE)
+7 DO SUMADD(TEXT,SUMTXT,.SUMNODE)
+8 SET TEXT=" Time Stamp: "_$GET(DATA(2))
+9 DO SUMADD(TEXT,SUMTXT,.SUMNODE)
+10 SET TEXT=" "
+11 DO SUMADD(TEXT,SUMTXT,.SUMNODE)
+12 QUIT
+13 ;
SUMSNOMD(SUMTXT,DATA,SUMNODE) ;SNOMED summary text
+1 NEW TEXT
+2 SET TEXT="ID (Fac#-File#-IEN): "_$GET(DATA(1))
+3 DO SUMADD(TEXT,SUMTXT,.SUMNODE)
+4 SET TEXT=" SNOMED CT: "_$GET(DATA(5))
+5 DO SUMADD(TEXT,SUMTXT,.SUMNODE)
+6 SET TEXT=" SNOMED CT Term: "_$GET(DATA(6))
+7 DO SUMADD(TEXT,SUMTXT,.SUMNODE)
+8 SET TEXT=" Mapping Exception: "_$GET(DATA(7))
+9 DO SUMADD(TEXT,SUMTXT,.SUMNODE)
+10 SET TEXT=" Term Status: "_$GET(DATA(11))
+11 DO SUMADD(TEXT,SUMTXT,.SUMNODE)
+12 SET TEXT=" "
+13 DO SUMADD(TEXT,SUMTXT,.SUMNODE)
+14 QUIT
+15 ;
SUMRFLAB(SUMTXT,DATA,SUMNODE) ;Reference lab summary text
+1 NEW TEXT
+2 SET TEXT=" Location Type Code: "_$GET(DATA(1))
+3 DO SUMADD(TEXT,SUMTXT,.SUMNODE)
+4 SET TEXT=" Location Number: "_$GET(DATA(2))
+5 DO SUMADD(TEXT,SUMTXT,.SUMNODE)
+6 SET TEXT=" Location Name: "_$GET(DATA(3))
+7 DO SUMADD(TEXT,SUMTXT,.SUMNODE)
+8 SET TEXT=" "
+9 DO SUMADD(TEXT,SUMTXT,.SUMNODE)
+10 QUIT
+11 ;
SUMID(SUMTXT,SANODE) ;Add ID to list of IDs added to XML document
+1 NEW TEXT,ARRTYPE,ID
+2 SET ARRTYPE=$DATA(@SANODE)
+3 IF ARRTYPE=0
QUIT
+4 IF ARRTYPE=1
SET ID=$PIECE($GET(@SANODE),"|",1)
+5 IF ARRTYPE=10
SET ID=$GET(@SANODE@(1))
+6 SET TEXT=$GET(@SUMTXT@(0))
+7 SET @SUMTXT@(0)=$SELECT(TEXT="":ID,1:TEXT_", "_ID)
+8 QUIT
+9 ;
FILENAME() ;Returns fabricated file name
+1 NEW TMP,OUT
+2 SET OUT=$$FACNUM^HDISVF01()
+3 SET TMP=$$HTE^XLFDT($HOROLOG,"7FS")
+4 SET OUT=OUT_"-"_$TRANSLATE(TMP," @/:","0-")
+5 SET OUT=OUT_".XML"
+6 QUIT OUT
+7 ;
SENDMSG(MSGTXT,SUBJ) ;Build/send message
+1 ; Input: MSGTXT - Array containing message text
+2 ; (FULL GLOBAL REFERENCE)
+3 ; SUBJ - Message subject (optional)
+4 ;Output: Message number of generated message (aka XMZ)
+5 ; 0 is returned if the message could not be generated
+6 ; Notes: If this is a non-production system the message is sent
+7 ; to the current user
+8 ;
+9 NEW HDISVTO,HDISVFLG,HDISVXMZ,XTYPE
+10 ;Default message subject
+11 SET SUBJ=$GET(SUBJ)
+12 IF (SUBJ="")
Begin DoDot:1
+13 NEW FACPTR,FACNUM
+14 ;Get pointer to current location
+15 if ('$$GETFAC^HDISVF07(,.FACPTR))
SET FACPTR=$$FACPTR^HDISVF01()
+16 ;Get facility number of current location
+17 SET FACNUM=$PIECE($$NS^XUAF4(FACPTR),"^",2)
+18 IF (FACNUM="")
SET FACNUM=$$FACNUM^HDISVF01()
+19 ;Build message subject
+20 SET SUBJ="LAB EXCEPTION DATA FROM "_FACNUM
+21 QUIT
End DoDot:1
+22 ;Deliver to mail group on FORUM
+23 SET HDISVTO("G.HDIS LAB EXCEPTIONS@DOMAIN.EXT")=""
+24 ;If this is a non-production system send message to current user
+25 if ('$$GETTYPE^HDISVF07(,.XTYPE))
SET XTYPE=$$PROD^XUPROD()
+26 IF ('XTYPE)
Begin DoDot:1
+27 KILL HDISVTO
+28 SET HDISVTO(DUZ)=""
+29 QUIT
End DoDot:1
+30 ;Unrestricted addressing
+31 SET HDISVFLG("ADDR FLAGS")="R"
+32 ;Message is info only
+33 SET HDISVFLG("FLAGS")="I"
+34 ;Message sender
+35 SET HDISVFLG("FROM")="Data Standardization Toolset"
+36 ;Send message (UUEncoded array is the message text)
+37 DO SENDMSG^XMXAPI(DUZ,SUBJ,MSGTXT,.HDISVTO,.HDISVFLG,.HDISVXMZ)
+38 IF $GET(XMERR)
Begin DoDot:1
+39 ;Error sending message - log error text
+40 DO ERR2XTMP^HDISVU01("HDI-XM","Message sending",$NAME(^TMP("XMERR",$JOB)))
+41 KILL XMERR,^TMP("XMERR",$JOB)
+42 ;Reset generated message number
+43 SET HDISVXMZ=0
+44 QUIT
End DoDot:1
+45 ;Done - return message number
+46 QUIT HDISVXMZ
+47 ;
GETTAGS(TAGS) ;Build array of element names
+1 NEW X,LINE
+2 KILL @TAGS
+3 FOR X=1:1
Begin DoDot:1
+4 SET LINE=$PIECE($TEXT(TAGS+X),";;",2)
+5 IF (LINE="")
SET X=0
QUIT
+6 SET @TAGS@(+$PIECE(LINE,"^",1))=$PIECE(LINE,"^",2)
+7 QUIT
End DoDot:1
if ('X)
QUIT
+8 QUIT
+9 ;
TAGS ;
+1 ;;1^Lab_Exceptions
+2 ;;2^Lab_Exception_Data
+3 ;;3^Administrative_Data
+4 ;;3.01^Exception_Station_Number
+5 ;;3.02^Exception_Station_Domain_IP
+6 ;;3.03^Exception_Station_System_Type
+7 ;;3.04^Exception_Type_Code
+8 ;;3.05^Exception_Transaction_Number
+9 ;;3.06^Exception_Time_Stamp
+10 ;;3.07^Lab_Package_Exception_Text
+11 ;;4^Lab_File_SNOMED_Data
+12 ;;4.01^FacilityNumber_FileNumber_IEN
+13 ;;4.02^Entry_Name
+14 ;;4.03^SNOMED_I
+15 ;;4.04^VUID
+16 ;;4.05^SNOMED_CT
+17 ;;4.06^SNOMED_CT_Term
+18 ;;4.07^Mapping_Exception
+19 ;;4.08^Related_Specimen
+20 ;;4.09^Related_Specimen_ID
+21 ;;4.10^Extract_Version
+22 ;;4.11^Term_Status
+23 ;;4.12^STS_Exception
+24 ;;4.13^STS_Exception_Reason
+25 ;;5^Mapping_Data_Being_Loaded
+26 ;;5.01^Mapping_Data_FacilityNumber_FileNumber_IEN
+27 ;;5.02^Mapping_Data_Entry_Name
+28 ;;5.03^Mapping_Data_SNOMED_I
+29 ;;5.04^Mapping_Data_STS_Further_Action
+30 ;;5.05^Mapping_Data_STS_SCT_ID
+31 ;;5.06^Mapping_Data_STS_Type_Of_Match
+32 ;;6^Reference_Lab_Data
+33 ;;6.01^Reference_Lab_Type_Code
+34 ;;6.02^Reference_Lab_Station_Number
+35 ;;6.03^Reference_Lab_Name
+36 ;;6.04^Reference_Lab_OBX-3
+37 ;;6.05^Reference_Lab_OBX-5
+38 ;;