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

ORKCHK4.m

Go to the documentation of this file.
  1. 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
  1. Q
  1. ;
  1. 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
  1. ; 1 FOR ALREADY EXECUTED
  1. ; EMPTY STRING FOR NOT YET EXECUTED
  1. ;ORDODSG: FLAG THAT DENOTES IF DOSAGE CHECKS SHOULD BE PERFORMED
  1. ; 1 FOR PERFORM DOSAGE CHECKS
  1. ; 0 FOR DO NOT PERFORM DOSAGE CHECKS
  1. Q:$$GET^XPAR("DIV^SYS^PKG","ORK SYSTEM ENABLE/DISABLE",1,"I")="D"
  1. ;
  1. N OI,ORKDG,HL7,ODT,ORNUM,HL7NPTR,HL7NTXT,HL7NCOD,HL7LPTR,HL7LTXT,HL7LCOD
  1. N ORKMSG,ORKTXT
  1. ;
  1. S OI=$P(ORKA,"|"),ORKDG=$P(ORKA,"|",2)
  1. S HL7=$P(ORKA,"|",3),ODT=$P(ORKA,"|",4),ORNUM=$P(ORKA,"|",5)
  1. S HL7NPTR=$P(HL7,U),HL7NTXT=$P(HL7,U,2),HL7NCOD=$P(HL7,U,3)
  1. S HL7LPTR=$P(HL7,U,4),HL7LTXT=$P(HL7,U,5),HL7LCOD=$P(HL7,U,6)
  1. ;
  1. I $E(ORKDG,1,2)="PS" D PHARM
  1. I $E(ORKDG,1,2)'="PS" D MLM^ORKCHK2(.ORKS,ORKDFN,ORKA,ORENT,"SELECT")
  1. Q
  1. ;
  1. PHARM ;process pharmacy order checks:
  1. N ORPSPKG,ORPSA,ORKDD
  1. N ORCRITN,ORCRITF,ORCRITD,ORSIGN,ORSIGF,ORSIGD,ORDUPN,ORDUPF,ORDUPD,ORDUPCN,ORDUPCF,ORDUPCD
  1. ;
  1. D PARAMS("CRITICAL DRUG INTERACTION",.ORCRITN,.ORCRITF,.ORCRITD)
  1. D PARAMS("SIGNIFICANT DRUG INTERACTION",.ORSIGN,.ORSIGF,.ORSIGD)
  1. D PARAMS("DUPLICATE DRUG ORDER",.ORDUPN,.ORDUPF,.ORDUPD)
  1. D PARAMS("DUPLICATE DRUG THERAPY",.ORDUPCN,.ORDUPCF,.ORDUPCD)
  1. ;
  1. ;dispense drug selected:
  1. I $L($G(HL7LPTR)),($G(HL7LCOD)="99PSD") D
  1. .D RXOCS
  1. .S:$P(ORKA,"|",7)'="" $P(ORKA,"|",7)=""
  1. .D MLM^ORKCHK2(.ORKS,ORKDFN,ORKA,ORENT,"SELECT")
  1. ;
  1. ;dispense drug NOT selected, split OI into dispense drugs:
  1. I '$L($G(HL7LPTR)) D
  1. .S ORPSPKG=$E(ORKDG,3)
  1. .I "IOH"[ORPSPKG D
  1. ..S ORPSA=$$OI2DD^ORKPS(OI,ORPSPKG,1)
  1. ..I +ORPSA D
  1. ...S HL7LTXT=$P($G(^ORD(101.43,OI,0)),U)
  1. ...S HL7NPTR=$P(ORPSA,";",2)
  1. ...S HL7LPTR=+ORPSA
  1. ...S HL7LCOD="99PSD",HL7NCOD="99NDF"
  1. ...S $P(HL7,U)=HL7NPTR,$P(HL7,U,3)=HL7NCOD
  1. ...S $P(HL7,U,4)=HL7LPTR,$P(HL7,U,5)=HL7LTXT,$P(HL7,U,6)=HL7LCOD
  1. ...S $P(ORKA,"|",3)=HL7 ;set these for MLM OCX call
  1. ..D RXOCS
  1. ..S:$P(ORKA,"|",7)'="" $P(ORKA,"|",7)=""
  1. ..Q:HL7LTXT=""
  1. ..D MLM^ORKCHK2(.ORKS,ORKDFN,ORKA,ORENT,"SELECT")
  1. ;ONLY DISPLAY THE ERROR MESSAGE FOR A FREE-TEXT DOSAGE WHEN PHARMACY SAYS TO
  1. I +$P($G(ORPSA),";",5)=1 D
  1. .N ORKSMSG,OROITXT,ORDOSE
  1. .S OROITXT=$P($G(^ORD(101.43,OI,0)),U),ORDOSE=$$DS^PSSDSAPI
  1. .I $L(OROITXT)>0 S OROITXT=" for drug "_$$TRIM^XLFSTR(OROITXT)
  1. .S ORKMSG="Order checks could not be done"_OROITXT_". Please complete a manual check for Drug Interactions"
  1. .S ORKMSG=ORKMSG_$S(ORDOSE:",",1:" and")_" Duplicate Therapy"
  1. .I ORDOSE S ORKMSG=ORKMSG_" and appropriate Dosing"
  1. .S ORKMSG=ORKMSG_"."
  1. .S ORKS("ORK",2_$E(ORKMSG,1,225))=ORNUM_U_25_U_3_U_ORKMSG,ORDODSG=0
  1. Q
  1. ;
  1. RXOCS ;drug-drug interaction, duplicate drug order, duplicate drug class
  1. Q:ORCRITF_ORSIGF_ORDUPF_ORDUPCF'["E" ;quit if none are "E"nabled
  1. N ORKRX,ORPSNUM,ORY,CHK,XX
  1. D CHECK^ORKPS(.ORKRX,ORKDFN,HL7LPTR_U_HL7LTXT,OI,ORKDG,.OROIL,+$P($G(ORPSA),";",4),$P(ORKA,"|",7),.ORIVRAN,.ORDODSG)
  1. S CHK=0,XX="" F S CHK=$O(ORKRX(CHK)) Q:'CHK D
  1. .S XX=ORKRX(CHK)
  1. .;
  1. .;get errors/exceptions/checks not done
  1. .I $P(XX,U)="ERR" D
  1. ..S ORKS("ORK",2_$E($P(XX,U,2),1,225))=ORNUM_U_25_U_3_U_$P(XX,U,2)
  1. .;
  1. .;critical drug interaction:
  1. .I $P(XX,U)="DI",$P(XX,U,2)="CRITICAL" D
  1. ..Q:ORCRITF="D"
  1. ..S ORPSNUM=$P(XX,U,3)
  1. ..S ORKTXT=$P(XX,U,2)_" drug-drug interaction: "_$P(XX,U,5)
  1. ..S ORKS("ORK",ORCRITD_","_$G(ORNUM)_","_ORPSNUM_","_$E(ORKTXT,1,225))=ORNUM_U_ORCRITN_U_ORCRITD_U_ORKTXT
  1. .;
  1. .;significant drug interaction:
  1. .I $P(XX,U)="DI",$P(XX,U,2)="SIGNIFICANT" D
  1. ..Q:ORSIGF="D"
  1. ..S ORPSNUM=$P(XX,U,3)
  1. ..S ORKTXT=$P(XX,U,2)_" drug-drug interaction: "_$P(XX,U,5)
  1. ..S ORKS("ORK",ORSIGD_","_$G(ORNUM)_","_ORPSNUM_","_$E(ORKTXT,1,225))=ORNUM_U_ORSIGN_U_ORSIGD_U_ORKTXT
  1. .;
  1. .;duplicate drug:
  1. .I $P(XX,U)="DD" D
  1. ..Q:ORDUPF="D"
  1. ..S ORPSNUM=$P(XX,U,4) ;get the associated order number
  1. ..S ORKTXT=$P(XX,U,3)
  1. ..I $L(ORPSNUM),$G(^OR(100,+ORPSNUM,0)) D
  1. ...D TEXT^ORQ12(.ORY,ORPSNUM,"")
  1. ...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)_"]"
  1. ..S ORKMSG="Duplicate drug order: "_ORKTXT
  1. ..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)
  1. .;
  1. .;duplicate class: NOW DRUG THERAPY
  1. .I $P(XX,U)="DC" D
  1. ..Q:ORDUPCF="D"
  1. ..S ORPSNUM=$P(XX,U,2) ;get the associated order number
  1. ..S ORKMSG=$P(XX,U,4)
  1. ..N ORKCNT S ORKCNT=1 F Q:'$D(ORKS("ORK",ORDUPCD_","_$G(ORNUM)_","_ORPSNUM_","_ORKCNT)) S ORKCNT=ORKCNT+1
  1. ..S ORKS("ORK",ORDUPCD_","_$G(ORNUM)_","_ORPSNUM_","_ORKCNT)=ORNUM_U_ORDUPCN_U_ORDUPCD_U_ORKMSG
  1. Q
  1. ;
  1. PARAMS(ORKNAME,ORKNUM,ORKFLAG,ORKDNGR) ; get parameter values for an order chk
  1. S ORKNUM=0,ORKNUM=$O(^ORD(100.8,"B",ORKNAME,ORKNUM))
  1. S ORKFLAG=$$GET^XPAR(ORENT,"ORK PROCESSING FLAG",ORKNUM,"I")
  1. S ORKDNGR=$$GET^XPAR("DIV^SYS^PKG","ORK CLINICAL DANGER LEVEL",ORKNUM,"I")
  1. Q