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

PSSDSEXE.m

Go to the documentation of this file.
PSSDSEXE ;BIR/CMF-Exceptions for Dose call Continuation ;02/24/09
 ;;1.0;PHARMACY DATA MANAGEMENT;**178,206,224**;9/30/97;Build 3
 ;
 ;Called from PSSDSEXD, this routine takes the results from the call to First DataBank and creates displayable TMP
 ;globals for the calling applications. Typically, PSSDBASA indicates a CPRS call, and PSSDBASB indicates a pharmacy call
 ;
 ;PSSDBCAR ARRAY pieces, set mostly in PSSDSAPD are described in PSSDSEXC:
 ;
 ;PSSDBCAX holds the errors to show
 ;
TWEAK2 ;; loop through exception then error globals, look for OR related tweaks
 N PSSDWEX2,PSSDWE2,PSSDWLP,NODE
 S PSSDWEX2=""
 F  S PSSDWEX2=$O(^TMP($J,PSSDBASE,"OUT","EXCEPTIONS","DOSE",PSSDWEX2)) Q:PSSDWEX2=""  D 
 .S PSSDWE2=""
 .F  S PSSDWE2=$O(^TMP($J,PSSDBASE,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,PSSDWE2)) Q:PSSDWE2=""  D
 ..S NODE=$G(^TMP($J,PSSDBASE,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,PSSDWE2))
 ..Q:NODE=""
 ..Q:$$TWEAK20(PSSDWEX2)
 ..Q:$$TWEAK21(NODE)
 ..Q:$$TWEAK23(NODE)
 ..Q:$$TWEAK24(NODE)
 ..Q:$$TWEAK25(NODE)
 ..Q:$$TWEAK26(NODE)
 ..Q:$$TWEAK29A(PSSDWEX2)
 D TWEAK22
 S PSSDWLP=""
 F  S PSSDWLP=$O(^TMP($J,PSSDBASF,"OUT","DOSE","ERROR",PSSDWLP)) Q:PSSDWLP=""  D 
 .Q:$$TWEAK28(PSSDWLP)
 .Q:$$TWEAK29(PSSDWLP)
 D TWEAK200^PSSDSEXF
 Q
 ;;
TWEAK21(NODE) ;; test for OR inactive drug
 N DRUGIEN,DRUGNAME,MESSAGE,REASON,FLAG
 S FLAG=0
 S DRUGIEN=$P(PSSDBCAR(PSSDWEX2),U,3)
 D:$$ORTEST(DRUGIEN)=1 
 .S DRUGNAME=$P(PSSDBCAR(PSSDWEX2),U,2)
 .S MESSAGE=$$CHECKMSG^PSSDSEXD(PSSDWEX2)_$$MSGEND(PSSDWEX2,DRUGNAME) ; could not be done for Drug: "_DRUGNAME_", please complete a manual check for appropriate Dosing."
 .S REASON=""
 .S $P(^TMP($J,PSSDBASE,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,PSSDWE2),U,7)=MESSAGE
 .S $P(^(PSSDWE2),U,10)=REASON
 .D:PSSDBASA 
 ..S ^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,1)=MESSAGE
 ..S ^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,2)=REASON
 .D:PSSDBASB 
 ..S ^TMP($J,PSSDBASG,"OUT",PSSDWEX2,"EXCEPTIONS",1)=MESSAGE
 ..S ^TMP($J,PSSDBASG,"OUT",PSSDWEX2,"EXCEPTIONS",2)=REASON
 .S $P(PSSDBCAR(PSSDWEX2),U,27)=1
 .S FLAG=1
 Q FLAG
 ;;
