source: WorldVistAEHR/trunk/r/CONSULT_REQUEST_TRACKING-GMRC-GMRS-GMRT/GMRCHL7A.m@ 1261

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

initial load of WorldVistAEHR

File size: 5.9 KB
RevLine 
[613]1GMRCHL7A ;SLC/DCM,MA - Receive HL-7 Message from OERR ;3/7/02 13:20
2 ;;3.0;CONSULT/REQUEST TRACKING;**1,5,12,15,21,22,33**;DEC 27, 1997
3 ;
4 ; This routine invokes IA #2849
5 ;
6URG(X) ;Return Urgency give Z-code from HL-7 segment; see ORC+9
7 S X=$S(X="S":"STAT",X="R":"ROUTINE",X="ZT":"TODAY",X="Z24":"WITHIN 24 HOURS",X="Z48":"WITHIN 48 HOURS",X="Z72":"WITHIN 72 HOURS",X="ZW":"WITHIN 1 WEEK",X="ZM":"WITHIN 1 MONTH",X="ZNA":"NEXT AVAILABLE",1:X)
8 I $E(X,1)="Z" S X=$S(X="ZT":"TODAY",X="ZE":"EMERGENCY",1:"")
9 Q X
10 ;
11ORC(GMRCORC) ;Get fields from ORC segment and set into GMRC variables
12 ;GMRCTRLC=ORC control code from HL7 Table 119
13 ;GMRCURGI=priority/urgency GMRCPLCR=who entered the order
14 ;GMRCORNP=provider GMRCNATO=nature of order
15 ;GMRCAD=date of request GMRCOCR=order request reason
16 ;GMRCORFN=oe/rr file number GMRCO=file 123 IEN - if not a new order
17 ;GMRCS38=order status - taken from Table 38, HL7 standard
18 S GMRCTRLC=$P(GMRCORC,SEP1,2),GMRCORFN=$P(GMRCORC,SEP1,3),GMRCORFN=$P($P(GMRCORFN,SEP2,1),";",1),GMRCAPP=$P($P(GMRCORC,SEP1,3),SEP2,2)
19 S GMRCS38=$P(GMRCORC,SEP1,6),GMRCURGI=$P($P(GMRCORC,SEP1,8),SEP2,6),GMRCPLCR=$P(GMRCORC,SEP1,11),GMRCORNP=$P(GMRCORC,SEP1,13)
20 I $L(GMRCURGI) S GMRCURGI="GMRCURGENCY - "_$$URG(GMRCURGI),GMRCURGI=$O(^ORD(101,"B",GMRCURGI,0))
21 S GMRCO=+$P($P(GMRCORC,SEP1,4),SEP2,1)
22 S GMRCODT=$P(GMRCORC,SEP1,16),GMRCAD=$$FMDATE^GMRCHL7(GMRCODT)
23 S GMRCOCR=$P(GMRCORC,SEP1,17),GMRCNATO=$P(GMRCOCR,SEP2,5)
24 Q
25OBR(GMRCOBR) ;Get fields from OBR segment and set into GMRC variables
26 ;GMRCTYPE=GMRC consult or GMRC request GMRCSS=To Service
27 ;GMRCPLI=place of consultation GMRCODT=observation date/time
28 ;GMRCATN=person to alert (attention) GMRCSTDT=status change date/time
29 ;GMRCS123=results status (table 123) GMRCINTR=results interpreter
30 ;GMRCPRI=procedure from file ^ORD(101,
31 ;GMRCXMF=foreign consult service
32 ; a flag that tells the HL7 routine that
33 ; consults does not need to return CPRS a file
34 ; IEN for file 123. See routine ^GMRCXMF
35 S GMRCPR=$P($P(GMRCOBR,SEP1,5),SEP2,6)
36 S GMRCTYPE=$S(GMRCPR="99PRC":"P",1:"C")
37 S GMRCPRI="",GMRCSS=""
38 I GMRCPR="99PRC" D
39 . S GMRCPRI=$P($P(GMRCOBR,SEP1,5),SEP2,4)
40 . S GMRCPRI=$S(+GMRCPRI:GMRCPRI_";GMR(123.3,",1:"")
41 . Q
42 ;
43 S GMRCOTXT=$P($P(GMRCOBR,SEP1,5),SEP2,5) ;consult type or service name
44 S GMRCODT=$P(GMRCOBR,SEP1,7) I GMRCODT]"" S GMRCODT=$$FMDATE^GMRCHL7(GMRCODT)
45 S GMRCPLI=$P(GMRCOBR,SEP1,19) I GMRCPLI]"" S GMRCPLI="GMRCPLACE - "_$S(GMRCPLI="OC":"ON CALL",GMRCPLI="B":"BEDSIDE",GMRCPLI="E":"EMERGENCY ROOM",1:GMRCPLI),GMRCPLI=$O(^ORD(101,"B",GMRCPLI,0))
46 S GMRCATN=$P(GMRCOBR,SEP1,20),GMRCSTDT=$P(GMRCOBR,SEP1,23),GMRCSTDT=$$FMDATE^GMRCHL7(GMRCSTDT)
47 S GMRCS123=$P(GMRCOBR,SEP1,26),GMRCINTR=$P(GMRCOBR,SEP1,33)
48 Q
49ZSV(GMRCZSV) ;Get service from ZSV segment and set into GMRCSS
50 S GMRCZSS=$P($P(GMRCZSV,SEP1,2),SEP2,4)
51 I +$G(GMRCZSS) S GMRCSS=+$G(GMRCZSS) ;Set the service if ZSV provided
52 I $L($P(GMRCZSV,"|",3)) S GMRCOTXT=$P(GMRCZSV,"|",3) ;consult type
53 Q
54OBX(GMRCOBX) ;Get fields from OBX segment and set into GMRC variables
55 ;GMRCVTYP=Value type from table 123 - i.e. TX(text), ST(string data),etc.
56 ;GMRCOID=observation id identifying value in seg. 5
57 ;GMRCVAL=observation value coded by segment 3
58 ;GMRCPRDG=provisional diagnosis
59 ; free text or code^free text^I9C
60 S GMRCMSG=MSG(GMRCOBX)
61 S GMRCVTYP=$P(GMRCMSG,SEP1,3),GMRCOID=$P($P(GMRCMSG,SEP1,4),SEP2,2),GMRCVAL=$P(GMRCOID,SEP2,3)
62 I GMRCOID="REASON FOR REQUEST" D
63 .S GMRCRFQ(1)=$P(GMRCMSG,SEP1,6)
64 .S LN=0 F S LN=$O(MSG(GMRCOBX,LN)) Q:LN="" S GMRCRFQ(LN+1)=MSG(GMRCOBX,LN)
65 .Q
66 I GMRCOID="PROVISIONAL DIAGNOSIS" D Q
67 . I GMRCVTYP="TX" S GMRCPRDG=$P(GMRCMSG,SEP1,6) Q
68 . I GMRCVTYP="CE" D Q
69 .. N PRDXSEG S PRDXSEG=$P(GMRCMSG,SEP1,6)
70 .. S GMRCPRDG=$P(PRDXSEG,"^",2)_" ("_$P(PRDXSEG,"^")_")"
71 .. S GMRCPRCD=$P(PRDXSEG,"^")
72 I GMRCOID["COMMENT" D
73 .S GMRCCMT(1)=$P(GMRCMSG,SEP1,6)
74 .S LN=0 F S LN=$O(MSG(GMRCOBX,LN)) Q:LN="" S GMRCCMT(LN+1)=MSG(GMRCOBX,LN)
75 .Q
76 K LN
77 Q
78EN(MSG) ;Entry point to routine
79 ;MSG = local array which contains the HL-7 segments
80 ;GMRCSEND=sending application GMRCFAC=sending facility
81 ;GMRCMTP=message type
82 N DFN,GMRCACT,GMRCADD,GMRCFAC,GMRCMTP,GMRCPNM,GMRCO,GMRCOCR,GMRCORNP
83 N GMRCORFN,GMRCPLCR,GMRCRB,GMRCSEND,GMRCSTS,GMRCTRLC,GMRCWARD,ORIFN
84 N GMRCTRLC,GMRCAD,ORC,GMRCSBR,GMRCZSS,GMRCSS,GMRCOTXT,GMRCPRCD
85 N GMRCREJ,GMRCRECV
86 S GMRCMSG="",GMRCNOD=0 F S GMRCNOD=$O(MSG(GMRCNOD)) Q:GMRCNOD="" S GMRCMSG=MSG(GMRCNOD) I $E(GMRCMSG,1,3)="MSH" D INIT^GMRCHL7U(GMRCMSG) D Q
87 .S GMRCSEND=$P(GMRCMSG,SEP1,3),GMRCFAC=$P(GMRCMSG,SEP1,4)
88 .S GMRCMTP=$P(GMRCMSG,SEP1,9),GMRCRECV=$P(GMRCMSG,SEP1,5)
89 .Q
90 I $G(GMRCRECV)'="CONSULTS" Q ;not intended for Consults
91 S GMRCMSG="",GMRCNOD=0
92 F S GMRCNOD=$O(MSG(GMRCNOD)) Q:GMRCNOD="" S GMRCMSG=MSG(GMRCNOD) D
93 .I $E(GMRCMSG,1,3)="PID" D PID^GMRCHL7U(GMRCMSG) Q
94 .I $E(GMRCMSG,1,3)="PV1" D PV1^GMRCHL7U(GMRCMSG) Q
95 .I $E(GMRCMSG,1,3)="ORC" D ORC(GMRCMSG) Q
96 .I $E(GMRCMSG,1,3)="OBR" D OBR(GMRCMSG) Q
97 .I $E(GMRCMSG,1,3)="ZSV" D ZSV(GMRCMSG) Q
98 .I $E(GMRCMSG,1,3)="OBX" D OBX(GMRCNOD) Q
99 .I $E(GMRCMSG,1,3)="NTE" D NTE^GMRCHL7U(.MSG,GMRCNOD,GMRCO,GMRCTRLC) Q
100 .I $E(GMRCMSG,1,3)="ZXX" S GMRCOFN=+$P(GMRCMSG,SEP1,2) K MSG(GMRCNOD) Q
101 .Q
102 ;Note, ZXX is not used yet; planned for future sharing consults with foreign facilities.
103 I '$D(GMRCTRLC) D EXIT^GMRCHL7U Q
104 I GMRCTRLC="Z@" D CPRSPURG^GMRCPURG(+GMRCO),EXIT^GMRCHL7U Q
105 I GMRCTRLC="NW" D NEW^GMRCHL7B(.GMRCREJ) D
106 . I $G(GMRCO) D RETURN^GMRCHL7U(GMRCO,GMRCTRLC) Q
107 . D REJECT^GMRCHL7U(.MSG,$G(GMRCREJ))
108 I '$D(GMRCO) D EXIT^GMRCHL7U Q
109 I $S(GMRCTRLC="CA":1,GMRCTRLC="DC":1,1:0) D DC^GMRCHL7B(GMRCO,GMRCTRLC),RETURN^GMRCHL7U(GMRCO,GMRCTRLC)
110 I GMRCTRLC="NA" D RTN(GMRCORFN,GMRCO)
111 I GMRCTRLC="XX" D MODIFY^GMRCHL7B ;Not currently returned by CPRS
112 ; If consults sends an XX, CPRS returns an NA.
113 D EXIT^GMRCHL7U
114 Q
115RTN(GMRCORN,DA) ;Put ^OR(100, ien for order into ^GMR(123,
116 S DIE="^GMR(123,",DR=".03////^S X=GMRCORN"
117 L +^GMR(123,DA) D ^DIE L -^GMR(123,DA)
118 K DIE,DR
119 Q
Note: See TracBrowser for help on using the repository browser.