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

AGTX1.m

Go to the documentation of this file.
AGTX1 ; IHS/ASDS/EFG - EXPORT REG DATA CONT'D ;  
 ;;7.1;PATIENT REGISTRATION;;AUG 25,2005
 ;
S2A ;EP
 K AGTEMP
S2AA S AGRCT=$O(^AGCHDFN(AGRCT)),DFN=AGRCT ;> LOOP PATIENTS
 G JOBEND^AGTX4:AGRCT="" S AG("SITE")=0 ;>END JOB
S2AAA ;EP -
 S AG("SITE")=$O(^AGCHDFN(AGRCT,AG("SITE"))) ;> LOOP SITE
 G S2AA:AG("SITE")="" S AGDTS=0
 D ^AGTX5 ;>PROC HRN/INS | D/M/C
 G:$P(^DPT(AGRCT,0),U,19) S2AA ;> MERGED PATIENT
CKDEL ;>CHECK DEL
 I AG("TXDEL") K AG("TXDEL") G S2AAA ;>DEL | NO DEMOG SENT
 S AG("MODCODE")=1
CHK1 ;> Check Demog
 K AGTEMP G S2AAA:'$D(^AUPNPAT(AGRCT,0))!'$D(^AUPNPAT(AGRCT,41,AG("SITE"),0))!'$D(^AUTTLOC(AG("SITE")))!'$D(^AUPNPAT(AGRCT,11)) ;> BAD DEMOG
 I '$D(^DPT(AGRCT,.11)) S AGDFN16="",AGBAD16=AGBAD16+1
 I '$D(^AUPNPAT(AGRCT,51)) S AGDFN51="",AGBAD51=AGBAD51+1
R1P1 ;> Gen RG1
 G:$D(^AGCHDFN(AGRCT,"RG1")) S2AAA ;>prev sent | merged |
 S ^AGCHDFN(AGRCT,"RG1")="" ;>mark as prev sent
ALL ;EP - From AGTXALL to extract all pt's.
 S AGTEMP(1)="RG1" D HRNPFAC
 S AGNAME=$P(^DPT(AGRCT,0),U)
 S AGNAME=$TR(AGNAME,"abcdefghijklmnopqrstuvwxyz)(/","ABCDEFGHIJKLMNOPQRSTUVWXYZ---")
 D NAMECVT S $P(AGTEMP(1),U,4)=AGLN,$P(AGTEMP(1),U,5)=AGFN,$P(AGTEMP(1),U,6)=AGMN
 S X=$P($G(^AUPNPAT(AGRCT,11)),U,11) I +X<1 G R1P8
 S $P(AGTEMP(1),U,7)=$P($G(^AUTTBEN(X,0)),U,2)
R1P8 ;Get date of Birth from DPT-put into 8th piece of transaction file-RG1
 S AGVAL=$P(^DPT(AGRCT,0),U,3) D D8CV S $P(AGTEMP(1),U,8)=AGVAL
 S $P(AGTEMP(1),U,9)=$P(^DPT(AGRCT,0),U,2)
 S AGVAL=$P(^DPT(AGRCT,0),U,9) I AGVAL["-" S AGVAL=$E(AGVAL,1,3)_$E(AGVAL,5,6)_$E(AGVAL,8,11)
 S $P(AGTEMP(1),U,10)=AGVAL
 S X=$P($G(^AUPNPAT(AGRCT,11)),U,8) I +X<1 S $P(AGTEMP(1),U,11)="" G R1P12
 S $P(AGTEMP(1),U,11)=$P(^AUTTTRI(X,0),U,2)
R1P12 ;
 S AGVAL=$P($G(^AUPNPAT(AGRCT,11)),U,10) I AGVAL]"" D QNTCVT I Y]"" S $P(AGTEMP(1),U,12)=Y
 I $D(^DPT(AGRCT,.24)) S AGNAME=$P(^DPT(AGRCT,.24),U),(AGLN,AGFN,AGMN)="" D NAMECVT:AGNAME]"" S $P(AGTEMP(1),U,13)=AGLN,$P(AGTEMP(1),U,14)=AGFN,$P(AGTEMP(1),U,15)=$E(AGMN,1,1)
