source: WorldVistAEHR/trunk/r/DIETETICS-FH/FHWOR2.m@ 660

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

initial load of WorldVistAEHR

File size: 4.1 KB
Line 
1FHWOR2 ; HISC/NCA - HL7 Diet Order ;11/22/00 11:05
2 ;;5.5;DIETETICS;;Jan 28, 2005
3 S (DATE,D1)=SDT I DATE="" S TXT="No Start Date." D ERR^FHWOR Q
4 D NOW^%DTC D CVT^FHWOR S D1=DATE
5 S (DATE,D2)=EDT
6 I DATE D CVT^FHWOR S D2=DATE
7 I D2,D1>D2 S TXT="Wrong Stop Date." D ERR^FHWOR Q
8 S DATE=NOW D CVT^FHWOR S NOW=DATE
9 S FHRDER=+FHORN
10 I D1<% S D1=%
11 K DI S N1=0 F K=5:1 S X=$G(FHMSG(K)) Q:X="" D
12 .I $E(X,1,3)'="ODS" S TXT="Msg Error." Q
13 .S TYP=$E($P(X,"|",2),2) I TYP="" S TXT="No Type of Service." Q
14 .I "TCD"'[TYP S TXT="Wrong Type of Tray." Q
15 .S DIET=$P(X,"|",4),Y=$P(DIET,"^",4),FILE=$P(DIET,"^",6),COM=$E($P(X,"|",5),1,80)
16 .I $E(FILE,1,5)'="99FHD" S TXT="Msg Error." Q
17 .S PREC=$P($G(^FH(111,+Y,0)),"^",4) I $D(DI(PREC)) S TXT="Msg Error." Q
18 .S N1=N1+1,DI(PREC)=Y_"^"_$G(^FH(111,+Y,0)) Q
19 I TXT'="" D ERR^FHWOR Q
20 I N1>1 D I CHK S TXT="Can not order REGULAR with another Diet." D ERR^FHWOR Q
21 .S CHK=0 F D0=0:0 S D0=$O(DI(D0)) Q:D0="" I +DI(D0)=1 S CHK=1 Q
22 I N1>5 S TXT="Can not order more than 5 Diets." D ERR^FHWOR Q
23 S D4=0,FHOR="^^^^",FHEVTX="",N1=0 F D0=0:0 S D0=$O(DI(D0)) Q:D0<1 S N1=N1+1,$P(FHOR,"^",N1)=+DI(D0),FHEVTX=FHEVTX_", "_$P(DI(D0),"^",8) S:$P(DI(D0),"^",7)="Y" D4=1
24 S FHLD=""
25 I '$O(^FH(111.1,"AB",FHOR,0)),$P($G(^FH(119.9,1,4)),"^",2)="Y" S EVT="M^O^^No Diet Pattern ("_$E(FHEVTX,3,999)_")" D ^FHORX
26 ; Process PROC
27 D PROC^FHORD1
28 S CAN=$$CANCEL^ORCDFH(FHRDER)
29 I CAN S FHTF=$P($G(^FHPT(FHDFN,"A",ADM,0)),"^",4) D:FHTF ORCAN^FHWOR5 K FHRDER
30 K FHRDER G KIL
31CAN ; Process Cancel or Discontinue
32 S FHORD=$P(FILL,";",3) I 'FHORD D CSEND^FHWOR Q
33 D GADM^FHWORR
34 S FHREA=$P(DATA,"|",17),FHREA=$P(FHREA,"^",5) I FHREA="Discharge" D DIS^FHWOR4,CSEND^FHWOR K FHREA Q
35 D NC
36 D CSEND^FHWOR
37 D KIL^FHORD3 Q
38NC ; Cancel Diet Order
39 D NOW^%DTC S NOW=% S OLD=""
40 I '$D(^FHPT(FHDFN,"A",+ADM,"DI",+FHORD,0)) Q
41 I $P($G(^FHPT(FHDFN,"A",ADM,"DI",+FHORD,0)),"^",19)'="" Q
42 S NSTR=0 F KK=0:0 S KK=$O(^FHPT(FHDFN,"A",ADM,"AC",KK)) Q:KK<1!(KK'<NOW) S NSTR=KK
43 F KK=NSTR-.000001:0 S KK=$O(^FHPT(FHDFN,"A",ADM,"AC",KK)) Q:KK<1 I $P(^(KK,0),"^",2)=FHORD G F1
44 Q
45F1 D T0^FHORD3
46 Q
47DO ; Code Diet Orders
48 K MSG S FILL=$G(FHNEW)
49 S SDT=D1,DATE1="" D SET
50 ; Code MSH, PID, and PV1
51 D MSH^FHWOR
52 ; code ORC
53 S MSG(4)="ORC|SN||"_FILL_"^FH||||^^^"_SDT_"^"_DATE1_"|||"_DUZ_"||"_DUZ_"|||"_DATE
54 ; Code ODS
55 F A1=5:1 S A2=$P(FHOR,"^",A1-4) Q:'A2 D
56 .;S MSG(A1)="ODS|ZT||^^^"_A2_"^"_$P($G(^FH(111,+A2,0)),"^",1)_"^99FHD" Q
57 .I $G(TYP)="" S TYP="T"
58 .S MSG(A1)="ODS|Z"_TYP_"||^^^"_A2_"^"_$P($G(^FH(111,+A2,0)),"^",1)_"^99FHD" Q
59 K DATE,DATE1,FILL,FHWRD,HOSP,RM,SITE,SDT,VAL
60 Q
61SET ; Set Date/Time in HL7 format
62 S:SDT SDT=$$FMTHL7^XLFDT(SDT)
63 S:NOW DATE=$$FMTHL7^XLFDT(NOW)
64 S:D2 DATE1=$$FMTHL7^XLFDT(D2) S:'DATE1 DATE1=""
65 Q
66KIL ; Kill
67 G KIL^FHORD1
68CODE ; Code Cancel/Discontinue Diet Order Status Change
69 K MSG N ACT,FILL S FILL=$G(FHMSG1) S ACT=$S(FHSTS=6:"IP",FHSTS=8:"SC",FHSTS=1:"DC",1:"") Q:ACT="" D SITE^FH
70 ; code MSH
71 S MSG(1)="MSH|^~\&|DIETETICS|"_SITE(1)_"|||||"_$S($D(FHORR):"ORR",1:"ORM")
72 ; code PID
73 S MSG(2)="PID|||"_DFN_"||"_$P($G(^DPT(DFN,0)),"^",1)
74 ; code ORC
75 S DATE=$S(FHDAT'="":$P(FHDAT,"^",1),1:"")
76 I DATE S DATE=$$FMTHL7^XLFDT(DATE) S $P(FHDAT,"^",1)=DATE
77 S DATE=$S(FHDAT'="":$P(FHDAT,"^",2),1:"")
78 I DATE S DATE=$$FMTHL7^XLFDT(DATE) S $P(FHDAT,"^",2)=DATE
79 S MSG(3)="ORC|"_$S($D(FHORR):"SR",1:"SC")_"|"_FHORN_"^OR|"_FILL_"^FH||"_ACT
80 I FHDAT'="" S MSG(3)=MSG(3)_"||^^^"_FHDAT
81 I ACT="DC" S MSG(3)=MSG(3)_"|||"_$S($D(FHPV):FHPV,1:"")_"||"_$S($D(FHPV):FHPV,1:"")
82 K ACT,DATE,FHORR,FILL,SITE,WKDAYS Q
83NA ; OE/RR Number Assign
84 S FHORD=+$P(FILL,";",3) S:ADM'=$P(FILL,";",2) ADM=$P(FILL,";",2)
85 S $P(^FHPT(FHDFN,"A",ADM,"DI",FHORD,0),"^",14)=+FHORN Q
86EL ; Late Trays HL7 to OE/RR
87 K MSG S WKDAYS="",(EDT,SDT)=DTE
88 S ITVL="ONCE",WKD="",SERV="L"
89 S FILL="E"_";"_ADM_";;"_SDT_";"_EDT_";"_WKD_";"_MEAL_";"_TIM_";"_BAG
90 D SET^FHWOR3
91 ; Code MSH, PID, and PV1
92 D MSH^FHWOR
93 ; code ORC
94 S MSG(4)="ORC|SN||"_FILL_"^FH||||^"_ITVL_"^^"_SDT_"^"_EDT_"|||"_DUZ_"||"_DUZ_"|||"_NOW
95 ; code ODT
96 S MSG(5)="ODT|"_$S(SERV="E":"EARLY",1:"LATE")_"|^^^"_MEAL_SERV_NUM_"^^99FHS|"_$S(BAG="Y":"bagged",1:"")
97 K FHWARD,FILL,HOSP,ITVL,FHORN,RM,SITE,WARD,WKDAYS,Z
98 Q
Note: See TracBrowser for help on using the repository browser.