PSJMDIR ;BIR/MV-MED DUE WORKSHEET DIR CALLS ; 5/14/09 8:13am
 ;;5.0; INPATIENT MEDICATIONS ;**225**;16 DEC 97;Build 16
 ;
MEDTYPE(PSGMARWD) ;*** Ask for Med choices
 ;PSGMARWD will be defined if the user was selected by ward.
 ;If PSJMPRN is defined, that mean this module is calling from the MDWS.
 ;
 K DIR S DIR(0)="LAO^1:6^I X[1&($L(X)>1) K X" S DIR("A")="Enter medication type(s): "
 ;PSJ*5*225 Update menu to include IVP
 S DIR("?",1)="1.  All medications",DIR("?",2)="2.  Non-IV medications only",DIR("?",3)="3.  IVPB (Includes IV syringe orders with a med route of IVP, IV, or IVPB."
 S DIR("?",4)="          All other IV syringe orders are included with non-IV medications).",DIR("?",5)="4.  LVPs",DIR("?",6)="5.  TPNs",DIR("?",7)="6.  Chemotherapy medications (IV)",DIR("?",8)=""
 N XTYPE S:$G(PSGMARWD) XTYPE=$P($G(^PS(59.6,+$O(^PS(59.6,"B",+PSGMARWD,0)),0)),"^",2) S DIR("B")=$S($G(XTYPE):XTYPE,1:2)
 S DIR("?")="e.g.  Enter 1 or 2-4,5 or 2."
 S DIR("?",9)="A combination of choices can be entered here except for option 1."
 W !! D ^DIR
 Q $$STOP
 ;
STDATE() ;*** Ask for starting date and time
 ;
 K DIR S DIR(0)="DO^::EXAR",DIR("A")="Enter Start Date and Time",DIR("?")="Date and time must be entered." W !! D ^DIR
 Q $$STOP
 ;
ENDATE(PSGTMP,PSGTMP1) ;*** Ask for eding date and time
 ;
 K DIR S DIR(0)="DAO^"_PSGTMP_":"_PSGTMP1_":EXAR",DIR("A")="Enter Ending Date and Time: "
 S DIR("?")="Time must be entered.",DIR("?",1)="The worksheet will list only medications due for a 24 hour",DIR("?",2)="period.  Please keep ending date and time within that range."
 W !! D ^DIR
 Q $$STOP
 ;
PRN() ;
 ;
 K DIR S DIR(0)="YO",DIR("A")="Would you like to include PRN Medications (Y/N)",DIR("B")="NO"
 S DIR("?")="Answer ""YES"" to include PRN orders in the Medication Due Worksheet.  (The PRN medications will print after the Continuous medications.)"
 W !! D ^DIR
 Q $$STOP
 ;
