PSSHRQ22 ;WOIFO/AV,TS - Handles parsing a PEPS drugTherapyChecks XML element ;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
;;
THERAPY(DOCHAND,NODE,BASE) ;
; @DRIVER
; @DESC Parses the drugTherapyChecks XML elements
;
; @DOCHAND Handle to XML document
; @NODE Node associated with XML element
; @PSSHAND Handle to DrugOrderChecks object
;
; @RETURNS Nothing
;
NEW PSS,MSGHASH,DRUGHASH,PSMSGCNT
;
SET PSS("child")=0
SET PSS("therapyCount")=0
SET PSMSGCNT=0
;
FOR SET PSS("child")=$$CHILD^MXMLDOM(DOCHAND,NODE,PSS("child")) QUIT:PSS("child")=0 DO
. SET PSS("childName")=$$NAME^MXMLDOM(DOCHAND,PSS("child"))
. ;
. ;XML allows messages within both drugTherapyChecks and drugTherapyCheck
. SET:PSS("childName")="message" PSMSGCNT=PSMSGCNT+1
. DO:PSS("childName")="message" MSGREAD(DOCHAND,PSS("child"),.MSGHASH,PSMSGCNT)
. ;
. SET:PSS("childName")="drugTherapyCheck" PSS("therapyCount")=PSS("therapyCount")+1
. DO:PSS("childName")="drugTherapyCheck" THERREAD(DOCHAND,PSS("child"),.DRUGHASH,PSS("therapyCount"),.MSGHASH,PSMSGCNT)
;
;MSGHASH is set in THEREAD
DO MSGWRITE^PSSHRQ21(.MSGHASH,BASE,"THERAPY")
DO THERWRIT(.DRUGHASH,BASE)
;
QUIT
;;
MSGREAD(DOCHAND,NODE,HASH,COUNT) ;
; @DESC Handles parsing message section
;
; @DOCHAND Handle to XML document
; @NODE Node associated with XML element
; @COUNT Count of message sections
; @HASH Where to store info
;
; @RETURNS Nothing
;
; Parse the message and store in hash
DO PARSEMSG^PSSHRCOM(DOCHAND,NODE,.HASH,COUNT)
;
QUIT
;
;
THERREAD(DOCHAND,NODE,HASH,COUNT,MSGHASH,MSGCNT) ;
; @DESC Handles parsing and storage of drugTherapyCheck element
;
; @DOCHAND Handle to XML document
; @NODE Node associated with XML element
; @COUNT Count of drug sections
; @HASH Where to store info
; @MSGHASH Where message (alert)from FDB is stored
; @MSGCNT-The current count of the number of messages (messages can occur in both places)
; @RETURNS Nothing
NEW PSS
NEW INTDRUG ;FOR TEST
SET PSS("child")=0
SET PSS("messageCount")=MSGCNT
;
FOR SET PSS("child")=$$CHILD^MXMLDOM(DOCHAND,NODE,PSS("child")) QUIT:PSS("child")=0 DO
. SET PSS("childName")=$$NAME^MXMLDOM(DOCHAND,PSS("child"))
.
. I PSS("childName")="message" D Q
. .S PSS("messageCount")=PSS("messageCount")+1
. .D MSGREAD(DOCHAND,PSS("child"),.MSGHASH,PSS("messageCount"))
. ;
. DO:PSS("childName")="interactedDrugList"
. . ; Store the interacted drug list
. . DO DRUGLIST^PSSHRCOM(DOCHAND,PSS("child"),.HASH,COUNT)
. DO:PSS("childName")="classification"
. . SET HASH(COUNT,"classification")=$$GETTEXT^PSSHRCOM(DOCHAND,PSS("child"))
. . QUIT
. DO:PSS("childName")="duplicateAllowance"
. . SET HASH(COUNT,"duplicateAllowance")=$$GETTEXT^PSSHRCOM(DOCHAND,PSS("child"))
. . QUIT
. DO:PSS("childName")="shortText"
. . SET HASH(COUNT,"shortText")=$$GETTEXT^PSSHRCOM(DOCHAND,PSS("child"))
. . QUIT
. QUIT
QUIT
;;
THERWRIT(HASH,BASE) ;
; @DESC Handles writing drugDrugChecks drugTherapy section of the XML document
;
; @HASH ByRef, Hash used to store response
; @BASE Base of output global
;
; @RETURNS Nothing. Stores values in output global.
;
NEW PSS,I,DRUGNUM,NODE,COUNT,INDX
;
SET I=""
SET COUNT=0
;
; Creates the index of drug combinations
; Each unique drug combination has the corresponding count
DO MAKEINDX(.INDX,.HASH)
;
FOR SET I=$ORDER(HASH(I)) QUIT:I="" DO
. ; Get the drugList identifier,
. ; Then get the count, count will be used to write global
. SET COUNT=INDX($$DLISTID(.HASH,I))
. ;
. ; Create the node to be used with subscript indirection
. SET NODE="^TMP($JOB,BASE,""OUT"",""THERAPY"",COUNT)"
. ; Write out the drug list to the global
. SET DRUGNUM=""
. FOR SET DRUGNUM=$ORDER(HASH(I,"drugList",DRUGNUM)) QUIT:DRUGNUM="" DO
. . DO TMPGLOB(.HASH,I,COUNT,DRUGNUM,BASE)
. . QUIT
. ;
. ; Write out the nodes to the correct subcount
. ; Get the correct subcount number first
. ; Get last count, then add 1 to move to next counter
. SET PSS("subCount")=$$SUBCOUNT(COUNT,BASE)
. SET @NODE@(PSS("subCount"),"ALLOW")=HASH(I,"duplicateAllowance")
. SET @NODE@(PSS("subCount"),"CLASS")=HASH(I,"classification")
. SET @NODE@(PSS("subCount"),"SHORT")=HASH(I,"shortText")
. ;
. QUIT
;
QUIT
;;
SUBCOUNT(COUNT,BASE) ;
; @DESC Returns the next subcount for drug therapy output global
; Format is ^TMP($JOB,BASE,"OUT","THERAPY",COUNT,SUBCOUNT)
;
; @COUNT The main count of drug therapy
; @BASE The base of output global
;
; @RETURNS The last subcount of drug therapy output global.
;
NEW PSS
;
; loop through the subcounts of the current count, store highest
; subcount and return it
SET PSS("subCount")=""
SET PSS("highCount")=0
FOR SET PSS("subCount")=$ORDER(^TMP($JOB,BASE,"OUT","THERAPY",COUNT,PSS("subCount"))) QUIT:PSS("subCount")="" DO
. IF +PSS("subCount")>PSS("highCount") SET PSS("highCount")=+PSS("subCount")
. QUIT
;
QUIT PSS("highCount")+1
;;
MAKEINDX(INDX,HASH) ;
; @DESC Creates index of drug list combinations. Uses gcn as the
; unique identifier of drug.
;
; @HASH ByRef, Holds the list of drugs
; @INDX ByRef, Used to store count of drug list
;
; @RETURNS Nothing. Values returned in INDX hash
;
NEW I,PSS
;
SET PSS("uniqueDrugCombinationCount")=0
;
SET I=""
FOR SET I=$ORDER(HASH(I)) QUIT:I="" DO
. ; Get the uniqueDrugCombinationId, i.e. gcn's strung together
. SET PSS("uniqueDrugCombination")=$$DLISTID(.HASH,I)
. ;
. ; Check to see if drug combination already exist
. ; If it does not exist increase the unique drug count
. IF $DATA(INDX(PSS("uniqueDrugCombination")))=0 DO
. . SET PSS("uniqueDrugCombinationCount")=PSS("uniqueDrugCombinationCount")+1
. . SET INDX(PSS("uniqueDrugCombination"))=PSS("uniqueDrugCombinationCount")
. QUIT
;
QUIT
;;
DLISTID(HASH,I) ;
; @DESC Returns the id of the drug list. The id of the drug list
; consist of the gcn in sorted order separated by '^'.
;
; @HASH ByRef, Holds the list of drugs
; @I The current count on the hash
;
; @RETURNS Id of drug list.
NEW J,K,PSS,ARRAY
; loop through the drug therapy checks count
; Create a temp array to sort the gcns in the ascending order
SET J=""
FOR SET J=$ORDER(HASH(I,"drugList",J)) QUIT:J="" DO
. ;SET PSS("uniqueDrugID")=HASH(I,"drugList",J,"orderNumber")
. SET PSS("uniqueDrugID")=HASH(I,"drugList",J,"gcn") ;PO: get GCN
. SET ARRAY(PSS("uniqueDrugID"))=1
. QUIT
;
; Create a uniqueDrugCombination from temp array
SET K=""
SET PSS("tempCount")=0
SET PSS("uniqueDrugCombination")=""
FOR SET K=$ORDER(ARRAY(K)) QUIT:K="" DO
. IF PSS("tempCount")>0 DO
. . SET PSS("uniqueDrugCombination")=PSS("uniqueDrugCombination")_"^"_K
. ;
. ; For first loop do no attach ^ before setting
. IF PSS("tempCount")=0 DO
. . SET PSS("tempCount")=PSS("tempCount")+1
. . SET PSS("uniqueDrugCombination")=K
. ;
. QUIT
;
QUIT PSS("uniqueDrugCombination")
;;
TMPGLOB(HASH,MAINCNT,CHEKCNT,DRUGNUM,BASE) ;
; @DESC Writes the drugList to the proper global
;
; @HASH ByRef, Has used to store response
; @CHECKCNT The current TherapyCheck result
; @DRUGNUM The current drug interaction
; @BASE Base of the output global
;
; @RETURNS Nothing. Stores values in output global.
;
NEW NODE
SET NODE="^TMP($JOB,BASE,""OUT"",""THERAPY"",CHEKCNT,""DRUGS"",DRUGNUM)"
SET @NODE=$$VALUE(.HASH,MAINCNT,DRUGNUM)
QUIT
;;
VALUE(HASH,MAINCNT,DRUGNUM) ;
; @DESC Provides the ""piece" data we use when creating the output global.
;
; @HASH ByRef, Has used to store response
; @MAINCNT The current TherapyCheck result
; @DRUGNUM The current drug interaction
;
; @RETURNS The right side of the global for therapy.
;
; PharmacyOrderNumber ^
; Drug IEN ^
; Drug Name ^
; CPRS Order Number ^
; Package
;
NEW OUT
SET OUT=HASH(MAINCNT,"drugList",DRUGNUM,"orderNumber")_"^"
SET OUT=OUT_HASH(MAINCNT,"drugList",DRUGNUM,"ien")_"^"
SET OUT=OUT_HASH(MAINCNT,"drugList",DRUGNUM,"drugName")_"^"
SET OUT=OUT_HASH(MAINCNT,"drugList",DRUGNUM,"cprsOrderNumber")_"^"
SET OUT=OUT_HASH(MAINCNT,"drugList",DRUGNUM,"package")
QUIT OUT
;;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSSHRQ22 8404 printed Dec 13, 2024@02:31:55 Page 2
PSSHRQ22 ;WOIFO/AV,TS - Handles parsing a PEPS drugTherapyChecks XML element ;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 ;;
THERAPY(DOCHAND,NODE,BASE) ;
+1 ; @DRIVER
+2 ; @DESC Parses the drugTherapyChecks XML elements
+3 ;
+4 ; @DOCHAND Handle to XML document
+5 ; @NODE Node associated with XML element
+6 ; @PSSHAND Handle to DrugOrderChecks object
+7 ;
+8 ; @RETURNS Nothing
+9 ;
+10 NEW PSS,MSGHASH,DRUGHASH,PSMSGCNT
+11 ;
+12 SET PSS("child")=0
+13 SET PSS("therapyCount")=0
+14 SET PSMSGCNT=0
+15 ;
+16 FOR
SET PSS("child")=$$CHILD^MXMLDOM(DOCHAND,NODE,PSS("child"))
if PSS("child")=0
QUIT
Begin DoDot:1
+17 SET PSS("childName")=$$NAME^MXMLDOM(DOCHAND,PSS("child"))
+18 ;
+19 ;XML allows messages within both drugTherapyChecks and drugTherapyCheck
+20 if PSS("childName")="message"
SET PSMSGCNT=PSMSGCNT+1
+21 if PSS("childName")="message"
DO MSGREAD(DOCHAND,PSS("child"),.MSGHASH,PSMSGCNT)
+22 ;
+23 if PSS("childName")="drugTherapyCheck"
SET PSS("therapyCount")=PSS("therapyCount")+1
+24 if PSS("childName")="drugTherapyCheck"
DO THERREAD(DOCHAND,PSS("child"),.DRUGHASH,PSS("therapyCount"),.MSGHASH,PSMSGCNT)
End DoDot:1
+25 ;
+26 ;MSGHASH is set in THEREAD
+27 DO MSGWRITE^PSSHRQ21(.MSGHASH,BASE,"THERAPY")
+28 DO THERWRIT(.DRUGHASH,BASE)
+29 ;
+30 QUIT
+31 ;;
MSGREAD(DOCHAND,NODE,HASH,COUNT) ;
+1 ; @DESC Handles parsing message section
+2 ;
+3 ; @DOCHAND Handle to XML document
+4 ; @NODE Node associated with XML element
+5 ; @COUNT Count of message sections
+6 ; @HASH Where to store info
+7 ;
+8 ; @RETURNS Nothing
+9 ;
+10 ; Parse the message and store in hash
+11 DO PARSEMSG^PSSHRCOM(DOCHAND,NODE,.HASH,COUNT)
+12 ;
+13 QUIT
+14 ;
+15 ;
THERREAD(DOCHAND,NODE,HASH,COUNT,MSGHASH,MSGCNT) ;
+1 ; @DESC Handles parsing and storage of drugTherapyCheck element
+2 ;
+3 ; @DOCHAND Handle to XML document
+4 ; @NODE Node associated with XML element
+5 ; @COUNT Count of drug sections
+6 ; @HASH Where to store info
+7 ; @MSGHASH Where message (alert)from FDB is stored
+8 ; @MSGCNT-The current count of the number of messages (messages can occur in both places)
+9 ; @RETURNS Nothing
+10 NEW PSS
+11 ;FOR TEST
NEW INTDRUG
+12 SET PSS("child")=0
+13 SET PSS("messageCount")=MSGCNT
+14 ;
+15 FOR
SET PSS("child")=$$CHILD^MXMLDOM(DOCHAND,NODE,PSS("child"))
if PSS("child")=0
QUIT
Begin DoDot:1
+16 SET PSS("childName")=$$NAME^MXMLDOM(DOCHAND,PSS("child"))
+17 +18 IF PSS("childName")="message"
Begin DoDot:2
+19 SET PSS("messageCount")=PSS("messageCount")+1
+20 DO MSGREAD(DOCHAND,PSS("child"),.MSGHASH,PSS("messageCount"))
End DoDot:2
QUIT
+21 ;
+22 if PSS("childName")="interactedDrugList"
Begin DoDot:2
+23 ; Store the interacted drug list
+24 DO DRUGLIST^PSSHRCOM(DOCHAND,PSS("child"),.HASH,COUNT)
End DoDot:2
+25 if PSS("childName")="classification"
Begin DoDot:2
+26 SET HASH(COUNT,"classification")=$$GETTEXT^PSSHRCOM(DOCHAND,PSS("child"))
+27 QUIT
End DoDot:2
+28 if PSS("childName")="duplicateAllowance"
Begin DoDot:2
+29 SET HASH(COUNT,"duplicateAllowance")=$$GETTEXT^PSSHRCOM(DOCHAND,PSS("child"))
+30 QUIT
End DoDot:2
+31 if PSS("childName")="shortText"
Begin DoDot:2
+32 SET HASH(COUNT,"shortText")=$$GETTEXT^PSSHRCOM(DOCHAND,PSS("child"))
+33 QUIT
End DoDot:2
+34 QUIT
End DoDot:1
+35 QUIT
+36 ;;
THERWRIT(HASH,BASE) ;
+1 ; @DESC Handles writing drugDrugChecks drugTherapy section of the XML document
+2 ;
+3 ; @HASH ByRef, Hash used to store response
+4 ; @BASE Base of output global
+5 ;
+6 ; @RETURNS Nothing. Stores values in output global.
+7 ;
+8 NEW PSS,I,DRUGNUM,NODE,COUNT,INDX
+9 ;
+10 SET I=""
+11 SET COUNT=0
+12 ;
+13 ; Creates the index of drug combinations
+14 ; Each unique drug combination has the corresponding count
+15 DO MAKEINDX(.INDX,.HASH)
+16 ;
+17 FOR
SET I=$ORDER(HASH(I))
if I=""
QUIT
Begin DoDot:1
+18 ; Get the drugList identifier,
+19 ; Then get the count, count will be used to write global
+20 SET COUNT=INDX($$DLISTID(.HASH,I))
+21 ;
+22 ; Create the node to be used with subscript indirection
+23 SET NODE="^TMP($JOB,BASE,""OUT"",""THERAPY"",COUNT)"
+24 ; Write out the drug list to the global
+25 SET DRUGNUM=""
+26 FOR
SET DRUGNUM=$ORDER(HASH(I,"drugList",DRUGNUM))
if DRUGNUM=""
QUIT
Begin DoDot:2
+27 DO TMPGLOB(.HASH,I,COUNT,DRUGNUM,BASE)
+28 QUIT
End DoDot:2
+29 ;
+30 ; Write out the nodes to the correct subcount
+31 ; Get the correct subcount number first
+32 ; Get last count, then add 1 to move to next counter
+33 SET PSS("subCount")=$$SUBCOUNT(COUNT,BASE)
+34 SET @NODE@(PSS("subCount"),"ALLOW")=HASH(I,"duplicateAllowance")
+35 SET @NODE@(PSS("subCount"),"CLASS")=HASH(I,"classification")
+36 SET @NODE@(PSS("subCount"),"SHORT")=HASH(I,"shortText")
+37 ;
+38 QUIT
End DoDot:1
+39 ;
+40 QUIT
+41 ;;
SUBCOUNT(COUNT,BASE) ;
+1 ; @DESC Returns the next subcount for drug therapy output global
+2 ; Format is ^TMP($JOB,BASE,"OUT","THERAPY",COUNT,SUBCOUNT)
+3 ;
+4 ; @COUNT The main count of drug therapy
+5 ; @BASE The base of output global
+6 ;
+7 ; @RETURNS The last subcount of drug therapy output global.
+8 ;
+9 NEW PSS
+10 ;
+11 ; loop through the subcounts of the current count, store highest
+12 ; subcount and return it
+13 SET PSS("subCount")=""
+14 SET PSS("highCount")=0
+15 FOR
SET PSS("subCount")=$ORDER(^TMP($JOB,BASE,"OUT","THERAPY",COUNT,PSS("subCount")))
if PSS("subCount")=""
QUIT
Begin DoDot:1
+16 IF +PSS("subCount")>PSS("highCount")
SET PSS("highCount")=+PSS("subCount")
+17 QUIT
End DoDot:1
+18 ;
+19 QUIT PSS("highCount")+1
+20 ;;
MAKEINDX(INDX,HASH) ;
+1 ; @DESC Creates index of drug list combinations. Uses gcn as the
+2 ; unique identifier of drug.
+3 ;
+4 ; @HASH ByRef, Holds the list of drugs
+5 ; @INDX ByRef, Used to store count of drug list
+6 ;
+7 ; @RETURNS Nothing. Values returned in INDX hash
+8 ;
+9 NEW I,PSS
+10 ;
+11 SET PSS("uniqueDrugCombinationCount")=0
+12 ;
+13 SET I=""
+14 FOR
SET I=$ORDER(HASH(I))
if I=""
QUIT
Begin DoDot:1
+15 ; Get the uniqueDrugCombinationId, i.e. gcn's strung together
+16 SET PSS("uniqueDrugCombination")=$$DLISTID(.HASH,I)
+17 ;
+18 ; Check to see if drug combination already exist
+19 ; If it does not exist increase the unique drug count
+20 IF $DATA(INDX(PSS("uniqueDrugCombination")))=0
Begin DoDot:2
+21 SET PSS("uniqueDrugCombinationCount")=PSS("uniqueDrugCombinationCount")+1
+22 SET INDX(PSS("uniqueDrugCombination"))=PSS("uniqueDrugCombinationCount")
End DoDot:2
+23 QUIT
End DoDot:1
+24 ;
+25 QUIT
+26 ;;
DLISTID(HASH,I) ;
+1 ; @DESC Returns the id of the drug list. The id of the drug list
+2 ; consist of the gcn in sorted order separated by '^'.
+3 ;
+4 ; @HASH ByRef, Holds the list of drugs
+5 ; @I The current count on the hash
+6 ;
+7 ; @RETURNS Id of drug list.
+8 NEW J,K,PSS,ARRAY
+9 ; loop through the drug therapy checks count
+10 ; Create a temp array to sort the gcns in the ascending order
+11 SET J=""
+12 FOR
SET J=$ORDER(HASH(I,"drugList",J))
if J=""
QUIT
Begin DoDot:1
+13 ;SET PSS("uniqueDrugID")=HASH(I,"drugList",J,"orderNumber")
+14 ;PO: get GCN
SET PSS("uniqueDrugID")=HASH(I,"drugList",J,"gcn")
+15 SET ARRAY(PSS("uniqueDrugID"))=1
+16 QUIT
End DoDot:1
+17 ;
+18 ; Create a uniqueDrugCombination from temp array
+19 SET K=""
+20 SET PSS("tempCount")=0
+21 SET PSS("uniqueDrugCombination")=""
+22 FOR
SET K=$ORDER(ARRAY(K))
if K=""
QUIT
Begin DoDot:1
+23 IF PSS("tempCount")>0
Begin DoDot:2
+24 SET PSS("uniqueDrugCombination")=PSS("uniqueDrugCombination")_"^"_K
End DoDot:2
+25 ;
+26 ; For first loop do no attach ^ before setting
+27 IF PSS("tempCount")=0
Begin DoDot:2
+28 SET PSS("tempCount")=PSS("tempCount")+1
+29 SET PSS("uniqueDrugCombination")=K
End DoDot:2
+30 ;
+31 QUIT
End DoDot:1
+32 ;
+33 QUIT PSS("uniqueDrugCombination")
+34 ;;
TMPGLOB(HASH,MAINCNT,CHEKCNT,DRUGNUM,BASE) ;
+1 ; @DESC Writes the drugList to the proper global
+2 ;
+3 ; @HASH ByRef, Has used to store response
+4 ; @CHECKCNT The current TherapyCheck result
+5 ; @DRUGNUM The current drug interaction
+6 ; @BASE Base of the output global
+7 ;
+8 ; @RETURNS Nothing. Stores values in output global.
+9 ;
+10 NEW NODE
+11 SET NODE="^TMP($JOB,BASE,""OUT"",""THERAPY"",CHEKCNT,""DRUGS"",DRUGNUM)"
+12 SET @NODE=$$VALUE(.HASH,MAINCNT,DRUGNUM)
+13 QUIT
+14 ;;
VALUE(HASH,MAINCNT,DRUGNUM) ;
+1 ; @DESC Provides the ""piece" data we use when creating the output global.
+2 ;
+3 ; @HASH ByRef, Has used to store response
+4 ; @MAINCNT The current TherapyCheck result
+5 ; @DRUGNUM The current drug interaction
+6 ;
+7 ; @RETURNS The right side of the global for therapy.
+8 ;
+9 ; PharmacyOrderNumber ^
+10 ; Drug IEN ^
+11 ; Drug Name ^
+12 ; CPRS Order Number ^
+13 ; Package
+14 ;
+15 NEW OUT
+16 SET OUT=HASH(MAINCNT,"drugList",DRUGNUM,"orderNumber")_"^"
+17 SET OUT=OUT_HASH(MAINCNT,"drugList",DRUGNUM,"ien")_"^"
+18 SET OUT=OUT_HASH(MAINCNT,"drugList",DRUGNUM,"drugName")_"^"
+19 SET OUT=OUT_HASH(MAINCNT,"drugList",DRUGNUM,"cprsOrderNumber")_"^"
+20 SET OUT=OUT_HASH(MAINCNT,"drugList",DRUGNUM,"package")
+21 QUIT OUT
+22 ;;