RGRSPT ;ALB/RJS,CML-HIGH LEVEL ROUTINE FOR PARSING AND FILING ;06/25/98
;;1.0;CLINICAL INFO RESOURCE NETWORK;**1,3,7,8,52**;30 Apr 99;Build 2
;
;Parse Incoming Message, and file.
;
;
Q:($G(HL("MTN"))'="ADT")
N RGRSDFN,VAFCA,RGRS,VAFCA08,RGRSARAY,BOGUS,RGDC,SENSTVTY,CMORDISP
N NAME,LASTNAME,SSN,ICN,CMOR,CMORIEN,OTHSITE,RGRSDATA,HERE,BULSUB,NODE
S RGRSARAY="RGRS(2)"
D INITIZE^RGRSUTIL ;copy HL7 message into local RGDC array
S VAFCA=$$EN^RGRSMSH() ;parse MSH for filer
D EN^RGRSPARS(RGRSARAY) ;parse HL7 message into local array RGRS
I $$SKIP^RGRSZZPT(1,RGRSARAY) D G EXIT ;skip if certain data is not there
. D SKIPBULL^RGRSBULL(RGRSARAY)
S RGRSDFN=$$GETDFN^MPIF001(@RGRSARAY@(991.01)) ;Get DFN from ICN
Q:+$$SEND2^VAFCUTL1(RGRSDFN,"T") ;safeguard to prevent the processing of test patients
S OTHSITE=@RGRSARAY@("SITENUM")\1
S HERE=$P($$SITE^VASITE,"^",3)\1
;
;If patient not known in site, send bulletin, go exit
;
I +RGRSDFN=-1 D EXC^RGHLLOG(210,"Msg#"_$G(HL("MID"))_" Bad DFN#"_$G(RGRSDFN)_" for "_$G(@RGRSARAY@(.01))_" (ICN#"_$G(@RGRSARAY@(991.01))_")") D STOP^RGHLLOG(1) Q
;
S NAME=$$GET1^DIQ(2,+RGRSDFN_",",.01)
S LASTNAME=$P(NAME,",",1)
S SSN=$$GET1^DIQ(2,+RGRSDFN_",",.09)
S NODE=$$MPINODE^MPIFAPI(RGRSDFN)
S ICN=$P(NODE,"^")
S CMORIEN=$P(NODE,"^",3)
S CMOR=$$NS^XUAF4(CMORIEN)
S CMORDISP=$P(CMOR,"^",1)
S CMOR=$P(CMOR,"^",2)
;
S @RGRSARAY@("NAME")=@RGRSARAY@(.01)
S @RGRSARAY@("SSN")=@RGRSARAY@(.09)
S @RGRSARAY@("ICN")=@RGRSARAY@(991.01)
S @RGRSARAY@("CMOR")=$P($$NS^XUAF4($$LKUP^XUAF4(OTHSITE)),"^")
;
;If ICN or CMOR don't match, send bulletin and go exit
I '$$MATCH(RGRSDFN,RGRSARAY,,,ICN,CMOR,.BULSUB) D G EXIT
. D MTCHBULL^RGRSBULL(RGRSDFN,RGRSARAY,NAME,SSN,ICN,CMORDISP,BULSUB)
;
;if ICN and CMOR match, check for SSN edit from CMOR
I @RGRSARAY@("SENDING SITE")=CMOR,(SSN'=@RGRSARAY@(.09)) D
.D SSNBULL^RGRSBUL1(RGRSDFN,RGRSARAY,NAME,SSN,ICN,CMORDISP)
;
;If patient is Sensitive at other site but not here send bulletin
S SENSTVTY=$G(@RGRSARAY@("SENSITIVITY"))
I '$$SENSTIVE^RGRSENS(RGRSDFN),SENSTVTY D SENSTIVE^RGRSBUL1(RGRSDFN,RGRSARAY,NAME)
;
;MPIC_772 - **52; Commented out Remote Date of Death Indicated section.
;If patient has DATE OF DEATH (DOD) at remote site send bulletin
;Ignore time if present with date.
;S RMTDOD=@RGRSARAY@(.351),RMTDOD=$P(RMTDOD,".")
;S DFN=RGRSDFN D DEM^VADPT
;S LOCDOD=$P($P(VADM(6),"^"),".")
;If there is a remote DOD but no local DOD OR
;if remote DOD is different from local DOD, send bulletin
;I RMTDOD D RMTDOD^RGRSBUL1(RGRSDFN,RGRSARAY,NAME,RMTDOD,LOCDOD)
;K LOCDOD,RMTDOD,VADM
;
D G EXIT ;**7
. ;
. ;IF it's the CMOR - review file
. ;
. I (OTHSITE)=(HERE) D Q
. . S VAFCA=VAFCA_"^"_RGRSDFN
. . S VAFCA08=1 S BOGUS=$$ADD^VAFCEHU1(VAFCA,"RGRS")
. ;
. ;IF it's not the CMOR - Don't Rebroadcast
. ;
. I (OTHSITE)'=(HERE) D Q
. . S VAFCA08=1
. . D EDIT^VAFCPTED(RGRSDFN,RGRSARAY,".01;.03;.09;.02;.2403") ;**7 broadcasted fields - removed .05,.08,.111;.112;.113;.114;.115;.1112;.117;.131;.132;.211;.219;.31115
EXIT ;
Q
;
MATCH(DFN,RGRSARAY,LASTNAME,SSN,ICN,CMOR,BULSUB) ;
Q:$G(DFN)=""!($G(RGRSARAY)="") 0
N COUNT,TRUE S (COUNT,TRUE)=0
S BULSUB=""
I $D(LASTNAME) D
. S COUNT=COUNT+1
. I (LASTNAME'=""),(LASTNAME=$P(@RGRSARAY@(.01),",",1)) S TRUE=TRUE+1
I $D(SSN) D
. S COUNT=COUNT+1
. I (SSN'=""),(SSN=$G(@RGRSARAY@(.09))) S TRUE=TRUE+1
I $D(ICN) D
. S COUNT=COUNT+1
. I (ICN'=""),(ICN=$G(@RGRSARAY@(991.01))) S TRUE=TRUE+1 Q
. S BULSUB=BULSUB_"ICN"
I $D(CMOR) D
. S COUNT=COUNT+1
. I (CMOR'=""),(CMOR=$G(@RGRSARAY@("SITENUM"))) S TRUE=TRUE+1 Q
. I BULSUB]"" S BULSUB=BULSUB_" & "
. S BULSUB=BULSUB_"CMOR"
I COUNT=TRUE Q 1
Q 0
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRGRSPT 3782 printed Sep 02, 2024@18:28:23 Page 2
RGRSPT ;ALB/RJS,CML-HIGH LEVEL ROUTINE FOR PARSING AND FILING ;06/25/98
+1 ;;1.0;CLINICAL INFO RESOURCE NETWORK;**1,3,7,8,52**;30 Apr 99;Build 2
+2 ;
+3 ;Parse Incoming Message, and file.
+4 ;
+5 ;
+6 if ($GET(HL("MTN"))'="ADT")
QUIT
+7 NEW RGRSDFN,VAFCA,RGRS,VAFCA08,RGRSARAY,BOGUS,RGDC,SENSTVTY,CMORDISP
+8 NEW NAME,LASTNAME,SSN,ICN,CMOR,CMORIEN,OTHSITE,RGRSDATA,HERE,BULSUB,NODE
+9 SET RGRSARAY="RGRS(2)"
+10 ;copy HL7 message into local RGDC array
DO INITIZE^RGRSUTIL
+11 ;parse MSH for filer
SET VAFCA=$$EN^RGRSMSH()
+12 ;parse HL7 message into local array RGRS
DO EN^RGRSPARS(RGRSARAY)
+13 ;skip if certain data is not there
IF $$SKIP^RGRSZZPT(1,RGRSARAY)
Begin DoDot:1
+14 DO SKIPBULL^RGRSBULL(RGRSARAY)
End DoDot:1
GOTO EXIT
+15 ;Get DFN from ICN
SET RGRSDFN=$$GETDFN^MPIF001(@RGRSARAY@(991.01))
+16 ;safeguard to prevent the processing of test patients
if +$$SEND2^VAFCUTL1(RGRSDFN,"T")
QUIT
+17 SET OTHSITE=@RGRSARAY@("SITENUM")\1
+18 SET HERE=$PIECE($$SITE^VASITE,"^",3)\1
+19 ;
+20 ;If patient not known in site, send bulletin, go exit
+21 ;
+22 IF +RGRSDFN=-1
DO EXC^RGHLLOG(210,"Msg#"_$GET(HL("MID"))_" Bad DFN#"_$GET(RGRSDFN)_" for "_$GET(@RGRSARAY@(.01))_" (ICN#"_$GET(@RGRSARAY@(991.01))_")")
DO STOP^RGHLLOG(1)
QUIT
+23 ;
+24 SET NAME=$$GET1^DIQ(2,+RGRSDFN_",",.01)
+25 SET LASTNAME=$PIECE(NAME,",",1)
+26 SET SSN=$$GET1^DIQ(2,+RGRSDFN_",",.09)
+27 SET NODE=$$MPINODE^MPIFAPI(RGRSDFN)
+28 SET ICN=$PIECE(NODE,"^")
+29 SET CMORIEN=$PIECE(NODE,"^",3)
+30 SET CMOR=$$NS^XUAF4(CMORIEN)
+31 SET CMORDISP=$PIECE(CMOR,"^",1)
+32 SET CMOR=$PIECE(CMOR,"^",2)
+33 ;
+34 SET @RGRSARAY@("NAME")=@RGRSARAY@(.01)
+35 SET @RGRSARAY@("SSN")=@RGRSARAY@(.09)
+36 SET @RGRSARAY@("ICN")=@RGRSARAY@(991.01)
+37 SET @RGRSARAY@("CMOR")=$PIECE($$NS^XUAF4($$LKUP^XUAF4(OTHSITE)),"^")
+38 ;
+39 ;If ICN or CMOR don't match, send bulletin and go exit
+40 IF '$$MATCH(RGRSDFN,RGRSARAY,,,ICN,CMOR,.BULSUB)
Begin DoDot:1
+41 DO MTCHBULL^RGRSBULL(RGRSDFN,RGRSARAY,NAME,SSN,ICN,CMORDISP,BULSUB)
End DoDot:1
GOTO EXIT
+42 ;
+43 ;if ICN and CMOR match, check for SSN edit from CMOR
+44 IF @RGRSARAY@("SENDING SITE")=CMOR
IF (SSN'=@RGRSARAY@(.09))
Begin DoDot:1
+45 DO SSNBULL^RGRSBUL1(RGRSDFN,RGRSARAY,NAME,SSN,ICN,CMORDISP)
End DoDot:1
+46 ;
+47 ;If patient is Sensitive at other site but not here send bulletin
+48 SET SENSTVTY=$GET(@RGRSARAY@("SENSITIVITY"))
+49 IF '$$SENSTIVE^RGRSENS(RGRSDFN)
IF SENSTVTY
DO SENSTIVE^RGRSBUL1(RGRSDFN,RGRSARAY,NAME)
+50 ;
+51 ;MPIC_772 - **52; Commented out Remote Date of Death Indicated section.
+52 ;If patient has DATE OF DEATH (DOD) at remote site send bulletin
+53 ;Ignore time if present with date.
+54 ;S RMTDOD=@RGRSARAY@(.351),RMTDOD=$P(RMTDOD,".")
+55 ;S DFN=RGRSDFN D DEM^VADPT
+56 ;S LOCDOD=$P($P(VADM(6),"^"),".")
+57 ;If there is a remote DOD but no local DOD OR
+58 ;if remote DOD is different from local DOD, send bulletin
+59 ;I RMTDOD D RMTDOD^RGRSBUL1(RGRSDFN,RGRSARAY,NAME,RMTDOD,LOCDOD)
+60 ;K LOCDOD,RMTDOD,VADM
+61 ;
+62 ;**7
Begin DoDot:1
+63 ;
+64 ;IF it's the CMOR - review file
+65 ;
+66 IF (OTHSITE)=(HERE)
Begin DoDot:2
+67 SET VAFCA=VAFCA_"^"_RGRSDFN
+68 SET VAFCA08=1
SET BOGUS=$$ADD^VAFCEHU1(VAFCA,"RGRS")
End DoDot:2
QUIT
+69 ;
+70 ;IF it's not the CMOR - Don't Rebroadcast
+71 ;
+72 IF (OTHSITE)'=(HERE)
Begin DoDot:2
+73 SET VAFCA08=1
+74 ;**7 broadcasted fields - removed .05,.08,.111;.112;.113;.114;.115;.1112;.117;.131;.132;.211;.219;.31115
DO EDIT^VAFCPTED(RGRSDFN,RGRSARAY,".01;.03;.09;.02;.2403")
End DoDot:2
QUIT
End DoDot:1
GOTO EXIT
EXIT ;
+1 QUIT
+2 ;
MATCH(DFN,RGRSARAY,LASTNAME,SSN,ICN,CMOR,BULSUB) ;
+1 if $GET(DFN)=""!($GET(RGRSARAY)="")
QUIT 0
+2 NEW COUNT,TRUE
SET (COUNT,TRUE)=0
+3 SET BULSUB=""
+4 IF $DATA(LASTNAME)
Begin DoDot:1
+5 SET COUNT=COUNT+1
+6 IF (LASTNAME'="")
IF (LASTNAME=$PIECE(@RGRSARAY@(.01),",",1))
SET TRUE=TRUE+1
End DoDot:1
+7 IF $DATA(SSN)
Begin DoDot:1
+8 SET COUNT=COUNT+1
+9 IF (SSN'="")
IF (SSN=$GET(@RGRSARAY@(.09)))
SET TRUE=TRUE+1
End DoDot:1
+10 IF $DATA(ICN)
Begin DoDot:1
+11 SET COUNT=COUNT+1
+12 IF (ICN'="")
IF (ICN=$GET(@RGRSARAY@(991.01)))
SET TRUE=TRUE+1
QUIT
+13 SET BULSUB=BULSUB_"ICN"
End DoDot:1
+14 IF $DATA(CMOR)
Begin DoDot:1
+15 SET COUNT=COUNT+1
+16 IF (CMOR'="")
IF (CMOR=$GET(@RGRSARAY@("SITENUM")))
SET TRUE=TRUE+1
QUIT
+17 IF BULSUB]""
SET BULSUB=BULSUB_" & "
+18 SET BULSUB=BULSUB_"CMOR"
End DoDot:1
+19 IF COUNT=TRUE
QUIT 1
+20 QUIT 0