source: FOIAVistA/trunk/r/ZZREGIONAL-A1C-A5C-CRHD-RGED-RGUT-RGWB-RG/RGADT.m@ 1742

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

initial load of FOIAVistA 6/30/08 version

File size: 4.4 KB
Line 
1RGADT ;HIRMFO/GJC-ADT MESSAGE PROCESSING/ROUTING ;09/21/99
2 ;;1.0;CLINICAL INFO RESOURCE NETWORK;**4,8,14,17**;30 Apr 99
3 Q ; quit if called from the top
4 ;
5EN ;entry point to process local ADT messages.
6 ;
7 ;This is call by the following clients:
8 ; RG ADT-A01 CLIENT & RG ADT-A03 CLIENT (Generate/Process
9 ; Routine(771) & Routing Logic(774) field definitions
10 ;
11 ; Integration Agreements (IAs) utilized in this application:
12 ; #2051-$$FIND1^DIC
13 ; #2165-GENACK^HLMA1
14 ; #2171-$$LKUP^XUAF4
15 ; #2541-$$KSP^XUPARAM
16 ; #2701-$$GETDFN^MPIF001
17 ; #2702-$$MPINODE^MPIFAPI
18 ; #2988-IAs for VAFCTFU utilities
19 ; #3037-ADT/HL7 EVENT REASON (#391.72) file access
20 ; #10106-$$FMDATE^HLFNC
21 ;
22 Q:$G(HL("MTN"))="ACK" ; quit if a ACK message type is passed here
23 K RGDC,RGDCDFN,RGDCERR,RGDCEVN,RGDCEVT1,RGDCPID,RGDCSFN,RGDCV,RGFLG
24 S RGFLG=0,U="^" D INITIZE^RGRSUTIL ; copy HL7 message into local RGDC
25 ; array
26 S RGDCV=$$EN^RGRSMSH() ;return: dt rec'd^event dt^sending fac.(xternal)
27 ; note: the above dates are in FileMan internal format
28 S RGDCFROM=$$LKUP^XUAF4(+$P(RGDCV,U,3)) ; facility that sent the
29 ; message. Could differ from the facility where the event occurred
30 ; if inbound data is sent from a site running RG*1.0*17
31 S RGDCPID=$$SEG1^RGRSUTIL("PID",1,"PID")
32 S RGDCPV1=$$SEG1^RGRSUTIL("PV1",1,"PV1")
33 S RGFLG=$S($P($P(RGDCPV1,HL("FS"),3),$E(HL("ECH")),4)["&":1,1:0)
34 ; if RGFLG, the inbound message is from a patch 17 site and this
35 ; site has patch 17 installed, so the message can be processed using
36 ; TF data off the PV1 segment
37 S RGDCEVN=$P($$SEG1^RGRSUTIL("EVN",1,"EVN"),HL("FS"),5)
38 ; RGDCEVN is the event reason code
39 S RGDCEVN=$$FIND1^DIC(391.72,"","AXM",RGDCEVN) ; event reason(internal)
40 S RGDCEVT1=$P($$SEG1^RGRSUTIL("EVN",1,"EVN"),HL("FS"),2) ; event type
41 S RGDCDFN=$$GETDFN^MPIF001(+$P(RGDCPID,HL("FS"),3))
42 ; Note: $P(RGDCPID,HL("FS"),3) is: ICN_"V"_ICN checksum
43 I RGFLG S RGDCSFN=$$SFN(RGDCPV1),RGDCSFN=$$LKUP^XUAF4(RGDCSFN)
44 S:'RGFLG RGDCSFN=RGDCFROM ; TF from MSH segment
45 ; RGDCSFN - obtain treating facility ien (file 4) from station #
46 ;
47 ; input variables to FILE^VAFCTFU
48 ; RGDCDFN - patient ien ; RGDCSFN - treating facility
49 ; $P(RGDCV,U,2) - date last treated ; RGDCEVN - event reason
50 D FILE^VAFCTFU(RGDCDFN,RGDCSFN_U_$P(RGDCV,U,2)_U_RGDCEVN,$$SFCMOR(RGDCDFN,RGDCFROM))
51 ; call to the TFL utility routine VAFCTFU. Centrally located code
52 ; to add or edit to the TFL file. If $$SFCMOR(RGDCDFN,RGDCFROM)
53 ; returns 1, let the Pivot file handle updates (MFUs) to subscribers.
54 ; If 0, file data and do not re-broadcast.
55 ;
56 D GENACK ; generate the 'ack' message
57 ;
58KILL ; kill and exit
59 K HLINKP,HLINKX,HLL,RGDC,RGDCDFN,RGDCERR,RGDCEVN,RGDCEVT1,RGDCFROM,RGDCPID,RGDCPV1,RGDCSFN,RGDCV,RGFLG
60 Q
61 ;
62DYNROU(RGDCEVT) ; dynamic message routing, but first need to update the
63 ; TREATING FACILITY LIST (TFL-391.91) file at the local site
64 ; input-{RGDCEVT=event type
65 K RGDCEDT,RGDCEVTR,RGDCSITE
66 S RGDCSITE=$$KSP^XUPARAM("INST"),U="^"
67 S RGDCEDT=$$FMDATE^HLFNC($P($$EVN(),U,3)) ; determine event date/time
68 S RGDCEVTR=$$FIND1^DIC(391.72,"","AXM",$P($$EVN(),U,5)) ; event reason
69 ;
70 ; input variables to FILE^VAFCTFU
71 ; DFN - patient ien ; RGDCSITE - treating facility
72 ; RGDCEDT - date last treated ; RGDCEVTR - event reason
73 D FILE^VAFCTFU(DFN,RGDCSITE_U_RGDCEDT_U_RGDCEVTR,1)
74 ; call to the TFL utility routine VAFCTFU. Centrally located code
75 ; to add or edit to the TFL file.
76 ;
77 ; route the message
78 D EN^RGRSDYN("RG ADT-"_RGDCEVT_" CLIENT",0)
79 K RGDCEDT,RGDCEVTR,RGDCSITE
80 Q
81EVN() ; pass back the EVN segment.
82 N I,X S I=0
83 F S I=$O(HLA("HLS",I)) Q:I'>0 D Q:$D(X)
84 . S:$P(HLA("HLS",I),U)="EVN" X=$G(HLA("HLS",I))
85 . Q
86 Q $G(X)
87GENACK ; Compile the 'ACK' segment, generate the 'ACK' message.
88 S HLA("HLA",1)="MSA"_HL("FS")_$S($G(RGDCERR)]"":"AE",1:"AA")_HL("FS")_HL("MID")_$S($G(RGDCERR)]"":HL("FS")_$G(RGDCERR),1:"")
89 S HLEID=HL("EID"),HLEIDS=HL("EIDS"),HLARYTYP="LM",HLFORMAT=1
90 D GENACK^HLMA1(HLEID,HLMTIENS,HLEIDS,HLARYTYP,HLFORMAT,.HLRESTLA)
91 Q
92 ;
93SFCMOR(DFN,SFAC) ; sent from CMOR? Determine if the patient's CMOR sent
94 ; this VistA HL7 message
95 ; input: DFN (patient dfn); SFAC (sending facility, ptr file 4)
96 ; yield: 1 if sent from CMOR of patient, else 0
97 Q $S(SFAC=$P($$MPINODE^MPIFAPI(DFN),"^",3):1,1:0)
98 ;
99SFN(X) ; return the station number of the sending facility; PV1(3)
100 ; input: PV1 segment
101 ; yield: station number of sending facility
102 N Y S Y=$P(X,HL("FS"),4) ; pnt_of_care~room~bed~&fac. station #
103 S Y=$P(Y,$E(HL("ECH")),4) ; &fac. station #
104 Q $P(Y,$E(HL("ECH"),4),2) ; fac. station #
Note: See TracBrowser for help on using the repository browser.