source: WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSGVBWU.m@ 1076

Last change on this file since 1076 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 7.6 KB
Line 
1PSGVBWU ;BIR/CML3,MV-GET ORDERS FOR COMPLETE/VERIFY ;15 May 98 / 9:26 AM
2 ;;5.0; INPATIENT MEDICATIONS ;**3,44,47,67,58,110,111**;16 DEC 97
3 ;
4 ; Reference to ^PS(55 is supported by DBIA 2191.
5 ;
6ECHK(DFN,O,DT,SD) ;
7 N OK S OK=0
8 I $P($G(^PS(55,DFN,5,O,0)),U,9)'["D" S ND=$G(^(0)) Q:ND="" 0 S ND4=$G(^(4)) D
9 .;I "DE"'[$P($G(^PS(55,DFN,5,O,0)),U,9) S ND=$G(^(0)) Q:ND="" 0 S ND4=$G(^(4)) D
10 .I $S(SD>PSGDT:$S(ND="":1,'$P(ND4,U,$S(PSJSYSU:PSJSYSU,1:1)):1,$P(ND4,U,13):1,$P(ND4,U,19):1,$P(ND4,U,23):1,1:$P(ND4,U,16)),$P(ND,U,7)="O":$S(ND4="":1,1:'$P(ND4,U,$S(PSJSYSU:PSJSYSU,1:1))),1:$P(ND4,U,16)) S OK=1
11 Q OK
12ECHK2(DFN,O,DT,SD) ;
13 N OK S OK=0
14 I $P($G(^PS(55,DFN,"IV",O,0)),U,17)'["D" S ND=$G(^(0)) Q:ND="" 0 S ND4=$G(^(4)) D:SD>PSGDT
15 . I (+PSJSYSU=1)&('$P(ND4,U,+PSJSYSU)) S OK=1 Q
16 . I (+PSJSYSU=3)&('$P(ND4,U,+PSJSYSU+1)) S OK=1 Q
17 Q OK
18 ;
19SET ;
20 I ON["P",$G(PSJCOM)]"",$G(PRNTON)=+PSJCOM Q
21 I ON["P",$G(PSJCOM)]"" S PRNTON=+PSJCOM,ON=+PSJCOM
22 S PSJPRIO=$S($G(PSJPRIO)="S":"A",1:"Z"),^TMP("PSJON",$J,PSJPRIO,LD_U_ON)=""
23 Q
24 ;
25CNTORDRS ; Display # pending orders by type and ward group
26 K ^TMP("PSJ",$J) D:$G(IOST(0)) ENS^%ZISS
27 N DFN,DIRUT,ON,TYP,PSGODT,PSJWD,PSJWG,X,X1,X2
28 S X1=$P(PSGDT,"."),X2=-2 D C^%DTC S PSGODT=X_(PSGDT#1)
29 W !!,"Searching for Pending and Non-Verified orders"
30 F STAT="P","N","I" F DFN=0:0 S DFN=$O(^PS(53.1,"AS",STAT,DFN)) Q:'DFN D
31 .W "." S PSJWG=$$WGNM($P($G(^DPT(DFN,.1)),U))
32 .F ON=0:0 S ON=$O(^PS(53.1,"AS",STAT,DFN,ON)) Q:'ON D
33 .. N OWG,A
34 .. S OWG=PSJWG I PSJWG="ZZ",$D(^PS(53.1,ON,"DSS")) S A=^("DSS"),PSJWG=$$CGNM(A,OWG)
35 ..;S TYP=$S(STAT="N"!(STAT="I"):"N",1:$P($G(^PS(53.1,ON,0)),U,4)) D CNTSET(PSJWG,$F("FIUN",TYP)-1)
36 ..S TYP=$P($G(^PS(53.1,ON,0)),U,4),OTYP=$S((STAT="P")&(TYP="F"):1,(STAT="P")&(TYP="I"):1,(STAT="P")&(TYP="U"):2,TYP="F":3,TYP="I":3,1:4) D CNTSET(PSJWG,OTYP) S PSJWG=OWG
37 ;
38 I '$D(^XTMP("PSJPVNV")) D
39 .N PSJXR S PSJXR=$S(+PSJSYSU=3:"APV",1:"ANV") F DFN=0:0 S DFN=$O(^PS(55,PSJXR,DFN)) Q:'DFN D
40 ..W "." D IN5^VADPT S PSJPAD=+VAIP(3) K VAIP F PSGORD=0:0 S PSGORD=$O(^PS(55,PSJXR,DFN,PSGORD)) Q:'PSGORD D
41 ...S PSGST=$P($G(^PS(55,DFN,5,PSGORD,0)),U,7),PSGFD=$P($G(^(2)),U,4) I ((PSGST="O")&(PSJPAD>0)&(PSGFD>PSJPAD))!((PSGST'="O")&(PSGFD'<PSGODT)) I $$ECHK(DFN,PSGORD,PSGDT,PSGFD) S PSJWD=$P($G(^DPT(DFN,.1)),U) I PSJWD]"" D
42 ....S PSJWG=$$WGNM(PSJWD)
43 .... N OWG,A
44 .... S OWG=PSJWG I PSJWG="ZZ",$D(^PS(55,DFN,5,PSGORD,8)) S A=^(8),PSJWG=$$CGNM(A,OWG)
45 .... D CNTSET(PSJWG,4) S PSJWG=OWG
46 .N PSJXR S PSJXR=$S(+PSJSYSU=3:"APIV",1:"ANIV") F DFN=0:0 S DFN=$O(^PS(55,PSJXR,DFN)) Q:'DFN D
47 ..W "." D IN5^VADPT S PSJPAD=+VAIP(3) K VAIP F PSGORD=0:0 S PSGORD=$O(^PS(55,PSJXR,DFN,PSGORD)) Q:'PSGORD D
48 ...S PSGFD=$P($G(^PS(55,DFN,"IV",PSGORD,0)),U,3) I $$ECHK2(DFN,PSGORD,PSGDT,PSGFD) S PSJWD=$P($G(^DPT(DFN,.1)),U) I PSJWD]"" D
49 ....S PSJWG=$$WGNM(PSJWD)
50 .... N OWG,A
51 .... S OWG=PSJWG I PSJWG="ZZ",$D(^PS(55,DFN,"IV",PSGORD,"DSS")) S A=^("DSS"),PSJWG=$$CGNM(A,OWG)
52 .... D CNTSET(PSJWG,3) S PSJWG=OWG
53 I $D(^XTMP("PSJPVNV")) S PSJWD="" F S PSJWD=$O(^DPT("CN",PSJWD)) Q:PSJWD="" S PSJWG=$$WGNM(PSJWD) F DFN=0:0 S DFN=$O(^DPT("CN",PSJWD,DFN)) Q:'DFN D
54 .; removed ref to ^DGPM
55 .;S PSJPAD=9999999.9999999-$O(^DGPM("ATID1",DFN,0))
56 .D IN5^VADPT S PSJPAD=+VAIP(3) K VAIP
57 .W "."
58 .F PSJST="C","O","OC","P","R" F PSGFD=$S(PSJST="O":PSJPAD,1:PSGODT):0 S PSGFD=$O(^PS(55,DFN,5,"AU",PSJST,PSGFD)) Q:'PSGFD D
59 ..F PSGORD=0:0 S PSGORD=$O(^PS(55,DFN,5,"AU",PSJST,PSGFD,PSGORD)) Q:'PSGORD I $$ECHK(DFN,PSGORD,PSGDT,PSGFD) D
60 ... N OWG,A
61 ... S OWG=PSJWG I PSJWG="ZZ",$D(^PS(55,DFN,"IV",PSGORD,"DSS")) S A=^("DSS"),PSJWG=$$CGNM(A,OWG)
62 ... D CNTSET(PSJWG,3) S PSJWG=OWG
63 .F SD=+PSJPAD:0 S SD=$O(^PS(55,PSGP,"IV","AIS",SD)) Q:'SD F O=0:0 S O=$O(^PS(55,PSGP,"IV","AIS",SD,O)) Q:'O S ON=O_"V" I $$ECHK2(PSGP,O,PSGDT,SD) D
64 .. N OWG,A
65 .. S OWG=PSJWG I PSJWG="ZZ",$D(^PS(55,DFN,"IV",PSGORD,"DSS")) S A=^("DSS"),PSJWG=$$CGNM(A,OWG)
66 .. D CNTSET(PSJWG,3) S PSJWG=OWG
67 ;
68DISPLAY ;
69 N H,I
70 D CNTHEAD I '$D(^TMP("PSJ",$J)) W ?21,"No pending/non-verified orders found.",! Q
71 S H("WG")="Ward Groups",H("CG")="Clinic Groups",H("C")="Clinics"
72 F I="WG","CG","C" I $D(^TMP("PSJ",$J,I)) D
73 . W !,H(I),!!
74 . S WG="" F S WG=$O(^TMP("PSJ",$J,I,WG)) Q:WG=""!$D(DIRUT) S X=$G(^(WG)) D
75 .. ;W $S(WG="ZZ":"^OTHER",1:WG),?30,$J(+X,6),?44,$J(+$P(X,U,2),6),?58,$J(+$P(X,U,3),6),?72,$J(+$P(X,U,4),6),!
76 .. W $S(WG="ZZ":"^OTHER",1:WG),?26,$J(+X,6),?36,$J(+$P(X,U,2),6),?51,$J(+$P(X,U,3),6),?63,$J(+$P(X,U,4),6),!
77 .. I $Y>(IOSL-2) N DIR S DIR(0)="E" D ^DIR Q:$D(DIRUT) D CNTHEAD
78 Q
79CNTSET(WG,X) ; Update counters for ward group totals
80 ; Input: WG - Ward Group IEN
81 ; X - piece identifying order type.
82 I $P(WG,"^",2)="" S $P(^TMP("PSJ",$J,"WG",WG),U,X)=$P($G(^TMP("PSJ",$J,"WG",WG)),U,X)+1 Q
83 I $P(WG,"^",2)]"" S $P(^TMP("PSJ",$J,$P(WG,"^",2),$P(WG,"^")),U,X)=$P($G(^TMP("PSJ",$J,$P(WG,"^",2),$P(WG,"^"))),U,X)+1 Q
84 Q
85 ;
86WGNM(WD) ; DETERMINE WARD GROUP NAME
87 N WG
88 I WD]"" S WG=+$O(^PS(57.5,"AB",+$O(^DIC(42,"B",WD,0)),0)),WG=$P($G(^PS(57.5,WG,0)),U)
89 S:$G(WG)="" WG="ZZ"
90 Q WG
91 ;
92CGNM(A,WGN) ;DETERMINE CLINIC GROUP NAME
93 N CGN,B
94 ;I $P(A,"^",2)="" Q WGN
95 S CGN="",B=$O(^PS(57.8,"AC",+A,"")) I B]"" S CGN=$P(^PS(57.8,B,0),"^")_"^CG"
96 I $P(CGN,"^")="" S CGN=$P(^SC(+A,0),"^")_"^C"
97 Q CGN
98 ;
99CNTHEAD ; Header for order count.
100 ;W @IOF,!,?16,"Pending/Non-Verified Order Totals by Ward Group",!!,?29,"Pending",?43,"Pending",?57,"Pending",!
101 ;W "Ward Group",?30,"Fluids",?48,"IV",?55,"Unit Dose",?66,"Non-Verified",!!
102 W @IOF,!,?16,"Pending/Non-Verified Order Totals by Ward Group/Clinic Location",!!,?33,"Pending",?56,"Non-Verified",!
103 W "Ward Group/Clinic Location",?30,"IV",?40,"UD",?55,"IV",?67,"UD",!
104 Q
105 ;
106ENGORD ; get and sort order
107 N PSJCOM,PRNTON
108 D NOW^%DTC S PSGDT=+$E(%,1,12),X1=$P(%,"."),X2=-2 D C^%DTC S PSGODT=X_(PSGDT#1),HDT=$$ENDTC^PSGMI(PSGDT),UDU=$P(PSJSYSU,";",3)>1 K ^TMP("PSJON",$J)
109 W !!,"...a few moments, please..."
110 I PSJTOO'=2 F PSGO2=+PSJPAD:0 S PSGO2=$O(^PS(55,PSGP,5,"AUS",PSGO2)) Q:'PSGO2 Q:PSGO2>PSGDT F PSGO3=0:0 S PSGO3=$O(^PS(55,PSGP,5,"AUS",PSGO2,PSGO3)) Q:'PSGO3 I $D(^PS(55,PSGP,5,PSGO3,0)) S PSGO4=^(0) I "DEH"'[$E($P(PSGO4,"^",9)) D ENUH
111 K PSGO1,PSGO2,PSGO3,PSGO4
112 I PSJTOO'=1 F SD="I","P" F O=0:0 S O=$O(^PS(53.1,"AS",SD,PSGP,O)) Q:'O D
113 .S ND=$G(^PS(53.1,O,0)),PSJPRIO=$P($G(^(.2)),U,4),PSJCOM=$P($G(^(.2)),U,8),LD=$P($G(^PS(53.1,O,0)),U,16),ON=O_"P"
114 .I $S(PSJPAC=3:1,PSJPAC=1&($P(ND,U,4)="U"):1,PSJPAC=2&($P(ND,U,4)'="U"):1,+$P(ND,U,13)&$G(PSJRNF):1,+$P(ND,U,13)&$G(PSJIRNF):1,1:0) D SET
115 Q:PSJTOO=2
116 F ST="C","O","OC","P","R" F SD=+PSJPAD:0 S SD=$O(^PS(55,PSGP,5,"AU",ST,SD)) Q:'SD F O=0:0 S O=$O(^PS(55,PSGP,5,"AU",ST,SD,O)) Q:'O S ON=O_"U" I $$ECHK(PSGP,O,PSGDT,SD) S LD=$P($G(^PS(55,PSGP,5,O,0)),U,16) D SET
117 F O=0:0 S O=$O(^PS(53.1,"AS","N",PSGP,O)) Q:'O S LD=$P($G(^PS(53.1,O,0)),U,16),PSJCOM=$P($G(^(.2)),U,8) S ON=O_"P" D SET
118 F SD=+PSJPAD:0 S SD=$O(^PS(55,PSGP,"IV","AIS",SD)) Q:'SD F O=0:0 S O=$O(^PS(55,PSGP,"IV","AIS",SD,O)) Q:'O S ON=O_"V" I $$ECHK2(PSGP,O,PSGDT,SD) S LD=$P($G(^PS(55,PSGP,"IV",O,2)),U) D SET
119 Q
120 ;
121ENUH ;
122 S $P(^PS(55,PSGP,5,PSGO3,0),"^",9)="E" D EN1^PSJHL2(PSGP,"SC",PSGO3_"U")
123 Q
124GOTOP ; Skip to a specific patient in list.
125 I '$$HIDDEN^PSJLMUTL("JUMP") S VALMBCK="R" Q
126 K PSJGOTO,DIR S DIR(0)="SM^J:Jump to a specific patient;E:Exit",DIR("A")="Select Action: ",DIR("B")="Exit" D ^DIR
127 Q:"JE"'[Y
128 I Y="E" S PSJGOTO=Y Q
129 K DIR S DIR(0)="PO^2:AEMQZ",DIR("S")="I $P(^(0),U)]"""",$D(^TMP(""PSJSELECT"",$J,""B"",$P(^(0),U)))",DIR("??")="^D GOTOPH^PSGVBWU" D ^DIR I Y<0 S PSGTOTO=Y Q
130 S VALMBCK="R",PSJGOTO=$S($P(Y,U,2)="":"E",1:$O(^TMP("PSJSELECT",$J,"B",$P(Y,U,2),0)))
131 Q
132 ;
133GOTOPH ;
134 F X=0:0 S X=$O(^TMP("PSJSELECT",$J,X)) Q:'X W !,$P($G(^TMP("PSJSELECT",$J,X)),U) I X#IOSL=0 N DIR S DIR(0)="E" D ^DIR Q:$D(DIRUT)
135 Q
136 Q
Note: See TracBrowser for help on using the repository browser.