source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORMBLDFH.m@ 730

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

initial load of WorldVistAEHR

File size: 4.6 KB
Line 
1ORMBLDFH ; SLC/MKB - Build outgoing Dietetics ORM msgs ;11/17/00 11:06
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**73,97,215**;Dec 17, 1997
3 ;
4HL7DATE(DATE) ; -- FM -> HL7 format
5 Q $$FMTHL7^XLFDT(DATE) ;**97
6 ;
7PTR(NAME) ; -- Returns ptr value of prompt in Dialog file
8 Q $O(^ORD(101.41,"AB",$E(NAME,1,63),0))
9 ;
10DIET ; -- new Diet order (incl NPO)
11 I $P(OR0,U,12)'="I" D OPM Q
12 N OI,START,STOP,OR3,TYPE,TEXT,QT,INST,J
13 S START=$P($G(^OR(100,IFN,0)),U,8),STOP=$P($G(^(0)),U,9),OR3=$G(^(3))
14 S TYPE=$G(ORDIALOG($$PTR("OR GTX DELIVERY"),1))
15 S TEXT=$G(ORDIALOG($$PTR("OR GTX FREE TEXT 1"),1))
16 S OI=$$PTR("OR GTX ORDERABLE ITEM")
17 S QT="^^^"_$$HL7DATE(START)_U_$$HL7DATE(STOP),$P(ORMSG(4),"|",8)=QT
18 I $$NPO(OI) S ORMSG(5)="ODS|D||^^^FH-5^NPO^99OTH|"_TEXT Q
19 S INST=0,J=4 F S INST=$O(ORDIALOG(OI,INST)) Q:INST'>0 D
20 . S J=J+1,ORMSG(J)="ODS|Z"_TYPE_"||"_$$USID^ORMBLD(ORDIALOG(OI,INST))_"|"_TEXT
21 I $P(OR3,U,5) S $P(ORMSG(4),"|",4)=$G(^OR(100,+$P(OR3,U,5),4))_"^FH"
22 Q
23 ;
24NPO(Y) ; -- Returns 1 or 0, if diet ordered is NPO
25 N X,I S X=$O(^ORD(101.43,"S.DIET","NPO",0)),I=$O(ORDIALOG(Y,0))
26 Q (X=ORDIALOG(Y,I))
27 ;
28OPM ; -- new Outpatient Meal
29 N START,STOP,SCH,DAYS,X,I,QT,OI,MEAL,TEXT,TYPE,DELVRY
30 S START=$P($P(OR0,U,8),"."),STOP=$P($P(OR0,U,9),"."),TYPE="D"
31 S SCH=$G(ORDIALOG($$PTR("OR GTX SCHEDULE"),1)),DAYS=""
32 I '$L(SCH),START=DT,STOP=DT S TYPE="S" ;S=special, D=recurring meal
33 I $G(SCH)="ONCE" D ;reset to day for message
34 . S X=$$UP^XLFSTR($$DOW^XLFDT(START))
35 . S SCH=$S(X="THURSDAY":"R",X="SUNDAY":"X",1:$E(X))
36 I $L(SCH) F I=1:1:$L(SCH) S X=$E(SCH,I),DAYS=DAYS_$S($L(DAYS):"~",1:"")_"QJ"_($F("MTWRFSX",X)-1)
37 S QT=U_DAYS_"^^"_$$HL7DATE(START)_U_$$HL7DATE(STOP),$P(ORMSG(4),"|",8)=QT
38 S OI=$$PTR("OR GTX ORDERABLE ITEM")
39 S MEAL=$G(ORDIALOG($$PTR("OR GTX MEAL"),1)),MEAL=$TR(MEAL,"BNE","135")
40 S TEXT=$G(ORDIALOG($$PTR("OR GTX FREE TEXT 1"),1))
41 I $$NPO(OI) S ORMSG(5)="ODS|"_TYPE_"|"_MEAL_"|^^^FH-5^NPO^99OTH|"_TEXT Q
42 S I=$$PTR("OR GTX DELIVERY"),DELVRY=$S($D(ORDIALOG(I,1)):$$EXT^ORCD(I,1),1:"")
43 S ORMSG(5)="ODS|"_TYPE_"|"_MEAL_"|"_$$USID^ORMBLD(ORDIALOG(OI,1))_"|"_DELVRY
44 Q
45 ;
46ADDN ; -- new Additional Diet order
47 N TEXT D DATES
48 S TEXT=$G(ORDIALOG($$PTR("OR GTX FREE TEXT 1"),1))
49 S ORMSG(5)="ODS|D||^^^FH-6^ADDITIONAL ORDER^99OTH|"_TEXT
50 Q
51 ;
52DATES ; -- get Start date for order IFN, QT field in msg
53 N X,INPT S INPT=$S($P($G(^OR(100,+IFN,0)),U,12)="I":1,1:0)
54 S X=$S(INPT:+$E($$NOW^XLFDT,1,12),1:+$G(ORDIALOG($$PTR("OR GTX DATE/TIME"),1)))
55 D DATES^ORCSAVE2(+IFN,X) ;Stop date for outpts?
56 S $P(ORMSG(4),"|",8)="^^^"_$$HL7DATE(X)
57 Q
58 ;
59TF ; -- new Tubefeeding order
60 N OI,STR,QT,TEXT,I,J,TF,X,QUAN,INT,DUR
61 S OI=$$PTR("OR GTX ORDERABLE ITEM"),STR=$$PTR("OR GTX STRENGTH FH")
62 S QT=$$PTR("OR GTX INSTRUCTIONS") D DATES
63 S TEXT=$G(ORDIALOG($$PTR("OR GTX FREE TEXT 1"),1))
64 S J=4,I=0 F S I=$O(ORDIALOG(OI,I)) Q:I'>0 D
65 . S TF=$$USID^ORMBLD(ORDIALOG(OI,I)),$P(TF,U,4)=$P(TF,U,4)_"-"_$G(ORDIALOG(STR,I))
66 . S J=J+1,ORMSG(J)="ODS|ZE||"_TF_"|"_TEXT
67 . S X=$G(ORDIALOG(QT,I)),QUAN=+X_"&"_$E($P(X," ",2))
68 . S INT=$P($P(X,"/",2)," "),DUR=$P(X," X ",2)
69 . S:DUR DUR=$S(DUR["H":"H",1:"X")_+DUR
70 . S J=J+1,ORMSG(J)="ZQT||"_QUAN_U_INT_U_DUR
71 Q
72 ;
73TRAY ; -- new Early/Late Tray order
74 N START,STOP,ORL,MEAL,TYPE,OI,X,TIME,SCH,I,DAYS,BAGGED,ORPARAM,ORTIME
75 S START=$P($G(^OR(100,IFN,0)),U,8),STOP=$P(^(0),U,9),ORL=$P(^(0),U,10)
76 D EN1^FHWOR8(ORL,.ORPARAM),EN2^ORCDFH
77 S MEAL=$G(ORDIALOG($$PTR("OR GTX MEAL"),1))
78 S OI=$G(ORDIALOG($$PTR("OR GTX ORDERABLE ITEM"),1)),TYPE=$P($P($G(^ORD(101.43,+OI,0)),U)," ")
79 S TIME=$G(ORDIALOG($$PTR("OR GTX MEAL TIME"),1)),TIME=+$G(ORTIME(OI,MEAL,"C",TIME))
80 S:$G(ORDIALOG($$PTR("OR GTX YES/NO"),1)) BAGGED="bagged"
81 S SCH=$G(ORDIALOG($$PTR("OR GTX SCHEDULE"),1)),DAYS="ONCE"
82 I $L(SCH) S DAYS="" F I=1:1:$L(SCH) S X=$E(SCH,I),DAYS=DAYS_$S($L(DAYS):"~",1:"")_"QJ"_($F("MTWRFSX",X)-1)
83 S $P(ORMSG(4),"|",8)=U_DAYS_"^^"_$$HL7DATE(START)_U_$$HL7DATE(STOP)
84 S ORMSG(5)="ODT|"_$$UP^XLFSTR(TYPE)_"|^^^"_MEAL_$E(TYPE)_TIME_"^^99FHS"_"|"_$G(BAGGED)
85 Q
86 ;
87IP ; -- new Isolation/Precaution order
88 N NOW,IP S NOW=+$E($$NOW^XLFDT,1,12) D DATES^ORCSAVE2(+IFN,NOW)
89 S $P(ORMSG(4),"|",8)="^^^"_$$HL7DATE(NOW)
90 S IP=+$G(ORDIALOG($$PTR("OR GTX ISOLATION TYPE"),1))
91 S ORMSG(5)="OBR||||||||||||^^^"_IP_U_$P($G(^FH(119.4,IP,0)),U)_"^99FHI"
92 Q
93 ;
94CANCEL(TIME,DFN,LOC,PROV) ; -- Cancel outpatient meal time(s) where
95 ; TIME(n) = date.time
96 N ORMSG,ORNOW,I,J S ORNOW=$$FMTHL7^XLFDT($$NOW^XLFDT)
97 S ORMSG(1)=$$MSH^ORMBLD("ORM","FH")
98 S ORMSG(2)=$$PID^ORMBLD(+$G(DFN))
99 S ORMSG(3)=$$PV1^ORMBLD(+$G(DFN),"O",$G(LOC)),J=3
100 S I=0 F S I=$O(TIME(I)) Q:I<1 S X=TIME(I),J=J+1,ORMSG(J)="ORC|CA||"_X_"^FH||||||"_ORNOW_"|"_$G(DUZ)_"||"_$G(PROV)_"|||"_ORNOW
101 D MSG^XQOR("OR EVSEND FH",.ORMSG)
102 Q
Note: See TracBrowser for help on using the repository browser.