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

RGRSPT.m

Go to the documentation of this file.
  1. 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
  1. ;
  1. ;Parse Incoming Message, and file.
  1. ;
  1. ;
  1. Q:($G(HL("MTN"))'="ADT")
  1. N RGRSDFN,VAFCA,RGRS,VAFCA08,RGRSARAY,BOGUS,RGDC,SENSTVTY,CMORDISP
  1. N NAME,LASTNAME,SSN,ICN,CMOR,CMORIEN,OTHSITE,RGRSDATA,HERE,BULSUB,NODE
  1. S RGRSARAY="RGRS(2)"
  1. D INITIZE^RGRSUTIL ;copy HL7 message into local RGDC array
  1. S VAFCA=$$EN^RGRSMSH() ;parse MSH for filer
  1. D EN^RGRSPARS(RGRSARAY) ;parse HL7 message into local array RGRS
  1. I $$SKIP^RGRSZZPT(1,RGRSARAY) D G EXIT ;skip if certain data is not there
  1. . D SKIPBULL^RGRSBULL(RGRSARAY)
  1. S RGRSDFN=$$GETDFN^MPIF001(@RGRSARAY@(991.01)) ;Get DFN from ICN
  1. Q:+$$SEND2^VAFCUTL1(RGRSDFN,"T") ;safeguard to prevent the processing of test patients
  1. S OTHSITE=@RGRSARAY@("SITENUM")\1
  1. S HERE=$P($$SITE^VASITE,"^",3)\1
  1. ;
  1. ;If patient not known in site, send bulletin, go exit
  1. ;
  1. 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
  1. ;
  1. S NAME=$$GET1^DIQ(2,+RGRSDFN_",",.01)
  1. S LASTNAME=$P(NAME,",",1)
  1. S SSN=$$GET1^DIQ(2,+RGRSDFN_",",.09)
  1. S NODE=$$MPINODE^MPIFAPI(RGRSDFN)
  1. S ICN=$P(NODE,"^")
  1. S CMORIEN=$P(NODE,"^",3)
  1. S CMOR=$$NS^XUAF4(CMORIEN)
  1. S CMORDISP=$P(CMOR,"^",1)
  1. S CMOR=$P(CMOR,"^",2)
  1. ;
  1. S @RGRSARAY@("NAME")=@RGRSARAY@(.01)
  1. S @RGRSARAY@("SSN")=@RGRSARAY@(.09)
  1. S @RGRSARAY@("ICN")=@RGRSARAY@(991.01)
  1. S @RGRSARAY@("CMOR")=$P($$NS^XUAF4($$LKUP^XUAF4(OTHSITE)),"^")
  1. ;
  1. ;If ICN or CMOR don't match, send bulletin and go exit
  1. I '$$MATCH(RGRSDFN,RGRSARAY,,,ICN,CMOR,.BULSUB) D G EXIT
  1. . D MTCHBULL^RGRSBULL(RGRSDFN,RGRSARAY,NAME,SSN,ICN,CMORDISP,BULSUB)
  1. ;
  1. ;if ICN and CMOR match, check for SSN edit from CMOR
  1. I @RGRSARAY@("SENDING SITE")=CMOR,(SSN'=@RGRSARAY@(.09)) D
  1. .D SSNBULL^RGRSBUL1(RGRSDFN,RGRSARAY,NAME,SSN,ICN,CMORDISP)
  1. ;
  1. ;If patient is Sensitive at other site but not here send bulletin
  1. S SENSTVTY=$G(@RGRSARAY@("SENSITIVITY"))
  1. I '$$SENSTIVE^RGRSENS(RGRSDFN),SENSTVTY D SENSTIVE^RGRSBUL1(RGRSDFN,RGRSARAY,NAME)
  1. ;
  1. ;MPIC_772 - **52; Commented out Remote Date of Death Indicated section.
  1. ;If patient has DATE OF DEATH (DOD) at remote site send bulletin
  1. ;Ignore time if present with date.
  1. ;S RMTDOD=@RGRSARAY@(.351),RMTDOD=$P(RMTDOD,".")
  1. ;S DFN=RGRSDFN D DEM^VADPT
  1. ;S LOCDOD=$P($P(VADM(6),"^"),".")
  1. ;If there is a remote DOD but no local DOD OR
  1. ;if remote DOD is different from local DOD, send bulletin
  1. ;I RMTDOD D RMTDOD^RGRSBUL1(RGRSDFN,RGRSARAY,NAME,RMTDOD,LOCDOD)
  1. ;K LOCDOD,RMTDOD,VADM
  1. ;
  1. D G EXIT ;**7
  1. . ;
  1. . ;IF it's the CMOR - review file
  1. . ;
  1. . I (OTHSITE)=(HERE) D Q
  1. . . S VAFCA=VAFCA_"^"_RGRSDFN
  1. . . S VAFCA08=1 S BOGUS=$$ADD^VAFCEHU1(VAFCA,"RGRS")
  1. . ;
  1. . ;IF it's not the CMOR - Don't Rebroadcast
  1. . ;
  1. . I (OTHSITE)'=(HERE) D Q
  1. . . S VAFCA08=1
  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
  1. EXIT ;
  1. Q
  1. ;
  1. MATCH(DFN,RGRSARAY,LASTNAME,SSN,ICN,CMOR,BULSUB) ;
  1. Q:$G(DFN)=""!($G(RGRSARAY)="") 0
  1. N COUNT,TRUE S (COUNT,TRUE)=0
  1. S BULSUB=""
  1. I $D(LASTNAME) D
  1. . S COUNT=COUNT+1
  1. . I (LASTNAME'=""),(LASTNAME=$P(@RGRSARAY@(.01),",",1)) S TRUE=TRUE+1
  1. I $D(SSN) D
  1. . S COUNT=COUNT+1
  1. . I (SSN'=""),(SSN=$G(@RGRSARAY@(.09))) S TRUE=TRUE+1
  1. I $D(ICN) D
  1. . S COUNT=COUNT+1
  1. . I (ICN'=""),(ICN=$G(@RGRSARAY@(991.01))) S TRUE=TRUE+1 Q
  1. . S BULSUB=BULSUB_"ICN"
  1. I $D(CMOR) D
  1. . S COUNT=COUNT+1
  1. . I (CMOR'=""),(CMOR=$G(@RGRSARAY@("SITENUM"))) S TRUE=TRUE+1 Q
  1. . I BULSUB]"" S BULSUB=BULSUB_" & "
  1. . S BULSUB=BULSUB_"CMOR"
  1. I COUNT=TRUE Q 1
  1. Q 0