PSSHRCOM ;WOIFO/AV,TS - Handles common PRE PEPS interface functionality ;09/20/07
;;1.0;PHARMACY DATA MANAGEMENT;**136**;9/30/97;Build 89;
;
; @authors - Alex Vazquez, Tim Sabat
; @date - September 19, 2007
; @version - 1.0
;
QUIT
;;
PARSEMSG(DOCHAND,NODE,HASH,COUNT) ;
; @DESC Parses the message XML element and stores
; severity, type, drugName and text in HASH parameter
;
; @DOCHAND Handle to XML document
; @NODE Node associated with XML element
; @HASH Passed by ref. Used to store return values
; @COUNT Count of messages
;
; @RETURNS Nothing, Values stored in HASH variable
;
NEW PSS,NAME
;
SET PSS("child")=0
;
FOR SET PSS("child")=$$CHILD^MXMLDOM(DOCHAND,NODE,PSS("child")) QUIT:PSS("child")<1 DO
. SET NAME=$$NAME^MXMLDOM(DOCHAND,PSS("child"))
. ;
. DO:NAME="drug"
. . DO PARSEDRG(DOCHAND,PSS("child"),.HASH,COUNT)
. . QUIT
. DO:NAME="severity"
. . SET HASH(COUNT,"severity")=$$GETTEXT(DOCHAND,PSS("child"))
. . QUIT
. DO:NAME="type"
. . SET HASH(COUNT,"type")=$$GETTEXT(DOCHAND,PSS("child"))
. . QUIT
. DO:NAME="drugName"
. . SET HASH(COUNT,"drugName")=$$GETTEXT(DOCHAND,PSS("child"))
. . QUIT
. DO:NAME="text"
. . SET HASH(COUNT,"text")=$$GETTEXT(DOCHAND,PSS("child"))
. . QUIT
. QUIT
QUIT
;;
DRUGLIST(DOCHAND,NODE,HASH,COUNT) ;
; @DESC Handles reading the interacted drug list and stores to a Hash
;
; @DOCHAND Handle to XML document
; @NODE Represents the interactedDrugList XML element
; @HASH Passed by ref. Used to store return values
; @COUNT Count of drugs
;
; @RETURNS Nothing, Values stored in HASH variable
;
NEW PSS,VAL,DRUGS
SET PSS("child")=0
SET PSS("interactedCount")=1
;
FOR SET PSS("child")=$$CHILD^MXMLDOM(DOCHAND,NODE,PSS("child")) QUIT:PSS("child")=0 DO
. ; Renew the DRUGS variable before passing in again
. KILL DRUGS
. DO PARSEDRG(DOCHAND,PSS("child"),.DRUGS,PSS("interactedCount"))
. SET VAL=""
. FOR SET VAL=$ORDER(DRUGS(VAL)) QUIT:VAL="" DO
. . SET HASH(COUNT,"drugList",PSS("interactedCount"),"vuid")=DRUGS(VAL,"vuid")
. . SET HASH(COUNT,"drugList",PSS("interactedCount"),"ien")=DRUGS(VAL,"ien")
. . SET HASH(COUNT,"drugList",PSS("interactedCount"),"gcn")=DRUGS(VAL,"gcn")
. . SET HASH(COUNT,"drugList",PSS("interactedCount"),"orderNumber")=DRUGS(VAL,"orderNumber")
. . SET HASH(COUNT,"drugList",PSS("interactedCount"),"drugName")=DRUGS(VAL,"drugName")
. . SET HASH(COUNT,"drugList",PSS("interactedCount"),"cprsOrderNumber")=$GET(DRUGS(VAL,"cprsOrderNumber"))
. . SET HASH(COUNT,"drugList",PSS("interactedCount"),"package")=$GET(DRUGS(VAL,"package"))
. SET PSS("interactedCount")=PSS("interactedCount")+1
. QUIT
QUIT
;;
PARSEDRG(DOCHAND,NODE,HASH,COUNT) ;
; @DESC Parses a drug element and stores values in HASH parameter
;
; @DOCHAND Handle to XML document
; @NODE Node associated with XML element
; @HASH Passed by ref. Used to store return values.
; @COUNT Count of drugs
;
; @RETURNS Nothing, Values stored in HASH values
;
SET HASH(COUNT,"vuid")=$$VALUE^MXMLDOM(DOCHAND,NODE,"vuid")
SET HASH(COUNT,"ien")=$$VALUE^MXMLDOM(DOCHAND,NODE,"ien")
SET HASH(COUNT,"gcn")=$$VALUE^MXMLDOM(DOCHAND,NODE,"gcnSeqNo")
SET HASH(COUNT,"drugName")=$$VALUE^MXMLDOM(DOCHAND,NODE,"drugName")
;
; Split the order number that is in the format 'orderNumber|cprsOrderNumber|package'
; Get the cprsOrderNumber and package from order number and order number
SET HASH(COUNT,"orderNumber")=$PIECE($$VALUE^MXMLDOM(DOCHAND,NODE,"orderNumber"),"|",1)
SET HASH(COUNT,"cprsOrderNumber")=$PIECE($$VALUE^MXMLDOM(DOCHAND,NODE,"orderNumber"),"|",2)
SET HASH(COUNT,"package")=$PIECE($$VALUE^MXMLDOM(DOCHAND,NODE,"orderNumber"),"|",3)
;
QUIT
;;
UPPER(PSSTEXT) ;
; @DESC Converts lowercase characters to uppercase
;
; @PSSTEXT Text to be converted
;
; @RETURNS Text in all UPPPERCASE
;
NEW PSS
;
SET PSS("lower")="abcdefghijklmnopqrstuvwxyz"
SET PSS("upper")="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
SET PSS("upperText")=$TR(PSSTEXT,PSS("lower"),PSS("upper"))
QUIT PSS("upperText")
;;
GETTEXT(DOCHAND,NODE) ;
; @DESC Gets text from XML element as a single string
;
; @DOCHAND Handle to XML document
; @NODE Node associated with XML element
;
; @RETURNS Text of XML element as a single string
;
NEW TEXT
;
DO TEXT^MXMLDOM(DOCHAND,NODE,$NA(TEXT))
; Store array values in string
SET TEXT=$$UNPARSE(.TEXT)
;
QUIT TEXT
;;
UNPARSE(ARRY) ;
; @DESC Creates a single string from an array
;
; @ARRY Array to be looped through for text
;
; @RETURNS Text of array as a single string
;
NEW VAL,STRING
;
SET VAL=""
SET STRING=""
;
FOR SET VAL=$ORDER(ARRY(VAL)) QUIT:VAL="" DO
. SET STRING=STRING_ARRY(VAL)
QUIT STRING
;;
ATRIBUTE(NAME,VALUE) ;
; @DESC Builds a valid encoded attribute from the name/value pair passed in
;
; @NAME The left side of the "name=value" relationship
; @VALUE The right side of the "name=value" relationship
;
; @RETURNS A valid/encoded name value pair
NEW PSS,QT
SET QT=""""
SET PSS("attribute")=NAME_"="_QT_$$SYMENC^MXMLUTL($GET(VALUE))_QT
QUIT PSS("attribute")
;;
ISPROF(ORDERNUM) ;
; @DESC Determines if a drug is a profile drug according to
; its orderNumber
;
; @RETURNS 1 if is a profile, 0 if not a profile
NEW PSS
;
SET PSS("isProfile")=$$UPPER^PSSHRCOM(ORDERNUM)["PROFILE"
;
QUIT PSS("isProfile")
;;
STACK ;
; @DESC Prints a stack trace
;
; @RETURNS Nothing
NEW PSSLOOP
FOR PSSLOOP=0:1:$STACK(-1) DO
. WRITE !,"Context level:",PSSLOOP,?25,"Context type: ",$STACK(PSSLOOP)
. WRITE !,?5,"Current place: ",$STACK(PSSLOOP,"PLACE")
. WRITE !,?5,"Current source: ",$STACK(PSSLOOP,"MCODE")
. WRITE !
. QUIT
QUIT
;;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSSHRCOM 5787 printed Oct 16, 2024@18:32:30 Page 2
PSSHRCOM ;WOIFO/AV,TS - Handles common PRE PEPS interface functionality ;09/20/07
+1 ;;1.0;PHARMACY DATA MANAGEMENT;**136**;9/30/97;Build 89;
+2 ;
+3 ; @authors - Alex Vazquez, Tim Sabat
+4 ; @date - September 19, 2007
+5 ; @version - 1.0
+6 ;
+7 QUIT
+8 ;;
PARSEMSG(DOCHAND,NODE,HASH,COUNT) ;
+1 ; @DESC Parses the message XML element and stores
+2 ; severity, type, drugName and text in HASH parameter
+3 ;
+4 ; @DOCHAND Handle to XML document
+5 ; @NODE Node associated with XML element
+6 ; @HASH Passed by ref. Used to store return values
+7 ; @COUNT Count of messages
+8 ;
+9 ; @RETURNS Nothing, Values stored in HASH variable
+10 ;
+11 NEW PSS,NAME
+12 ;
+13 SET PSS("child")=0
+14 ;
+15 FOR
SET PSS("child")=$$CHILD^MXMLDOM(DOCHAND,NODE,PSS("child"))
if PSS("child")<1
QUIT
Begin DoDot:1
+16 SET NAME=$$NAME^MXMLDOM(DOCHAND,PSS("child"))
+17 ;
+18 if NAME="drug"
Begin DoDot:2
+19 DO PARSEDRG(DOCHAND,PSS("child"),.HASH,COUNT)
+20 QUIT
End DoDot:2
+21 if NAME="severity"
Begin DoDot:2
+22 SET HASH(COUNT,"severity")=$$GETTEXT(DOCHAND,PSS("child"))
+23 QUIT
End DoDot:2
+24 if NAME="type"
Begin DoDot:2
+25 SET HASH(COUNT,"type")=$$GETTEXT(DOCHAND,PSS("child"))
+26 QUIT
End DoDot:2
+27 if NAME="drugName"
Begin DoDot:2
+28 SET HASH(COUNT,"drugName")=$$GETTEXT(DOCHAND,PSS("child"))
+29 QUIT
End DoDot:2
+30 if NAME="text"
Begin DoDot:2
+31 SET HASH(COUNT,"text")=$$GETTEXT(DOCHAND,PSS("child"))
+32 QUIT
End DoDot:2
+33 QUIT
End DoDot:1
+34 QUIT
+35 ;;
DRUGLIST(DOCHAND,NODE,HASH,COUNT) ;
+1 ; @DESC Handles reading the interacted drug list and stores to a Hash
+2 ;
+3 ; @DOCHAND Handle to XML document
+4 ; @NODE Represents the interactedDrugList XML element
+5 ; @HASH Passed by ref. Used to store return values
+6 ; @COUNT Count of drugs
+7 ;
+8 ; @RETURNS Nothing, Values stored in HASH variable
+9 ;
+10 NEW PSS,VAL,DRUGS
+11 SET PSS("child")=0
+12 SET PSS("interactedCount")=1
+13 ;
+14 FOR
SET PSS("child")=$$CHILD^MXMLDOM(DOCHAND,NODE,PSS("child"))
if PSS("child")=0
QUIT
Begin DoDot:1
+15 ; Renew the DRUGS variable before passing in again
+16 KILL DRUGS
+17 DO PARSEDRG(DOCHAND,PSS("child"),.DRUGS,PSS("interactedCount"))
+18 SET VAL=""
+19 FOR
SET VAL=$ORDER(DRUGS(VAL))
if VAL=""
QUIT
Begin DoDot:2
+20 SET HASH(COUNT,"drugList",PSS("interactedCount"),"vuid")=DRUGS(VAL,"vuid")
+21 SET HASH(COUNT,"drugList",PSS("interactedCount"),"ien")=DRUGS(VAL,"ien")
+22 SET HASH(COUNT,"drugList",PSS("interactedCount"),"gcn")=DRUGS(VAL,"gcn")
+23 SET HASH(COUNT,"drugList",PSS("interactedCount"),"orderNumber")=DRUGS(VAL,"orderNumber")
+24 SET HASH(COUNT,"drugList",PSS("interactedCount"),"drugName")=DRUGS(VAL,"drugName")
+25 SET HASH(COUNT,"drugList",PSS("interactedCount"),"cprsOrderNumber")=$GET(DRUGS(VAL,"cprsOrderNumber"))
+26 SET HASH(COUNT,"drugList",PSS("interactedCount"),"package")=$GET(DRUGS(VAL,"package"))
End DoDot:2
+27 SET PSS("interactedCount")=PSS("interactedCount")+1
+28 QUIT
End DoDot:1
+29 QUIT
+30 ;;
PARSEDRG(DOCHAND,NODE,HASH,COUNT) ;
+1 ; @DESC Parses a drug element and stores values in HASH parameter
+2 ;
+3 ; @DOCHAND Handle to XML document
+4 ; @NODE Node associated with XML element
+5 ; @HASH Passed by ref. Used to store return values.
+6 ; @COUNT Count of drugs
+7 ;
+8 ; @RETURNS Nothing, Values stored in HASH values
+9 ;
+10 SET HASH(COUNT,"vuid")=$$VALUE^MXMLDOM(DOCHAND,NODE,"vuid")
+11 SET HASH(COUNT,"ien")=$$VALUE^MXMLDOM(DOCHAND,NODE,"ien")
+12 SET HASH(COUNT,"gcn")=$$VALUE^MXMLDOM(DOCHAND,NODE,"gcnSeqNo")
+13 SET HASH(COUNT,"drugName")=$$VALUE^MXMLDOM(DOCHAND,NODE,"drugName")
+14 ;
+15 ; Split the order number that is in the format 'orderNumber|cprsOrderNumber|package'
+16 ; Get the cprsOrderNumber and package from order number and order number
+17 SET HASH(COUNT,"orderNumber")=$PIECE($$VALUE^MXMLDOM(DOCHAND,NODE,"orderNumber"),"|",1)
+18 SET HASH(COUNT,"cprsOrderNumber")=$PIECE($$VALUE^MXMLDOM(DOCHAND,NODE,"orderNumber"),"|",2)
+19 SET HASH(COUNT,"package")=$PIECE($$VALUE^MXMLDOM(DOCHAND,NODE,"orderNumber"),"|",3)
+20 ;
+21 QUIT
+22 ;;
UPPER(PSSTEXT) ;
+1 ; @DESC Converts lowercase characters to uppercase
+2 ;
+3 ; @PSSTEXT Text to be converted
+4 ;
+5 ; @RETURNS Text in all UPPPERCASE
+6 ;
+7 NEW PSS
+8 ;
+9 SET PSS("lower")="abcdefghijklmnopqrstuvwxyz"
+10 SET PSS("upper")="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+11 SET PSS("upperText")=$TRANSLATE(PSSTEXT,PSS("lower"),PSS("upper"))
+12 QUIT PSS("upperText")
+13 ;;
GETTEXT(DOCHAND,NODE) ;
+1 ; @DESC Gets text from XML element as a single string
+2 ;
+3 ; @DOCHAND Handle to XML document
+4 ; @NODE Node associated with XML element
+5 ;
+6 ; @RETURNS Text of XML element as a single string
+7 ;
+8 NEW TEXT
+9 ;
+10 DO TEXT^MXMLDOM(DOCHAND,NODE,$NAME(TEXT))
+11 ; Store array values in string
+12 SET TEXT=$$UNPARSE(.TEXT)
+13 ;
+14 QUIT TEXT
+15 ;;
UNPARSE(ARRY) ;
+1 ; @DESC Creates a single string from an array
+2 ;
+3 ; @ARRY Array to be looped through for text
+4 ;
+5 ; @RETURNS Text of array as a single string
+6 ;
+7 NEW VAL,STRING
+8 ;
+9 SET VAL=""
+10 SET STRING=""
+11 ;
+12 FOR
SET VAL=$ORDER(ARRY(VAL))
if VAL=""
QUIT
Begin DoDot:1
+13 SET STRING=STRING_ARRY(VAL)
End DoDot:1
+14 QUIT STRING
+15 ;;
ATRIBUTE(NAME,VALUE) ;
+1 ; @DESC Builds a valid encoded attribute from the name/value pair passed in
+2 ;
+3 ; @NAME The left side of the "name=value" relationship
+4 ; @VALUE The right side of the "name=value" relationship
+5 ;
+6 ; @RETURNS A valid/encoded name value pair
+7 NEW PSS,QT
+8 SET QT=""""
+9 SET PSS("attribute")=NAME_"="_QT_$$SYMENC^MXMLUTL($GET(VALUE))_QT
+10 QUIT PSS("attribute")
+11 ;;
ISPROF(ORDERNUM) ;
+1 ; @DESC Determines if a drug is a profile drug according to
+2 ; its orderNumber
+3 ;
+4 ; @RETURNS 1 if is a profile, 0 if not a profile
+5 NEW PSS
+6 ;
+7 SET PSS("isProfile")=$$UPPER^PSSHRCOM(ORDERNUM)["PROFILE"
+8 ;
+9 QUIT PSS("isProfile")
+10 ;;
STACK ;
+1 ; @DESC Prints a stack trace
+2 ;
+3 ; @RETURNS Nothing
+4 NEW PSSLOOP
+5 FOR PSSLOOP=0:1:$STACK(-1)
Begin DoDot:1
+6 WRITE !,"Context level:",PSSLOOP,?25,"Context type: ",$STACK(PSSLOOP)
+7 WRITE !,?5,"Current place: ",$STACK(PSSLOOP,"PLACE")
+8 WRITE !,?5,"Current source: ",$STACK(PSSLOOP,"MCODE")
+9 WRITE !
+10 QUIT
End DoDot:1
+11 QUIT
+12 ;;