Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: RGADT

RGADT.m

Go to the documentation of this file.
  1. RGADT ;HIRMFO/GJC-ADT MESSAGE PROCESSING/ROUTING ;09/21/99
  1. ;;1.0;CLINICAL INFO RESOURCE NETWORK;**4,8,14,17**;30 Apr 99
  1. Q ; quit if called from the top
  1. ;
  1. EN ;entry point to process local ADT messages.
  1. ;
  1. ;This is call by the following clients:
  1. ; RG ADT-A01 CLIENT & RG ADT-A03 CLIENT (Generate/Process
  1. ; Routine(771) & Routing Logic(774) field definitions
  1. ;
  1. ; Integration Agreements (IAs) utilized in this application:
  1. ; #2051-$$FIND1^DIC
  1. ; #2165-GENACK^HLMA1
  1. ; #2171-$$LKUP^XUAF4
  1. ; #2541-$$KSP^XUPARAM
  1. ; #2701-$$GETDFN^MPIF001
  1. ; #2702-$$MPINODE^MPIFAPI
  1. ; #2988-IAs for VAFCTFU utilities
  1. ; #3037-ADT/HL7 EVENT REASON (#391.72) file access
  1. ; #10106-$$FMDATE^HLFNC
  1. ;
  1. Q:$G(HL("MTN"))="ACK" ; quit if a ACK message type is passed here
  1. K RGDC,RGDCDFN,RGDCERR,RGDCEVN,RGDCEVT1,RGDCPID,RGDCSFN,RGDCV,RGFLG
  1. S RGFLG=0,U="^" D INITIZE^RGRSUTIL ; copy HL7 message into local RGDC
  1. ; array
  1. S RGDCV=$$EN^RGRSMSH() ;return: dt rec'd^event dt^sending fac.(xternal)
  1. ; note: the above dates are in FileMan internal format
  1. S RGDCFROM=$$LKUP^XUAF4(+$P(RGDCV,U,3)) ; facility that sent the
  1. ; message. Could differ from the facility where the event occurred
  1. ; if inbound data is sent from a site running RG*1.0*17
  1. S RGDCPID=$$SEG1^RGRSUTIL("PID",1,"PID")
  1. S RGDCPV1=$$SEG1^RGRSUTIL("PV1",1,"PV1")
  1. S RGFLG=$S($P($P(RGDCPV1,HL("FS"),3),$E(HL("ECH")),4)["&":1,1:0)
  1. ; if RGFLG, the inbound message is from a patch 17 site and this
  1. ; site has patch 17 installed, so the message can be processed using
  1. ; TF data off the PV1 segment
  1. S RGDCEVN=$P($$SEG1^RGRSUTIL("EVN",1,"EVN"),HL("FS"),5)
  1. ; RGDCEVN is the event reason code
  1. S RGDCEVN=$$FIND1^DIC(391.72,"","AXM",RGDCEVN) ; event reason(internal)
  1. S RGDCEVT1=$P($$SEG1^RGRSUTIL("EVN",1,"EVN"),HL("FS"),2) ; event type
  1. S RGDCDFN=$$GETDFN^MPIF001(+$P(RGDCPID,HL("FS"),3))
  1. ; Note: $P(RGDCPID,HL("FS"),3) is: ICN_"V"_ICN checksum
  1. I RGFLG S RGDCSFN=$$SFN(RGDCPV1),RGDCSFN=$$LKUP^XUAF4(RGDCSFN)
  1. S:'RGFLG RGDCSFN=RGDCFROM ; TF from MSH segment
  1. ; RGDCSFN - obtain treating facility ien (file 4) from station #
  1. ;
  1. ; input variables to FILE^VAFCTFU
  1. ; RGDCDFN - patient ien ; RGDCSFN - treating facility
  1. ; $P(RGDCV,U,2) - date last treated ; RGDCEVN - event reason
  1. D FILE^VAFCTFU(RGDCDFN,RGDCSFN_U_$P(RGDCV,U,2)_U_RGDCEVN,$$SFCMOR(RGDCDFN,RGDCFROM))
  1. ; call to the TFL utility routine VAFCTFU. Centrally located code
  1. ; to add or edit to the TFL file. If $$SFCMOR(RGDCDFN,RGDCFROM)
  1. ; returns 1, let the Pivot file handle updates (MFUs) to subscribers.
  1. ; If 0, file data and do not re-broadcast.
  1. ;
  1. D GENACK ; generate the 'ack' message
  1. ;
  1. KILL ; kill and exit
  1. K HLINKP,HLINKX,HLL,RGDC,RGDCDFN,RGDCERR,RGDCEVN,RGDCEVT1,RGDCFROM,RGDCPID,RGDCPV1,RGDCSFN,RGDCV,RGFLG
  1. Q
  1. ;
  1. DYNROU(RGDCEVT) ; dynamic message routing, but first need to update the
  1. ; TREATING FACILITY LIST (TFL-391.91) file at the local site
  1. ; input-{RGDCEVT=event type
  1. K RGDCEDT,RGDCEVTR,RGDCSITE
  1. S RGDCSITE=$$KSP^XUPARAM("INST"),U="^"
  1. S RGDCEDT=$$FMDATE^HLFNC($P($$EVN(),U,3)) ; determine event date/time
  1. S RGDCEVTR=$$FIND1^DIC(391.72,"","AXM",$P($$EVN(),U,5)) ; event reason
  1. ;
  1. ; input variables to FILE^VAFCTFU
  1. ; DFN - patient ien ; RGDCSITE - treating facility
  1. ; RGDCEDT - date last treated ; RGDCEVTR - event reason
  1. D FILE^VAFCTFU(DFN,RGDCSITE_U_RGDCEDT_U_RGDCEVTR,1)
  1. ; call to the TFL utility routine VAFCTFU. Centrally located code
  1. ; to add or edit to the TFL file.
  1. ;
  1. ; route the message
  1. D EN^RGRSDYN("RG ADT-"_RGDCEVT_" CLIENT",0)
  1. K RGDCEDT,RGDCEVTR,RGDCSITE
  1. Q
  1. EVN() ; pass back the EVN segment.
  1. N I,X S I=0
  1. F S I=$O(HLA("HLS",I)) Q:I'>0 D Q:$D(X)
  1. . S:$P(HLA("HLS",I),U)="EVN" X=$G(HLA("HLS",I))
  1. . Q
  1. Q $G(X)
  1. GENACK ; Compile the 'ACK' segment, generate the 'ACK' message.
  1. 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:"")
  1. S HLEID=HL("EID"),HLEIDS=HL("EIDS"),HLARYTYP="LM",HLFORMAT=1
  1. D GENACK^HLMA1(HLEID,HLMTIENS,HLEIDS,HLARYTYP,HLFORMAT,.HLRESTLA)
  1. Q
  1. ;
  1. SFCMOR(DFN,SFAC) ; sent from CMOR? Determine if the patient's CMOR sent
  1. ; this VistA HL7 message
  1. ; input: DFN (patient dfn); SFAC (sending facility, ptr file 4)
  1. ; yield: 1 if sent from CMOR of patient, else 0
  1. Q $S(SFAC=$P($$MPINODE^MPIFAPI(DFN),"^",3):1,1:0)
  1. ;
  1. SFN(X) ; return the station number of the sending facility; PV1(3)
  1. ; input: PV1 segment
  1. ; yield: station number of sending facility
  1. N Y S Y=$P(X,HL("FS"),4) ; pnt_of_care~room~bed~&fac. station #
  1. S Y=$P(Y,$E(HL("ECH")),4) ; &fac. station #
  1. Q $P(Y,$E(HL("ECH"),4),2) ; fac. station #