TWEAK22 ;; loop through initial entry array, look for drugs which may have not been excepted
 N I,DRUGIEN,DRUGNAME,PSSDWEX2,MESSAGE,REASON
 Q:'$D(PSSDBFDB)
 S I=0
 F  S I=$O(PSSDBFDB(I)) Q:'I  D 
 .S DRUGIEN=+$G(PSSDBFDB(I,"DRUG_IEN"))
 .Q:DRUGIEN<1
 .Q:$$ORTEST(DRUGIEN)=0
 .S PSSDWEX2=$G(PSSDBFDB(I,"RX_NUM"))
 .Q:PSSDWEX2=""
 .Q:$D(^TMP($J,PSSDBASE,"OUT","EXCEPTIONS","DOSE",PSSDWEX2))  ;; already handled by TWEAK21
 .S DRUGNAME=$G(PSSDBFDB(I,"DRUG_NM"))
 .Q:DRUGNAME=""
 .S MESSAGE=$$CHECKMSG^PSSDSEXD(PSSDWEX2)_$$MSGEND(PSSDWEX2,DRUGNAME) ;" could not be done for Drug: "_DRUGNAME_", please complete a manual check for appropriate Dosing."
 .S REASON=""
 .S $P(^TMP($J,PSSDBASE,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,1),U,7)=MESSAGE
 .S $P(^TMP($J,PSSDBASE,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,1),U,10)=REASON
 .D:PSSDBASA 
 ..S ^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,1)=MESSAGE
 ..S ^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,2)=REASON
 .D:PSSDBASB 
 ..S ^TMP($J,PSSDBASG,"OUT",PSSDWEX2,"EXCEPTIONS",1)=MESSAGE
 ..S ^TMP($J,PSSDBASG,"OUT",PSSDWEX2,"EXCEPTIONS",2)=REASON
 .S $P(PSSDBCAR(PSSDWEX2),U,27)=1
 Q
 ;;
TWEAK23(NODE) ;; change CPRS message on bad dose route, bad dose type
 N DRUGIEN,DRUGNAME,ROUTE,MESSAGE,REASON,FLAG
 S FLAG=0
 D:$P(PSSDBCAR(PSSDWEX2),U,23)=1 
 .S DRUGNAME=$P(PSSDBCAR(PSSDWEX2),U,2)
 .D:+$P(PSSDBCAR(PSSDWEX2),U,31)=0 
 ..S $P(PSSDBCAR(PSSDWEX2),U,31)=1
 ..S ROUTE=$P(PSSDBCAR(PSSDWEX2),U,9)
 ..D:ROUTE=""
 ...F I=1:1 S ROUTE(I)=$G(PSSDBFDB(I,"RX_NUM")) Q:ROUTE(I)=""  S ROUTE("RX_NUM",ROUTE(I))=I
 ...S ROUTE("I")=$G(ROUTE("RX_NUM",PSSDWEX2))
 ...S:+ROUTE("I") ROUTE("MR_IEN")=$G(PSSDBDS(ROUTE("I"),"MR_IEN"))
 ...S:+ROUTE("MR_IEN") ROUTE=$$GET1^DIQ(51.2,ROUTE("MR_IEN"),".01","E")
 ..S $P(PSSDBCAR(PSSDWEX2),U,32)=" for "_ROUTE_" route: "
 .S MESSAGE=$$CHECKMSG^PSSDSEXD(PSSDWEX2)_$$MSGEND(PSSDWEX2,DRUGNAME) ;" could not be done for Drug: "_DRUGNAME_", please complete a manual check for appropriate Dosing."
 .S REASON=""
 .S $P(^TMP($J,PSSDBASE,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,PSSDWE2),U,7)=MESSAGE
 .S $P(^(PSSDWE2),U,10)=REASON
 .D:PSSDBASA 
 ..S ^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,1)=MESSAGE
 ..S ^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,2)=REASON
 .D:PSSDBASB 
 ..S ^TMP($J,PSSDBASG,"OUT",PSSDWEX2,"EXCEPTIONS",1)=MESSAGE
 ..S ^TMP($J,PSSDBASG,"OUT",PSSDWEX2,"EXCEPTIONS",2)=REASON
 .S $P(PSSDBCAR(PSSDWEX2),U,27)=1
 .S FLAG=1
 Q FLAG
 ;;
