PSGPER0 ;BIR/CML3-PRINTS PRE-EXCHANGE NEEDS REPORT ;24 JAN 94 / 11:14 AM
;;5.0; INPATIENT MEDICATIONS ;**58,82,95,115**;16 DEC 97
;
; Reference to ^PS(55 is supported by DBIA 2191.
;
ENQ ;
D ENP:'$G(PSGPXPT),ENPAT:$G(PSGPXPT) S DIK="^PS(53.4,",DA=PSGPXN D ^DIK K DA,DIK,PSGPXN Q
;
ENPAT ;
Q:'$G(DFN)
K ^TMP("PSGPER",$J) U IO D PAT,DONE
Q
;
ENP ;
K ^TMP("PSGPER",$J) U IO
F DFN=0:0 S DFN=$O(^PS(53.4,PSGPXN,1,DFN)) Q:'DFN D PAT,DONE
Q
;
PAT ;
D PID^VADPT,GWR F ON=0:0 S ON=$O(^PS(53.4,PSGPXN,1,DFN,1,ON)) Q:'ON D ONI F DD=0:0 S DD=$O(^PS(53.4,PSGPXN,1,DFN,1,ON,1,DD)) Q:'DD I $D(^(DD,0)) S ND=^(0) D DDS
D NOW^%DTC S %=$$ENDTC^PSGMI(%),(BORD,F,L)="",$P(L,"-",81)="",$P(BORD,"#",25)="",T=IO'=IO(0)!($E(IOST)'="C"),RF=$S(T:0,1:0) D:'RF HEADER S (DN,DDN,NP,WD)=""
F S WD=$O(^TMP("PSGPER",$J,WD)) Q:WD="" S PI="" F S F=0,PI=$O(^TMP("PSGPER",$J,WD,PI)) Q:PI="" S RB=^(PI) D
. D PPI F S F=1,DN=$O(^TMP("PSGPER",$J,WD,PI,DN)) Q:DN="" S PX=^(DN) D OP F S DDN=$O(^TMP("PSGPER",$J,WD,PI,DN,DDN)) Q:DDN="" S PX=^(DDN) D PRT
. I $O(^TMP("PSGPER",$J,WD,PI))]"" S F="" D NP
W:T&($Y) @IOF,@IOF D ^%ZISC
Q
;
DONE ;
K ^TMP("PSGPER",$J),BORD,DN,DD,DO,DRG,DRGS,F,L,MR,ND,ND0,ND2,ND4,NP,ON,PI,PDN,PN,PX,RB,RF,SCH,SDN,SN,SND1,SPN,STOP,STRT,T,UD,VD,VU,W,WD,X,XL,Y,DDN,I2,ND1,PSG25,PSG26,PSGEB,PSGEBN,PSGNODE,PSGOAT,PSGSTAT
K DONE,FIL,NF,PDM,PDRG,PSGACTO,PSGDA,PSGNEFDO,PSGNESDO,PSGPEN,PSGPENWS,PSGY,PSIVAC,PSIVCT,PSIVE,PSIVEXAM,PSIVUP,PSIVWAT,PSJH,PSJNOO,PSJNOON
Q
;
NP ;
I 'T K DIR S DIR(0)="E" W ! D ^DIR S:'Y WD="zzz" W:Y $C(13),# Q
;
W:$Y @IOF W !?20,"PRE-EXCHANGE UNITS REPORT - ",%
W !!,"Ward",?32,"Room-bed",!,"Patient",!?5,"Order",!?20,"Dispense Drug",?64,"U/D",?72,"Needs",!,L
W:F !!,$S(WD'="zz":WD,1:"NOT FOUND"),?32,RB,!,PN_" ("_SN_")" Q
;
GWR ;
S WD=$G(^DPT(DFN,.1)),RB=$G(^(.101)),PN=$P($G(^(0)),"^") S:WD="" WD="zz" S:RB="" RB="NOT FOUND" S:PN="" PN=DFN_";DPT("
S SPN=$E(PN,1,20)_"^"_DFN,^TMP("PSGPER",$J,WD,SPN)=PN_"^"_RB_"^"_VA("BID") Q
;
ONI ;
S ND=$G(^PS(55,DFN,5,ON,0)),DN=$G(^(.2)),SCH=$P($G(^(2)),"^"),MR=$P(ND,"^",3),ND=$$ENNPN^PSGMI($P(ND,"^",2)),DO=$P(DN,"^",2),DN=$P(DN,"^") I DN="" S DN="zz"
E S DN=$$ENPDN^PSGMI(DN)
S:MR]"" MR=$$ENMRN^PSGMI(MR) S SDN=$E(DN,1,20)_"^"_ON,^TMP("PSGPER",$J,WD,SPN,SDN)=DN_"^"_DO_"^"_MR_"^"_SCH_"^"_$P(ND,"^",2) Q
;
DDS ;
S ND1=$G(^PS(55,DFN,5,ON,1,+ND,0)),UD=$P(ND1,"^",2),ND1=$$ENDDN^PSGMI(+ND1),SND1=$E(ND1,1,20)_"^"_+ND,ND=$P(ND,"^",2)
I ND#1 S ND=(ND\1)+1
S ^TMP("PSGPER",$J,WD,SPN,SDN,SND1)=ND1_"^"_UD_"^"_ND
Q
;
PPI ;
S DFN=$P(PI,"^",2),PN=$P(RB,"^"),SN=$P(RB,"^",3),RB=$P(RB,"^",2) I 'RF,$Y+6>IOSL D NP Q:NP["^"
W !!,$S(WD'="zz":WD,1:"NOT FOUND"),?32,RB,!,PN," ("_SN_")" Q
;
OP ;
S PDN=$P(PX,"^"),DO=$P(PX,"^",2),MR=$P(PX,"^",3),SCH=$P(PX,"^",4)
W !?5,PDN," ",DO," ",MR,$S(MR]"":" ",1:""),SCH
Q
PRT ; find order info and print same
I 'RF,$Y+4>IOSL D NP Q:NP="^"
I 1 S PDN=$P(PX,"^"),UD=$P(PX,"^",2),PX=$P(PX,"^",3) W !?20,PDN,?62,$J($S('UD:1,$E(UD)=".":0_UD,1:UD),5),?72,$J(PX,5) Q
S ON=$P(DN,"^",2),ND=$G(^PS(55,DFN,5,ON,0)),ND2=$G(^(2)),ND4=$G(^(4)),Y=$P($G(^(6)),"^"),ND0=$G(^(.1)),DO=$P(ND0,"^",2)
S DRG=$$ENDDN^PSGMI($P(ND0,"^")),MR=$$ENMRN^PSGMI(MR) ; ,DRGS=$P($G(^(+$O(^PS(55,DFN,5,ON,1,0)),0)),"^")
I 'RF W !?5,DRG,?47,DO,?65,$J($S('UD:1,UD=.5:"1/2",UD=.25:"1/4",UD?1".".N:0_UD,1:UD),5),?75,$J(+PX,5) Q
;
S SCH=$P(ND2,"^"),STRT=$P(ND2,"^",2),STOP=$P(ND2,"^",4),VU=$P(ND4,"^",3),VD=$P(ND4,"^",4),VU=$P($G(^VA(200,+VU,0)),"^",2) S:VU="" VU=$P(ND4,"^",3)
F Q="STRT","STOP","VD" S @Q=$$ENDTC^PSGMI(@Q)
W:$Y @IOF W !!?6,BORD_" PRE-EXCHANGE MED "_BORD,!?6,"#",?73,"#",!?6,"# ",PN,?50,"Ward: ",WD,?73,"#",!?6,"# ("_SN_")",?52,"RB: "_RB,?73,"#",!?6,"#",?73,"#"
W !?6,"# "_DRG,?46,"START: "_STRT,?73,"#",!?6,"# "_$S(DRGS]"":"("_DRGS_")",1:""),?47,"STOP: "_STOP,?73,"#",!?6,"# GIVE: "_$S(DO]"":" "_DO,1:"")_$S(MR]"":" "_MR,1:"")_$S(SCH]"":" "_SCH,1:""),?73,"#"
S XL=0 I Y="" W !?6,"#",?73,"#",!?6,"# (NO SPECIAL INSTRUCTIONS)"
E W !?6,"#",?73,"#",!?6,"# " S Y=$$ENSET^PSGSICHK(Y) F Q=1:1:$L(Y," ") S X=$P(Y," ",Q) S:$X+$L(X)>72 XL=XL+1 W:$X+$L(X)>72 ?73,"#",!?6,"# " W X_" "
W ?73,"#",!?6,"#",?73,"#",!,?6,"#",?43,"VERIFIED: "_VD,?73,"#",!?6,"#",?49,"BY: "_VU,?73,"#",!?6,"#",?38,"SEND TO FLOOR: "_PX,?73,"#"
S XL=2-XL I XL>0 F Q=1:1:XL W !?6,"#",?73,"#"
W !?6,"#",?73,"#",!?6,"#",?36,"_______________ _______________ #",!?6,"#",?36,"FILLED BY",?56,"CHECKED BY",?73,"#",!?6,BORD_BORD_$E(BORD,1,20) Q
PSGPER0 ;BIR/CML3-PRINTS PRE-EXCHANGE NEEDS REPORT ;24 JAN 94 / 11:14 AM
+1 ;;5.0; INPATIENT MEDICATIONS ;**58,82,95,115**;16 DEC 97
+2 ;
+3 ; Reference to ^PS(55 is supported by DBIA 2191.
+4 ;
ENQ ;
+1 IF '$GET(PSGPXPT)
DO ENP
IF $GET(PSGPXPT)
DO ENPAT
SET DIK="^PS(53.4,"
SET DA=PSGPXN
DO ^DIK
KILL DA,DIK,PSGPXN
QUIT
+2 ;
ENPAT ;
+1 IF '$GET(DFN)
QUIT
+2 KILL ^TMP("PSGPER",$JOB)
USE IO
DO PAT
DO DONE
+3 QUIT
+4 ;
ENP ;
+1 KILL ^TMP("PSGPER",$JOB)
USE IO
+2 FOR DFN=0:0
SET DFN=$ORDER(^PS(53.4,PSGPXN,1,DFN))
IF 'DFN
QUIT
DO PAT
DO DONE
+3 QUIT
+4 ;
PAT ;
+1 DO PID^VADPT
DO GWR
FOR ON=0:0
SET ON=$ORDER(^PS(53.4,PSGPXN,1,DFN,1,ON))
IF 'ON
QUIT
DO ONI
FOR DD=0:0
SET DD=$ORDER(^PS(53.4,PSGPXN,1,DFN,1,ON,1,DD))
IF 'DD
QUIT
IF $DATA(^(DD,0))
SET ND=^(0)
DO DDS
+2 DO NOW^%DTC
SET %=$$ENDTC^PSGMI(%)
SET (BORD,F,L)=""
SET $PIECE(L,"-",81)=""
SET $PIECE(BORD,"#",25)=""
SET T=IO'=IO(0)!($EXTRACT(IOST)'="C")
SET RF=$SELECT(T:0,1:0)
IF 'RF
DO HEADER
SET (DN,DDN,NP,WD)=""
+3 FOR
SET WD=$ORDER(^TMP("PSGPER",$JOB,WD))
IF WD=""
QUIT
SET PI=""
FOR
SET F=0
SET PI=$ORDER(^TMP("PSGPER",$JOB,WD,PI))
IF PI=""
QUIT
SET RB=^(PI)
Begin DoDot:1
+4 DO PPI
FOR
SET F=1
SET DN=$ORDER(^TMP("PSGPER",$JOB,WD,PI,DN))
IF DN=""
QUIT
SET PX=^(DN)
DO OP
FOR
SET DDN=$ORDER(^TMP("PSGPER",$JOB,WD,PI,DN,DDN))
IF DDN=""
QUIT
SET PX=^(DDN)
DO PRT
+5 IF $ORDER(^TMP("PSGPER",$JOB,WD,PI))]""
SET F=""
DO NP
End DoDot:1
+6 IF T&($Y)
WRITE @IOF,@IOF
DO ^%ZISC
+7 QUIT
+8 ;
DONE ;
+1 KILL ^TMP("PSGPER",$JOB),BORD,DN,DD,DO,DRG,DRGS,F,L,MR,ND,ND0,ND2,ND4,NP,ON,PI,PDN,PN,PX,RB,RF,SCH,SDN,SN,SND1,SPN,STOP,STRT,T,UD,VD,VU,W,WD,X,XL,Y,DDN,I2,ND1,PSG25,PSG26,PSGEB,PSGEBN,PSGNODE,PSGOAT,PSGSTAT
+2 KILL DONE,FIL,NF,PDM,PDRG,PSGACTO,PSGDA,PSGNEFDO,PSGNESDO,PSGPEN,PSGPENWS,PSGY,PSIVAC,PSIVCT,PSIVE,PSIVEXAM,PSIVUP,PSIVWAT,PSJH,PSJNOO,PSJNOON
+3 QUIT
+4 ;
NP ;
+1 IF 'T
KILL DIR
SET DIR(0)="E"
WRITE !
DO ^DIR
IF 'Y
SET WD="zzz"
IF Y
WRITE $CHAR(13),#
QUIT
+2 ;
+1 IF $Y
WRITE @IOF
WRITE !?20,"PRE-EXCHANGE UNITS REPORT - ",%
+2 WRITE !!,"Ward",?32,"Room-bed",!,"Patient",!?5,"Order",!?20,"Dispense Drug",?64,"U/D",?72,"Needs",!,L
+3 IF F
WRITE !!,$SELECT(WD'="zz":WD,1:"NOT FOUND"),?32,RB,!,PN_" ("_SN_")"
QUIT
+4 ;
GWR ;
+1 SET WD=$GET(^DPT(DFN,.1))
SET RB=$GET(^(.101))
SET PN=$PIECE($GET(^(0)),"^")
IF WD=""
SET WD="zz"
IF RB=""
SET RB="NOT FOUND"
IF PN=""
SET PN=DFN_";DPT("
+2 SET SPN=$EXTRACT(PN,1,20)_"^"_DFN
SET ^TMP("PSGPER",$JOB,WD,SPN)=PN_"^"_RB_"^"_VA("BID")
QUIT
+3 ;
ONI ;
+1 SET ND=$GET(^PS(55,DFN,5,ON,0))
SET DN=$GET(^(.2))
SET SCH=$PIECE($GET(^(2)),"^")
SET MR=$PIECE(ND,"^",3)
SET ND=$$ENNPN^PSGMI($PIECE(ND,"^",2))
SET DO=$PIECE(DN,"^",2)
SET DN=$PIECE(DN,"^")
IF DN=""
SET DN="zz"
+2 IF '$TEST
SET DN=$$ENPDN^PSGMI(DN)
+3 IF MR]""
SET MR=$$ENMRN^PSGMI(MR)
SET SDN=$EXTRACT(DN,1,20)_"^"_ON
SET ^TMP("PSGPER",$JOB,WD,SPN,SDN)=DN_"^"_DO_"^"_MR_"^"_SCH_"^"_$PIECE(ND,"^",2)
QUIT
+4 ;
DDS ;
+1 SET ND1=$GET(^PS(55,DFN,5,ON,1,+ND,0))
SET UD=$PIECE(ND1,"^",2)
SET ND1=$$ENDDN^PSGMI(+ND1)
SET SND1=$EXTRACT(ND1,1,20)_"^"_+ND
SET ND=$PIECE(ND,"^",2)
+2 IF ND#1
SET ND=(ND\1)+1
+3 SET ^TMP("PSGPER",$JOB,WD,SPN,SDN,SND1)=ND1_"^"_UD_"^"_ND
+4 QUIT
+5 ;
PPI ;
+1 SET DFN=$PIECE(PI,"^",2)
SET PN=$PIECE(RB,"^")
SET SN=$PIECE(RB,"^",3)
SET RB=$PIECE(RB,"^",2)
IF 'RF
IF $Y+6>IOSL
DO NP
IF NP["^"
QUIT
+2 WRITE !!,$SELECT(WD'="zz":WD,1:"NOT FOUND"),?32,RB,!,PN," ("_SN_")"
QUIT
+3 ;
OP ;
+1 SET PDN=$PIECE(PX,"^")
SET DO=$PIECE(PX,"^",2)
SET MR=$PIECE(PX,"^",3)
SET SCH=$PIECE(PX,"^",4)
+2 WRITE !?5,PDN," ",DO," ",MR,$SELECT(MR]"":" ",1:""),SCH
+3 QUIT
PRT ; find order info and print same
+1 IF 'RF
IF $Y+4>IOSL
DO NP
IF NP="^"
QUIT
+2 IF 1
SET PDN=$PIECE(PX,"^")
SET UD=$PIECE(PX,"^",2)
SET PX=$PIECE(PX,"^",3)
WRITE !?20,PDN,?62,$JUSTIFY($SELECT('UD:1,$EXTRACT(UD)=".":0_UD,1:UD),5),?72,$JUSTIFY(PX,5)
QUIT
+3 SET ON=$PIECE(DN,"^",2)
SET ND=$GET(^PS(55,DFN,5,ON,0))
SET ND2=$GET(^(2))
SET ND4=$GET(^(4))
SET Y=$PIECE($GET(^(6)),"^")
SET ND0=$GET(^(.1))
SET DO=$PIECE(ND0,"^",2)
+4 ; ,DRGS=$P($G(^(+$O(^PS(55,DFN,5,ON,1,0)),0)),"^")
SET DRG=$$ENDDN^PSGMI($PIECE(ND0,"^"))
SET MR=$$ENMRN^PSGMI(MR)
+5 IF 'RF
WRITE !?5,DRG,?47,DO,?65,$JUSTIFY($SELECT('UD:1,UD=.5:"1/2",UD=.25:"1/4",UD?1".".N:0_UD,1:UD),5),?75,$JUSTIFY(+PX,5)
QUIT
+6 ;
+7 SET SCH=$PIECE(ND2,"^")
SET STRT=$PIECE(ND2,"^",2)
SET STOP=$PIECE(ND2,"^",4)
SET VU=$PIECE(ND4,"^",3)
SET VD=$PIECE(ND4,"^",4)
SET VU=$PIECE($GET(^VA(200,+VU,0)),"^",2)
IF VU=""
SET VU=$PIECE(ND4,"^",3)
+8 FOR Q="STRT","STOP","VD"
SET @Q=$$ENDTC^PSGMI(@Q)
+9 IF $Y
WRITE @IOF
WRITE !!?6,BORD_" PRE-EXCHANGE MED "_BORD,!?6,"#",?73,"#",!?6,"# ",PN,?50,"Ward: ",WD,?73,"#",!?6,"# ("_SN_")",?52,"RB: "_RB,?73,"#",!?6,"#",?73,"#"
+10 WRITE !?6,"# "_DRG,?46,"START: "_STRT,?73,"#",!?6,"# "_$SELECT(DRGS]"":"("_DRGS_")",1:""),?47,"STOP: "_STOP,?73,"#",!?6,"# GIVE: "_$SELECT(DO]"":" "_DO,1:"")_$SELECT(MR]"":" "_MR,1:"")_$SELECT(SCH]"":" "_SCH,1:""),?73,"#"
+11 SET XL=0
IF Y=""
WRITE !?6,"#",?73,"#",!?6,"# (NO SPECIAL INSTRUCTIONS)"
+12 IF '$TEST
WRITE !?6,"#",?73,"#",!?6,"# "
SET Y=$$ENSET^PSGSICHK(Y)
FOR Q=1:1:$LENGTH(Y," ")
SET X=$PIECE(Y," ",Q)
IF $X+$LENGTH(X)>72
SET XL=XL+1
IF $X+$LENGTH(X)>72
WRITE ?73,"#",!?6,"# "
WRITE X_" "
+13 WRITE ?73,"#",!?6,"#",?73,"#",!,?6,"#",?43,"VERIFIED: "_VD,?73,"#",!?6,"#",?49,"BY: "_VU,?73,"#",!?6,"#",?38,"SEND TO FLOOR: "_PX,?73,"#"
+14 SET XL=2-XL
IF XL>0
FOR Q=1:1:XL
WRITE !?6,"#",?73,"#"
+15 WRITE !?6,"#",?73,"#",!?6,"#",?36,"_______________ _______________ #",!?6,"#",?36,"FILLED BY",?56,"CHECKED BY",?73,"#",!?6,BORD_BORD_$EXTRACT(BORD,1,20)
QUIT