source: WorldVistAEHR/trunk/r/DIETETICS-FH/FHWOR71.m@ 1800

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

initial load of WorldVistAEHR

File size: 5.4 KB
RevLine 
[613]1FHWOR71 ; HISC/CAH - Diet Profile for CPRS ;1/30/97 08:54
2 ;;5.5;DIETETICS;**1,2**;Jan 28, 2005
3P(DFN) ;Dietetics Profile for CPRS
4 ; INPUT: DFN = Patient file #2 internal record number
5 ; OUTPUT: -1^displayable error text (if invalid DFN or no profile)
6 ; with version 5.5 selection of outpatients is allowed
7 ; 1 if successful, and displayable data in
8 ; ^TMP($J,"FHPROF",DFN,n) = line of text
9 ; where n = sequential number
10 ;
11 I 'DFN Q "-1^Invalid patient selection"
12 S FHZ115="P"_DFN D CHECK^FHOMDPA I FHDFN="" Q "-1^No Report Available"
13 N %,%H,%I,%T,%ZIS,A1,ADM,AGE,ALG,ALL,BAG,C,CAL,COM,CON,CT,D3,DA,DAS,FHDU,DOB,DTP,FHI,FHOR,FHLD,FHQ,I,IOP,K,K1,K2,KK,L,L1,LST,MEAL,N,NO,NOW,FHORD,FHWF,FHPV,FHX,FHY
14 N POP,Q,QUA,QT,QTY,RM,SEX,PID,BID,ST1,ST2,STR,TYP,TF,TF2,TIM,TQU,TUN,WARD,X,X1,X2,XY,Y,YN,Z,Z1
15 S FHQ=1 K ^TMP($J,"FHPROF",DFN) S FHX=0 D F0
16 Q FHQ
17F0 ; Display Diet
18 D NOW^%DTC S NOW=%,DT=NOW\1,QT=""
19 S WARD=$G(^DPT(DFN,.1)) I WARD="" D CPRS^FHOMPP Q
20 ;S WARD=$G(^DPT(DFN,.1)) I WARD="" S FHQ="-1^Not currently an inpatient" Q
21 S ADM=$G(^DPT("CN",WARD,DFN)) I ADM<1 S FHQ="-1^No current diet order" Q
22 I '$D(^FHPT(FHDFN,"A",ADM,0)) S FHQ="-1^No current diet order2" Q
23 K N S P1=1 F K=0:0 S K=$O(^FHPT(FHDFN,"P",K)) Q:K<1 S X=^(K,0),M=$P(X,"^",2) I M'="" S:M="A" M="BNE" D SP
24 I $O(N(""))="" S FHX=$$SPACNG(1,FHX) S ^TMP($J,"FHPROF",DFN,FHX)="No Food Preferences on file" S FHX=$$SPACNG(0,FHX) G A0
25 S FHX=$$SPACNG(1,FHX) S ^TMP($J,"FHPROF",DFN,FHX)="Food Preferences Currently on file" S FHX=$$SPACNG(1,FHX)
26 K ST1 S $P(ST1," ",81)="",$E(ST1,27,32)="Likes",$E(ST1,59,67)="Dislikes" S ^TMP($J,"FHPROF",DFN,FHX)=ST1 S FHX=$$SPACNG(1,FHX)
27 S (M1,M2,MM)="",FHX=$$SPACNG(0,FHX) F S M1=$O(N(M1)) Q:M1="" I $D(N(M1)) S ^TMP($J,"FHPROF",DFN,FHX)=$P(M1,"~",2) D
28 . S (P1,P2)=0 F S:P1'="" P1=$O(N(M1,"L",P1)) S X1=$S(P1>0:N(M1,"L",P1),1:"") S:P2'="" P2=$O(N(M1,"D",P2)) S X2=$S(P2>0:N(M1,"D",P2),1:"") Q:P1=""&(P2="") D W0 S:M2'=M1 FHX=$$SPACNG(0,FHX)
29 . S M2=M1 Q
30 S FHX=$$SPACNG(0,FHX) K L,N,M,M1,M2,MM,P1,P2
31A0 S X(0)=^FHPT(FHDFN,"A",ADM,0),X=$P(X(0),"^",10) G:X="" F1
32 S FHX=$$SPACNG(1,FHX) S ^TMP($J,"FHPROF",DFN,FHX)="Isolation/Precaution Type is "_$P($G(^FH(119.4,X,0)),"^",1)
33F1 D CUR^FHORD7 S FHX=$$SPACNG(1,FHX) S ^TMP($J,"FHPROF",DFN,FHX)="Current Diet: "_$S(Y'="":Y,1:"No current order")
34 I Y'="",FHORD>0 I $D(^FHPT(FHDFN,"A",ADM,"DI",FHORD,1)) S COM=^(1) D
35 . I COM'="" S FHX=$$SPACNG(0,FHX) S ^TMP($J,"FHPROF",DFN,FHX)="Comment: "_COM
36 S TYP=$P(X,"^",8) I TYP'="" D
37 . S FHX=$$SPACNG(0,FHX)
38 . S ^TMP($J,"FHPROF",DFN,FHX)="Service: "_$S(TYP="T":"Tray",TYP="D":"Dining Room",1:"Cafeteria")
39 S DTP=$P(X(0),"^",3) I DTP D DTP^FH S FHX=$$SPACNG(0,FHX) S ^TMP($J,"FHPROF",DFN,FHX)="Expires: "_DTP
40 S TF=$P(X(0),"^",4) G:TF<1 F2
41 S Y=^FHPT(FHDFN,"A",ADM,"TF",TF,0)
42 S DTP=$P(Y,"^",1),COM=$P(Y,"^",5),TQU=$P(Y,"^",6),CAL=$P(Y,"^",7)
43 D DTP^FH S FHX=$$SPACNG(1,FHX) S ^TMP($J,"FHPROF",DFN,FHX)="Tubefeed Ordered: "_DTP
44 F TF2=0:0 S TF2=$O(^FHPT(FHDFN,"A",ADM,"TF",TF,"P",TF2)) Q:TF2<1 S XY=^(TF2,0) D LP
45 S FHX=$$SPACNG(0,FHX) K ST1 S ST1="Total Quantity: "_TQU_" ml",$E(ST1,43,(56+$L(CAL)))="Total KCAL: "_CAL S ^TMP($J,"FHPROF",DFN,FHX)=ST1
46 I COM'="" S FHX=$$SPACNG(0,FHX) S ^TMP($J,"FHPROF",DFN,FHX)="Comment: "_COM
47F2 S NO=$P(X(0),"^",7),Y=$S('NO:"",1:^FHPT(FHDFN,"A",ADM,"SF",NO,0))
48 S L=$P(Y,"^",4) S FHX=$$SPACNG(1,FHX) S ^TMP($J,"FHPROF",DFN,FHX)="Supplemental Feeding: "_$S('L:"No Order",1:$P(^FH(118.1,L,0),"^",1)) G:'NO F3
49 S DTP=$P(Y,"^",30) D DTP^FH S ^TMP($J,"FHPROF",DFN,FHX)=^(FHX)_" Reviewed: "_DTP
50 S L=4 F K1=1:1:3 S K=0,N(K1)="" F K2=1:1:4 S Z=$P(Y,U,L+1),Q=$P(Y,U,L+2),L=L+2 I Z'="" S:'Q Q=1 S:N(K1)'="" N(K1)=N(K1)_"; " S N(K1)=N(K1)_Q_" "_$P(^FH(118,Z,0),"^",1)
51 S FHX=$$SPACNG(0,FHX) F K1=1:1:3 I N(K1)'="" S FHX=$$SPACNG(0,FHX) S ^TMP($J,"FHPROF",DFN,FHX)=$P(" 10am; 2pm; 8pm",";",K1)_": "_N(K1)
52F3 G ^FHWOR72
53LP S TUN=$P(XY,"^",1),STR=$P(XY,"^",2),QUA=$P(XY,"^",3)
54 I QUA["CC" S QUAFI=$P(QUA,"CC",1),QUASE=$P(QUA,"CC",2),QUA=QUAFI_"ML"_QUASE
55 S FHX=$$SPACNG(0,FHX) S ^TMP($J,"FHPROF",DFN,FHX)="Product: "_$P($G(^FH(118.2,TUN,0)),"^",1)_", "_$S(STR=4:"Full",STR=1:"1/4",STR=2:"1/2",1:"3/4")_" Str., "_QUA Q
56SP S Z=$G(^FH(115.2,+X,0)),L1=$P(Z,"^",1),KK=$P(Z,"^",2),M1="",DAS=$P(X,"^",4)
57 I KK="L" S Q=$P(X,"^",3),L1=$S(Q:Q,1:1)_" "_L1
58 I M="BNE" S M1="1~All Meals" G SP1
59 S Z1=$E(M,1) I Z1'="" S M1=$S(Z1="B":"2~Break",Z1="N":"3~Noon",1:"4~Even")
60 S Z1=$E(M,2) I Z1'="" S M1=M1_","_$S(Z1="B":"Break",Z1="N":"Noon",1:"Even")
61SP1 S:'$D(N(M1,KK,P1)) N(M1,KK,P1)="" I $L(N(M1,KK,P1))+$L(L1)<255 S N(M1,KK,P1)=N(M1,KK,P1)_$S(N(M1,KK,P1)="":"",1:", ")_L1_$S(DAS="Y":" (D)",1:"")
62 E S:'$D(N(M1,KK,K)) N(M1,KK,K)="" S N(M1,KK,K)=L1_$S(DAS="Y":" (D)",1:"") S P1=K
63 Q
64W0 I X1'="" K ST2 S $P(ST2," ",13)="" S FHY=$G(^TMP($J,"FHPROF",DFN,FHX)) S ^TMP($J,"FHPROF",DFN,FHX)=FHY_$E(ST2,1,(11-$L(FHY))) S X=X1 D W1 S X1=X
65 I X2'="" K ST2 S $P(ST2," ",47)="" S FHY=$G(^TMP($J,"FHPROF",DFN,FHX)) S ^TMP($J,"FHPROF",DFN,FHX)=FHY_$E(ST2,1,(46-$L(FHY))) S X=X2 D W1 S X2=X
66 Q:X1=""&(X2="") S FHX=$$SPACNG(0,FHX) G W0
67W1 I $L(X)<34 S FHY=$G(^TMP($J,"FHPROF",DFN,FHX)) S ^TMP($J,"FHPROF",DFN,FHX)=FHY_" "_X S X="" Q
68 F KK=35:-1:1 Q:$E(X,KK-1,KK)=", "
69 S ^TMP($J,"FHPROF",DFN,FHX)=^(FHX)_" "_$E(X,1,KK-2) S X=$E(X,KK+1,999)
70 Q
71SPACNG(FHI,FHX) ;Multiple spacing before next line of text in ^TMP global
72 N I F I=1:1:FHI S FHX=FHX+1 S ^TMP($J,"FHPROF",DFN,FHX)=" "
73 S FHX=FHX+1
74 Q FHX
75TEST ; FOR TESTING ONLY - DFN must be defined
76 S I="" F S I=$O(^TMP($J,"FHPROF",DFN,I)) Q:I="" W !,^TMP($J,"FHPROF",DFN,I)
77 Q
Note: See TracBrowser for help on using the repository browser.