TWEAK24(NODE) ;; change CPRS message on bad frequency or bad frequency duration
 N DRUGNAME,MESSAGE,REASON,FLAG
 S FLAG=0
 S REASON=$$UP^XLFSTR($P(^TMP($J,PSSDBASE,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,PSSDWE2),U,10))
 D:(REASON="INVALID OR UNDEFINED FREQUENCY")!(REASON="FREQUENCY GREATER THAN ORDER DURATION")
 .I $P(PSSDBCAR(PSSDWEX2),U,1)="S"&(+$P(PSSDBCAR(PSSDWEX2),U,8)=0) D  Q  ;;rtc#570308,#591734 ; ignore,remove frequency issues for 'single' type
 ..K ^TMP($J,PSSDBASE,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,PSSDWE2)
 ..S FLAG=1
 ..S $P(PSSDBCAR(PSSDWEX2),U,27)=1
 .S DRUGNAME=$P(PSSDBCAR(PSSDWEX2),U,2)
 .S MESSAGE="Max Daily Dose Check "_$$MSGEND(PSSDWEX2,DRUGNAME) ;could not be done for Drug: "_DRUGNAME_", please complete a manual check for appropriate Dosing."
 .S REASON=""
 .S $P(^(PSSDWE2),U,7)=MESSAGE
 .S $P(^(PSSDWE2),U,10)=REASON
 .D:PSSDBASA 
 ..S ^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,1)=MESSAGE
 ..S ^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,2)=REASON
 .D:PSSDBASB 
 ..S ^TMP($J,PSSDBASG,"OUT",PSSDWEX2,"EXCEPTIONS",1)=MESSAGE
 ..S ^TMP($J,PSSDBASG,"OUT",PSSDWEX2,"EXCEPTIONS",2)=REASON
 .S $P(PSSDBCAR(PSSDWEX2),U,27)=1
 .S FLAG=1
 Q FLAG
 ;;
TWEAK25(NODE) ;; change CPRS message on Free Text Dosage could not be evaluated
 N DRUGNAME,MESSAGE,REASON,FLAG
 S FLAG=0
 S REASON=$$UP^XLFSTR($P(^TMP($J,PSSDBASE,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,PSSDWE2),U,10))
 D:REASON="FREE TEXT DOSAGE COULD NOT BE EVALUATED"
 .S DRUGNAME=$P(PSSDBCAR(PSSDWEX2),U,2)
 .S MESSAGE=$$CHECKMSG^PSSDSEXD(PSSDWEX2)_$$MSGEND(PSSDWEX2,DRUGNAME) ;" could not be done for Drug: "_DRUGNAME_", please complete a manual check for appropriate Dosing."
 .S REASON=""
 .S $P(^(PSSDWE2),U,7)=MESSAGE
 .S $P(^(PSSDWE2),U,10)=REASON
 .D:PSSDBASA 
 ..S ^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,1)=MESSAGE
 ..S ^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,2)=REASON
 .D:PSSDBASB 
 ..S ^TMP($J,PSSDBASG,"OUT",PSSDWEX2,"EXCEPTIONS",1)=MESSAGE
 ..S ^TMP($J,PSSDBASG,"OUT",PSSDWEX2,"EXCEPTIONS",2)=REASON
 .S $P(PSSDBCAR(PSSDWEX2),U,27)=1
 .S FLAG=1
 .;;per RTC#534584;;D TWEAK25A()
 Q FLAG
 ;;
 ;;TWEAK25A()  ;;remove general messages when CPRS, free text error, multi-dispense drugs
 ;;N DRUGNAME,DRUGIEN,DRUGORI,FLAG
 ;;S FLAG=0
 ;;S DRUGNAME=$P(PSSDBCAR(PSSDWEX2),U,2)
 ;;S DRUGIEN=$P(PSSDBCAR(PSSDWEX2),U,3)
 ;;Q:(DRUGNAME="")!(DRUGIEN="")
 ;;S DRUGORI=$P($G(^PSDRUG(DRUGIEN,2)),U)
 ;;Q:DRUGORI=""
 ;;S DRUGORI("Top")=$O(^PSDRUG("ASP",DRUGORI,0))
 ;;S DRUGORI("Bottom")=$O(^PSDRUG("ASP",DRUGORI,9999999),-1)
 ;;D:DRUGORI("Top")'=DRUGORI("Bottom") 
 ;;.S FLAG=1
 ;;.K ^TMP($J,PSSDBASE,"OUT","DOSE",PSSDWEX2,DRUGNAME,"GENERAL","MESSAGE",DRUGIEN)
 ;;.I PSSDBASA K ^TMP($J,PSSDBASF,"OUT","DOSE",PSSDWEX2,DRUGNAME,"3_GENERAL","MESSAGE",DRUGIEN,1)
 ;;.I PSSDBASB K ^TMP($J,PSSDBASG,"OUT",PSSDWEX2,"MESSAGE","3_GENERAL",DRUGIEN,1)
 ;;Q FLAG
 ;;
