source: FOIAVistA/tag/r/DIETETICS-FH/FHSELA1.m@ 1222

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

WorldVistAEHR overlayed on FOIAVistA

File size: 6.6 KB
Line 
1FHSELA1 ;Hines OIFO/RTK - Map GMR Allergy file to Food Prefs ;3/07/2007
2 ;;5.5;DIETETICS;**8**;Jan 28, 2005;Build 28
3 ;
4CREATE ; Check for any missing Allergy-type FP's or one's not renamed in 115.2
5 ; and allow user to create the FP on the fly
6 D ^FHSELA2 S NUM=0,FHQUIT=0
7 W !!!,"The following Allergy Food Preference titles are not on file."
8 W !,"You may use this option to create these Food Preference entries:"
9 D CRLIST I NUM=0 W !,"No Food Preferences need to be mapped." D EXIT Q
10 I FHQUIT=1 D EXIT Q
11 I FHRESP=""!(FHRESP="M") D EXIT Q
12 S FHAFPNM=$P(FHLIST(FHRESP),"^",1)
13 W !,FHAFPNM," "
14 K DIR S DIR("A")="Add to Food Preference file",DIR(0)="Y" D ^DIR
15 I $D(DIRUT) D EXIT Q
16 I Y'=1 D CREATE Q
17 D ADD
18 W !!," ...done. ",FHAFPNM," Food Preference has been added!" H 1
19 D CREATE Q
20 D EXIT Q
21CRLIST ;
22 W !!?5,"MISSING FOOD PREFERENCE LIST"
23 W !?5,"============================"
24 S FHSEL=0,FHK=""
25 F S FHK=$O(^TMP($J,"FHALG",FHK)) Q:FHK=""!(FHQUIT=1)!(FHSEL=1) D
26 .S FHFPS=$P(^TMP($J,"FHALG",FHK),";",1,99)
27 .S FHZ1="ALLERGY - "_$P(FHFPS,";",1)
28 .I $D(^FH(115.2,"B",FHZ1)) Q
29 .S NUM=NUM+1,PAD=$S($L(NUM)=1:" ",1:"") W !,PAD,NUM
30 .W ?8,FHZ1
31 .S FHLIST(NUM)=FHZ1_"^"_FHFPS
32 .I NUM#5=0!($O(^TMP($J,"FHALG",FHK))="") D PG Q
33 .Q
34 I FHQUIT=0,FHSEL=0,NUM#5'=0 D PG Q
35 Q
36ADD ;
37 S FHALGMZ=1
38 S X=FHAFPNM K DIC,DO
39 S (DIC,DIE)="^FH(115.2,",DIC(0)="L" D FILE^DICN
40 S (FHDA,DA)=+Y,DR=".01;26;1//DISLIKE;S:X=""D"" Y=0;3;20;S:'X Y=99;21;99"
41 D ^DIE K DA,DIE,DR
42 D TRAN^FHSEL1
43 Q
44PG ;
45 S FHRESP="" W ! K DIR
46 S DIR("A")="Select Food Preference or 'M' to see more ('^' to EXIT)"
47 S DIR(0)="F",DIR("B")="M" D ^DIR I $D(DIRUT) S FHQUIT=1 Q
48 S FHRESP=Y
49 I FHRESP?1"M" Q
50 I FHRESP?1.3N,FHRESP>0,FHRESP<(NUM+1) S FHSEL=1 Q
51 W !!,"Select from 1 to ",NUM D PG Q
52 Q
53MAP ; Map allergies by setting pointers in 115.2 to correct entries in 120.82
54 D ^FHSELA2
55 S FHK=""
56 F S FHK=$O(^TMP($J,"FHALG",FHK)) Q:FHK="" D
57 .S FHFPS=$P(^TMP($J,"FHALG",FHK),";",1,99)
58 .S FHZ1="ALLERGY - "_$P(FHFPS,";",1)
59 .I '$D(^FH(115.2,"B",FHZ1)) Q ;not set-up in 115.2, can't map
60 .S FHFPIEN=$O(^FH(115.2,"B",FHZ1,""))
61 .S FHALMP=$P(FHFPS,";",2,99) I FHALMP="" Q ;no allergies to map
62 .S FHZ=0 F S FHZ=FHZ+1 S FHANAM=$P(FHALMP,";",FHZ) Q:FHANAM="" D
63 ..D LOOKUP
64 Q
65LOOKUP ; Look-up the Allergy in 120.82 and set the pointer
66 S FHX=FHANAM
67 F FHVAL=0:0 S FHVAL=$O(^GMRD(120.82,"B",FHX,FHVAL)) Q:FHVAL'>0 D
68 .I $D(^FH(115.2,FHFPIEN,"ALG","B",FHVAL)) Q ;pointer already exists
69 .S Y=FHVAL K DIC,DO S DA(1)=FHFPIEN,DIC="^FH(115.2,"_DA(1)_",""ALG"","
70 .S DIC(0)="L",DIC("P")=$P(^DD(115.2,25,0),U,2),X=+Y
71 .D FILE^DICN
72 Q
73DISPMAP ;
74 W !!,"This option can be used to display the Standard GMR Allergy"
75 W !,"entries and the Food Preferences they map to.",!! K DIR
76 S DIR("A")="Display Map by Allergies or by Food Preferences (A/F): "
77 S DIR(0)="SA^A:Allergies;F:Food Preferences" D ^DIR
78 I $D(DIRUT) D EXIT Q
79 S FHSEL=Y
80 D DEV
81 Q
82DEV ;get device and set up queue
83 W ! K %ZIS,IOP S %ZIS="Q" D ^%ZIS Q:POP
84 I '$D(IO("Q")) U IO D LISTMAP,^%ZISC,EXIT Q
85 S ZTRTN="LISTMAP^FHSELA1",ZTSAVE("FHSEL")=""
86 S ZTDESC="GMR Allergy/Food Preference Map Display" D ^%ZTLOAD
87 D ^%ZISC K %ZIS,IOP
88 D EXIT
89 Q
90LISTMAP ; List Map by Allergies or by Food Preferences
91 I FHSEL="A" D LISTAL Q
92 I FHSEL="F" D LISTFP Q
93 Q
94LISTFP ; List all the Allergy-type Food Pref's and corresponding GMR Allergies
95 D ^FHSELA2
96 S FHK="" W !!,"ALLERGY TYPE FOOD PREFERENCE MAP"
97 W !!,"NFS Food Preference Title",?40,"GMR Standard Allergy(s)"
98 W !,"==================================="
99 W ?40,"==================================="
100 F S FHK=$O(^TMP($J,"FHALG",FHK)) Q:FHK="" D
101 .S FHFPS=$P(^TMP($J,"FHALG",FHK),";",1,99),FHZ1=$P(FHFPS,";",1)
102 .W !,"ALLERGY - ",FHZ1
103 .S FHALMP=$P(FHFPS,";",2,99) I FHALMP="" W ?40,"** NONE **" Q
104 .S FHZ=0,N=0 F S FHZ=FHZ+1,FHANAM=$P(FHALMP,";",FHZ) Q:FHANAM="" D
105 ..W ?40,$S(FHZ>1:",",1:"") S N=N+$L(FHANAM)+1 W:N>40 !?40 S:N>40 N=0 W FHANAM I N=0 S N=N+$L(FHANAM)+1
106 D EXIT Q
107LISTAL ; List all the GMR Allergies and the Food Pref to map to
108 D ^FHSELA2
109 S FHK="" W !!,"GMR STANDARD FOOD ALLERGY MAP"
110 W !!,"GMR Allergy Name",?25,"Corresponding NFS Food Preference"
111 W !,"=======================",?25,"===================================="
112 F S FHK=$O(^TMP($J,"FHALG",FHK)) Q:FHK="" D
113 .S FHFPS=$P(^TMP($J,"FHALG",FHK),";",1,99),FHZ1=$P(FHFPS,";",1)
114 .S FHALMP=$P(FHFPS,";",2,99) I FHALMP="" Q
115 .S FHZ=0,N=0 F S FHZ=FHZ+1,FHANAM=$P(FHALMP,";",FHZ) Q:FHANAM="" D
116 ..S ^TMP($J,"FHAL",FHANAM)="ALLERGY - "_FHZ1
117 S FHANAMZ=""
118 F S FHANAMZ=$O(^TMP($J,"FHAL",FHANAMZ)) Q:FHANAMZ="" D
119 .W !,FHANAMZ,?25,"...maps to: ",^TMP($J,"FHAL",FHANAMZ)
120 D EXIT Q
121MISSING ; List all Food Pref's with no pointers to 120.82
122 D ^FHSELA2
123 S FHK=""
124 F S FHK=$O(^TMP($J,"FHALG",FHK)) Q:FHK="" D
125 .S FHFPS=$P(^TMP($J,"FHALG",FHK),";",1,99),FHZ1=$P(FHFPS,";",1)
126 .I $P(FHFPS,";",2)'="" Q
127 .W !?5,"ALLERGY - ",FHZ1," does not have corresponding 120.82 entries"
128 D EXIT Q
129CHECK ; Check for any missing Allergy-type FP's or one's not renamed in 115.2
130 D ^FHSELA2
131 S FHK="",FLG=0
132 W !,"The following Food Preferences titles were not found in file #115.2:"
133 F S FHK=$O(^TMP($J,"FHALG",FHK)) Q:FHK="" D
134 .S FHFPS=$P(^TMP($J,"FHALG",FHK),";",1,99)
135 .S FHZ1="ALLERGY - "_$P(FHFPS,";",1)
136 .I '$D(^FH(115.2,"B",FHZ1)) W !,FHZ1 S FLG=1
137 I FLG=0 W !,"ALL FOOD PREFERENCES HAVE BEEN RENAMED!"
138 D EXIT Q
139 ;
140UPDATE ;Update Food Preferences for all Patient's based on Allergies
141 D ^FHSELA2 S FHCOUNT=0,FHQT=0
142 W !!,"...Updating Patient Food Preferences based on Food-Type Allergies"
143 W "..." K FHMISS F FHDFN=0:0 S FHDFN=$O(^FHPT(FHDFN)) Q:FHDFN'>0 D
144 .S FHCOUNT=FHCOUNT+1 I FHCOUNT#100=0 W "."
145 .D GETZN^FHOMUTL I FILE'="P" Q
146 .S DFN=IEN D ALG^FHCLN I '$O(^TMP($J,"FHGMRAL","")) Q
147 .F FHGMRN=0:0 S FHGMRN=$O(^TMP($J,"FHGMRAL",FHGMRN)) Q:FHGMRN="" D UPDFP1^FHWGMR
148 I $G(FHPST8)=1 K ^TMP($J,"FHGMRAL"),^TMP($J,"FHMISS"),FHGMRN,FHMSAL,FHMSFP,FHMSPT,FHPST8,FHCOUNT Q
149 D LIST
150 K ^TMP($J,"FHGMRAL"),^TMP($J,"FHMISS"),FHGMRN,FHMSAL,FHMSFP,FHMSPT,FHPST8,FHCOUNT,FHQT
151 Q
152LIST ;
153 I '$D(^TMP($J,"FHMISS")) Q
154 W !!,"The following entries need to be mapped in order to automatically"
155 W !,"update the Patient Food Preferences:",! S FHCOUNT=0,FHQT=0
156 S FHMSFP="" F S FHMSFP=$O(^TMP($J,"FHMISS",FHMSFP)) Q:FHMSFP=""!(FHQT=1) D
157 .W !,"'ALLERGY - ",FHMSFP,"'" S FHCOUNT=FHCOUNT+1
158 .S FHMSPT="" F S FHMSPT=$O(^TMP($J,"FHMISS",FHMSFP,FHMSPT)) Q:FHMSPT="" D
159 ..S FHMSAL=$P($G(^TMP($J,"FHMISS",FHMSFP,FHMSPT)),U,1)
160 ..W !?3,"Patient: ",$E(FHMSPT,1,30),?43,"Allergy: ",FHMSAL
161 ..S FHCOUNT=FHCOUNT+1
162 ..I FHCOUNT>14 S FHCOUNT=0 W ! K DIR S DIR(0)="E" D ^DIR W ! I X="^" S FHQT=1
163 Q
164EXIT ;
165 D MAP
166 K ^TMP($J,"FHALG"),^TMP($J,"FHAL")
167 K FHFPIEN,FHK,FHX,FHZ,FHFPS,FHZ1,FHVAL,N,FHANAM,FHANAMZ
168 K FHQUIT,NUM,FHRESP,FHAFPNM,FHSEL,PAD,FHLIST,FHALGMZ,FHALMP
Note: See TracBrowser for help on using the repository browser.