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

AGTX5.m

Go to the documentation of this file.
AGTX5 ; IHS/ASDS/EFG - EXPORT REG DATA CONT'D APR 14,1995 ;  
 ;;7.1;PATIENT REGISTRATION;;AUG 25,2005
 ;
START ;
 S (AGDTS,AGFHRN,AGLHRN)=0,AG("TXMERG")="",AG("TXDEL")=""
 I '$D(^AGCHDFN(DFN,"CK")) S DFN=AGRCT K AG("ER") D ^AGDATCK I $D(AG("ER")) K AG("ER") S ^AGCHDFN(AGRCT,"RG1")="" ;mark to not send rg1 if datchk fails
AGDTS ;
 F  S AGDTS=$O(^AGCHDFN(AGRCT,AG("SITE"),AGDTS)) Q:'+AGDTS  D RG3MGR ;>LOOP DATE/TIME | one patient
 G BLDRG3 ;>PROC RG3
RG3MGR ;>HRN/INS D/M/C | RG5
 S AGX=^AGCHDFN(AGRCT,AG("SITE"),AGDTS)
 S:AGX="NEW" AG("TXNEW")=1 ;mark so as not to send any Change HRNs
 D:($D(^AGCHDFN(AGRCT,AG("SITE"),AGDTS))>1) DELINS ;>DEL INS | RG5
 Q:'+AGX  ;>NO HRN D/M/C
 I $P(AGX,"^",6) S AG("TXMERG")=AGDTS Q  ;>MERG
 Q:'$D(^AGFAC("AC",AG("SITE")))  ;>NOT PARENT FAC
 I $P(AGX,"^",3)="" S AG("TXDEL")=AGDTS Q  ;>DEL HRN/PAT
 S:'AGFHRN AGFHRN=$P(AGX,"^",2)
 S AG("CHRN")=AGDTS,AGLHRN=$P(AGX,"^",3)
 Q
BLDRG3 ;EP - Build various RG3s
TXCHRN ;>HRN CHANGES
 G:'$D(AG("CHRN")) TXMERG ;>NO HRN CHANGE
 G:'$G(AG("TXNEW")) TXMERG ;new pat - send no Chng HRN
 S AGDTS=AG("CHRN")
 D SETRG3
 S $P(AGTEMP(3),U,3,4)=AGFHRN_"^"_AGLHRN
 D SETAGTX
TXMERG ;>MERGS
 G:AG("TXMERG")="" TXDEL ;----- ;>NO MERG
 S AGDTS=AG("TXMERG"),AGX=^AGCHDFN(AGRCT,AG("SITE"),AGDTS)
 D SETRG3,SETAGTX
 S ^AGCHDFN(AGRCT,"RG1")="" ;mark to not send demog for merged patient
TXDEL ;>DEL PAT
 G:AG("TXDEL")="" FIN ;>NO DEL HRN
 S AGDTS=AG("TXDEL"),AGX=^AGCHDFN(AGRCT,AG("SITE"),AGDTS),AGX1=$P(^AUTTLOC(+AGX,0),U,10)
 S AGTEMP(3)="RG3^"_AGX1_U_$P(AGX,U,2,99) D SETAGTX S ^AGCHDFN(AGRCT,"RG1")=""
FIN ;>CLEAN UP | RET AG("TXDEL")
 K AGDTS,AGRHRN,AGLHRN,AG("MERG"),AG("CHRN"),AG("TXNEW")
 Q
DELINS ;INSURANCE COVERAGE DELETES ;>LOOP INS
 S AG("SUB")=""
 F AGZ("I")=1:1 S AG("SUB")=$O(^AGCHDFN(AGRCT,AG("SITE"),AGDTS,AG("SUB"))) Q:AG("SUB")=""  D DELCOV
 Q