TWEAK26(NODE) ;; change CPRS message on Free Text Infusion Rate could not be evaluated
 N DRUGNAME,MESSAGE,REASON,FLAG
 S FLAG=0
 S REASON=$$UP^XLFSTR($P(^TMP($J,PSSDBASE,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,PSSDWE2),U,10))
 D:REASON="FREE TEXT INFUSION RATE COULD NOT BE EVALUATED"
 .S DRUGNAME=$P(PSSDBCAR(PSSDWEX2),U,2)
 .S MESSAGE=$$CHECKMSG^PSSDSEXD(PSSDWEX2)_$$MSGEND(PSSDWEX2,DRUGNAME) ;" could not be done for Drug: "_DRUGNAME_", please complete a manual check for appropriate Dosing."
 .S REASON=""
 .S $P(^(PSSDWE2),U,7)=MESSAGE
 .S $P(^(PSSDWE2),U,10)=REASON
 .D:PSSDBASA 
 ..S ^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,1)=MESSAGE
 ..S ^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,2)=REASON
 .D:PSSDBASB 
 ..S ^TMP($J,PSSDBASG,"OUT",PSSDWEX2,"EXCEPTIONS",1)=MESSAGE
 ..S ^TMP($J,PSSDBASG,"OUT",PSSDWEX2,"EXCEPTIONS",2)=REASON
 .S $P(PSSDBCAR(PSSDWEX2),U,27)=1
 .S FLAG=1
 Q FLAG
 ;;
TWEAK27(PSSDWLP,PSSDWL1)  ;; if single type or complex, flag & scrub Max Daily warnings 
 N PSSDWMSG,FLAG
 S FLAG=0
 D:($P(PSSDBCAR(PSSDWLP),U,1)="S")!($P(PSSDBCAR(PSSDWLP),U,16)=1) 
 .S PSSDWMSG=$G(^TMP($J,PSSDBASE,"OUT","DOSE","ERROR",PSSDWLP,PSSDWL1,"MSG"))
 .D:PSSDWMSG["Max Daily Dose Check" 
 ..K ^TMP($J,PSSDBASE,"OUT","DOSE","ERROR",PSSDWLP,PSSDWL1)
 ..K:PSSDBASA ^TMP($J,PSSDBASF,"OUT","DOSE","ERROR",PSSDWLP,PSSDWL1)
 ..K:PSSDBASB ^TMP($J,PSSDBASG,"OUT",PSSDWLP,"ERROR",PSSDWL1)
 ..S $P(PSSDBCAR(PSSDWLP),U,27)=1
 ..S FLAG=1
 Q FLAG
 ;;
TWEAK20(PSSDWEX2)  ;; if single type CPRS call, flag & scrub Max Daily exceptions 
 N PSSDEMSG,FLAG
 S FLAG=0
 D:(PSSDSWHE=1)&($P(PSSDBCAR(PSSDWEX2),U,1)="S")&(+$P(PSSDBCAR(PSSDWEX2),U,8)=0) 
 .S PSSDEMSG=$G(^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,1))
 .D:PSSDEMSG["Max Daily Dose Check" 
 ..K ^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2)
 ..S $P(PSSDBCAR(PSSDWEX2),U,27)=1
 ..S FLAG=1
 Q FLAG
 ;;
