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

AGSS1.m

Go to the documentation of this file.
  1. AGSS1 ; IHS/ASDS/EFG - SSN VERIFICATION FROM NPIRS/SSA ;
  1. ;;7.1;PATIENT REGISTRATION;**2**;JAN 31, 2007
  1. ;
  1. S ;START
  1. D CVARS D LVARS D:$G(AGSDFN) SM1
  1. Q
  1. CVARS ;>SET C VARS modified next line to handle new file format
  1. CVAR S AGSUFAC=$P(AGSCREC,U)
  1. ;parse out HRN,SSN,Last Name,First Name,Middle Name,DOB
  1. ;modified next 6 lines to handle new file format
  1. S AGSHRN=+$P(AGSCREC,U,2)
  1. S AGSCSSN1=$P(AGSCREC,U,3)
  1. S AGSCLN=$P(AGSCREC,U,4)
  1. S AGSCFN=$P(AGSCREC,U,5)
  1. S AGSCMN=$P(AGSCREC,U,6)
  1. S AGSCDOB=$P(AGSCREC,U,7)
  1. S:AGSCLN[" " AGSCLN=$P(AGSCLN," ") ;NPIRS puts SR JR III as part of the last name
  1. S AGSCSX=$P(AGSCREC,U,8),AGSCVC=$P(AGSCREC,U,9)
  1. S AGSCSSN2=$P(AGSCREC,U,10)
  1. S AGSCFI=$E(AGSCFN),AGSCMI=$E(AGSCMN),AGSCLI=$E(AGSCLN)
  1. F AGSX="AGSCLN","AGSCFN","AGSCMN" S AGSY=$L(@AGSX) I AGSY F AGSI=AGSY:-1:0 Q:$E(@AGSX,AGSI)]" " S @AGSX=$E(@AGSX,0,AGSI-1)
  1. S AGSCNM=AGSCLN_","_AGSCFN
  1. S:AGSCVC="V" AGSCSSN2=AGSCSSN1
  1. ECVAR Q
  1. ;D DSPCVAR ; test loop to read records
  1. ;
  1. LVARS ;>SET LOCAL VARS
  1. S DFN=0,AGSDFN=0 I '$D(^AUPNPAT("D",AGSHRN)) D DELHRN Q ;no hrn in data base
  1. Q:$G(AGSCVC)'="V" ;only process Vs
  1. I +AGSHRN=999999 D RP Q
  1. LVAR S (DFN,AGSFLG,AGDFNC)=0,AGSLVC="" F S DFN=$O(^AUPNPAT("D",AGSHRN,DFN)) Q:DFN'>0 I $D(^AUPNPAT("D",AGSHRN,DFN,AGSSITE)) S AGDFNC=AGDFNC+1,AGSDFN=DFN
  1. I AGDFNC=1 K AGDFNC
  1. ;E D:AGDFNC=0 DELHRN K AGDFNC,DFN Q ;none or two many
  1. ;IF THERE WAS THE SAME HRN ASSIGNED TO TWO DIFFERENT PATINETS IN THE SAME FACILITY
  1. ;THE LVARS WOULD NOT BE SET AND THE SM1 SUBROUTINE WOULD BE EXECUTED. KILLING AGSDFN
  1. ;PREVENTS THIS
  1. ;IHS/SD/TPF 5/24/2006 AG*7.1*2 IM20923
  1. E D:AGDFNC=0 DELHRN K AGDFNC,DFN,AGSDFN Q ;none or two many
  1. I $D(^AUPNPAT(AGSDFN)),$D(^DPT(AGSDFN))
  1. E K DFN,AGSDFN Q ;--->
  1. S AGSLNM=$P(^DPT(AGSDFN,0),U)
  1. S AGSLDOB=$P(^DPT(AGSDFN,0),U,3)
  1. S AGSLSSN=$P(^DPT(AGSDFN,0),U,9),AGSLSX=$P(^DPT(AGSDFN,0),U,2)
  1. S AGSLLN=$P(AGSLNM,","),AGSLFN=$P(AGSLNM,",",2)
  1. S:(AGSLFN[" ") AGSLFN=$P(AGSLFN," ",1) ;match against the 1st " " piece
  1. S:(AGSLLN[" ") AGSLLN=$P(AGSLLN," ",1) ;match against the 1st " " piece
  1. S AGSLNM=AGSLLN_","_AGSLFN
  1. ELVAR Q
  1. SM1 ;
  1. ;(AGSLSSN=AGSCSSN2) ;does FAC SSN = SSA SSN
  1. ;(AGSLSSN=AGSCSSN) ;does FAC SSN = NPIRS SSN
  1. ;
  1. I AGSLNM=AGSCNM,AGSLSX=AGSCSX,AGSCDOB=AGSLDOB+17000000 G MATCH
  1. E G NOMATCH
  1. MATCH I 'AGSLSSN,AGSCSSN2,"VA"[AGSCVC S AGSLVC="A" D SETFLG,SETSSN,SEND:'(AGSCSSN1=AGSCSSN2),RA Q
  1. I AGSLSSN,AGSCSSN2,"VA"[AGSCVC,(AGSLSSN=AGSCSSN2) D
  1. .I $P(^AUPNPAT(AGSDFN,0),U,23)]"",$D(^AUTTSSN($P(^(0),U,23),0)),$P(^(0),U)="A" D
  1. ..I '(AGSLSSN=AGSCSSN1) D SETFLG,SEND,RR Q ;if previously added and still "A" remain as "A"
  1. .S AGSLVC="V" D SETFLG,SEND:'(AGSLSSN=AGSCSSN1),RV Q
  1. I AGSLSSN,AGSCSSN2,'(AGSLSSN=AGSCSSN2) S AGSLVC="N" D SETFLG,SEND:(AGSCVC="?"),RN Q
  1. I AGSLSSN,'AGSCSSN2,(AGSLSSN=AGSCSSN1) S AGSLVC="X" D SETFLG,RX Q
  1. I AGSLSSN,'AGSCSSN2,'(AGSLSSN=AGSCSSN1) S AGSLVC="P" D SETFLG,SEND:'(AGSLSSN=AGSCSSN1),RP Q
  1. Q
  1. NOMATCH ;
  1. I 'AGSLSSN,AGSCSSN2 S AGSLVC="P" D SETFLG,RP Q
  1. I AGSLSSN,AGSCSSN2,(AGSLSSN=AGSCSSN2) S AGSLVC="D" D SETFLG,RD Q
  1. I AGSLSSN,AGSCSSN2,'(AGSLSSN=AGSCSSN2) S AGSLVC="P" D SETFLG,RP Q
  1. S AGSLVC="P" D SETFLG
  1. ESM1 Q
  1. SETFLG K DIC,DIE,DR
  1. S DA=AGSDFN,DIE="^AUPNPAT(",DR=".23///"_AGSLVC D ^DIE
  1. Q
  1. SETSSN K DIC,DIE,DR Q:"^AUPN"["t" ;REMOVE Q WHEN READY
  1. S DIE="^DPT(",DA=AGSDFN,DR=".09////"_AGSCSSN2 D ^DIE
  1. K DIC,DIE,DR S DIE="^AUPNPAT(",DA=AGSDFN,DR=".24///@" D ^DIE
  1. S ^AGPATCH(DT,AGSSITE,AGSDFN)=""
  1. Q
  1. SEND S AGSFLG=1 Q ;S ^AGPATCH(DT,AGSSITE,AGSDFN)="" Q ;REMOVE Q WHEN READY
  1. R ;REPORTS
  1. RA S ^AGSSTEMP(AGSSITE,"RA",AGSDFN)=AGSCSSN2 Q
  1. RV S ^AGSSTEMP(AGSSITE,"RV",AGSDFN)="" Q
  1. RP S ^AGSSTEMP(AGSSITE,"RP",AGSDFN)=AGSCREC Q
  1. RN S ^AGSSTEMP(AGSSITE,"RN",AGSDFN)=AGSCREC Q
  1. RD S ^AGSSTEMP(AGSSITE,"RD",AGSDFN)=AGSCREC Q
  1. RR S ^AGSSTEMP(AGSSITE,"RR",AGSDFN)=AGSCREC Q
  1. RX S ^AGSSTEMP(AGSSITE,"RX",AGSDFN)=AGSCREC Q
  1. DELHRN ;delete
  1. S AGSINT=$E(AGSCLN)_$E(AGSCFN)
  1. S ^AGSSTEMP(AGSSITE,"DEL",AGSHRN)="RG3^"_AGSSUFAC_"^"_AGSHRN_"^^"_AGSINT_"^"_AGSCSX
  1. Q
  1. EM ;
  1. PRTSSN ;
  1. U AGSPIO
  1. TST ;
  1. I "VA"[$G(AGSLVC) Q
  1. U IO(0) I 'AGSFLG Q
  1. U IO(0) W !,AGSSC
  1. PATL U IO(0) W !,"HRN:",AGSHRN,?15,"LOC:",AGSLSSN,?30,AGSLVC,?35,AGSLNM,?65,AGSLSX,?68,AGSLDOB
  1. PATC W !,"DPS:",AGSCSSN1,?15,"SSA:",AGSCSSN2,?30,AGSCVC,?35,AGSCNM,?65,AGSCSX,?68,AGSCDOB
  1. W !,"sflg: ",AGSFLG
  1. Q