R1P16 I $D(^AUPNPAT(AGRCT,11)) S X=$P(^(11),"^",17) I X,$D(^AUTTCOM(X,0)) S AGVAL=$P(^AUTTCOM(X,0),U,8),$P(AGTEMP(1),U,16)=$E(AGVAL,5,7)_$E(AGVAL,3,4)_$E(AGVAL,1,2)
R1P17 I '$D(^DPT(AGRCT,.11)) G R1P20A
 S $P(AGTEMP(1),U,17)=$P(^DPT(AGRCT,.11),U),$P(AGTEMP(1),U,18)=$P(^(.11),U,4),X=$P(^(.11),U,5)
 I +X<1 G R1P20
 S $P(AGTEMP(1),U,19)=$P(^DIC(5,X,0),U,2)
R1P20 S AGTX=$P(^DPT(AGRCT,.11),U,6),AGTX=$TR(AGTX,"-"),$P(AGTEMP(1),U,20)=AGTX
R1P20A D SETAGTX G R2P1^AGTX2
HRNPFAC ;>HRN PARENT FAC
 ;substitute for a HRN at a parent facility in this data base
 S DFN=AGRCT,AGRSITE=AG("SITE") D ^AGTXRHRN ;get a registering HRN
 I 'AGRHRN K AGRSITE D ^AGTXRHRN ;get a registering fac & hrn
 S:AGRSITE $P(AGTEMP(1),U,2)=$P($G(^AUTTLOC(AGRSITE,0)),U,10)
 S $P(AGTEMP(1),U,3)=AGRHRN
 Q  ;found proper FAC:HRN
 K AGRSITE,AGRHRN
EHRNPFAC Q
SETAGTX ;>SET AGTXDATA
 I '$D(ZTQUEUED),'$G(AGTXALL) W:AGOUTFLG !,AGTEMP(1) I 'AGOUTFLG,AGROUT#10=0 X XY W AGROUT
 I $G(AGTXALL) S T(1)=$P(AGTEMP(1),U,1)_U_U_$P(AGTEMP(1),U,2,999) D SET^AGTXALL(1) KILL T(1) Q
 S AGROUT=AGROUT+1,AGTEMP(1)=$P(AGTEMP(1),U,1)_U_$$UID^AGTXID(AGRCT)_U_$P(AGTEMP(1),U,2,999),$P(AGTEMP(1),U,21)=$P(AGTEMP(1),U,21),^AGTXDATA(AGROUT)=AGTEMP(1)
 Q
QNTCVT S (Y,X)="" I +AGVAL>0 S X=$P(AGVAL,"/",1)/$P(AGVAL,"/",2)
QUANTIHS S Y=$S((AGVAL="FULL"!(X=1)):1,AGVAL="NONE":5,AGVAL="UNSPECIFIED":6,AGVAL="UNKNOWN":7,+AGVAL'>0:7,1:Y) Q:Y]""
 S Y=$S(X'<.5:2,X'<.25:3,X'<.125:4,X<.125:4,1:Y)
 Q
D6CV ;EP -
 S AGVAL=$E(AGVAL,4,7)_$E(AGVAL,2,3) Q
D7CV ;EP -
 S AGCC=$E(AGVAL,1,3),AGCC=$E((1700+AGCC),2,4)
 S AGVAL=$E(AGVAL,4,7)_AGCC Q
D8CV ;EP - date conversion from fileman format to CCYYMMDD
 I $G(AGVAL) S AGVAL=AGVAL+17000000                                          ;Y2000
 Q
NAMECVT ;EP -
 S AGN1=$P(AGNAME,",",1),AGN2=$P(AGNAME,",",2),AGN3=$P(AGNAME,",",3)
 S AGLN=AGN1,AGFN=$P(AGN2," ",1),AGMN=$P(AGN2," ",2)
 I AGN3]"" S AGLN=AGLN_" "_AGN3
 Q