TWEAK28(PSSDWLP)  ;; if CPRS call, alter 'Unable to convert' errors to generic 
 N PSSDWCNT,PSSDWMSG,PSSDWRSN,FLAG
 S FLAG=0
 S PSSDWCNT=0
 F  S PSSDWCNT=$O(^TMP($J,PSSDBASF,"OUT","DOSE","ERROR",PSSDWLP,PSSDWCNT)) Q:'PSSDWCNT  D 
 .S PSSDWRSN=$G(^TMP($J,PSSDBASF,"OUT","DOSE","ERROR",PSSDWLP,PSSDWCNT,"TEXT"))
 .D:PSSDWRSN["Unable to convert units" 
 ..S PSSDWMSG=$$CHECKMSG^PSSDSEXD(PSSDWLP)_$$MSGEND(PSSDWLP,$P(PSSDBCAR(PSSDWLP),U,2))
 ..S PSSDWRSN=""
 ..S ^TMP($J,PSSDBASF,"OUT","DOSE","ERROR",PSSDWLP,PSSDWCNT,"MSG")=PSSDWMSG
 ..S ^TMP($J,PSSDBASF,"OUT","DOSE","ERROR",PSSDWLP,PSSDWCNT,"TEXT")=PSSDWRSN
 ..D:(PSSDWMSG["Dosing Checks")&(PSSDWCNT=1)
 ...F  S PSSDWCNT=$O(^TMP($J,PSSDBASF,"OUT","DOSE","ERROR",PSSDWLP,PSSDWCNT)) Q:'PSSDWCNT  D
 ....K ^TMP($J,PSSDBASF,"OUT","DOSE","ERROR",PSSDWLP,PSSDWCNT)
 ..S $P(PSSDBCAR(PSSDWLP),U,27)=1
 ..S FLAG=1
 Q FLAG
 ;;
TWEAK29(PSSDWLP)  ;; if CPRS call, alter 'No dosing information' errors to generic 
 N PSSDWCNT,PSSDWMSG,PSSDWRSN,FLAG
 S FLAG=0
 S PSSDWCNT=0
 F  S PSSDWCNT=$O(^TMP($J,PSSDBASF,"OUT","DOSE","ERROR",PSSDWLP,PSSDWCNT)) Q:'PSSDWCNT  D 
 .S PSSDWRSN=$G(^TMP($J,PSSDBASF,"OUT","DOSE","ERROR",PSSDWLP,PSSDWCNT,"TEXT"))
 .D:PSSDWRSN["No dosing information specific to" 
 ..S PSSDWMSG=$$CHECKMSG^PSSDSEXD(PSSDWLP)_$$ROUTEMSG(PSSDWLP,$P(PSSDBCAR(PSSDWLP),U,2))
 ..S PSSDWRSN=""
 ..S ^TMP($J,PSSDBASF,"OUT","DOSE","ERROR",PSSDWLP,PSSDWCNT,"MSG")=PSSDWMSG
 ..S ^TMP($J,PSSDBASF,"OUT","DOSE","ERROR",PSSDWLP,PSSDWCNT,"TEXT")=PSSDWRSN
 ..D:(PSSDWMSG["Dosing Checks")&(PSSDWCNT=1)
 ...F  S PSSDWCNT=$O(^TMP($J,PSSDBASF,"OUT","DOSE","ERROR",PSSDWLP,PSSDWCNT)) Q:'PSSDWCNT  D
 ....K ^TMP($J,PSSDBASF,"OUT","DOSE","ERROR",PSSDWLP,PSSDWCNT)
 ..S $P(PSSDBCAR(PSSDWLP),U,27)=1
 ..S FLAG=1
 Q FLAG
 ;;
TWEAK29A(PSSDWEX2)  ;; ensure no age warnings for Max Single for excluded from daily  
 N PSSDWE2,PSSDEMSG,PSSREPL,FLAG
 S FLAG=0
 S PSSDWE2=0
 F  S PSSDWE2=$O(^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,PSSDWE2)) Q:'PSSDWE2  D 
 .D:($P(PSSDBCAR(PSSDWEX2),U,15)=1)&($P(PSSDBCAR(PSSDWEX2),U,19)=1) 
 ..S PSSDEMSG=^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,PSSDWE2)
 ..D:PSSDEMSG["Dosing checks" 
 ...S PSSREPL("Dosing checks")="Maximum Single Dose Check"
 ...S PSSDEMSG=$$REPLACE^XLFSTR(PSSDEMSG,.PSSREPL)
 ...S ^TMP($J,PSSDBASF,"OUT","EXCEPTIONS","DOSE",PSSDWEX2,PSSDWE2)=PSSDEMSG
 ...S $P(PSSDBCAR(PSSDWEX2),U,27)=1
 ...S FLAG=1
 Q FLAG
 ;;
ORTEST(DRUGIEN) ;; return 1 if Orderable Item is inactive
 N ITEMIEN,ITEMINCT
 S DRUGIEN=+$G(DRUGIEN)
 Q:'$D(^PSDRUG(DRUGIEN)) 0
 S ITEMIEN=$$GET1^DIQ(50,DRUGIEN,2.1,"I")
 Q:ITEMIEN="" 0
 S ITEMINCT=$$GET1^DIQ(50.7,ITEMIEN,.04,"I")
 Q:ITEMINCT="" 0
 Q $S(ITEMINCT>DT:0,1:1)
 ;;
MSGEND(PSSDWEX2,DRUGNAME) ;; build end of message, add dose to drugname if necessary, add route information if necessary
 N RESULT
 S:$$ISCMPLEX^PSSDSEXD(PSSDWEX2)=1 DRUGNAME=DRUGNAME_"(Dose="_$G(PSSDSDPL(PSSDWEX2))_")"
 Q $$ROUTEMSG(PSSDWEX2,DRUGNAME)
 ;;
ROUTEMSG(PSSDWEX2,DRUGNAME) ;; build end of message, add route information if necessary
 N RESULT
 S:+$P(PSSDBCAR(PSSDWEX2),U,31)=1 DRUGNAME=DRUGNAME_$P($P(PSSDBCAR(PSSDWEX2),U,32),":")
 S RESULT=" could not be done for Drug: "_DRUGNAME_", please complete a manual check for appropriate Dosing."
 Q RESULT
 ;; 
TWEAK4  ;; loop through error global, set piece 34 and 35 of PSSDBCAR array when piece 1="B"
 N PSSDWE5,PSSDWDRG,PSSDWIEN
 S PSSDWE5=""
 F  S PSSDWE5=$O(^TMP($J,PSSDBASE,"OUT","DOSE",PSSDWE5)) Q:PSSDWE5=""  I $D(PSSDBCAR(PSSDWE5)),'$P(PSSDBCAR(PSSDWE5),"^",14),$P(PSSDBCAR(PSSDWE5),"^",1)="B" D  ;2.1 piece 14 check added
 .S PSSDWDRG=$P(PSSDBCAR(PSSDWE5),"^",2),PSSDWIEN=$P(PSSDBCAR(PSSDWE5),"^",3) Q:PSSDWDRG=""!('PSSDWIEN)
 .I $G(^TMP($J,PSSDBASE,"OUT","DOSE",PSSDWE5,PSSDWDRG,"SINGLE","STATUSCODE",PSSDWIEN))=5 S $P(PSSDBCAR(PSSDWE5),"^",34)=1
 .I $G(^TMP($J,PSSDBASE,"OUT","DOSE",PSSDWE5,PSSDWDRG,"DAILYMAX","STATUSCODE",PSSDWIEN))=5 S $P(PSSDBCAR(PSSDWE5),"^",35)=1
 Q
 ;;
ISCMPLET(PSSLOOP) ;; is completed
 N PSSP1
 S PSSP1=$P(PSSDBCAR(PSSLOOP),U,1)
 Q $S(PSSP1="S":"Maximum Single Dose Check",PSSP1="D":"Max Daily Dose Check",1:$$ISCMPLEB(PSSLOOP))
 ;;
ISCMPLEB(PSSLOOP) ;; is completed, both attempted, did both finish?
 N PSSP15,PSSP33,PSSP34,PSSP35
 S PSSP15=+$P(PSSDBCAR(PSSLOOP),U,15)
 S PSSP33=+$P(PSSDBCAR(PSSLOOP),U,33)
 S PSSP34=+$P(PSSDBCAR(PSSLOOP),U,34)
 S PSSP35=+$P(PSSDBCAR(PSSLOOP),U,35)
 Q:(PSSP15=1)!((PSSP34=1)&(PSSP35=0)&(PSSP33=0)) "Maximum Single Dose Check"
 Q:(PSSP35=1)&(PSSP34=0)&(PSSP33=0) "Max Daily Dose Check"
 Q "Dosing Checks"
 ;;
GETGNRL3(PSSDWEX2) ;; ensure General Dosing set if intermittent + bad frequency 
 N DRUGNAME,DRUGIEN,MESSAGE
 S DRUGNAME=$P(PSSDBCAR(PSSDWEX2),U,2)
 S DRUGIEN=$P(PSSDBCAR(PSSDWEX2),U,3)
 Q:(DRUGNAME="")!(DRUGIEN="")
 D:'$D(^TMP($J,PSSDBASE,"OUT","DOSE",PSSDWEX2,DRUGNAME,"GENERAL","MESSAGE",DRUGIEN)) 
 .K ^TMP($J,"PSSDSEXD")
 .M ^TMP($J,"PSSDSEXD","IN")=^TMP($J,PSSDBASE,"IN")
 .S $P(^TMP($J,"PSSDSEXD","IN","DOSE",PSSDWEX2),U,10)=$P(^TMP($J,"PSSDSEXD","IN","DOSE",PSSDWEX2),U,8) ; duration rate = dose rate
 .S $P(^TMP($J,"PSSDSEXD","IN","DOSE",PSSDWEX2),U,8)=1 ;; frequency
 .S $P(^TMP($J,"PSSDSEXD","IN","DOSE",PSSDWEX2),U,9)=1 ;; duration
 .D IN^PSSHRQ2("PSSDSEXD")
 .Q:$D(^TMP($J,"PSSDSEXD","OUT","EXCEPTIONS"))
 .S ^TMP($J,PSSDBASE,"OUT","DOSE",PSSDWEX2,DRUGNAME,"GENERAL","MESSAGE",DRUGIEN)=^TMP($J,"PSSDSEXD","OUT","DOSE",PSSDWEX2,DRUGNAME,"GENERAL","MESSAGE",DRUGIEN)
 I $D(^TMP($J,"PSSDSEXD","OUT","EXCEPTIONS")) K ^TMP($J,"PSSDSEXD") Q
 S MESSAGE=^TMP($J,PSSDBASE,"OUT","DOSE",PSSDWEX2,DRUGNAME,"GENERAL","MESSAGE",DRUGIEN)
 I PSSDBASA S ^TMP($J,PSSDBASF,"OUT","DOSE",PSSDWEX2,DRUGNAME,"3_GENERAL","MESSAGE",DRUGIEN,1)=MESSAGE
 I PSSDBASB S ^TMP($J,PSSDBASG,"OUT",PSSDWEX2,"MESSAGE","3_GENERAL",DRUGIEN,1)=MESSAGE
 K ^TMP($J,"PSSDSEXD")
 Q
 ;;