VistA-WorldVistAEHR/r/CONTROLLED_SUBSTANCES-PSD/PSDLBLB.m

51 lines
2.7 KiB
Mathematica

PSDLBLB ;B'ham ISC/JPW - CS Print for Patient ID List ; 2 Mar 94
;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
S PSDWN="" F S PSDWN=$O(PSDW(PSDWN)) Q:PSDWN="" F PSD1=0:0 S PSD1=$O(^DPT("ACN",PSDWN,PSD1)) Q:'PSD1 I $D(^DPT(PSD1,0)) D
.S DFN=PSD1 D DEM^VADPT S PATN=$S('VAERR:VADM(1),1:"UNKNOWN"),SSN=$P(VADM(2),"^"),PATN=PATN_" ("_VA("BID")_")"
.S VAINDT=PSDT D INP^VADPT S PSDRM=VAIN(5)
.K DFN,VADM,VAIN,VAINDT
.S PSDCNT=PSDCNT+1,^TMP("PSDLBLP",$J,PSDWN,$S(PSDRM]"":PSDRM,1:0),PSDCNT)=SSN_"^"_PATN
PRINT ;print labels
S (PSDOUT,PG)=0,$P(LN,"-",80)="",(PSDX1,PSDCNT)=1
I '$D(^TMP("PSDLBLP",$J)) D HDR W !!,?15,"**** NO PATIENT WARD INFO ****",!! G DONE
D HDR
S PSDN="" F S PSDN=$O(^TMP("PSDLBLP",$J,PSDN)) Q:PSDN=""!(PSDOUT) Q:PSDOUT D Q:PSDOUT
.S PSD="" F S PSD=$O(^TMP("PSDLBLP",$J,PSDN,PSD)) Q:PSD=""!(PSDOUT) D:$Y+26>IOSL HDR Q:PSDOUT F PSD1=0:0 S PSD1=$O(^TMP("PSDLBLP",$J,PSDN,PSD,PSD1)) Q:'PSD1!(PSDOUT) S NODE=^(PSD1) D
..I $Y+26>IOSL D HDR Q:PSDOUT
..W !,$P(NODE,U,2),?45,$S(PSD=0:"NONE",1:PSD)," ",$G(PSDN)
..W ! I $D(PSDPRT) W @PSDBAR1,$P(NODE,"^"),@PSDBAR0,!!
DONE I $E(IOST)'="C" W @IOF
I $E(IOST,1,2)="C-",'PSDOUT W ! K DIR,DIRUT S DIR(0)="EA",DIR("A")="END OF REPORT! Press <RET> to return to the menu" D ^DIR K DIR
END ;kill variables and exit
D KVAR^VADPT K VA
K %,%H,%ZIS,ANS,DA,DFN,DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,JJ,JJ1,JJ2,LN,NODE,POP,PATN,PG,PSD,PSD1,PSDBAR0,PSDBAR1,PSDCNT,PSDN,PSDOUT
K PSDPRT,PSDR,PSDRM,PSDT,PSDW,PSDWN,PSDX1,PSDX2,SSN,VADM,VAERR,VAIN,VAINDT,X,Y,ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTSK
K ^TMP("PSDLBLP",$J)
D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
Q
HDR ;prints header information
I $E(IOST,1,2)="C-",PG K DA,DIR S DIR(0)="E" D ^DIR K DIR I 'Y S PSDOUT=1 Q
S PG=PG+1,PSD(1)=0 W:$Y @IOF W !,"Patient ID List for "
;F S PSD(1)=$O(PSDW(PSD(1))) Q:PSD(1)']"" W PSD(1)
W $S($G(PSD2)]"":PSD2,$G(PSDN)]"":PSDN,$G(NAOUN)]"":NAOUN,$O(PSDW(""))]"":$O(PSDW("")),1:"")
W " Printed: ",$$HTE^XLFDT($H,"P"),?70,"Page: ",PG,!
W "PATIENT",?45,"ROOM-BED",!,LN,!!
Q
SAVE ;save queued variables
S ZTSAVE("PSDW(")="",ZTSAVE("PSD2")=""
S:$D(NAOUN) ZTSAVE("NAOUN")=""
Q
ASKN ;ask nursing location
K DA,DIC S DIC=211.4,DIC(0)="QEA",DIC("A")="Select Nursing Location: "
W ! D ^DIC K DIC I Y<0 S PSDOUT=1 Q
N PSD S PSD2=$P($P($G(^SC(+$P(Y,U,2),0)),U)," ",2)
D GETS^DIQ(211.4,+Y_",","2*","","PSD") S PSD(1)=0
F S PSD(1)=$O(PSD(211.41,PSD(1))) Q:PSD(1)']"" D:$G(PSD(211.41,PSD(1),.01))]""
.S PSDW($G(PSD(211.41,PSD(1),.01)))=0
Q
WARD2 W !!,"Compiling Ward data for ",NAOUN,"..."
F JJ=0:0 S JJ=$O(^PSD(58.8,"D",JJ)) Q:'JJ F JJ1=0:0 S JJ1=$O(^PSD(58.8,"D",JJ,JJ1)) Q:'JJ1 F JJ2=0:0 S JJ2=$O(^PSD(58.8,"D",JJ,JJ1,JJ2)) Q:('JJ2)!(JJ2'=NAOU) D
.Q:$P($G(^DIC(42,+JJ1,0)),"^")']""
.S PSDW($P($G(^DIC(42,+JJ1,0)),"^"))=+JJ1_"^"_$P($G(^DIC(42,+JJ1,0)),"^")
Q