source: FOIAVistA/trunk/r/DIETETICS-FH/FHSP1.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 7.0 KB
Line 
1FHSP1 ; HISC/NCA - Consolidated Standing Orders List ;7/28/94 12:59
2 ;;5.5;DIETETICS;**5**;Jan 28, 2005;Build 53
3 ;11/09/05 - modified for SO patch
4 ;if FHOPT=1, it's consolidated
5 ;if FHOPT=2,it's print labels
6 ;if FHOPT=3, it's tabulated
7E1 ; Set Consolidated List flag
8 S FHOPT=1 G E3
9E2 ; Set Print Label flag
10 S FHOPT=2
11E3 S FHP=$O(^FH(119.72,0)) I FHP'<1,$O(^FH(119.72,FHP))<1 G D2
12D0 R !!,"Select SERVICE POINT (or ALL): ",X:DTIME G:'$T!("^"[X) KIL D:X="all" TR^FH I X="ALL" S FHP=0
13 E K DIC S DIC="^FH(119.72,",DIC(0)="EMQ" D ^DIC G:Y<1 D0 S FHP=+Y
14D2 R !!,"Select Meal (B,N,E,or ALL): ",MEAL:DTIME G:'$T!(U[MEAL) KIL S X=MEAL D TR^FH S MEAL=X S:$P("ALL",MEAL,1)="" MEAL="A"
15 I "BNEA"'[MEAL!(MEAL'?1U) W *7,!,"Enter B for Breakfast, N for Noon, E for Evening or ALL for all meals" G D2
16 S D3="" G:FHOPT=2 D5
17D3 R !!,"Consolidated List Only? Y//",X:DTIME G:'$T!(X="^") KIL S:X="" X="Y" D TR^FH I $P("YES",X,1)'="",$P("NO",X,1)'="" W *7," Answer YES or NO" G D3
18 S X=$E(X,1),D3=1 S:X="Y" D3=D3+1
19D5 W ! K DIR,LABSTART S DIR(0)="NA^1:10",DIR("A")="If using laser label sheets, what row do you want to begin printing at? ",DIR("B")=1 D ^DIR
20 Q:$D(DIRUT) S LABSTART=Y
21 W:'D3 !!,"Place Labels in Printer"
22PR K IOP S %ZIS="MQ",%ZIS("A")="Select "_$S('D3:"LABEL",1:"LIST")_" Printer: " W ! D ^%ZIS K %ZIS,IOP G:POP KIL
23 I $D(IO("Q")) S FHPGM="Q1^FHSP1",FHLST="D3^FHOPT^FHP^MEAL^LABSTART" D EN2^FH G KIL
24 U IO D Q1 D ^%ZISC K %ZIS,IOP G KIL
25Q1 ; Print Standing Orders List or Labels
26 K ^TMP($J),C,D,N S (CHK,N1,PG)=0 D NOW^%DTC S NOW=%,DT=%\1
27 S COUNT=0,LINE=1,DTP=NOW D DTP^FH S DTR=DTP
28 I FHOPT=2 S LAB=$P($G(^FH(119.9,1,"D",IOS,0)),"^",2) S:'LAB LAB=1
29 S FHMLSAV=MEAL
30 I MEAL="A" S MEAL="B" D Q2 S MEAL="N" D Q2 S MEAL="E"
31 D Q2
32 I $G(LAB)>2 D DPLL^FHLABEL Q
33 F L=1:1:$S('D3:18,1:1) W !
34 Q
35Q2 S T0=NOW\1_$S(MEAL="B":".07",MEAL="N":".11",1:".17"),TT=0
36 F W1=0:0 S W1=$O(^FH(119.6,W1)) Q:W1<1 D DP I DP'="" D P0 F FHDFN=0:0 S FHDFN=$O(^FHPT("AW",W1,FHDFN)) Q:FHDFN<1 S ADM=^FHPT("AW",W1,FHDFN) D ADD
37 ;check and include outpatient stnading orders.
38 D ADDO
39 ;
40 G:FHOPT=2 ^FHSP11
41 S DTP=DT D DTP^FH S DTE=DTP_" "_$S(MEAL="B":"Break",MEAL="N":"Noon",1:"Even")
42 G:D3=2 CON
43 K S F K=0:0 S K=$O(D(K)) Q:K="" S X=$G(^FH(119.72,K,0)),N2=$P(X,"^",1),N3=$P(X,"^",4) S:N3="" N3=$E(N2,1,6) S S(N3,K)=$E(N3,1,6)
44 S A1="" F S A1=$O(S(A1)) Q:A1="" F K=0:0 S K=$O(S(A1,K)) Q:K="" S N2=$G(S(A1,K)) D LST
45 K C,D,N Q
46ADD Q:ADM<1
47 D CHK I K2 F K2=0:0 S K2=$O(^FHPT("ASP",FHDFN,ADM,K2)) Q:K2<1 S Y=^FHPT(FHDFN,"A",ADM,"SP",K2,0) D A1
48 Q
49 ;
50A1 D PATNAME^FHOMUTL I DFN="" Q
51 S Y=$P(Y,"^",2,3)_"^"_$P(Y,"^",8) Q:Y?."^" I FHOPT=2 S Y=Y_"^"_IS,RM=$G(^DPT(DFN,.101)),WRD=P0_$E(WRDN,1,27-$L(RM))_"/"_RM,^TMP($J,"SOL",SP,WRD,FHDFN,K2)=Y Q
52 S FHORD=$P(Y,"^",1),M1=$P(Y,"^",2)
53 I FHORD,M1[MEAL S:'$D(N(FHORD,SP)) N(FHORD,SP)=0 S Q=$P(Y,"^",3),N(FHORD,SP)=N(FHORD,SP)+$S(Q:Q,1:1) S:'$D(C(MEAL,SP)) C(MEAL,SP)=0 I TT'=FHDFN S C(MEAL,SP)=C(MEAL,SP)+1,TT=FHDFN
54 Q
55CHK S K2=0,X1=$G(^FHPT(FHDFN,"A",ADM,0)),FHORD=$P(X1,"^",2),IS=$P(X1,"^",10),X1=$P(X1,"^",3) G:FHORD<1 C1
56 I IS S IS=$P($G(^FH(119.4,IS,0)),"^",3) S:IS'="N" IS=""
57 I X1>1,X1'>T0 G C2
58C0 I '$D(^FHPT(FHDFN,"A",ADM,"DI",FHORD,0)) G C2
59 S X1=$P(^FHPT(FHDFN,"A",ADM,"DI",FHORD,0),"^",8) I X1="" G C1
60 S:X1="D" X1="T" Q:'$D(S(X1)) S:DP[X1 K2=1 S:K2 SP=S(X1)
61C1 K FHORD,A1,K,X1 Q
62C2 S A1=0 F K=0:0 S K=$O(^FHPT(FHDFN,"A",ADM,"AC",K)) Q:K<1!(K>T0) S A1=K
63 G:'A1 C1 S FHORD=$P(^FHPT(FHDFN,"A",ADM,"AC",A1,0),"^",2) G:FHORD'<1 C0 K ^FHPT(FHDFN,"A",ADM,"AC",A1) G C2
64 ;
65DP K S S DP=""
66 F L=5,6 S X=$P($G(^FH(119.6,W1,0)),"^",L) I X=FHP!('FHP) S:X S($E("TC",L-4))=X,D(X)="",DP=DP_$E("TC",L-4)
67 Q
68P0 S X=^FH(119.6,W1,0),P0=$P(X,"^",4),P0=$S(P0<1:99,P0<10:"0"_P0,1:P0),WRDN=$P(X,"^",1) Q
69 ;
70LST D HDR1 S NX="" F S NX=$O(^FH(118.3,"B",NX)) Q:NX="" F KK=0:0 S KK=$O(^FH(118.3,"B",NX,KK)) Q:KK<1 S Z=$G(N(KK,K)) D:$Y>(IOSL-6) HDR1 I Z W !?(80-30\2),$J(Z,6)," ",$P(^FH(118.3,KK,0),"^",1)
71 S N1=N1+$G(C(MEAL,K))
72 D PP S N1=0 Q
73CON K S S L1=36
74 F K=0:0 S K=$O(D(K)) Q:K="" S X=^FH(119.72,K,0),N2=$P(X,"^",1),N3=$P(X,"^",4) S:N3="" N3=$E(N2,1,6) S S(N3,K)=$J(N3,8),L1=L1+8
75 S:L1<80 L1=80 D HDR
76 S NX="" F S NX=$O(^FH(118.3,"B",NX)) Q:NX="" F KK=0:0 S KK=$O(^FH(118.3,"B",NX,KK)) Q:KK<1 I $D(N(KK)) D SOR
77 W !!,"# OF PATIENTS",?31
78 S X="" F S X=$O(S(X)) Q:X="" F K=0:0 S K=$O(S(X,K)) Q:K="" S Z=$G(C(MEAL,K)) W $S(Z:$J(Z,6),1:$J("",6))," " S N1=N1+Z
79 W $S(N1:$J(N1,6),1:$J("",6))
80 S N1=0 K C,D,N Q
81SOR D:$Y>(IOSL-6) HDR
82 W !,$P($G(^FH(118.3,KK,0)),"^",1),?31
83 S Z1=0,X="" F S X=$O(S(X)) Q:X="" F K=0:0 S K=$O(S(X,K)) Q:K="" S Z=$G(N(KK,K)) W $S(Z:$J(Z,6),1:$J("",6))," " S Z1=Z1+Z
84 W $S(Z1:$J(Z1,6),1:$J("",6))
85 Q
86PP W !!?(80-21\2),"**** PATIENTS = ",N1," ****",! Q
87HDR ; Header for Consolidated List
88 W:'($E(IOST,1,2)'="C-"&'PG) @IOF S PG=PG+1
89 W !,DTR,?(L1-11),"Page ",PG,!!?(L1-55\2),"C O N S O L I D A T E D S T A N D I N G O R D E R S",!!?(L1-$L(DTE)\2),DTE,!!?29
90 S X="" F S X=$O(S(X)) Q:X="" F K=0:0 S K=$O(S(X,K)) Q:K="" W S(X,K)
91 W " TOTAL",! Q
92HDR1 ; Header for Standing Order List
93 W:'($E(IOST,1,2)'="C-"&'PG) @IOF S PG=PG+1 W !,DTR,?69,"Page ",PG,!!?20,"S T A N D I N G O R D E R S L I S T"
94 W !?(80-$L(N2)\2),N2,!?(80-$L(DTE)\2),DTE,! Q
95 ;
96ADDO ;process outpatient STANDING ORDER for consolidated, print labels and tabulated reports.
97 S IS=""
98 F FHI=0:0 S FHI=$O(^FHPT("ASPO",FHI)) Q:FHI'>0 F FHJ=0:0 S FHJ=$O(^FHPT("ASPO",FHI,FHJ)) Q:FHJ'>0 D
99 .S FHOPDAT=^FHPT(FHI,"OP",FHJ,0)
100 .S FHDATE=$P(FHOPDAT,U,1)
101 .Q:$P(FHOPDAT,U,15)="C"
102 .Q:FHDATE'=DT
103 .S RM="",RMIEN=$P(FHOPDAT,U,18) I $G(RMIEN),$D(^DG(405.4,RMIEN,0)) S RM=$E($P(^DG(405.4,RMIEN,0),U,1),1,10)
104 .S FHLOC=$P(FHOPDAT,U,3)
105 .F K2=0:0 S K2=$O(^FHPT("ASPO",FHI,FHJ,K2)) Q:K2'>0 D
106 ..S Y=^FHPT(FHI,"OP",FHJ,"SP",K2,0),(SP,WRD)="***"
107 ..Q:$P(Y,U,6) ;quit if cancelled.
108 ..S (FHLODAT,FHSER1,FHSER2,FHSERV,FHSRFLG,WRDN,P0)=""
109 ..I $G(FHLOC),$D(^FH(119.6,FHLOC,0)) S FHLODAT=^FH(119.6,FHLOC,0)
110 ..I FHLODAT'="" S WRDN=$P(FHLODAT,U,1),FHSER1=$P(FHLODAT,U,5),FHSER2=$P(FHLODAT,U,6),P0=$P(FHLODAT,"^",4),P0=$S(P0<1:99,P0<10:"0"_P0,1:P0)
111 ..I $G(FHSER1) S SP=FHSER1
112 ..I SP="***",$G(FHSER2) S SP=FHSER2
113 ..I $G(FHP),$G(FHSER1),FHP=FHSER1 S FHSRFLG=1
114 ..I $G(FHP),$G(FHSER2),FHP=FHSER2 S FHSRFLG=1
115 ..I $G(FHP),'$G(FHSRFLG) Q
116 ..S FHMLOUT=$P(FHOPDAT,U,4)
117 ..I MEAL'=FHMLOUT Q
118 ..S FHDFN=FHI,ADM=FHJ
119 ..S Y=$P(Y,"^",2,3)_"^"_$P(Y,"^",8) Q:Y?."^"
120 ..I FHOPT=2 S Y=Y_"^"_IS,WRD=P0_$E(WRDN,1,20-$L(RM))_"/"_RM,^TMP($J,"SOL",SP,WRD,FHDFN,K2)=Y Q
121 ..S FHORD=$P(Y,"^",1),M1=$P(Y,"^",2)
122 ..I FHOPT=1,FHORD,M1[MEAL S:'$D(N(FHORD,SP)) N(FHORD,SP)=0 S Q=$P(Y,"^",3),N(FHORD,SP)=N(FHORD,SP)+$S(Q:Q,1:1) S:'$D(C(MEAL,SP)) C(MEAL,SP)=0 I TT'=FHDFN S C(MEAL,SP)=C(MEAL,SP)+1,TT=FHDFN
123 ..I FHOPT=3,FHORD,M1[MEAL S:'$D(N(FHORD)) N(FHORD)=0 S Q=$P(Y,"^",3),N(FHORD)=N(FHORD)+$S(Q:Q,1:1)
124 Q
125 ;
126KIL K ^TMP($J) G KILL^XUSCLEAN
127 ;
128EVNT Q:FHCNSOF=0 S:'$D(FHDTP) FHDTP=""
129 I $D(FHDT1) S DTP=FHDT1 D DTP^FH S FHDTP=DTP
130 I $D(FHDT2) S DTP=FHDT2 D DTP^FH S:FHDTP'=DTP FHDTP=FHDTP_" to "_DTP
131 S FHACT="O",FHTXT="Outpatient Standing Order: "_NUM_" "_$P($G(^FH(118.3,SP,0)),U,1)_" ("_FHALML_"), "_FHLOCN_", "_FHDTP D OPFILE^FHORX
132 Q
Note: See TracBrowser for help on using the repository browser.