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