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

PSSHRVL1.m

Go to the documentation of this file.
  1. PSSHRVL1 ;WOIFO/Alex Vasquez, Timothy Sabat, Steve Gordon - Continuation Data Validation routine for drug checks ;01/15/07
  1. ;;1.0;PHARMACY DATA MANAGEMENT;**136,169,160,173,178,224**;9/30/97;Build 3
  1. ;
  1. ; Reference to ^PSNDF(50.68 supported by IA #2079
  1. ; Reference to ^PSNDF(50.68 supported by IA #3735
  1. ;
  1. NEXTEX(PSS,PSSHASH) ;
  1. ;@DESC Gets the next exception
  1. ;@PSS The temp hash
  1. ;@PSSHASH The internal hash
  1. ;
  1. N PSNEXT
  1. S PSNEXT=":"
  1. S PSNEXT=$ORDER(^TMP($JOB,PSSHASH("Base"),"OUT","EXCEPTIONS",PSS("PharmOrderNo"),PSNEXT),-1)
  1. Q PSNEXT+1
  1. ;;
  1. NEXTEXD(PSS,PSSHASH) ;
  1. ;@DESC Gets the next dose exception
  1. ;@PSS The temp hash
  1. ;@PSSHASH The internal hash
  1. N PSNEXT
  1. S PSNEXT=":"
  1. S PSNEXT=$ORDER(^TMP($JOB,PSSHASH("Base"),"OUT","EXCEPTIONS","DOSE",PSS("PharmOrderNo"),PSNEXT),-1)
  1. Q PSNEXT+1
  1. ;;
  1. WRITE(PSSHASH) ;
  1. ;@Writes a response, based on the list of exceptions stored in Hash
  1. ;@NOTE The internal hash looks like this:
  1. ;PSSHASH("Exception","PROSPECTIVE","DOSE",PharmacyOrderNum,Counter)=Gcn,Vuid,IEN,DrugName,CprsOrderNum,Package,Reason,ReasonCode,ResonSource,ReasonText,NoWrite
  1. ;PSSHASH("Exception","PROSPECTIVE",PharmacyOrderNum,Counter)=Gcn,Vuid,IEN,DrugName,CprsOrderNum,Package,Reason,ReasonCode,ResonSource,ReasonText,NoWrite
  1. ;PSSHASH("Exception","PROFILE",PharmacyOrderNum,Counter)=Gcn,Vuid,IEN,DrugName,CprsOrderNum,Package,Reason,ReasonCode,ResonSource,ReasonText,NoWrite
  1. ;PSSHASH("Exception","PatientIenMissing")=""
  1. ;PSSHASH("Reason")="Failed Validation"
  1. ;
  1. ;
  1. NEW PSS
  1. SET PSS("PharmOrderNo")=""
  1. SET PSS("I")=""
  1. FOR SET PSS("PharmOrderNo")=$ORDER(PSSHASH("Exception","PROFILE",PSS("PharmOrderNo"))) QUIT:PSS("PharmOrderNo")="" DO
  1. . FOR SET PSS("I")=$ORDER(PSSHASH("Exception","PROFILE",PSS("PharmOrderNo"),PSS("I"))) QUIT:PSS("I")="" DO
  1. . . DO WPROFILE(.PSSHASH,.PSS)
  1. . . QUIT
  1. . QUIT
  1. ;
  1. SET PSS("PharmOrderNo")=""
  1. SET PSS("I")=""
  1. FOR SET PSS("PharmOrderNo")=$ORDER(PSSHASH("Exception","PROSPECTIVE","DOSE",PSS("PharmOrderNo"))) QUIT:PSS("PharmOrderNo")="" DO
  1. . FOR SET PSS("I")=$ORDER(PSSHASH("Exception","PROSPECTIVE","DOSE",PSS("PharmOrderNo"),PSS("I"))) QUIT:PSS("I")="" DO
  1. . . DO WDOSE(.PSSHASH,.PSS)
  1. . . ;kill off node to prevent next loop from setting PSS("PharmOrderNo") to "DOSE"
  1. . . K PSSHASH("Exception","PROSPECTIVE","DOSE",PSS("PharmOrderNo"),PSS("I"))
  1. . QUIT
  1. ;
  1. SET PSS("PharmOrderNo")=""
  1. SET PSS("I")=""
  1. FOR SET PSS("PharmOrderNo")=$ORDER(PSSHASH("Exception","PROSPECTIVE",PSS("PharmOrderNo"))) QUIT:PSS("PharmOrderNo")="" DO
  1. . FOR SET PSS("I")=$ORDER(PSSHASH("Exception","PROSPECTIVE",PSS("PharmOrderNo"),PSS("I"))) QUIT:PSS("I")="" DO
  1. . . DO WPROSPEC(.PSSHASH,.PSS)
  1. . QUIT
  1. ;
  1. QUIT
  1. ;;
  1. WDOSE(PSSHASH,PSS) ;
  1. ;@DESC Writes the dose exceptions out.
  1. ;@PSSHASH The internal hash
  1. ;@PSS The temp hash
  1. ;@NOTE The exception hash looks like this.
  1. ;PSSHASH("Exception","PROSPECTIVE","DOSE",PharmacyOrderNum,Counter)=Gcn,Vuid,IEN,DrugName,CprsOrderNum,Package,Reason,ReasonCode,ResonSource,ReasonText
  1. ;
  1. NEW TYPE,I
  1. SET PSS("DoseValue")=$G(^TMP($JOB,PSSHASH("Base"),"IN","DOSE",PSS("PharmOrderNo")))
  1. ;Set the next exception
  1. D:$P(PSSHASH("Exception","PROSPECTIVE","DOSE",PSS("PharmOrderNo"),PSS("I")),U,11)'=1
  1. .S ^TMP($JOB,PSSHASH("Base"),"OUT","EXCEPTIONS","DOSE",PSS("PharmOrderNo"),$$NEXTEXD(.PSS,.PSSHASH))=PSSHASH("Exception","PROSPECTIVE","DOSE",PSS("PharmOrderNo"),PSS("I"))
  1. QUIT
  1. ;;
  1. WPROFILE(PSSHASH,PSS) ;
  1. ;@DESC Writes the profile drug exceptions out.
  1. ;@PSSHASH The internal hash
  1. ;@PSS The temp hash
  1. ;Kill the corresponding profile drug
  1. ;KILL ^TMP($JOB,PSSHASH("Base"),"IN","PROFILE",PSS("PharmOrderNo"))
  1. ;Set the exception in the global
  1. S:$P(PSSHASH("Exception","PROFILE",PSS("PharmOrderNo"),PSS("I")),U,11)'=1 ^TMP($JOB,PSSHASH("Base"),"OUT","EXCEPTIONS",PSS("PharmOrderNo"),$$NEXTEX(.PSS,.PSSHASH))=PSSHASH("Exception","PROFILE",PSS("PharmOrderNo"),PSS("I"))
  1. ;If no profile drugs left and the proVpro flag exists, delete it.
  1. DO:'$DATA(^TMP($JOB,PSSHASH("Base"),"IN","PROFILE"))
  1. . ;KILL ^TMP($JOB,PSSHASH("Base"),"IN","PROFILEVPROFILE")
  1. . D KILLCHEK(PSSHASH("Base"),"PROFILEVPROFILE")
  1. . QUIT
  1. QUIT
  1. ;;
  1. WPROSPEC(PSSHASH,PSS) ;
  1. ;@DESC Writes the prospective drug exceptions out.
  1. ;@PSSHASH The internal hash
  1. ;@PSS The temp hash
  1. ;@NOTE Exception Hash Looks Like
  1. ;PSSHASH("Exception","PROSPECTIVE","DOSE",PharmacyOrderNum,Counter)=Gcn,Vuid,IEN,DrugName,CprsOrderNum,Package,Reason,ReasonCode,ResonSource,ReasonText
  1. ;PSSHASH("Exception","PROSPECTIVE",PharmacyOrderNum,Counter)=Gcn,Vuid,IEN,DrugName,CprsOrderNum,Package,Reason,ReasonCode,ResonSource,ReasonText
  1. ;
  1. ;Set the exception data
  1. S:$P(PSSHASH("Exception","PROSPECTIVE",PSS("PharmOrderNo"),PSS("I")),U,11)'=1 ^TMP($JOB,PSSHASH("Base"),"OUT","EXCEPTIONS",PSS("PharmOrderNo"),$$NEXTEX(.PSS,.PSSHASH))=PSSHASH("Exception","PROSPECTIVE",PSS("PharmOrderNo"),PSS("I"))
  1. QUIT
  1. ;
  1. KILLALL(BASE) ;
  1. ;INPUTS BASE SUBCRIPT
  1. ;@DESC Kills the DrugDrug, Therapy, ProfileVProfile, and Dose check nodes.
  1. DO KILLCHEK("DRUGDRUG",BASE)
  1. DO KILLCHEK("THERAPY",BASE)
  1. DO KILLCHEK("PROFILEVPROFILE",BASE)
  1. DO KILLCHEK("DOSE",BASE)
  1. QUIT
  1. ;;
  1. KILLCHEK(PSSCHECK,BASE) ;
  1. ;@DESC Kills the check node specified in parameter
  1. ;@PSSCHEK The node to kill
  1. ;
  1. KILL ^TMP($JOB,BASE,"IN",PSSCHECK)
  1. QUIT
  1. ;
  1. ;
  1. KILLNODE(BASE,TYPE,ORDER) ;
  1. ;
  1. ;@DESC KILLS A SINGLE NODE FOR A DRUG
  1. ;@BASE--the subscript after $JOB
  1. ;@TYPE-Can have 3 possible values: "PROSPECTIVE","PROFILE" or "DOSE"
  1. ;@ODRDER-Is the order information to make the node unique
  1. KILL ^TMP($JOB,BASE,"IN",TYPE,ORDER)
  1. Q
  1. ;
  1. GCNREASN(DRUGIEN,DRUGNM,ORDRNUM,BADGCN) ;
  1. ;
  1. ;Returns a message and reason on why a drug does not have a GCNSEQNO
  1. ;inputs: DRUGIEN-IEN OF DRUG
  1. ;DRUGNM-NAME OF DRUG
  1. ;ORDRNUM-PHARMACY ORDER NUM
  1. ;BADGCN-(OPTIONAL)FLAG IS SET to 1 IF DRUG RETURNED AS NOT FOUND BY SWRI/FDB
  1. ; if set to -1 Missing or invalid GCNSEQNO from Input node
  1. N VAPROD1,NDNODE,REASON,MESSAGE,VAIEN,PSSVQPAC,PSSVQDOS,PSSVQNOM,PSSVQREM,PSSVQTY1,PSSVQTY2,PSSREASN
  1. S MESSAGE=$$NOCHKMSG(DRUGNM,ORDRNUM),PSSVQDOS=0,PSSVQPAC=$S($E(PSSHASH("Base"),1,2)="PS":1,1:0) I $T(DS^PSSDSAPI)]"",$$DS^PSSDSAPI S PSSVQDOS=1
  1. S REASON="",PSSVQREM=$S($P(ORDRNUM,";")="R":1,1:0)
  1. S PSSVQTY1=$P(ORDRNUM,";",3),PSSVQTY1=$$UP^XLFSTR(PSSVQTY1),PSSVQTY2=$S(PSSVQTY1["PROSPECTIVE":1,1:0)
  1. ;
  1. S VAPROD1=""
  1. D ;Case statement
  1. .I $G(BADGCN)=1 S MESSAGE=$$NXCHKMSG(DRUGNM) S PSSVQNOM=$$GCMESS,REASON=$S(PSSVQNOM:"^1",1:""),PSSREASN=1 Q
  1. .I '$G(DRUGIEN),'PSSVQREM S REASON="No dispense drug found for Orderable Item",PSSREASN=2 Q
  1. .S NDNODE=$G(^PSDRUG(DRUGIEN,"ND"))
  1. .;if no ndnode or 3rd piece not populated
  1. .I 'PSSVQREM,'$L(NDNODE)!('$P(NDNODE,U,3)) D Q
  1. ..S REASON="Drug not matched to NDF",PSSREASN=3 D:PSSVQPAC&($D(^TMP($J,PSSHASH("Base"),"IN","DOSE"))) NZMSG I 'PSSVQPAC S MESSAGE=$$NXCHKMSG(DRUGNM),REASON=""
  1. .S VAIEN=$S('PSSVQREM:+$P(NDNODE,U,3),1:0)
  1. .S:VAIEN VAPROD1=$P($G(^PSNDF(50.68,VAIEN,1)),U,5) ; Get the GCNSEQNO
  1. .I 'VAPROD1!($G(BADGCN)=-1) D
  1. ..S MESSAGE=$$NXCHKMSG(DRUGNM) S PSSVQNOM=$$GCMESS,REASON=$S(PSSVQNOM:"^1",1:""),PSSREASN=4
  1. ;
  1. I PSSVQPAC=0,PSSVQTY2=1 D
  1. .S ^TMP($J,PSSHASH("Base"),"OR-TRANSIENT",DRUGIEN,DRUGNM,ORDRNUM,BADGCN)=MESSAGE_U_PSSREASN
  1. Q MESSAGE_U_REASON
  1. ;
  1. NOCHKMSG(DRUGNM,ORDRNUM) ;
  1. ;Returns msg that no checks could be performed.
  1. ;INPUTS:
  1. ;DRUGNM-Name of drug
  1. ;ORDRNUM-PHARMACY ORDER NUMBER
  1. N MESSAGE
  1. S MESSAGE="Enhanced Order Checks cannot be performed for "_$$LOCORREM(ORDRNUM)_$$OUTPAT(ORDRNUM)_" Drug: "_DRUGNM
  1. Q MESSAGE
  1. ;
  1. OUTPAT(ORDRNUM) ;
  1. ; Returns " Outpatient" if it is one.
  1. ;INPUTS:
  1. ;ORDRNUM-PHARMACY ORDER NUMBER
  1. ;PSSBASE - globally defined
  1. ;
  1. N OUTPAT
  1. S OUTPAT=""
  1. I $$LOCORREM(ORDRNUM)="Local" D
  1. .I $E(ORDRNUM)'="I",$E(ORDRNUM)'="R",ORDRNUM["PROFILE",$G(^TMP($J,PSSBASE,"IN","SOURCE"))="I" S OUTPAT=" Outpatient"
  1. Q OUTPAT
  1. ;
  1. OIMSG(OINAME,PSSNOITN) ;
  1. ;INPUT: Orderable item name
  1. ; Order number
  1. ;RETURNS-ERROR MESSAGE
  1. N MESSAGE,PSSNOITP,PSSNOITD,PSSNOIT1,PSSNOIT2
  1. S PSSNOITP=$S($E(PSSHASH("Base"),1,2)="PS":0,1:1)
  1. S PSSNOITD=0 I $T(DS^PSSDSAPI)]"",$$DS^PSSDSAPI S PSSNOITD=1
  1. S PSSNOIT1=$P(PSSNOITN,";",3),PSSNOIT1=$$UP^XLFSTR(PSSNOIT1),PSSNOIT2=$S(PSSNOIT1["PROSPECTIVE":1,1:0)
  1. I PSSNOITP D Q MESSAGE
  1. .I $D(^TMP($J,PSSHASH("Base"),"IN","DOSE")) D Q
  1. ..S MESSAGE="Maximum Single Dose Check could not be done for Drug: "_OINAME_", please complete a manual check for appropriate Dosing."
  1. .S MESSAGE="Order Checks could not be done for Drug: "_OINAME_", please complete a manual check for Drug Interactions"_$S(PSSNOITD&($G(PSSNOIT2)):", Duplicate Therapy and appropriate Dosing.",1:" and Duplicate Therapy.")
  1. S MESSAGE="Enhanced Order Checks cannot be performed for Orderable Item: "_OINAME
  1. Q MESSAGE
  1. ;
  1. INRSON(ERRNUM,ORDERNUM) ;
  1. ;INPUT-REASON CODE (1,2 OR 3)
  1. ;ORDERNUM-(OPTIONAL)-ORDERNUMBER
  1. ;OUTPUT-REASON MESSAGE
  1. ;
  1. N REASON,NONVAFLG
  1. S NONVAFLG=0 ;DEFAULT
  1. S ORDERNUM=$G(ORDERNUM)
  1. I $E(ORDERNUM)="N" S NONVAFLG=1
  1. D
  1. .I ERRNUM=1 D Q
  1. .. I 'NONVAFLG S REASON="No Dispense Drug found." Q ; No active Dispense Drug found for Pending order.
  1. .. I NONVAFLG S REASON="No Dispense Drug found." ; No active Dispense Drug found for Non-VA med order.
  1. .I ERRNUM=2 S REASON="Free Text Dosage could not be evaluated." Q
  1. .I ERRNUM=3 S REASON="Free Text Infusion Rate could not be evaluated."
  1. .I ERRNUM=4 S REASON="No active IV Additive/Solution marked for IV fluid order entry could be found."
  1. Q REASON
  1. ;
  1. DEMOCHK(AGE,BSA,WEIGHT,PSDRUG,WHERE) ;
  1. ;Checks age and returns message and error reason
  1. ;input: AGE--AGE
  1. ;BSA-BSA
  1. ;WEIGHT OF THE PATIENT
  1. ;WHERE value of PSSDSWHE (1 for OR, 0 for IP/OP) as determined by dosing API
  1. ;output: message and reason strings
  1. ;
  1. N PSMESSAGE,PSREASON,PSRESULT,TEXT,X,FLAG
  1. S PSRESULT="",PSREASON="",TEXT="",WHERE=$S(+$G(WHERE)=1:1,1:0),AGE=+$G(AGE),BSA=+$G(BSA),WEIGHT=+$G(WEIGHT)
  1. I AGE=0 D Q PSRESULT
  1. .S TEXT=" AGE"
  1. .D:WHERE=0
  1. ..S PSMESSAGE=$$DOSEMSG(PSDRUG)
  1. ..S PSREASON="One or more required patient parameters unavailable:"_TEXT
  1. .D:WHERE=1
  1. ..S PSMESSAGE="Dosing checks could not be done for Drug: "_PSDRUG_", please complete a manual check for appropriate dosing."
  1. .S PSRESULT=PSMESSAGE_U_PSREASON
  1. Q PSRESULT
  1. ;
  1. MEDRTE(PSROUTE,PSDRUGNM) ;
  1. ;Checks route if null
  1. ;inputs: ROUTE-MEDICATION ROUTE
  1. ;DRUGNM-DRUG NAME
  1. ;RETURNS THE ERROR MESSAGE AND ERROR REASON
  1. N PSMESSAGE,PSREASON,PSRESULT
  1. S PSRESULT=""
  1. I '$L(PSROUTE) D
  1. .S PSMESSAGE=$$DOSEMSG(PSDRUGNM)
  1. .;S PSREASON="Unmapped Local Medication Route"
  1. .S PSREASON="Invalid or Undefined Dose Route"
  1. .S PSRESULT=PSMESSAGE_U_PSREASON
  1. Q PSRESULT
  1. ;
  1. ;
  1. CHKDSTYP(DOSETYP,PSDRUGNM) ;
  1. ;inputs: DOSETYP-DOSE TYPE (MAINTENANCE,LOADING)
  1. ;PSDRUGNM-DRUG NAME
  1. ;RETURNS THE ERROR MESSAGE AND ERROR REASON
  1. N PSREASON,PSRESULT,PSMSG,TEXT,OKFLAG
  1. S PSRESULT="",OKFLAG=0
  1. F TEXT="LOADING","MAINTENANCE","INITIAL DOSE","INTERMEDIATE DOSE","PROPHYLACTIC","SINGLE DOSE" D Q:OKFLAG
  1. .I DOSETYP=TEXT S OKFLAG=1 Q
  1. I '$L(DOSETYP)!'OKFLAG D
  1. .S PSMSG=$$DOSEMSG(PSDRUGNM)
  1. .;S PSREASON="Undefined Dose Type"
  1. .S PSREASON="Invalid or Undefined Dose Type"
  1. .S PSRESULT=PSMSG_U_PSREASON
  1. Q PSRESULT
  1. ;
  1. CHKDOSE(PSDOSE,PSDRUGNM) ;
  1. ;CHECKS THE DOSE OF DRUG DOSE REQUEST
  1. ;INPUTS: PSDOSE-ORDERED DOSE OF A DRUG
  1. ;PSDRUGNM=NAME OF DRUG
  1. ;RETURNS THE ERROR MESSAGE AND ERROR REASON
  1. N PSREASON,PSRESULT,PSMSG
  1. S PSRESULT=""
  1. I PSDOSE'=+PSDOSE D
  1. .S PSMSG=$$DOSEMSG(PSDRUGNM)
  1. .S PSREASON="Invalid or Undefined Dose"
  1. .S PSRESULT=PSMSG_U_PSREASON
  1. Q PSRESULT
  1. ;
  1. CHKUNIT(PSUNIT,PSDRUGNM) ;
  1. ;CHECKS THE UNITS OF A DOSE-RETURNS ERROR AND REASON
  1. ;INPUTS: PSUNIT-UNITS OF THE DRUG
  1. ;PSDRUGNM-NAME OF THE DRUG
  1. N PSREASON,PSRESULT,PSMSG
  1. S PSRESULT=""
  1. I '$L(PSUNIT) D
  1. .S PSMSG=$$DOSEMSG(PSDRUGNM)
  1. .S PSREASON="Invalid or Undefined Dose Unit"
  1. .S PSRESULT=PSMSG_U_PSREASON
  1. Q PSRESULT
  1. ;
  1. CHKFREQ(PSFREQ) ;
  1. ;INPUTS: PSFREQ-HOW OFTEN A DRUG IS ADMINISTRED
  1. ;RETURNS-ERROR MESSAGE AND ERROR REASON
  1. N PSREASON,PSRESULT,PSMSG
  1. S PSMSG="Daily Dosage Range Check could not be performed."
  1. S PSRESULT=""
  1. D
  1. .I '$L(PSFREQ) Q ;Freq can be null
  1. .I '$$VALFREQ^PSSHFREQ(PSFREQ) D
  1. ..S PSREASON="Invalid or Undefined Frequency"
  1. ..S PSRESULT=PSMSG_U_PSREASON
  1. Q PSRESULT
  1. ;
  1. CHKRATE(PSRATE,TYPE,DRUGNM,DURATION) ;
  1. ;INPUTS: PSRATE-Can be either dose or duration rate
  1. ;TYPE-DOSE OR DURATION
  1. ;DRUGNM-DRUG NAME
  1. ;DURATION-OPTIONAL DURATION NUMERIC
  1. S DURATION=$G(DURATION)
  1. ;output: returns error message and reason
  1. N OKFLAG,STDRATE,RESULT,REASON,PSMSG
  1. S RESULT=""
  1. S OKFLAG=0 ;ASSUME BAD
  1. D
  1. .I '$L(PSRATE),TYPE="DURATION",'$L(DURATION) Q ;can be null for duration if duration is null
  1. .F STDRATE="H","HOUR","MINUTE","MIN","DAY" D Q:OKFLAG
  1. ..I PSRATE=STDRATE S OKFLAG=1
  1. .I 'OKFLAG D
  1. ..S TYPE=$S(TYPE="DURATION":"Duration",TYPE="DOSE":"DOSE",1:"Duration or Dose")
  1. ..S REASON="Invalid or Undefined "_TYPE_" Rate"
  1. ..S PSMSG=$$DOSEMSG(DRUGNM)
  1. ..S RESULT=PSMSG_U_REASON
  1. Q RESULT
  1. ;
  1. CHKDRATN(DURATION,DRUGNM) ;
  1. ;INPUTS; DURATION-INTEGER-HOW LONG A DRUG IS TAKEN
  1. ;PSMSG-ERROR MESSAGE
  1. N RESULT,REASON,PSMSG
  1. S RESULT=""
  1. ;If not integer error
  1. D
  1. .I '$L(DURATION) Q ;can be null OK
  1. .;must be an integer > 0
  1. .;I (DURATION'=+DURATION)!(DURATION'=(DURATION\1))!(DURATION=0) D
  1. .I (DURATION=0)!(DURATION'?1.N) D
  1. ..S REASON="Invalid or Undefined Duration"
  1. ..S PSMSG=$$DOSEMSG(DRUGNM)
  1. ..S RESULT=PSMSG_U_REASON
  1. Q RESULT
  1. ;
  1. DOSEMSG(DRUGNAME,TYPE,WARN) ;
  1. ;INPUTS:DRUGNMAME
  1. ;TYPE-either "R" for range or "S" for single or "D" for daily or "M" for max daily (optional)
  1. ;WARN-'W' for warning text, else exception text
  1. ;OUTPUT STANDARD DOSAGE ERROR MESSAGE
  1. N RETURN,TEXT
  1. S TYPE=$G(TYPE) ;OPTIONAL PARAMETER ONLY CALLED FROM PSSHRQ23
  1. S WARN=$G(WARN) ;OPTIONAL PARAMETER ONLY CALLED FROM PSSDSEXD
  1. S TEXT=$S(WARN="W":" Warning for ",1:" could not be performed for Drug: ")
  1. D
  1. .I TYPE="S" D Q
  1. ..SET RETURN="Maximum Single Dose Check"_TEXT_DRUGNAME
  1. .I TYPE="M" D Q
  1. ..S RETURN="Max Daily Dose Check"_TEXT_DRUGNAME
  1. .S RETURN=$S(WARN="W":"Dosing Order Check",1:"Dosing Checks")_TEXT_DRUGNAME
  1. Q RETURN
  1. ;
  1. GETUCI() ;
  1. ;RETURNS CURRENT UCI
  1. N Y
  1. X ^%ZOSF("UCI")
  1. Q Y
  1. ;
  1. ERRMSG(TYPE,DRUGNAME,ORDRNUM,WARNING) ;
  1. ;Returns standard messages for error nodes
  1. ;created from FDB alerts
  1. ;inputs:
  1. ;TYPE-DRUGDRUG,THERAPY,DOSE
  1. ;DRUGNAME-NAME OF DRUG
  1. ;WARNING (OPTIONAL) 1 OR 0 IF SET CAME BACKF FROM FDB AS SEVERITY OF WARINING)
  1. ;CALLED BY MSGWRITE^PSSHRQ21
  1. ;FDB Errors, Input Exceptions and Dose Screening prior to FDB call pass in Null Type
  1. N MSG,LOCORREM
  1. S WARNING=$G(WARNING)
  1. S MSG=""
  1. S LOCORREM=$$LOCORREM(ORDRNUM)
  1. D
  1. .I WARNING D Q
  1. ..I TYPE="DRUGDRUG" S MSG="Drug Interaction Order Check for "_LOCORREM_" Drug: "
  1. ..I TYPE="THERAPY" S MSG="Duplicate Therapy Order Check for "_LOCORREM_" Drug: "
  1. ..I TYPE="DOSE" S MSG="Dosing Order Check Warning for "_DRUGNAME_":" Q ; do not execute the next line - and 2.1 change from Maximum to Dosing Order..
  1. ..S MSG=MSG_DRUGNAME_" Warning"
  1. .I TYPE="DRUGDRUG" S MSG="Drug Interaction Order Check could not be performed."
  1. .I TYPE="THERAPY" S MSG="Duplicate Therapy Order Check could not be performed for "_LOCORREM_" Drug: "_DRUGNAME
  1. .I TYPE="DOSE" S MSG=$$DOSEMSG(DRUGNAME)
  1. Q MSG
  1. ;
  1. ORDRTYP(ORDERNUM) ;
  1. ;RETURNS THE TYPE OF ORDER: OUTPATIENT PROSPECTIVE DRUG, OUTPATIENT, REMOTE OR INPATIENT
  1. ;INPUTS: ORDERNUM: TYPE;ORDER NUMBER;DRUG TYPE (PROFILE, PROSPECTIVE, REMOTE);COUNTER
  1. N TYPE,C1
  1. S TYPE=""
  1. S C1=$E(ORDERNUM)
  1. D
  1. .I ORDERNUM["REMOTE" S TYPE="REMOTE" Q
  1. .I C1="O" S TYPE="OUTPATIENT" Q
  1. .I C1="Z" S TYPE="OUTPATIENT" Q
  1. .I C1="I" S TYPE="INPATIENT" Q
  1. .I C1="R" S TYPE="REMOTE" Q
  1. Q TYPE
  1. ;
  1. LOCORREM(ORDERNUM) ;
  1. ;INPUTS: ORDERNUM: TYPE;ORDER NUMBER;DRUG TYPE (PROFILE, PROSPECTIVE, REMOTE);COUNTER
  1. ;OUTPUTS:-String either "local" or "Remote"
  1. N ORDRTYP,LOCORREM
  1. S ORDRTYP=$$ORDRTYP(ORDERNUM)
  1. D
  1. .I ORDRTYP="REMOTE" S LOCORREM="Remote" Q
  1. .S LOCORREM="Local"
  1. Q LOCORREM
  1. ;
  1. STATMSG() ;
  1. ;This returns the standard message when an FDB update is being performed.
  1. ;
  1. N MSG
  1. ;S MSG="Enhanced Order checks are unavailable. A Vendor database update is in progress."
  1. ;S MSG="The connection to the vendor database has been disabled."
  1. S MSG=$S(+$G(PSSDSWHE)=0:"The connection to the vendor database has been disabled.",1:"Vendor database updates are being processed.") ;2.1 message text split
  1. Q MSG
  1. ;
  1. ;
  1. GCMESS() ;Get Exclude field
  1. N PSSVQND,PSSVQEXC,PSSVQPVP
  1. S PSSVQPVP=$P(ORDRNUM,";",3)
  1. I '$D(PSJDGCK) S PSSVQND=^TMP($J,PSSHASH("Base"),"IN",PSSVQPVP,ORDRNUM)
  1. I $D(PSJDGCK) S PSSVQND=^TMP($J,PSSHASH("Base"),"IN","PROSPECTIVE",ORDRNUM)
  1. S PSSVQEXC=""
  1. D GCNMESX
  1. Q PSSVQEXC
  1. ;
  1. ;
  1. GCNMESX ;
  1. N PSSVQDRG,PSSVQ1,PSSVQ3,PSSVQVUI,PSSVQAR,PSSVQ4,PSSVQARR
  1. S PSSVQDRG=$P(PSSVQND,"^",3) I PSSVQDRG D Q
  1. .S PSSVQ1=$P($G(^PSDRUG(PSSVQDRG,"ND")),"^"),PSSVQ3=$P($G(^PSDRUG(PSSVQDRG,"ND")),"^",3)
  1. .I PSSVQ1,PSSVQ3 S PSSVQEXC=$$DDIEX^PSNAPIS(PSSVQ1,PSSVQ3)
  1. S PSSVQVUI=$P(PSSVQND,"^",2) I 'PSSVQVUI Q
  1. S PSSVQAR="PSSVQARR"
  1. D GETIREF^XTID(50.68,.01,PSSVQVUI,PSSVQAR)
  1. S PSSVQ4=$O(PSSVQARR(50.68,.01,""))
  1. I PSSVQ4 S PSSVQEXC=$$DDIEX^PSNAPIS("",PSSVQ4)
  1. Q
  1. ;
  1. ;
  1. NXCHKMSG(DRUGNM) ;2.1 changes
  1. N PSSZMESS
  1. I $D(^TMP($J,PSSHASH("Base"),"IN","DOSE")) D Q PSSZMESS
  1. .I 'PSSVQDOS!('PSSVQTY2)!(PSSVQREM)!($$EXMT(DRUGIEN)) S PSSZMESS=MESSAGE Q
  1. .S PSSZMESS="Dosing Checks could not be performed for Drug: "_DRUGNM_", please complete a manual check for appropriate Dosing." ; 2.1 Schedule not known, so message must stay generic
  1. S PSSZMESS="Order Checks could not be done for"
  1. S PSSZMESS=PSSZMESS_$S(PSSVQREM:" Remote",2:"")_" Drug: "_DRUGNM_", please complete a manual check for Drug Interactions"_$S(PSSVQDOS&($G(PSSVQTY2))&('$$EXMT(DRUGIEN)):", Duplicate Therapy and appropriate Dosing.",1:" and Duplicate Therapy.")
  1. Q PSSZMESS
  1. ;
  1. ;
  1. NZMSG ;Reset Message for Pharmacy Not matched to NDF error for Dosing
  1. S MESSAGE="Maximum Single Dose Check could not be performed for Drug: "_DRUGNM
  1. Q
  1. ;;
  1. EXMT(PSSHRDRG) ; given drug ien, is it exempt from dosing call? 2.1 change
  1. I PSSHRDRG'>0 Q 0
  1. Q $$EXMT^PSSDSAPI(PSSHRDRG)