source: FOIAVistA/trunk/r/DIETETICS-FH/FHWTRN.m@ 1310

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

initial load of FOIAVistA 6/30/08 version

File size: 6.1 KB
Line 
1FHWTRN ; HISC/REL - Process Transfers ;3/17/92 14:39
2 ;;5.5;DIETETICS;**4**;Jan 28, 2005;Build 32
3 ;patch 4 - added alert if pt is transferred
4 S (FHWRNEW,FHWROLD)=""
5 S FHZ115="P"_DFN,FHWROLD="" D CHECK^FHOMDPA I FHDFN'="" D
6 .S:ADM FHWROLD=$P($G(^FHPT(FHDFN,"A",ADM,0)),U,8)
7 I FHOLD="" G T0
8 ; Edit,Delete Transfers
9 I $P(FHOLD,"^",18)=$P(FHNEW,"^",18) G EX
10 S XT=$P(FHOLD,"^",18)
11 I "^1^2^3^"[("^"_XT_"^") D RET
12 I "^22^23^24^"[("^"_XT_"^") D PASS
13T0 S XT=$P(FHNEW,"^",18)
14 I "^1^2^3^"[("^"_XT_"^") D PASS
15 I "^22^23^24^"[("^"_XT_"^") D RET
16EX D WRD^FHWADM
17 G:'$G(FHDFN) KIL
18 S:ADM FHWRNEW=$P($G(^FHPT(FHDFN,"A",ADM,0)),U,8)
19 I FHWRNEW,(FHWROLD'=FHWRNEW) D XQAL ;process alert for transfer
20 G KIL
21PASS ; Place on Pass
22 S FHZ115="P"_DFN D CHECK^FHOMDPA I FHDFN="" Q
23 D SET Q:FHLD="P" Q:'$D(^FHPT(FHDFN,"A",ADM))
24 S FHOR="^^^^",FHLD="P",TYP="",D1=X1,D2="",D4=0,COM="" D STR^FHORD7 Q
25RET ; Remove from Pass
26 D SET I FHLD'="P",FHLD'="X" Q
27 S X=^FHPT(FHDFN,"A",ADM,"DI",FHORD,0),D1=$P(X,"^",9),D2=$S(D1'>X1:X1,1:D1)
28 S $P(^FHPT(FHDFN,"A",ADM,"DI",FHORD,0),"^",10)=D2
29 S A2=0 F KK=0:0 S KK=$O(^FHPT(FHDFN,"A",ADM,"AC",KK)) Q:KK<1!(KK>X1) S A2=KK
30 Q:'A2 Q:$P(^FHPT(FHDFN,"A",ADM,"AC",A2,0),"^",2)'=FHORD
31 F K9=A2-.000001:0 S K9=$O(^FHPT(FHDFN,"A",ADM,"AC",K9)) Q:K9<1 I $P(^(K9,0),"^",2)=FHORD S D1=K9 D S0^FHORD3
32 D UPD^FHORD7 Q
33SET D NOW^%DTC S NOW=%,DT=%\1,FHPV=DUZ,FHWF=$S($D(^ORD(101)):1,1:0)
34 S X=$P($G(^DGPM(ADM,0)),"^",1),X1=$S(X'>NOW:NOW,1:X)
35 S A1=0,(FHOR,FHLD)="" F KK=0:0 S KK=$O(^FHPT(FHDFN,"A",ADM,"AC",KK)) Q:KK<1!(KK>X1) S A1=KK
36 Q:'A1 S FHORD=$P(^FHPT(FHDFN,"A",ADM,"AC",A1,0),"^",2),X=^FHPT(FHDFN,"A",ADM,"DI",FHORD,0),FHOR=$P(X,"^",2,6),FHLD=$P(X,"^",7) Q
37 ;
38XQAL ; Check a patient
39 S FHCLIN=""
40 D PATNAME^FHOMUTL I DFN="" Q
41 D CLR
42 D NOW^%DTC S NOW=%,FHEDT=$P(NOW,".")
43 S Y=^DPT(DFN,0),NAM=$P(Y,"^",1),SEX=$P(Y,"^",2),DOB=$P(Y,"^",3)
44 S AGE="" I DOB'="" S AGE=$E(NOW,1,3)-$E(DOB,1,3)-($E(NOW,4,7)<$E(DOB,4,7))
45 S FHDUZ=$P($G(^FH(119.6,FHWRNEW,0)),U,2)
46 S:FHDUZ FHCLIN=$P($G(^VA(200,FHDUZ,0)),U,1)
47P0 ; Calculate BMI
48 S GMRVSTR="WT" D EN6^GMRVUTL S WT=$P(X,"^",8),FHWTDT=$P(X,"^",1)
49 S GMRVSTR="HT" D EN6^GMRVUTL S HT=$P(X,"^",8),FHHTDT=$P(X,"^",1)
50 S FHGMDT=$S(FHWTDT>FHHTDT:FHWTDT,FHHTDT>FHWTDT:FHHTDT,1:FHWTDT)
51 S BMI="" I WT,HT S A2=HT*.0254,BMI=+$J(WT/2.2/(A2*A2),0,1)
52 I $G(BMI)=""!($G(BMI)'<18.5) G P1
53 S MONTX="Monitor: BMI < 18.5",DTE=NOW
54 S N=$O(^FHPT(FHDFN,"A",ADM,"MO","B",MONTX,""),-1)
55 I N,'$P(^FHPT(FHDFN,"A",ADM,"MO",N,0),U,4) D FIL S MONIFN=N D TCK G P1
56 I 'N,(FHGMDT>(FHEDT-7)) D FIL,TFIL G P1
57 I 'N G P1
58 ; Check if been 30 days
59 S LST=$P($G(^FHPT(FHDFN,"A",ADM,"MO",N,0)),"^",2)
60 S X=$$FMDIFF^XLFDT(DTE,LST,3) I X>30 D FIL,TFIL
61P1 ; Check for current Tubefeeding
62 S TF=$P($G(^FHPT(FHDFN,"A",ADM,0)),"^",4) I 'TF G P2
63 S MONTX="Monitor: On Tubefeeding",DTE=NOW
64 S N=$O(^FHPT(FHDFN,"A",ADM,"MO","B",MONTX,""),-1)
65 I N,'$P(^FHPT(FHDFN,"A",ADM,"MO",N,0),U,4) D FIL S MONIFN=N D TCK G P2
66 I 'N D FIL,TFIL G P2
67 ; Check if been 7 days
68 S LST=$P($G(^FHPT(FHDFN,"A",ADM,"MO",N,0)),"^",2)
69 S X=$$FMDIFF^XLFDT(DTE,LST,3) I X>7 D FIL,TFIL
70P2 ; Check for Hyperals
71 S MONTX="",DTE=NOW
72 D PSS435^PSS55(DFN,,"FHIV") F DA=0:0 S DA=$O(^TMP($J,"FHIV",DA)) Q:DA<1 D
73 .S X0=$P($G(^TMP($J,"FHIV",DA,.02)),"^",2) I X0>NOW Q
74 .S MONTX="Monitor: On Hyperals" Q
75 I MONTX'="" D FIL,TFIL
76P3 ; Check for Serum Albumin
77 S MONTX="",PX=6 D LAB^FHASM4 I $D(^TMP($J,"LRTST")) D
78 .F L=0:0 S L=$O(^TMP($J,"LRTST",L)) Q:L<1 S Y=$TR($P(^(L),"^",6)," ","") I Y'?1A.E,Y<2.8 S MONTX="Monitor: Albumin < 2.8",DTE=$P(^(L),"^",7) Q
79 .Q
80 I MONTX="" G P4
81 S N=$O(^FHPT(FHDFN,"A",ADM,"MO","B",MONTX,""),-1)
82 I N,'$P(^FHPT(FHDFN,"A",ADM,"MO",N,0),U,4) D FIL S MONIFN=N D TCK G P4
83 ;process new Albumin if old test date is within 7 days.
84 I 'N S X=$$FMDIFF^XLFDT(NOW,DTE) I X<8 D FIL,TFIL G P4
85 I 'N G P4
86 ; Check if same test
87 S LST=$P($G(^FHPT(FHDFN,"A",ADM,"MO",N,0)),"^",2) I DTE>LST D FIL,TFIL
88P4 ; Check for NPO+Clr Liq > 3 days
89 S A1=NOW,DTE=NOW
90 F D Q:'A1
91 .S A1=$O(^FHPT(FHDFN,"A",ADM,"AC",A1),-1) Q:'A1
92 .S FHORD=$P($G(^FHPT(FHDFN,"A",ADM,"AC",A1,0)),"^",2) I 'FHORD S A1="" Q
93 .S FHOR=$G(^FHPT(FHDFN,"A",ADM,"DI",FHORD,0))
94 .I $P(FHOR,"^",7)="N" S DTE=A1 Q
95 .I $P(FHOR,"^",2)=CLR S DTE=A1 Q
96 .S A1="" Q
97 I DTE'<NOW G P5
98 S X=$$FMDIFF^XLFDT(NOW,DTE,3) G:X<3 P5
99 S MONTX="Monitor: NPO+Clr Liq > 3 days",DTE=NOW
100 S N=$O(^FHPT(FHDFN,"A",ADM,"MO","B",MONTX,""),-1)
101 I N,'$P(^FHPT(FHDFN,"A",ADM,"MO",N,0),U,4) D FIL S MONIFN=N D TCK G P5
102 I 'N D FIL,TFIL G P5
103 ; Check if been 3 days
104 S LST=$P($G(^FHPT(FHDFN,"A",ADM,"MO",N,0)),"^",2)
105 S X=$$FMDIFF^XLFDT(NOW,LST,3) I X>3 D FIL,TFIL
106P5 ; Done
107 Q
108CLR ; Find Clear Liquid
109 S CLR=$O(^FH(111,"B","CLEAR LIQUID",0)) Q:CLR
110 S CLR=$O(^FH(111,"C","CLEAR LIQUID",0)) Q:CLR
111 S CLR=$O(^FH(111,"C","CLR LIQ",0)) Q:CLR
112 S CLR=$O(^FH(111,"C","CL",0)) Q:CLR
113 Q
114FIL ; File Monitor
115 K XQA
116 D PATNAME^FHOMUTL
117 Q:(MONTX["BMI")&($P($G(^FH(119.6,FHWRNEW,1)),"^",5)'="Y")
118 Q:(MONTX["Tubefeed")&($P($G(^FH(119.6,FHWRNEW,1)),"^",6)'="Y")
119 Q:(MONTX["Hyperals")&($P($G(^FH(119.6,FHWRNEW,1)),"^",7)'="Y")
120 Q:(MONTX["Albumin")&($P($G(^FH(119.6,FHWRNEW,1)),"^",8)'="Y")
121 Q:(MONTX["NPO+Clr")&($P($G(^FH(119.6,FHWRNEW,1)),"^",9)'="Y")
122 K XQA,XQAMSG,XQAOPT,XQAROU
123 S XQAID="FH,"_$J_","_$H
124 S XQAMSG=$E(FHPTNM,1,9)_" ("_$E(FHPTNM,1,1)_$P(FHSSN,"-",3)_"): "
125 S XQAOPT="FHCTF2",XQAMSG=XQAMSG_" "_MONTX_" "_$E(DTE,4,5)_"/"_$E(DTE,6,7)_"/"_$E(DTE,2,3)_" Clinician: "_FHCLIN
126 F A=0:0 S A=$O(^FH(119.6,FHWRNEW,2,A)) Q:A'>0 S TK=$P($G(^FH(119.6,FHWRNEW,2,A,0)),U,1),XQA(TK)=""
127 I '$D(XQA(FHDUZ)) S XQA(FHDUZ)=""
128 D SETUP^XQALERT
129 Q
130TFIL ;File patient info
131 L +^FHPT(FHDFN,"A",ADM,"MO",0)
132 I '$D(^FHPT(FHDFN,"A",ADM,"MO",0)) S ^FHPT(FHDFN,"A",ADM,"MO",0)="^115.11^^"
133 L -^FHPT(FHDFN,"A",ADM,"MO",0)
134 K DIC,DD,DO,DINUM S DIC="^FHPT(FHDFN,""A"",ADM,""MO"",",DIC(0)="L",DA(1)=ADM,DA(2)=FHDFN,DLAYGO=115,X=MONTX D FILE^DICN K DIC,DLAYGO
135 Q:Y<1 S MONIFN=+Y
136 S $P(^FHPT(FHDFN,"A",ADM,"MO",MONIFN,0),"^",2)=DTE,^FHPT(FHDFN,"A",ADM,"MO","AC",DTE,MONIFN)=""
137TCK S FHTF=DTE_"^M^"_MONTX_"^"_DFN_"^"_ADM_"^"_MONIFN ;set tickler for a clinician
138 D:FHDUZ FILE^FHCTF2
139 Q
140 ;
141KIL K %,A1,A2,COM,D1,D2,D4,FHDU,FHLD,FHOR,FHPV,FHX1,FHX2,FHX3,K,K9,KK,NOW,FHORD,TYP,X,X1,X2,X9
142 K FHEDT,FHGMDT,FHWTDT,FHHTDT Q
Note: See TracBrowser for help on using the repository browser.