source: FOIAVistA/trunk/r/DIETETICS-FH/FHDCR1D.m@ 1757

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

initial load of FOIAVistA 6/30/08 version

File size: 7.0 KB
Line 
1FHDCR1D ; HISC/REL/NCA/RVD - Build Separate Meal Diet Card ;2/23/00 09:52
2 ;;5.5;DIETETICS;**3,5**;Jan 28, 2005;Build 53
3 ;RVD 8/10/05 added logic on Food Preferences for Bread/Beverages default for outpatient.
4 ;patch #5 - added outpatient SO and fix diet pattern for outpatient.
5BLD ; Build Diet Card list for a patient in three per page format
6 S X1=$G(^FHPT(+FHDFN,"A",+ADM,0)),FHORD=$P(X1,"^",2),SVC=$P(X1,"^",5),SF=$P(X1,"^",7),IS=$P(X1,"^",10),FHD=$P(X1,"^",16),(FHOR,X)=""
7 I FHPAR'="Y" Q:SVC="C"
8 I SVC="C" S:SP'=SP1 SP=SP1 Q:'SP
9 Q:'FHORD S X=$G(^FHPT(FHDFN,"A",ADM,"DI",FHORD,0))
10 S PD=$P(X,"^",13),FHOR=$P(X,"^",2,6) Q:"^^^^"[FHOR
11 I IS S IS=$G(^FH(119.4,+IS,0)) S:IS'="" SVC=SVC_"-"_$P(IS,"^",2)_$P(IS,"^",3)
12 S:SF SVC=SVC_" "_"SF"_"("_$S($P($G(^FHPT(FHDFN,"A",ADM,"SF",+SF,0)),"^",34)="Y":"M",1:"I")_")"
13 I UPD D OLD^FHMTK11 I OLD=FHOR S FLG2=0 D EVT^FHDCR2 Q:'FLG2
14 S STR=$G(^FHPT(FHDFN,"A",ADM,"DI",FHORD,2))
15 S DPAT=$O(^FH(111.1,"AB",FHOR,0))
16 K FP,MP,N2,NN I $P(STR,";",$S(MEAL="B":1,MEAL="N":2,1:3))'="" D DECOD^FHDCR1B
17 I DPAT S PD=$P($G(^FH(111.1,DPAT,0)),"^",7) D
18 .I $P(STR,";",$S(MEAL="B":1,MEAL="N":2,1:3))="",$O(MP(MEAL,""))="" F X8=0:0 S X8=$O(^FH(111.1,DPAT,MEAL,X8)) Q:X8<1 S Z1=$G(^(X8,0)) D
19 ..S ZZ=$G(^FH(114.1,+Z1,0)),NAM=$P(ZZ,"^",1)
20 ..S K4=$P(ZZ,"^",3),K4=$S('K4:99,K4<10:"0"_K4,1:K4)
21 ..S MP(MEAL,K4_"~"_+Z1_"~"_NAM)=$P(Z1,"^",2) Q
22 .Q
23 Q:PD="" S PD=$P($G(^FH(116.2,PD,0)),"^",2) Q:PD="" D CHK^FHMTK1B
24 I NBR=3 D PRT^FHMTK1C K MM,PP,S S NBR=0
25 S NBR=NBR+1 D PID^FHDPA
26 F X6=0:0 S X6=$O(^FHPT(FHDFN,"P","B",X6)) Q:X6<1 F X7=0:0 S X7=$O(^FHPT(FHDFN,"P","B",X6,X7)) Q:X7<1 D
27 .S PS=$P($G(^FH(115.2,+X6,0)),"^",4) I PS S P4=$G(^FH(114,+PS,0)),P1=$P(P4,"^",7)_"^"_+PS_"^"_$P(P4,"^",1) I +P1,$D(^TMP($J,"FHDEF",MEAL,+P1)) D
28 ..S CHK="" F S CHK=$O(^TMP($J,"DEF",MEAL,PD,CHK)) Q:CHK="" S C1=$G(^(CHK)) I +CHK=+P1,$D(^TMP($J,"FHDEF",MEAL,+CHK,+C1)) D Q
29 ...S C2=$G(^FHPT(FHDFN,"P",+X7,0)) Q:$P(C2,"^",2)'[MEAL
30 ...S P2=+P1,P3=$P(P1,"^",3) S:'$D(N2(P2,P3)) N2(P2,P3)=+$P(P1,"^",2)_"^"_P3 Q
31 ..Q
32 S LP="" F S LP=$O(^TMP($J,"DEF",MEAL,PD,LP)) Q:LP="" I '$D(N2(+LP)) D
33 .S TST=$G(^TMP($J,"DEF",MEAL,PD,LP)),CHK="~"_$P(TST,"~",4,$L(TST,"~")) Q:'$F(CHK,"~"_SP_"~")
34 .I '$D(FP(+TST)) S N2(+LP,$P(LP,"~",2))=+TST_"^"_$P(LP,"~",2) Q
35 .Q:FLG
36 .F X6=0:0 S X6=$O(^FHPT(FHDFN,"P","B",X6)) Q:X6<1 F X7=0:0 S X7=$O(^FHPT(FHDFN,"P","B",X6,X7)) Q:X7<1 D
37 ..S PS=$P($G(^FH(115.2,+X6,0)),"^",4) I +PS S P4=$G(^FH(114,+PS,0)),P1=$P(P4,"^",7)_"^"_+PS_"^"_$P(P4,"^",1) I +P1,+P1=+LP D
38 ...S C2=$G(^FHPT(FHDFN,"P",+X7,0)) Q:$P(C2,"^",2)'[MEAL
39 ...S P2=+P1,P3=$P(P1,"^",3) S:'$D(N2(P2,P3)) N2(P2,P3)=+$P(P1,"^",2)_"^"_P3 Q
40 ..Q
41 S Y0=$P($G(^DPT(DFN,0)),"^",1)_" ("_BID_")"_" "_SVC,S(NBR)=0,N1=0
42 D CUR^FHORD7 S N1=N1+1 I $L(Y)<40 S PP(N1,NBR)=Y
43 E S L=$S($L($P(Y,",",1,3))<40:3,1:2) S PP(N1,NBR)=$P(Y,",",1,L),N1=N1+1,PP(N1,NBR)=$E($P(Y,",",L+1,5),2,99)
44 S MM(0,NBR)=Y0_"^"_WRDN_"^"_RM
45 I $G(DFN) D ALG^FHCLN S ALG="ALLGS.: "_$S(ALG="":"NONE ON FILE",1:ALG) S J=0 D BRK^FHMTK1B
46 S X8="" F S X8=$O(MP(MEAL,X8)) Q:X8="" S X1=+MP(MEAL,X8) D
47 .S Z1=+$P(X8,"~",2),QTY="" Q:'X1 S QTY=$S(+X1#1>0:$J(+X1,3,1),1:+X1_" ")_" "
48 .S Z1=+$P(X8,"~",2),QTY="" Q:'X1 S PAD=$E(" ",1,5-$L(X1)),QTY=+X1_PAD
49 .I $D(N2(Z1)) D Q
50 ..S X7="" F S X7=$O(N2(Z1,X7)) Q:X7="" S C1=$P(X8,"~",1,2)_"~"_X7 I '$D(NN(C1)) S NN(C1)=QTY_X7
51 ..Q
52 .S NN(X8)=QTY_$P(X8,"~",3)
53 .Q
54 S X8="" F S X8=$O(NN(X8)) Q:X8="" D
55 .S S(NBR)=S(NBR)+1,MM(S(NBR),NBR)=$G(NN(X8)) Q
56 S S(NBR)=S(NBR)+1,MM(S(NBR),NBR)=""
57 D SO^FHMTK1B
58 S S(NBR)=S(NBR)+1,MM(S(NBR),NBR)=""
59 D DISL
60 Q
61 ;
62OUT ;process outpatient data
63 S (SVC,SF,IS)=""
64 I '$D(FHKDAT)!'$G(FHADM) Q
65 S X1=FHKDAT
66 S FHWARD=W1 D LOC^FHDCR11
67 S (FHOR,FHORD)=$P(FHKDAT,U,2),FHD=$P(X1,"^",14)
68 I FHPAR'="Y" Q:SVC="C"
69 I SVC="C" S:SP'=SP1 SP=SP1 Q:'SP
70 S:$D(^FHPT(FHDFN,0)) IS=$P(^FHPT(FHDFN,0),U,5)
71 I $D(^FHPT(FHDFN,"OP",FHADM,"SF",0)) S SF=$P(^(0),U,3)
72 I IS S IS=$G(^FH(119.4,+IS,0)) S:IS'="" SVC=SVC_"-"_$P(IS,"^",2)_$P(IS,"^",3)
73 I SF,$D(^FHPT(FHDFN,"OP",FHADM,"SF",SF,0)),'$P(^(0),U,32) S SVC=SVC_" "_"SF"_"("_$S($P($G(^FHPT(FHDFN,"OP",FHADM,"SF",+SF,0)),"^",34)="Y":"M",1:"I")_")"
74 S MEAL=FHMEAL
75 I UPD D OLD^FHMTK11 I OLD=FHOR S FLG2=0 D EVT^FHDCR2 Q:'FLG2
76 S STR=""
77 S:$G(FHOR) FHOR=FHOR_"^^^^"
78 I FHOR="" S FHOR=$P(FHKDAT,U,7,11)
79 S DPAT=$O(^FH(111.1,"AB",FHOR,0))
80 K FP,MP,N2,NN
81 S PD=""
82 S:$G(MPD) PD=MPD
83 I DPAT S PD=$P($G(^FH(111.1,DPAT,0)),"^",7) D
84 .F X8=0:0 S X8=$O(^FH(111.1,DPAT,MEAL,X8)) Q:X8<1 S Z1=$G(^(X8,0)) D
85 ..S ZZ=$G(^FH(114.1,+Z1,0)),NAM=$P(ZZ,"^",1)
86 ..S K4=$P(ZZ,"^",3),K4=$S('K4:99,K4<10:"0"_K4,1:K4)
87 ..S MP(MEAL,K4_"~"_+Z1_"~"_NAM)=$P(Z1,"^",2) Q
88 Q:PD="" S PD=$P($G(^FH(116.2,PD,0)),"^",2) Q:PD="" D CHK^FHMTK1B
89 ;
90 I NBR=3 D PRT^FHMTK1C K MM,PP,S S NBR=0
91 S NBR=NBR+1 D PATNAME^FHOMUTL
92 ;
93 F X6=0:0 S X6=$O(^FHPT(FHDFN,"P","B",X6)) Q:X6<1 F X7=0:0 S X7=$O(^FHPT(FHDFN,"P","B",X6,X7)) Q:X7<1 D
94 .S PS=$P($G(^FH(115.2,+X6,0)),"^",4) I PS S P4=$G(^FH(114,+PS,0)),P1=$P(P4,"^",7)_"^"_+PS_"^"_$P(P4,"^",1) I +P1,$D(^TMP($J,"FHDEF",MEAL,+P1)) D
95 ..S CHK="" F S CHK=$O(^TMP($J,"DEF",MEAL,PD,CHK)) Q:CHK="" S C1=$G(^(CHK)) I +CHK=+P1,$D(^TMP($J,"FHDEF",MEAL,+CHK,+C1)) D Q
96 ...S C2=$G(^FHPT(FHDFN,"P",+X7,0)) Q:$P(C2,"^",2)'[MEAL
97 ...S P2=+P1,P3=$P(P1,"^",3) S:'$D(N2(P2,P3)) N2(P2,P3)=+$P(P1,"^",2)_"^"_P3 Q
98 ..Q
99 S LP="" F S LP=$O(^TMP($J,"DEF",MEAL,PD,LP)) Q:LP="" I '$D(N2(+LP)) D
100 .S TST=$G(^TMP($J,"DEF",MEAL,PD,LP)),CHK="~"_$P(TST,"~",4,$L(TST,"~")) Q:'$F(CHK,"~"_SP_"~")
101 .I '$D(FP(+TST)) S N2(+LP,$P(LP,"~",2))=+TST_"^"_$P(LP,"~",2) Q
102 .Q:FLG
103 .F X6=0:0 S X6=$O(^FHPT(FHDFN,"P","B",X6)) Q:X6<1 F X7=0:0 S X7=$O(^FHPT(FHDFN,"P","B",X6,X7)) Q:X7<1 D
104 ..S PS=$P($G(^FH(115.2,+X6,0)),"^",4) I +PS S P4=$G(^FH(114,+PS,0)),P1=$P(P4,"^",7)_"^"_+PS_"^"_$P(P4,"^",1) I +P1,+P1=+LP D
105 ...S C2=$G(^FHPT(FHDFN,"P",+X7,0)) Q:$P(C2,"^",2)'[MEAL
106 ...S P2=+P1,P3=$P(P1,"^",3) S:'$D(N2(P2,P3)) N2(P2,P3)=+$P(P1,"^",2)_"^"_P3 Q
107 ..Q
108 ;
109 S Y0=FHPTNM_" ("_FHBID_")"_" "_SVC,S(NBR)=0,N1=0,Y="***"
110 I '$G(FHDIET) S FHRNUM=FHKD D DIETPAT^FHOMRR1 S Y=$E(FHDIETP,1,18)
111 S:$G(FHDIET) Y=$P(^FH(111,FHDIET,0),U,7)
112 S N1=N1+1 I $L(Y)<40 S PP(N1,NBR)=Y
113 E S L=$S($L($P(Y,",",1,3))<40:3,1:2) S PP(N1,NBR)=$P(Y,",",1,L),N1=N1+1,PP(N1,NBR)=$E($P(Y,",",L+1,5),2,99)
114 S MM(0,NBR)=Y0_"^"_WRDN_"^"_RM_"^^^^"_FHMEAL
115 I $G(DFN) D ALG^FHCLN S ALG="ALLGS.: "_$S(ALG="":"NONE ON FILE",1:ALG) S J=0 D BRK^FHMTK1B
116 ;
117 S X8="" F S X8=$O(MP(MEAL,X8)) Q:X8="" S X1=+MP(MEAL,X8) D
118 .S Z1=+$P(X8,"~",2),QTY="" Q:'X1 S QTY=$S(+X1#1>0:$J(+X1,3,1),1:+X1_" ")_" "
119 .S Z1=+$P(X8,"~",2),QTY="" Q:'X1 S PAD=$E(" ",1,5-$L(X1)),QTY=+X1_PAD
120 .I $D(N2(Z1)) D Q
121 ..S X7="" F S X7=$O(N2(Z1,X7)) Q:X7="" S C1=$P(X8,"~",1,2)_"~"_X7 I '$D(NN(C1)) S NN(C1)=QTY_X7
122 ..Q
123 .S NN(X8)=QTY_$P(X8,"~",3)
124 .Q
125 S X8="" F S X8=$O(NN(X8)) Q:X8="" D
126 .S S(NBR)=S(NBR)+1,MM(S(NBR),NBR)=$G(NN(X8)) Q
127 I $G(FHKD) S ADM=FHKD D SOUT^FHMTK1B ;get outpatient standing orders.
128 S S(NBR)=S(NBR)+1,MM(S(NBR),NBR)=""
129 D DISL
130 Q
131 ;
132DISL ; Store patient dislikes
133 F LL=0:0 S LL=$O(^TMP($J,"X",MEAL,LL)) Q:LL<1 D DL1
134 Q
135DL1 S X6=$O(^FHPT(FHDFN,"P","B",LL,0)) Q:X6<1
136 S X2=$G(^FHPT(FHDFN,"P",X6,0)) Q:$P(X2,"^",2)'[MEAL
137 S S(NBR)=S(NBR)+1
138 S MM(S(NBR),NBR)=" "_$E($P($G(^FH(115.2,+X2,0)),"^",1),1,25)
139 Q
Note: See TracBrowser for help on using the repository browser.