ADMTM ;*** Askif user want to sort by admin team
 ;
 S (PSGTM,PSGTMALL)=0
 K DIR S DIR(0)="YO",DIR("A")="Do you want to sort by Administration Team (Y/N)",DIR("B")="NO"
 S DIR("?",1)="Enter ""Y"" for ""YES"" if you wish to sort by Administration",DIR("?",2)="team. Enter ""N"" for ""NO"" if you do not wish to sort by",DIR("?",3)="Administration Team."
 S DIR("?",4)="",DIR("?",5)="If you choose to sort by Adminstration Team, you",DIR("?")="may choose which teams will be included in the report."
 W !! D ^DIR Q:$$STOP!'+Y
 ;
 ;*** Because "ALL" is not a team, must use DIR to include "ALL"
 ;    default and then call DIC to look up the selected team
 ;
 F  Q:$$STOP!(X="")!$G(PSGTMALL)  D ADMTM2
 S PSGTM=$S($O(PSGTM(0))'="":1,1:0)
 Q
ADMTM2 ;
 K DIR S DIR(0)="FAO",DIR("A")="Select Administration Team: ",DIR("B")="ALL",DIR("?")="^D DICTM^PSJMDIR" W ! D ^DIR Q:$$STOP  I Y="ALL" S PSGTMALL=1 Q
 D DICTM
 S PSJSTOP=$S($D(DTOUT):1,$D(DUOUT):1,(Y<0)&'$D(PFLG):1,1:0)
 Q
 ;
DICTM ;*** LooK up a team.
 ;
 K DIC S DIC="^PS(57.7,"_PSGWD_",1,",DIC(0)="QEMIZ"
 F PFLG=0:1 D ^DIC Q:Y<0  I PFLG S DIC(0)=DIC(0)_"A",DIC("A")="Select another Administration Team: " S PSGTM(Y(0,0))=+Y
 Q
 ;
RBADM ;*** Sort by PATIENT, ROOM-BED or ADMIN TIME
 ;
 K DIR S DIR(0)="SAO^A:Administration Time;R:Room-Bed;P:Patient",DIR("A")="Do you wish to sort by Administration Time (A), Room-Bed (R), Patient (P): ",DIR("B")="A"
 S DIR("?",1)="Enter an ""A"" if you want orders to display in order of Administration Time.",DIR("?",2)="Enter a ""R"" if you want orders to display in order of patient room-bed."
 S DIR("?")="Enter a ""P"" if you want orders to display in order of patient name."
 W ! D ^DIR Q:$$STOP  S PSGRBADM=Y
 Q
 ;
RBPPN ;*** Sort by ROOM-BED or PATIENT(when selected by WARD).
 ;
 K DIR S DIR(0)="SAO^R:Room-Bed;P:PATIENT",DIR("A")="Do you wish to sort by Room-Bed (R), Patient (P): ",DIR("B")="R"
 S DIR("?",1)="Enter an ""R"" if you want orders to display in order of patient room-bed.",DIR("?")="Enter a ""P"" if you want orders to display in order of patient name."
 W ! D ^DIR Q:$$STOP  S PSGRBPPN=Y
 Q
 ;
STOP() ;
 ;
 S PSJSTOP=$S($D(DTOUT):1,$D(DUOUT):1,$D(DIRUT):1,1:0)
 Q PSJSTOP
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSJMDIR   4146     printed  Sep 23, 2025@19:43:44                                                                                                                                                                                                     Page 2
PSJMDIR   ;BIR/MV-MED DUE WORKSHEET DIR CALLS ; 5/14/09 8:13am
 +1       ;;5.0; INPATIENT MEDICATIONS ;**225**;16 DEC 97;Build 16
 +2       ;
MEDTYPE(PSGMARWD) ;*** Ask for Med choices
 +1       ;PSGMARWD will be defined if the user was selected by ward.
 +2       ;If PSJMPRN is defined, that mean this module is calling from the MDWS.
 +3       ;
 +4        KILL DIR
           SET DIR(0)="LAO^1:6^I X[1&($L(X)>1) K X"
           SET DIR("A")="Enter medication type(s): "
 +5       ;PSJ*5*225 Update menu to include IVP
 +6        SET DIR("?",1)="1.  All medications"
           SET DIR("?",2)="2.  Non-IV medications only"
           SET DIR("?",3)="3.  IVPB (Includes IV syringe orders with a med route of IVP, IV, or IVPB."
 +7        SET DIR("?",4)="          All other IV syringe orders are included with non-IV medications)."
           SET DIR("?",5)="4.  LVPs"
           SET DIR("?",6)="5.  TPNs"
           SET DIR("?",7)="6.  Chemotherapy medications (IV)"
           SET DIR("?",8)=""
 +8        NEW XTYPE
           if $GET(PSGMARWD)
               SET XTYPE=$PIECE($GET(^PS(59.6,+$ORDER(^PS(59.6,"B",+PSGMARWD,0)),0)),"^",2)
           SET DIR("B")=$SELECT($GET(XTYPE):XTYPE,1:2)
 +9        SET DIR("?")="e.g.  Enter 1 or 2-4,5 or 2."
 +10       SET DIR("?",9)="A combination of choices can be entered here except for option 1."
 +11       WRITE !!
           DO ^DIR
 +12       QUIT $$STOP
 +13      ;
STDATE()  ;*** Ask for starting date and time
 +1       ;
 +2        KILL DIR
           SET DIR(0)="DO^::EXAR"
           SET DIR("A")="Enter Start Date and Time"
           SET DIR("?")="Date and time must be entered."
           WRITE !!
           DO ^DIR
 +3        QUIT $$STOP
 +4       ;
ENDATE(PSGTMP,PSGTMP1) ;*** Ask for eding date and time
 +1       ;
 +2        KILL DIR
           SET DIR(0)="DAO^"_PSGTMP_":"_PSGTMP1_":EXAR"
           SET DIR("A")="Enter Ending Date and Time: "
 +3        SET DIR("?")="Time must be entered."
           SET DIR("?",1)="The worksheet will list only medications due for a 24 hour"
           SET DIR("?",2)="period.  Please keep ending date and time within that range."
 +4        WRITE !!
           DO ^DIR
 +5        QUIT $$STOP
 +6       ;
PRN()     ;
 +1       ;
 +2        KILL DIR
           SET DIR(0)="YO"
           SET DIR("A")="Would you like to include PRN Medications (Y/N)"
           SET DIR("B")="NO"
 +3        SET DIR("?")="Answer ""YES"" to include PRN orders in the Medication Due Worksheet.  (The PRN medications will print after the Continuous medications.)"
 +4        WRITE !!
           DO ^DIR
 +5        QUIT $$STOP
 +6       ;
ADMTM     ;*** Askif user want to sort by admin team
 +1       ;
 +2        SET (PSGTM,PSGTMALL)=0
 +3        KILL DIR
           SET DIR(0)="YO"
           SET DIR("A")="Do you want to sort by Administration Team (Y/N)"
           SET DIR("B")="NO"
 +4        SET DIR("?",1)="Enter ""Y"" for ""YES"" if you wish to sort by Administration"
           SET DIR("?",2)="team. Enter ""N"" for ""NO"" if you do not wish to sort by"
           SET DIR("?",3)="Administration Team."
 +5        SET DIR("?",4)=""
           SET DIR("?",5)="If you choose to sort by Adminstration Team, you"
           SET DIR("?")="may choose which teams will be included in the report."
 +6        WRITE !!
           DO ^DIR
           if $$STOP!'+Y
               QUIT 
 +7       ;
 +8       ;*** Because "ALL" is not a team, must use DIR to include "ALL"
 +9       ;    default and then call DIC to look up the selected team
 +10      ;
 +11       FOR 
               if $$STOP!(X="")!$GET(PSGTMALL)
                   QUIT 
               DO ADMTM2
 +12       SET PSGTM=$SELECT($ORDER(PSGTM(0))'="":1,1:0)
 +13       QUIT 
ADMTM2    ;
 +1        KILL DIR
           SET DIR(0)="FAO"
           SET DIR("A")="Select Administration Team: "
           SET DIR("B")="ALL"
           SET DIR("?")="^D DICTM^PSJMDIR"
           WRITE !
           DO ^DIR
           if $$STOP
               QUIT 
           IF Y="ALL"
               SET PSGTMALL=1
               QUIT 
 +2        DO DICTM
 +3        SET PSJSTOP=$SELECT($DATA(DTOUT):1,$DATA(DUOUT):1,(Y<0)&'$DATA(PFLG):1,1:0)
 +4        QUIT 
 +5       ;
DICTM     ;*** LooK up a team.
 +1       ;
 +2        KILL DIC
           SET DIC="^PS(57.7,"_PSGWD_",1,"
           SET DIC(0)="QEMIZ"
 +3        FOR PFLG=0:1
               DO ^DIC
               if Y<0
                   QUIT 
               IF PFLG
                   SET DIC(0)=DIC(0)_"A"
                   SET DIC("A")="Select another Administration Team: "
                   SET PSGTM(Y(0,0))=+Y
 +4        QUIT 
 +5       ;
RBADM     ;*** Sort by PATIENT, ROOM-BED or ADMIN TIME
 +1       ;
 +2        KILL DIR
           SET DIR(0)="SAO^A:Administration Time;R:Room-Bed;P:Patient"
           SET DIR("A")="Do you wish to sort by Administration Time (A), Room-Bed (R), Patient (P): "
           SET DIR("B")="A"
 +3        SET DIR("?",1)="Enter an ""A"" if you want orders to display in order of Administration Time."
           SET DIR("?",2)="Enter a ""R"" if you want orders to display in order of patient room-bed."
 +4        SET DIR("?")="Enter a ""P"" if you want orders to display in order of patient name."
 +5        WRITE !
           DO ^DIR
           if $$STOP
               QUIT 
           SET PSGRBADM=Y
 +6        QUIT 
 +7       ;
RBPPN     ;*** Sort by ROOM-BED or PATIENT(when selected by WARD).
 +1       ;
 +2        KILL DIR
           SET DIR(0)="SAO^R:Room-Bed;P:PATIENT"
           SET DIR("A")="Do you wish to sort by Room-Bed (R), Patient (P): "
           SET DIR("B")="R"
 +3        SET DIR("?",1)="Enter an ""R"" if you want orders to display in order of patient room-bed."
           SET DIR("?")="Enter a ""P"" if you want orders to display in order of patient name."
 +4        WRITE !
           DO ^DIR
           if $$STOP
               QUIT 
           SET PSGRBPPN=Y
 +5        QUIT 
 +6       ;
STOP()    ;
 +1       ;
 +2        SET PSJSTOP=$SELECT($DATA(DTOUT):1,$DATA(DUOUT):1,$DATA(DIRUT):1,1:0)
 +3        QUIT PSJSTOP