1 | PSIVPAT ;BIR/PR-PATIENT COST REPORT ;07 OCT 97 / 9:48 AM
|
---|
2 | ;;5.0; INPATIENT MEDICATIONS ;;16 DEC 97
|
---|
3 | K ^UTILITY($J) S Y=I7 X ^DD("DD") S HEAD=Y,Y=I8 X ^DD("DD") S HEAD=HEAD_" THROUGH "_Y,Y=DT X ^DD("DD") S DATE=Y
|
---|
4 | F IV=0:0 S IV=$O(^PS(50.8,IV)) Q:'IV I $D(^(IV,2)) F DAT=I7-1:0 S DAT=$O(^PS(50.8,IV,2,DAT)) Q:'DAT!(DAT>I8) D ND
|
---|
5 | PRTQUE G:'$D(I6) W S ZTIO=I6,ZTDESC="IV PATIENT COST REPORT (PRINT)",ZTRTN="W^PSIVPAT",ZTDTH=$H
|
---|
6 | S ZTSAVE("^UTILITY($J,")="" F G="I7","I8","I5","I4","I15","I6","HEAD","PC","DATE","DX","PSJSYSU","PSJSYSP0" S ZTSAVE(G)=""
|
---|
7 | S %ZIS="QN",IOP=I6 D ^%ZIS,^%ZTLOAD G K
|
---|
8 | W I '$D(VAIN) S DFN=I5 D ENIV^PSJAC K DFN
|
---|
9 | U IO S DRG="",(TOTDIS,TOTCOS,PC,TOTRT,RT,UD,DEST,TOTCAN)=0 D H G P S:$D(ZTQUEUED) ZTREQ="@"
|
---|
10 | Q
|
---|
11 | ;
|
---|
12 | ND I $D(^PS(50.8,IV,2,DAT,2)) F DA=0:0 S DA=$O(^PS(50.8,IV,2,DAT,2,DA)) Q:'DA I $D(^(DA,0)),$D(^(1,I5,0)) D B
|
---|
13 | Q
|
---|
14 | ;
|
---|
15 | B S G1=^PS(50.8,IV,2,DAT,2,DA,0),DRUG=$P(G1,U),UC=$P(G1,U,5),G1=$P(G1,U,6)
|
---|
16 | S UD=$P(^PS(50.8,IV,2,DAT,2,DA,1,I5,0),U,2),RT=$P(^(0),U,3),DEST=$P(^(0),U,4),CAN=$P(^(0),U,6)
|
---|
17 | S G=$S($D(^UTILITY($J,I5,DRUG)):^(DRUG),1:UC_U_G1),^(DRUG)=$P(G,U,1,2)_U_($P(G,U,3)+UD)_U_(UD-RT-CAN*UC+$P(G,U,4))_U_($P(G,U,5)+RT)_U_($P(G,U,6)+DEST)_U_($P(G,U,7)+CAN)
|
---|
18 | Q
|
---|
19 | ;
|
---|
20 | H ;Header
|
---|
21 | W:$Y @IOF S PC=PC+1 W ?97,$J(DATE,13),!!
|
---|
22 | W !?51,"PATIENT COST REPORT FOR:",?97,"PAGE ",$J(PC,3)
|
---|
23 | W !?51,VADM(1)," PID: ",VA("PID"),!?51,HEAD
|
---|
24 | W !?51,"WARD: ",$S(VAIN(4)]"":$P(VAIN(4),U,2),1:"OUTPATIENT") W:VAIN(5)]"" " ",VAIN(5)
|
---|
25 | W !,?51,"DOB: ",$S(VADM(3)]"":$P(VADM(3),U,2),1:"NF")," ","SEX: ",$S(VADM(5)]"":$P(VADM(5),U,2),1:"NF")
|
---|
26 | W !?51,"Weight (kg): ",$S(+PSJPWT:+PSJPWT,1:"NF")
|
---|
27 | W !?51,"DX: ",$S(VAIN(9)'="":VAIN(9),1:"NF")
|
---|
28 | W !!!!,"DRUG NAME",?39,"DISPENSED",?57,"(DESTROYED)",?78,"RECYCLED",?101,"CANCELLED",?123,"DRUG COST",!
|
---|
29 | F LN=1:1:132 W "="
|
---|
30 | W !
|
---|
31 | Q
|
---|
32 | P ;
|
---|
33 | I '$D(^UTILITY($J)) W !!,$C(7),"No data exists." W:$E(IOST)'="C"&($Y) @IOF D ^%ZISC G K
|
---|
34 | F JJ=0:0 S DRG=$O(^UTILITY($J,I5,DRG)) Q:DRG="" D P1
|
---|
35 | G P2
|
---|
36 | P1 ;
|
---|
37 | S G=^UTILITY($J,I5,DRG),C=$P(G,U,2),CC=$P(^DD(52.6,2,0),U,3),CC=$P(CC,";",C),CC=$P(CC,":",2),C=CC K CC
|
---|
38 | S TOTDIS=TOTDIS+$P(G,U,3),TOTCOS=TOTCOS+$P(G,U,4),TOTRT=TOTRT+$P(G,U,5),TOTCAN=TOTCAN+$P(G,U,7)
|
---|
39 | W !,$E(DRG,1,37),?38,$J($P(G,U,3),10,2)_" "_C,?60,$J($P(G,U,6),8,2),?78,$J($P(G,U,5),8,2),?99,$J($P(G,U,7),10,2),?116,"$",$J($P(G,U,4),15,4)
|
---|
40 | D:$Y+4>IOSL H
|
---|
41 | Q
|
---|
42 | P2 W !,?117,"==============="
|
---|
43 | W !,?20,"GRAND TOTAL:",?116,"$",$J(TOTCOS,15,4) D TM^PSIVDCR1
|
---|
44 | K ;
|
---|
45 | S:$D(ZTQUEUED) ZTREQ="@"
|
---|
46 | K ^UTILITY($J),DRUG,DRG,C,G1,DATE,G,HEAD,LN,DA,RT,ST,TOTCOS,TOTDIS,TOTRT,UC,UD,PC,I8,I7,I5,SEX,WT,Y,X3,X4,X5,DX,IV,Z,%I,CAN,DAT,DEST,TOTCAN,%H Q
|
---|