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

PSIVPAT.m

Go to the documentation of this file.
PSIVPAT ;BIR/PR-PATIENT COST REPORT ;07 OCT 97 / 9:48 AM 
 ;;5.0; INPATIENT MEDICATIONS ;;16 DEC 97
 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
 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
PRTQUE G:'$D(I6) W S ZTIO=I6,ZTDESC="IV PATIENT COST REPORT (PRINT)",ZTRTN="W^PSIVPAT",ZTDTH=$H
 S ZTSAVE("^UTILITY($J,")="" F G="I7","I8","I5","I4","I15","I6","HEAD","PC","DATE","DX","PSJSYSU","PSJSYSP0" S ZTSAVE(G)=""
 S %ZIS="QN",IOP=I6 D ^%ZIS,^%ZTLOAD G K
W I '$D(VAIN) S DFN=I5 D ENIV^PSJAC K DFN
 U IO S DRG="",(TOTDIS,TOTCOS,PC,TOTRT,RT,UD,DEST,TOTCAN)=0 D H G P S:$D(ZTQUEUED) ZTREQ="@"
 Q
 ;
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
 Q
 ;
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)
 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)
 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)
 Q
 ;
H ;Header
 W:$Y @IOF S PC=PC+1 W ?97,$J(DATE,13),!!
 W !?51,"PATIENT COST REPORT FOR:",?97,"PAGE ",$J(PC,3)
 W !?51,VADM(1)," PID: ",VA("PID"),!?51,HEAD
 W !?51,"WARD: ",$S(VAIN(4)]"":$P(VAIN(4),U,2),1:"OUTPATIENT") W:VAIN(5)]"" "  ",VAIN(5)
 W !,?51,"DOB: ",$S(VADM(3)]"":$P(VADM(3),U,2),1:"NF"),"  ","SEX: ",$S(VADM(5)]"":$P(VADM(5),U,2),1:"NF")
 W !?51,"Weight (kg): ",$S(+PSJPWT:+PSJPWT,1:"NF")
 W !?51,"DX: ",$S(VAIN(9)'="":VAIN(9),1:"NF")
 W !!!!,"DRUG NAME",?39,"DISPENSED",?57,"(DESTROYED)",?78,"RECYCLED",?101,"CANCELLED",?123,"DRUG COST",!
 F LN=1:1:132 W "="
 W !
 Q
P ;
 I '$D(^UTILITY($J)) W !!,$C(7),"No data exists." W:$E(IOST)'="C"&($Y) @IOF D ^%ZISC G K
 F JJ=0:0 S DRG=$O(^UTILITY($J,I5,DRG)) Q:DRG=""  D P1
 G P2
P1 ;
 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
 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)
 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)
 D:$Y+4>IOSL H
 Q
P2 W !,?117,"==============="
 W !,?20,"GRAND TOTAL:",?116,"$",$J(TOTCOS,15,4) D TM^PSIVDCR1
K ;
 S:$D(ZTQUEUED) ZTREQ="@"
 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