DELCOV ;>DEL INS COV | AGTEMP(5)=RG5^..
 Q:($P(^AGCHDFN(AGRCT,AG("SITE"),AGDTS,AG("SUB")),U,2)="")!($P(^(AG("SUB")),U,3)="")
 S AGTXSUB=AG("SUB")
 I $P(^AGCHDFN(AGRCT,AG("SITE"),AGDTS,AG("SUB")),U)="MCARE" Q:'$D(^AUTTMCS($P(^(AGTXSUB),U,3)))
 I $P(^AGCHDFN(AGRCT,AG("SITE"),AGDTS,AG("SUB")),U)="MCAID" Q:'$D(^DIC(5,$P(^(AGTXSUB),U,3)))
 S AGTEMP(5)="RG5",$P(AGTEMP(5),U,2)=$E($P(^AGCHDFN(AGRCT,AG("SITE"),AGDTS,AG("SUB")),U,2),1,14),AGCT=$P(^AGCHDFN(AGRCT,AG("SITE"),AGDTS,AG("SUB")),U,6),AGELGEND=$P(^(AG("SUB")),U,5)
S1 ;
 S $P(AGTEMP(5),U,2)=$P(AGTEMP(5),U,2)_$S($P(^AGCHDFN(AGRCT,AG("SITE"),AGDTS,AG("SUB")),U)="MCARE":$P(^AUTTMCS($P(^(AG("SUB")),U,3),0),U),1:"")
 S AGVAL=$P(^DPT(AGRCT,0),U,3) D D8CV^AGTX1
 S $P(AGTEMP(5),U,4)=$S(AGCT="A":1,AGCT="B":2,AGCT="AB":3,1:4)
 S $P(AGTEMP(5),U,5)=AGVAL
 S $P(AGTEMP(5),U,6)=$$Y2KD2($P(^AGCHDFN(AGRCT,AG("SITE"),AGDTS,AG("SUB")),U,4))
 S $P(AGTEMP(5),U,15,18)=""
 S $P(AGTEMP(5),U,$S(AGCT="A":15,AGCT="B":16,AGCT="AB":17,1:18))=$$Y2KD2(AGELGEND)
RG5 ;>AGTXDATA=AGTEMP(5)
 S AGROUT=AGROUT+1,AGTEMP(5)=$P(AGTEMP(5),U,1)_U_$$UID^AGTXID(AGRCT)_U_$P(AGTEMP(5),U,2,999),$P(AGTEMP(5),U,20)=$P(^AUTTLOC(AGTXSITE,0),U,10),^AGTXDATA(AGROUT)=AGTEMP(5),AG("TOT")=AG("TOT")+1
 W:AGOUTFLG !,AGTEMP(5)
 I 'AGOUTFLG,AGROUT#10=0 X XY W AGROUT
 Q
SETRG3 ;>AGTEMP(3)=RG3^..
 S AGTEMP(3)="RG3^"_$P(^AUTTLOC($P(^AGCHDFN(AGRCT,AG("SITE"),AGDTS),U),0),U,10)_U_$P(^AGCHDFN(AGRCT,AG("SITE"),AGDTS),U,2,5)_U_""
 I $P(^AGCHDFN(AGRCT,AG("SITE"),AGDTS),U,6)]"" S $P(AGTEMP(3),U,7,8)=1_"^"_$P(^AUTTLOC($P(AGX,U,6),0),U,10)
 Q
SETAGTX ;>AGTXDATA=AGTEMP(3)
 I '$D(ZTQUEUED) W:AGOUTFLG !,AGTEMP(3) I 'AGOUTFLG,AGROUT#10=0 X XY W AGROUT
 S AGROUT=AGROUT+1,AGTEMP(3)=$P(AGTEMP(3),U,1)_U_$$UID^AGTXID(AGRCT)_U_$P(AGTEMP(3),U,2,999),$P(AGTEMP(3),U,9)=$P(AGTEMP(3),U,9),^AGTXDATA(AGROUT)=AGTEMP(3),AG("TOT")=$G(AG("TOT"))+1
 Q
Y2KD2(X) ;EP - date from fileman to Y2K format Y=CCYYMMDD
 N Y
 I X="" Q X
 S Y=($E(X,1,3)+1700)_$E(X,4,7)
 Q Y