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

PSSHRQ22.m

Go to the documentation of this file.
  1. 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
  1. ;
  1. ; @authors - Alex Vazquez, Tim Sabat
  1. ; @date - September 19, 2007
  1. ; @version - 1.0
  1. ;
  1. QUIT
  1. ;;
  1. THERAPY(DOCHAND,NODE,BASE) ;
  1. ; @DRIVER
  1. ; @DESC Parses the drugTherapyChecks XML elements
  1. ;
  1. ; @DOCHAND Handle to XML document
  1. ; @NODE Node associated with XML element
  1. ; @PSSHAND Handle to DrugOrderChecks object
  1. ;
  1. ; @RETURNS Nothing
  1. ;
  1. NEW PSS,MSGHASH,DRUGHASH,PSMSGCNT
  1. ;
  1. SET PSS("child")=0
  1. SET PSS("therapyCount")=0
  1. SET PSMSGCNT=0
  1. ;
  1. FOR SET PSS("child")=$$CHILD^MXMLDOM(DOCHAND,NODE,PSS("child")) QUIT:PSS("child")=0 DO
  1. . SET PSS("childName")=$$NAME^MXMLDOM(DOCHAND,PSS("child"))
  1. . ;
  1. . ;XML allows messages within both drugTherapyChecks and drugTherapyCheck
  1. . SET:PSS("childName")="message" PSMSGCNT=PSMSGCNT+1
  1. . DO:PSS("childName")="message" MSGREAD(DOCHAND,PSS("child"),.MSGHASH,PSMSGCNT)
  1. . ;
  1. . SET:PSS("childName")="drugTherapyCheck" PSS("therapyCount")=PSS("therapyCount")+1
  1. . DO:PSS("childName")="drugTherapyCheck" THERREAD(DOCHAND,PSS("child"),.DRUGHASH,PSS("therapyCount"),.MSGHASH,PSMSGCNT)
  1. ;
  1. ;MSGHASH is set in THEREAD
  1. DO MSGWRITE^PSSHRQ21(.MSGHASH,BASE,"THERAPY")
  1. DO THERWRIT(.DRUGHASH,BASE)
  1. ;
  1. QUIT
  1. ;;
  1. MSGREAD(DOCHAND,NODE,HASH,COUNT) ;
  1. ; @DESC Handles parsing message section
  1. ;
  1. ; @DOCHAND Handle to XML document
  1. ; @NODE Node associated with XML element
  1. ; @COUNT Count of message sections
  1. ; @HASH Where to store info
  1. ;
  1. ; @RETURNS Nothing
  1. ;
  1. ; Parse the message and store in hash
  1. DO PARSEMSG^PSSHRCOM(DOCHAND,NODE,.HASH,COUNT)
  1. ;
  1. QUIT
  1. ;
  1. ;
  1. THERREAD(DOCHAND,NODE,HASH,COUNT,MSGHASH,MSGCNT) ;
  1. ; @DESC Handles parsing and storage of drugTherapyCheck element
  1. ;
  1. ; @DOCHAND Handle to XML document
  1. ; @NODE Node associated with XML element
  1. ; @COUNT Count of drug sections
  1. ; @HASH Where to store info
  1. ; @MSGHASH Where message (alert)from FDB is stored
  1. ; @MSGCNT-The current count of the number of messages (messages can occur in both places)
  1. ; @RETURNS Nothing
  1. NEW PSS
  1. NEW INTDRUG ;FOR TEST
  1. SET PSS("child")=0
  1. SET PSS("messageCount")=MSGCNT
  1. ;
  1. FOR SET PSS("child")=$$CHILD^MXMLDOM(DOCHAND,NODE,PSS("child")) QUIT:PSS("child")=0 DO
  1. . SET PSS("childName")=$$NAME^MXMLDOM(DOCHAND,PSS("child"))
  1. .
  1. . I PSS("childName")="message" D Q
  1. . .S PSS("messageCount")=PSS("messageCount")+1
  1. . .D MSGREAD(DOCHAND,PSS("child"),.MSGHASH,PSS("messageCount"))
  1. . ;
  1. . DO:PSS("childName")="interactedDrugList"
  1. . . ; Store the interacted drug list
  1. . . DO DRUGLIST^PSSHRCOM(DOCHAND,PSS("child"),.HASH,COUNT)
  1. . DO:PSS("childName")="classification"
  1. . . SET HASH(COUNT,"classification")=$$GETTEXT^PSSHRCOM(DOCHAND,PSS("child"))
  1. . . QUIT
  1. . DO:PSS("childName")="duplicateAllowance"
  1. . . SET HASH(COUNT,"duplicateAllowance")=$$GETTEXT^PSSHRCOM(DOCHAND,PSS("child"))
  1. . . QUIT
  1. . DO:PSS("childName")="shortText"
  1. . . SET HASH(COUNT,"shortText")=$$GETTEXT^PSSHRCOM(DOCHAND,PSS("child"))
  1. . . QUIT
  1. . QUIT
  1. QUIT
  1. ;;
  1. THERWRIT(HASH,BASE) ;
  1. ; @DESC Handles writing drugDrugChecks drugTherapy section of the XML document
  1. ;
  1. ; @HASH ByRef, Hash used to store response
  1. ; @BASE Base of output global
  1. ;
  1. ; @RETURNS Nothing. Stores values in output global.
  1. ;
  1. NEW PSS,I,DRUGNUM,NODE,COUNT,INDX
  1. ;
  1. SET I=""
  1. SET COUNT=0
  1. ;
  1. ; Creates the index of drug combinations
  1. ; Each unique drug combination has the corresponding count
  1. DO MAKEINDX(.INDX,.HASH)
  1. ;
  1. FOR SET I=$ORDER(HASH(I)) QUIT:I="" DO
  1. . ; Get the drugList identifier,
  1. . ; Then get the count, count will be used to write global
  1. . SET COUNT=INDX($$DLISTID(.HASH,I))
  1. . ;
  1. . ; Create the node to be used with subscript indirection
  1. . SET NODE="^TMP($JOB,BASE,""OUT"",""THERAPY"",COUNT)"
  1. . ; Write out the drug list to the global
  1. . SET DRUGNUM=""
  1. . FOR SET DRUGNUM=$ORDER(HASH(I,"drugList",DRUGNUM)) QUIT:DRUGNUM="" DO
  1. . . DO TMPGLOB(.HASH,I,COUNT,DRUGNUM,BASE)
  1. . . QUIT
  1. . ;
  1. . ; Write out the nodes to the correct subcount
  1. . ; Get the correct subcount number first
  1. . ; Get last count, then add 1 to move to next counter
  1. . SET PSS("subCount")=$$SUBCOUNT(COUNT,BASE)
  1. . SET @NODE@(PSS("subCount"),"ALLOW")=HASH(I,"duplicateAllowance")
  1. . SET @NODE@(PSS("subCount"),"CLASS")=HASH(I,"classification")
  1. . SET @NODE@(PSS("subCount"),"SHORT")=HASH(I,"shortText")
  1. . ;
  1. . QUIT
  1. ;
  1. QUIT
  1. ;;
  1. SUBCOUNT(COUNT,BASE) ;
  1. ; @DESC Returns the next subcount for drug therapy output global
  1. ; Format is ^TMP($JOB,BASE,"OUT","THERAPY",COUNT,SUBCOUNT)
  1. ;
  1. ; @COUNT The main count of drug therapy
  1. ; @BASE The base of output global
  1. ;
  1. ; @RETURNS The last subcount of drug therapy output global.
  1. ;
  1. NEW PSS
  1. ;
  1. ; loop through the subcounts of the current count, store highest
  1. ; subcount and return it
  1. SET PSS("subCount")=""
  1. SET PSS("highCount")=0
  1. FOR SET PSS("subCount")=$ORDER(^TMP($JOB,BASE,"OUT","THERAPY",COUNT,PSS("subCount"))) QUIT:PSS("subCount")="" DO
  1. . IF +PSS("subCount")>PSS("highCount") SET PSS("highCount")=+PSS("subCount")
  1. . QUIT
  1. ;
  1. QUIT PSS("highCount")+1
  1. ;;
  1. MAKEINDX(INDX,HASH) ;
  1. ; @DESC Creates index of drug list combinations. Uses gcn as the
  1. ; unique identifier of drug.
  1. ;
  1. ; @HASH ByRef, Holds the list of drugs
  1. ; @INDX ByRef, Used to store count of drug list
  1. ;
  1. ; @RETURNS Nothing. Values returned in INDX hash
  1. ;
  1. NEW I,PSS
  1. ;
  1. SET PSS("uniqueDrugCombinationCount")=0
  1. ;
  1. SET I=""
  1. FOR SET I=$ORDER(HASH(I)) QUIT:I="" DO
  1. . ; Get the uniqueDrugCombinationId, i.e. gcn's strung together
  1. . SET PSS("uniqueDrugCombination")=$$DLISTID(.HASH,I)
  1. . ;
  1. . ; Check to see if drug combination already exist
  1. . ; If it does not exist increase the unique drug count
  1. . IF $DATA(INDX(PSS("uniqueDrugCombination")))=0 DO
  1. . . SET PSS("uniqueDrugCombinationCount")=PSS("uniqueDrugCombinationCount")+1
  1. . . SET INDX(PSS("uniqueDrugCombination"))=PSS("uniqueDrugCombinationCount")
  1. . QUIT
  1. ;
  1. QUIT
  1. ;;
  1. DLISTID(HASH,I) ;
  1. ; @DESC Returns the id of the drug list. The id of the drug list
  1. ; consist of the gcn in sorted order separated by '^'.
  1. ;
  1. ; @HASH ByRef, Holds the list of drugs
  1. ; @I The current count on the hash
  1. ;
  1. ; @RETURNS Id of drug list.
  1. NEW J,K,PSS,ARRAY
  1. ; loop through the drug therapy checks count
  1. ; Create a temp array to sort the gcns in the ascending order
  1. SET J=""
  1. FOR SET J=$ORDER(HASH(I,"drugList",J)) QUIT:J="" DO
  1. . ;SET PSS("uniqueDrugID")=HASH(I,"drugList",J,"orderNumber")
  1. . SET PSS("uniqueDrugID")=HASH(I,"drugList",J,"gcn") ;PO: get GCN
  1. . SET ARRAY(PSS("uniqueDrugID"))=1
  1. . QUIT
  1. ;
  1. ; Create a uniqueDrugCombination from temp array
  1. SET K=""
  1. SET PSS("tempCount")=0
  1. SET PSS("uniqueDrugCombination")=""
  1. FOR SET K=$ORDER(ARRAY(K)) QUIT:K="" DO
  1. . IF PSS("tempCount")>0 DO
  1. . . SET PSS("uniqueDrugCombination")=PSS("uniqueDrugCombination")_"^"_K
  1. . ;
  1. . ; For first loop do no attach ^ before setting
  1. . IF PSS("tempCount")=0 DO
  1. . . SET PSS("tempCount")=PSS("tempCount")+1
  1. . . SET PSS("uniqueDrugCombination")=K
  1. . ;
  1. . QUIT
  1. ;
  1. QUIT PSS("uniqueDrugCombination")
  1. ;;
  1. TMPGLOB(HASH,MAINCNT,CHEKCNT,DRUGNUM,BASE) ;
  1. ; @DESC Writes the drugList to the proper global
  1. ;
  1. ; @HASH ByRef, Has used to store response
  1. ; @CHECKCNT The current TherapyCheck result
  1. ; @DRUGNUM The current drug interaction
  1. ; @BASE Base of the output global
  1. ;
  1. ; @RETURNS Nothing. Stores values in output global.
  1. ;
  1. NEW NODE
  1. SET NODE="^TMP($JOB,BASE,""OUT"",""THERAPY"",CHEKCNT,""DRUGS"",DRUGNUM)"
  1. SET @NODE=$$VALUE(.HASH,MAINCNT,DRUGNUM)
  1. QUIT
  1. ;;
  1. VALUE(HASH,MAINCNT,DRUGNUM) ;
  1. ; @DESC Provides the ""piece" data we use when creating the output global.
  1. ;
  1. ; @HASH ByRef, Has used to store response
  1. ; @MAINCNT The current TherapyCheck result
  1. ; @DRUGNUM The current drug interaction
  1. ;
  1. ; @RETURNS The right side of the global for therapy.
  1. ;
  1. ; PharmacyOrderNumber ^
  1. ; Drug IEN ^
  1. ; Drug Name ^
  1. ; CPRS Order Number ^
  1. ; Package
  1. ;
  1. NEW OUT
  1. SET OUT=HASH(MAINCNT,"drugList",DRUGNUM,"orderNumber")_"^"
  1. SET OUT=OUT_HASH(MAINCNT,"drugList",DRUGNUM,"ien")_"^"
  1. SET OUT=OUT_HASH(MAINCNT,"drugList",DRUGNUM,"drugName")_"^"
  1. SET OUT=OUT_HASH(MAINCNT,"drugList",DRUGNUM,"cprsOrderNumber")_"^"
  1. SET OUT=OUT_HASH(MAINCNT,"drugList",DRUGNUM,"package")
  1. QUIT OUT
  1. ;;