ORKCHK4 ; SLC/CLA - Support routine called by ORKCHK to do SELECT mode order checks ;03/29/18 06:02
;;3.0;ORDER ENTRY/RESULTS REPORTING;**6,32,74,87,94,123,162,190,249,272,345,481**;Dec 17, 1997;Build 3
Q
;
EN(ORKS,ORKDFN,ORKA,ORENT,ORKTMODE,OROIL,ORIVRAN,ORDODSG) ;perform order checking for orderable item selection
;ORIVRAN: FLAG THAT DENOTES IF CHECK^ORKPS HAS ALREADY RUN FOR THIS INFUSION ORDER
; 1 FOR ALREADY EXECUTED
; EMPTY STRING FOR NOT YET EXECUTED
;ORDODSG: FLAG THAT DENOTES IF DOSAGE CHECKS SHOULD BE PERFORMED
; 1 FOR PERFORM DOSAGE CHECKS
; 0 FOR DO NOT PERFORM DOSAGE CHECKS
Q:$$GET^XPAR("DIV^SYS^PKG","ORK SYSTEM ENABLE/DISABLE",1,"I")="D"
;
N OI,ORKDG,HL7,ODT,ORNUM,HL7NPTR,HL7NTXT,HL7NCOD,HL7LPTR,HL7LTXT,HL7LCOD
N ORKMSG,ORKTXT
;
S OI=$P(ORKA,"|"),ORKDG=$P(ORKA,"|",2)
S HL7=$P(ORKA,"|",3),ODT=$P(ORKA,"|",4),ORNUM=$P(ORKA,"|",5)
S HL7NPTR=$P(HL7,U),HL7NTXT=$P(HL7,U,2),HL7NCOD=$P(HL7,U,3)
S HL7LPTR=$P(HL7,U,4),HL7LTXT=$P(HL7,U,5),HL7LCOD=$P(HL7,U,6)
;
I $E(ORKDG,1,2)="PS" D PHARM
I $E(ORKDG,1,2)'="PS" D MLM^ORKCHK2(.ORKS,ORKDFN,ORKA,ORENT,"SELECT")
Q
;
PHARM ;process pharmacy order checks:
N ORPSPKG,ORPSA,ORKDD
N ORCRITN,ORCRITF,ORCRITD,ORSIGN,ORSIGF,ORSIGD,ORDUPN,ORDUPF,ORDUPD,ORDUPCN,ORDUPCF,ORDUPCD
;
D PARAMS("CRITICAL DRUG INTERACTION",.ORCRITN,.ORCRITF,.ORCRITD)
D PARAMS("SIGNIFICANT DRUG INTERACTION",.ORSIGN,.ORSIGF,.ORSIGD)
D PARAMS("DUPLICATE DRUG ORDER",.ORDUPN,.ORDUPF,.ORDUPD)
D PARAMS("DUPLICATE DRUG THERAPY",.ORDUPCN,.ORDUPCF,.ORDUPCD)
;
;dispense drug selected:
I $L($G(HL7LPTR)),($G(HL7LCOD)="99PSD") D
.D RXOCS
.S:$P(ORKA,"|",7)'="" $P(ORKA,"|",7)=""
.D MLM^ORKCHK2(.ORKS,ORKDFN,ORKA,ORENT,"SELECT")
;
;dispense drug NOT selected, split OI into dispense drugs:
I '$L($G(HL7LPTR)) D
.S ORPSPKG=$E(ORKDG,3)
.I "IOH"[ORPSPKG D
..S ORPSA=$$OI2DD^ORKPS(OI,ORPSPKG,1)
..I +ORPSA D
...S HL7LTXT=$P($G(^ORD(101.43,OI,0)),U)
...S HL7NPTR=$P(ORPSA,";",2)
...S HL7LPTR=+ORPSA
...S HL7LCOD="99PSD",HL7NCOD="99NDF"
...S $P(HL7,U)=HL7NPTR,$P(HL7,U,3)=HL7NCOD
...S $P(HL7,U,4)=HL7LPTR,$P(HL7,U,5)=HL7LTXT,$P(HL7,U,6)=HL7LCOD
...S $P(ORKA,"|",3)=HL7 ;set these for MLM OCX call
..D RXOCS
..S:$P(ORKA,"|",7)'="" $P(ORKA,"|",7)=""
..Q:HL7LTXT=""
..D MLM^ORKCHK2(.ORKS,ORKDFN,ORKA,ORENT,"SELECT")
;ONLY DISPLAY THE ERROR MESSAGE FOR A FREE-TEXT DOSAGE WHEN PHARMACY SAYS TO
I +$P($G(ORPSA),";",5)=1 D
.N ORKSMSG,OROITXT,ORDOSE
.S OROITXT=$P($G(^ORD(101.43,OI,0)),U),ORDOSE=$$DS^PSSDSAPI
.I $L(OROITXT)>0 S OROITXT=" for drug "_$$TRIM^XLFSTR(OROITXT)
.S ORKMSG="Order checks could not be done"_OROITXT_". Please complete a manual check for Drug Interactions"
.S ORKMSG=ORKMSG_$S(ORDOSE:",",1:" and")_" Duplicate Therapy"
.I ORDOSE S ORKMSG=ORKMSG_" and appropriate Dosing"
.S ORKMSG=ORKMSG_"."
.S ORKS("ORK",2_$E(ORKMSG,1,225))=ORNUM_U_25_U_3_U_ORKMSG,ORDODSG=0
Q
;
RXOCS ;drug-drug interaction, duplicate drug order, duplicate drug class
Q:ORCRITF_ORSIGF_ORDUPF_ORDUPCF'["E" ;quit if none are "E"nabled
N ORKRX,ORPSNUM,ORY,CHK,XX
D CHECK^ORKPS(.ORKRX,ORKDFN,HL7LPTR_U_HL7LTXT,OI,ORKDG,.OROIL,+$P($G(ORPSA),";",4),$P(ORKA,"|",7),.ORIVRAN,.ORDODSG)
S CHK=0,XX="" F S CHK=$O(ORKRX(CHK)) Q:'CHK D
.S XX=ORKRX(CHK)
.;
.;get errors/exceptions/checks not done
.I $P(XX,U)="ERR" D
..S ORKS("ORK",2_$E($P(XX,U,2),1,225))=ORNUM_U_25_U_3_U_$P(XX,U,2)
.;
.;critical drug interaction:
.I $P(XX,U)="DI",$P(XX,U,2)="CRITICAL" D
..Q:ORCRITF="D"
..S ORPSNUM=$P(XX,U,3)
..S ORKTXT=$P(XX,U,2)_" drug-drug interaction: "_$P(XX,U,5)
..S ORKS("ORK",ORCRITD_","_$G(ORNUM)_","_ORPSNUM_","_$E(ORKTXT,1,225))=ORNUM_U_ORCRITN_U_ORCRITD_U_ORKTXT
.;
.;significant drug interaction:
.I $P(XX,U)="DI",$P(XX,U,2)="SIGNIFICANT" D
..Q:ORSIGF="D"
..S ORPSNUM=$P(XX,U,3)
..S ORKTXT=$P(XX,U,2)_" drug-drug interaction: "_$P(XX,U,5)
..S ORKS("ORK",ORSIGD_","_$G(ORNUM)_","_ORPSNUM_","_$E(ORKTXT,1,225))=ORNUM_U_ORSIGN_U_ORSIGD_U_ORKTXT
.;
.;duplicate drug:
.I $P(XX,U)="DD" D
..Q:ORDUPF="D"
..S ORPSNUM=$P(XX,U,4) ;get the associated order number
..S ORKTXT=$P(XX,U,3)
..I $L(ORPSNUM),$G(^OR(100,+ORPSNUM,0)) D
...D TEXT^ORQ12(.ORY,ORPSNUM,"")
...S ORKTXT=ORKTXT_$S($D(ORY(2))=1:" "_$$TRIM^XLFSTR(ORY(2)),1:"")_" ["_$P($G(^ORD(100.01,+$P(^OR(100,+ORPSNUM,3),U,3),0)),U,1)_"]"
..S ORKMSG="Duplicate drug order: "_ORKTXT
..S ORKS("ORK",ORDUPD_","_$G(ORNUM)_","_ORPSNUM_",Duplicate drug order: "_$E($P(XX,U,3),1,200))=ORNUM_U_ORDUPN_U_ORDUPD_U_ORKMSG_U_$G(ORPSNUM)
.;
.;duplicate class: NOW DRUG THERAPY
.I $P(XX,U)="DC" D
..Q:ORDUPCF="D"
..S ORPSNUM=$P(XX,U,2) ;get the associated order number
..S ORKMSG=$P(XX,U,4)
..N ORKCNT S ORKCNT=1 F Q:'$D(ORKS("ORK",ORDUPCD_","_$G(ORNUM)_","_ORPSNUM_","_ORKCNT)) S ORKCNT=ORKCNT+1
..S ORKS("ORK",ORDUPCD_","_$G(ORNUM)_","_ORPSNUM_","_ORKCNT)=ORNUM_U_ORDUPCN_U_ORDUPCD_U_ORKMSG
Q
;
PARAMS(ORKNAME,ORKNUM,ORKFLAG,ORKDNGR) ; get parameter values for an order chk
S ORKNUM=0,ORKNUM=$O(^ORD(100.8,"B",ORKNAME,ORKNUM))
S ORKFLAG=$$GET^XPAR(ORENT,"ORK PROCESSING FLAG",ORKNUM,"I")
S ORKDNGR=$$GET^XPAR("DIV^SYS^PKG","ORK CLINICAL DANGER LEVEL",ORKNUM,"I")
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HORKCHK4 5257 printed Dec 13, 2024@02:31:02 Page 2
ORKCHK4 ; SLC/CLA - Support routine called by ORKCHK to do SELECT mode order checks ;03/29/18 06:02
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**6,32,74,87,94,123,162,190,249,272,345,481**;Dec 17, 1997;Build 3
+2 QUIT
+3 ;
EN(ORKS,ORKDFN,ORKA,ORENT,ORKTMODE,OROIL,ORIVRAN,ORDODSG) ;perform order checking for orderable item selection
+1 ;ORIVRAN: FLAG THAT DENOTES IF CHECK^ORKPS HAS ALREADY RUN FOR THIS INFUSION ORDER
+2 ; 1 FOR ALREADY EXECUTED
+3 ; EMPTY STRING FOR NOT YET EXECUTED
+4 ;ORDODSG: FLAG THAT DENOTES IF DOSAGE CHECKS SHOULD BE PERFORMED
+5 ; 1 FOR PERFORM DOSAGE CHECKS
+6 ; 0 FOR DO NOT PERFORM DOSAGE CHECKS
+7 if $$GET^XPAR("DIV^SYS^PKG","ORK SYSTEM ENABLE/DISABLE",1,"I")="D"
QUIT
+8 ;
+9 NEW OI,ORKDG,HL7,ODT,ORNUM,HL7NPTR,HL7NTXT,HL7NCOD,HL7LPTR,HL7LTXT,HL7LCOD
+10 NEW ORKMSG,ORKTXT
+11 ;
+12 SET OI=$PIECE(ORKA,"|")
SET ORKDG=$PIECE(ORKA,"|",2)
+13 SET HL7=$PIECE(ORKA,"|",3)
SET ODT=$PIECE(ORKA,"|",4)
SET ORNUM=$PIECE(ORKA,"|",5)
+14 SET HL7NPTR=$PIECE(HL7,U)
SET HL7NTXT=$PIECE(HL7,U,2)
SET HL7NCOD=$PIECE(HL7,U,3)
+15 SET HL7LPTR=$PIECE(HL7,U,4)
SET HL7LTXT=$PIECE(HL7,U,5)
SET HL7LCOD=$PIECE(HL7,U,6)
+16 ;
+17 IF $EXTRACT(ORKDG,1,2)="PS"
DO PHARM
+18 IF $EXTRACT(ORKDG,1,2)'="PS"
DO MLM^ORKCHK2(.ORKS,ORKDFN,ORKA,ORENT,"SELECT")
+19 QUIT
+20 ;
PHARM ;process pharmacy order checks:
+1 NEW ORPSPKG,ORPSA,ORKDD
+2 NEW ORCRITN,ORCRITF,ORCRITD,ORSIGN,ORSIGF,ORSIGD,ORDUPN,ORDUPF,ORDUPD,ORDUPCN,ORDUPCF,ORDUPCD
+3 ;
+4 DO PARAMS("CRITICAL DRUG INTERACTION",.ORCRITN,.ORCRITF,.ORCRITD)
+5 DO PARAMS("SIGNIFICANT DRUG INTERACTION",.ORSIGN,.ORSIGF,.ORSIGD)
+6 DO PARAMS("DUPLICATE DRUG ORDER",.ORDUPN,.ORDUPF,.ORDUPD)
+7 DO PARAMS("DUPLICATE DRUG THERAPY",.ORDUPCN,.ORDUPCF,.ORDUPCD)
+8 ;
+9 ;dispense drug selected:
+10 IF $LENGTH($GET(HL7LPTR))
IF ($GET(HL7LCOD)="99PSD")
Begin DoDot:1
+11 DO RXOCS
+12 if $PIECE(ORKA,"|",7)'=""
SET $PIECE(ORKA,"|",7)=""
+13 DO MLM^ORKCHK2(.ORKS,ORKDFN,ORKA,ORENT,"SELECT")
End DoDot:1
+14 ;
+15 ;dispense drug NOT selected, split OI into dispense drugs:
+16 IF '$LENGTH($GET(HL7LPTR))
Begin DoDot:1
+17 SET ORPSPKG=$EXTRACT(ORKDG,3)
+18 IF "IOH"[ORPSPKG
Begin DoDot:2
+19 SET ORPSA=$$OI2DD^ORKPS(OI,ORPSPKG,1)
+20 IF +ORPSA
Begin DoDot:3
+21 SET HL7LTXT=$PIECE($GET(^ORD(101.43,OI,0)),U)
+22 SET HL7NPTR=$PIECE(ORPSA,";",2)
+23 SET HL7LPTR=+ORPSA
+24 SET HL7LCOD="99PSD"
SET HL7NCOD="99NDF"
+25 SET $PIECE(HL7,U)=HL7NPTR
SET $PIECE(HL7,U,3)=HL7NCOD
+26 SET $PIECE(HL7,U,4)=HL7LPTR
SET $PIECE(HL7,U,5)=HL7LTXT
SET $PIECE(HL7,U,6)=HL7LCOD
+27 ;set these for MLM OCX call
SET $PIECE(ORKA,"|",3)=HL7
End DoDot:3
+28 DO RXOCS
+29 if $PIECE(ORKA,"|",7)'=""
SET $PIECE(ORKA,"|",7)=""
+30 if HL7LTXT=""
QUIT
+31 DO MLM^ORKCHK2(.ORKS,ORKDFN,ORKA,ORENT,"SELECT")
End DoDot:2
End DoDot:1
+32 ;ONLY DISPLAY THE ERROR MESSAGE FOR A FREE-TEXT DOSAGE WHEN PHARMACY SAYS TO
+33 IF +$PIECE($GET(ORPSA),";",5)=1
Begin DoDot:1
+34 NEW ORKSMSG,OROITXT,ORDOSE
+35 SET OROITXT=$PIECE($GET(^ORD(101.43,OI,0)),U)
SET ORDOSE=$$DS^PSSDSAPI
+36 IF $LENGTH(OROITXT)>0
SET OROITXT=" for drug "_$$TRIM^XLFSTR(OROITXT)
+37 SET ORKMSG="Order checks could not be done"_OROITXT_". Please complete a manual check for Drug Interactions"
+38 SET ORKMSG=ORKMSG_$SELECT(ORDOSE:",",1:" and")_" Duplicate Therapy"
+39 IF ORDOSE
SET ORKMSG=ORKMSG_" and appropriate Dosing"
+40 SET ORKMSG=ORKMSG_"."
+41 SET ORKS("ORK",2_$EXTRACT(ORKMSG,1,225))=ORNUM_U_25_U_3_U_ORKMSG
SET ORDODSG=0
End DoDot:1
+42 QUIT
+43 ;
RXOCS ;drug-drug interaction, duplicate drug order, duplicate drug class
+1 ;quit if none are "E"nabled
if ORCRITF_ORSIGF_ORDUPF_ORDUPCF'["E"
QUIT
+2 NEW ORKRX,ORPSNUM,ORY,CHK,XX
+3 DO CHECK^ORKPS(.ORKRX,ORKDFN,HL7LPTR_U_HL7LTXT,OI,ORKDG,.OROIL,+$PIECE($GET(ORPSA),";",4),$PIECE(ORKA,"|",7),.ORIVRAN,.ORDODSG)
+4 SET CHK=0
SET XX=""
FOR
SET CHK=$ORDER(ORKRX(CHK))
if 'CHK
QUIT
Begin DoDot:1
+5 SET XX=ORKRX(CHK)
+6 ;
+7 ;get errors/exceptions/checks not done
+8 IF $PIECE(XX,U)="ERR"
Begin DoDot:2
+9 SET ORKS("ORK",2_$EXTRACT($PIECE(XX,U,2),1,225))=ORNUM_U_25_U_3_U_$PIECE(XX,U,2)
End DoDot:2
+10 ;
+11 ;critical drug interaction:
+12 IF $PIECE(XX,U)="DI"
IF $PIECE(XX,U,2)="CRITICAL"
Begin DoDot:2
+13 if ORCRITF="D"
QUIT
+14 SET ORPSNUM=$PIECE(XX,U,3)
+15 SET ORKTXT=$PIECE(XX,U,2)_" drug-drug interaction: "_$PIECE(XX,U,5)
+16 SET ORKS("ORK",ORCRITD_","_$GET(ORNUM)_","_ORPSNUM_","_$EXTRACT(ORKTXT,1,225))=ORNUM_U_ORCRITN_U_ORCRITD_U_ORKTXT
End DoDot:2
+17 ;
+18 ;significant drug interaction:
+19 IF $PIECE(XX,U)="DI"
IF $PIECE(XX,U,2)="SIGNIFICANT"
Begin DoDot:2
+20 if ORSIGF="D"
QUIT
+21 SET ORPSNUM=$PIECE(XX,U,3)
+22 SET ORKTXT=$PIECE(XX,U,2)_" drug-drug interaction: "_$PIECE(XX,U,5)
+23 SET ORKS("ORK",ORSIGD_","_$GET(ORNUM)_","_ORPSNUM_","_$EXTRACT(ORKTXT,1,225))=ORNUM_U_ORSIGN_U_ORSIGD_U_ORKTXT
End DoDot:2
+24 ;
+25 ;duplicate drug:
+26 IF $PIECE(XX,U)="DD"
Begin DoDot:2
+27 if ORDUPF="D"
QUIT
+28 ;get the associated order number
SET ORPSNUM=$PIECE(XX,U,4)
+29 SET ORKTXT=$PIECE(XX,U,3)
+30 IF $LENGTH(ORPSNUM)
IF $GET(^OR(100,+ORPSNUM,0))
Begin DoDot:3
+31 DO TEXT^ORQ12(.ORY,ORPSNUM,"")
+32 SET ORKTXT=ORKTXT_$SELECT($DATA(ORY(2))=1:" "_$$TRIM^XLFSTR(ORY(2)),1:"")_" ["_$PIECE($GET(^ORD(100.01,+$PIECE(^OR(100,+ORPSNUM,3),U,3),0)),U,1)_"]"
End DoDot:3
+33 SET ORKMSG="Duplicate drug order: "_ORKTXT
+34 SET ORKS("ORK",ORDUPD_","_$GET(ORNUM)_","_ORPSNUM_",Duplicate drug order: "_$EXTRACT($PIECE(XX,U,3),1,200))=ORNUM_U_ORDUPN_U_ORDUPD_U_ORKMSG_U_$GET(ORPSNUM)
End DoDot:2
+35 ;
+36 ;duplicate class: NOW DRUG THERAPY
+37 IF $PIECE(XX,U)="DC"
Begin DoDot:2
+38 if ORDUPCF="D"
QUIT
+39 ;get the associated order number
SET ORPSNUM=$PIECE(XX,U,2)
+40 SET ORKMSG=$PIECE(XX,U,4)
+41 NEW ORKCNT
SET ORKCNT=1
FOR
if '$DATA(ORKS("ORK",ORDUPCD_","_$GET(ORNUM)_","_ORPSNUM_","_ORKCNT))
QUIT
SET ORKCNT=ORKCNT+1
+42 SET ORKS("ORK",ORDUPCD_","_$GET(ORNUM)_","_ORPSNUM_","_ORKCNT)=ORNUM_U_ORDUPCN_U_ORDUPCD_U_ORKMSG
End DoDot:2
End DoDot:1
+43 QUIT
+44 ;
PARAMS(ORKNAME,ORKNUM,ORKFLAG,ORKDNGR) ; get parameter values for an order chk
+1 SET ORKNUM=0
SET ORKNUM=$ORDER(^ORD(100.8,"B",ORKNAME,ORKNUM))
+2 SET ORKFLAG=$$GET^XPAR(ORENT,"ORK PROCESSING FLAG",ORKNUM,"I")
+3 SET ORKDNGR=$$GET^XPAR("DIV^SYS^PKG","ORK CLINICAL DANGER LEVEL",ORKNUM,"I")
+4 QUIT