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

BGP2AUUP.m

Go to the documentation of this file.
BGP2AUUP ; IHS/CMI/LAB - UPLOAD SITE FILES, CREATE EXCEL FILES ;
 ;;12.1;IHS CLINICAL REPORTING;;MAY 17, 2012;Build 66
 ;
DESC ;----- ROUTINE DESCRIPTION
 ;; 
 ;;This routine processes the monthly GPRA files received from
 ;;the sites.  It creates the Excel file and sends it to the
 ;;DeepSee server to be uploaded into the database.
 ;;$$END
 ;
 N I,X F I=1:1 S X=$P($T(DESC+I),";;",2) Q:X["$$END"  D EN^DDIOL(X)
 Q
AUTO ;EP -- AUTOQUEUED JOB ENTRY POINT
 ;  
 N BGPBEGDT,BGPENDDT
 ;
 D ^XBKVAR
 ;
 D CALC(.BGPBEGDT,.BGPENDDT)
 D EN(BGPBEGDT,BGPENDDT)
 ;
 Q
MAN ;EP -- MANUALLY PROCESS SITE FILES
 ;
 N BGPBEGDT,BGPDTS,BGPENDDT,BGPMAN
 ;
 D CALC(.BGPBEGDT,.BGPENDDT)
 D DATES(.BGPDTS,BGPBEGDT,BGPENDDT)
 Q:'BGPDTS
 S BGPBEGDT=$P(BGPDTS,U)
 S BGPENDDT=$P(BGPDTS,U,2)
 S BGPMAN=1
 D EN(BGPBEGDT,BGPENDDT,BGPMAN)
 Q
DQ ;EP -- QUEUED JOB STARTS HERE
 ;
 ;      EXPECTS BGPBEGDT,BGPENDDT
 ;
 D EN($G(BGPBEGDT),$G(BGPENDDT))
 K BGPBEGDT,BGPENDDT
 Q
EN(BGPBEGDT,BGPENDDT,BGPMAN) ;EP -- MAIN ENTRY POINT
 ;
 ;      INPUT:
 ;      BGPBEGDT  =  DATA EXTRACT BEGIN DATE
 ;      BGPENDDT  =  DATA EXTRACT END DATE
 ;      BGPMAN    =  MANUAL RUN INDICATOR
 ;
 N BGPDFILE,BGPDPD0,BGPERR,BGPF,BGPFACS,BGPFILE,BGPOUT,BGPPATH,X,BGPLIST
 ;
 S BGPOUT=0
 K ^TMP("BGPGPAM",$J,"FILE")
 ;
 S BGPDFILE=""
 ;
 D STAT(.BGPDPD0,BGPBEGDT)
 ;quit if status=1 COMPLETED
 Q:$P($G(^BGPGP1PM(1,7,BGPDPD0,0)),U,4)=1
 ;quit trying to process after 5 attempts
 Q:$P($G(^BGPGP1PM(1,7,BGPDPD0,0)),U,6)>5
 ;
 S BGPPATH=$P($G(^BGPGP1PM(1,1)),U)
 Q:BGPPATH']""
 ;
 ;create tmp file containing list of files in directory
 ;S X="dir "_BGPPATH_"BGPAM121* > "_BGPPATH_"BGPgp1tmp"
 ;S X=$$JOBWAIT^%HOSTCMD(X)
 ;
 ;open tmp file and read it into ^TMP global
 ;S BGPFILE="BGPgp1tmp"
 ;D READ(BGPPATH,BGPFILE,.BGPOUT)
 ;I BGPOUT D
 ;. S BGPERR="CAN'T READ BGPgp1tmp FILE"
 ;. I $G(BGPMAN) D  Q
 ;. . W !,BGPERR
 ;. D REQUE(BGPENDDT)
 ;. D STAT(BGPDPD0,BGPENDDT,$$NOW^XLFDT,2,BGPERR,$$ATT(BGPDPD0))
 ;Q:BGPOUT
 ;
 K ^TMP("BGPGPAM",$J,"FILE")
 K BGPLIST S BGPLIST="",X=$$LIST^%ZISH(BGPPATH,"BGPAM121*",.BGPLIST)
 ;check ^TMP global to see if all files are there
 S (X,C)=0 F  S X=$O(BGPLIST(X)) Q:X'=+X  S C=C+1,^TMP("BGPGPAM",$J,"FILE",C,0)=BGPLIST(X)
 S ^TMP("BGPGPAM",$J,"FILE",0)=C
 D CHK(BGPENDDT,.BGPFACS,.BGPOUT)
 I BGPOUT D
 . S BGPERR="MISSING FACILITY FILES"
 . ;S $ZE="BGP2AUUP MISSING FACILITY FILES"
 . ;D ^ZTER
 . K ^TMP("BGPGPAM",$J,"FILE")
 . I $G(BGPMAN) D  Q
 . . W !,BGPERR
 . . D MSG1^BGP2AU1M(BGPBEGDT,BGPENDDT,.BGPFACS)
 . ;SEND EMAIL/ALERT THAT FILES ARE NOT ALL THERE
 . D ALERTMM(1,BGPBEGDT,BGPENDDT,.BGPFACS,.BGPF,BGPDFILE)
 . D REQUE(BGPBEGDT,BGPENDDT)
 . D STAT(BGPDPD0,BGPBEGDT,$G(BGPENDDT),$$NOW^XLFDT,2,BGPERR,$$ATT(BGPDPD0))
 Q:BGPOUT
 ;
 ;upload all files into the BGP 11 DATA* files
 D UPLOAD(BGPPATH,BGPBEGDT,BGPENDDT,.BGPFACS)
 ;
 ;create the 5 excel files
 D EN^BGP2AU1A(BGPBEGDT,BGPENDDT,.BGPEND,.BGPF)
 ;
 ;upload the 5 excel files into BGPGP1 GPRA FLAT FILE DATA file
 D EN^BGP2AU1R(.BGPF)
 ;
 ;create data dump text file
 D EN^BGP2AU1D(BGPBEGDT,BGPEND,.BGPDFILE)
 ;
 ;***send data dump file to DeepSee server
 ;D SEND(BGPDFILE)
 ;
 ;send email that excel and data dump files are created
 D ALERTMM1(2,BGPBEGDT,BGPENDDT,,.BGPF,BGPDFILE)
 ;
 ;update status to completed
 D STAT(BGPDPD0,BGPBEGDT,(BGPEND-17000000),$$NOW^XLFDT,1,"@",$$ATT(BGPDPD0))
 ;
 ;clean everything up
 D CLEAN(BGPBEGDT,BGPENDDT)
 K ^TMP("BGPGPAM",$J,BGPFILE)
 D MOVEFL(BGPENDDT,.BGPFACS,.BGPF,BGPDFILE)
 ;
 I $G(BGPMAN) D
 . W !,"ALL FILES SUCCESSFULLY CREATED AND EMAIL MESSAGE SENT"
 Q
UPLOAD(BGPPATH,BGPBEGDT,BGPENDDT,BGPFACS) ;
 ;----- UPLOAD THE FILES INTO THE BGP DATA FILES
 ;      use BGPFACS array created in CHK
 ;      
 ;      INPUT:
 ;      BGPPATH   =  DIRECTORY PATH
 ;      BGPBEGDT  =  THE EXTRACT BEGINNING DATE
 ;      BGPFACS   =  ARRAY CONTAINING FILE NAMES
 ;
 N BGPASU,BGPFILE
 ;
 D CLEAN(BGPBEGDT,BGPENDDT)
 ;
 S BGPASU=0
 F  S BGPASU=$O(BGPFACS(BGPENDDT,BGPASU)) Q:BGPASU=""  D
 . S BGPFILE=BGPFACS(BGPENDDT,BGPASU)
 . Q:BGPFILE']""
 . D EN^BGP2AUUL(BGPPATH,BGPFILE)
 Q
SEND(BGPDFILE) ;----- SEND DATA DUMP FILE TO DEEPSEE SERVER
 ;
 ;***need ip address, username, password
 ;***use BGPsend script?
 Q
CHK(BGPBEGDT,BGPFACS,BGPOUT) ;
 ;----- CHECK TO SEE IF ALL FILES ARE THERE
 ;      LOOKS AT THE ^TMP GLOBAL CREATED BY READ
 ;      RETURNS BGPFACS ARRAY
 ;
 ;      INPUT:
 ;      BGPBEGDT  =  BEGIN DATE OF REPORTS
 ;
 N BGPD0,BGPASU,BGPD1,BGPDATA,BGPDT,BGPERR,BGPFILE
 ;
 S BGPOUT=0
 K BGPFACS
 ;
 ;build BGPFACS array of entries in parameters file
 S BGPD1=0
 F  S BGPD1=$O(^BGPGP1PM(1,9,BGPD1)) Q:'BGPD1  D
 . S BGPDATA=$G(^BGPGP1PM(1,9,BGPD1,0))
 . Q:'$P(BGPDATA,U,3)   ;don't include INACTIVE
 . S BGPASU=$P(BGPDATA,U,2)
 . S BGPFACS(BGPENDDT,BGPASU)=""
 ;
 ;loop through ^TMP global and see if there is a file for each
 ;entry in the BGPFACS array
 S BGPD0=0
 F  S BGPD0=$O(^TMP("BGPGPAM",$J,"FILE",BGPD0)) Q:'BGPD0  D
 . S BGPDATA=$G(^TMP("BGPGPAM",$J,"FILE",BGPD0,0))
 . Q:BGPDATA'["BGPAM121"
 . S BGPFILE="BGPAM121"_$P(BGPDATA,"BGPAM121",2)
 . S BGPDT=$E(BGPFILE,9,15) ;use BGPDT to preserve BGPBEGDT
 . S BGPASU=$E(BGPFILE,16,21)
 . I $D(BGPFACS(BGPDT,BGPASU)) S BGPFACS(BGPDT,BGPASU)=BGPFILE
 ;
 ;see if they are all there, set BGPOUT=1 if not
 S BGPASU=0
 F  S BGPASU=$O(BGPFACS(BGPENDDT,BGPASU))  Q:BGPASU=""  D
 . I BGPFACS(BGPENDDT,BGPASU)']"" S BGPOUT=1
 ;
 Q
STAT(BGPDPD0,BGPBEGDT,BGPEND,BGPDT,BGPSTAT,BGPERR,BGPATT) ;
 ;----- UPDATE DATE PROCESSED STATUS IN PARAMETERS FILE
 ;
 N DA,DIE,DR,X,Y,G
 ;
 S BGPEND=$G(BGPEND)
 S BGPDPD0=$G(BGPDPD0)
 I $P(^BGPGP1PM(1,0),U,2)="T" I '$G(BGPDPD0) S BGPDPD0=$O(^BGPGP1PM(1,7,"B",BGPBEGDT,0))
 I $P(^BGPGP1PM(1,0),U,2)="G" I '$G(BGPDPD0) D
 .S X=0,G=0 F  S X=$O(^BGPGP1PM(1,7,"B",BGPBEGDT,X)) Q:X'=+X!(G)  D
 ..I $E($P(^BGPGP1PM(1,7,X,0),U,9),1,5)=$E(DT,1,5) S BGPDPD0=X,G=1
 I 'BGPDPD0 D ADDSTAT(.BGPDPD0,BGPBEGDT)
 Q:'BGPDPD0
 S DR=""
 S DR=".02////^S X=BGPEND" I $P(^BGPGP1PM(1,7,BGPDPD0,0),U,9)="" S DR=DR_";.09////"_DT
 I $G(BGPDT)]"" S DR=DR_";.03////^S X=BGPDT"
 I $G(BGPSTAT)]"" S DR=DR_";.04////^S X=BGPSTAT"
 I $G(BGPERR)]"" S DR=DR_";.05////^S X=BGPERR"
 I $G(BGPATT)]"" S DR=DR_";.06////^S X=BGPATT"
 Q:DR']""
 S DA=BGPDPD0
 S DA(1)=1
 S DIE="^BGPGP1PM("_DA(1)_",7,"
 D ^DIE
 Q
ADDSTAT(BGPDPD0,BGPBEGDT) ;
 ;----- ADD NEW ENTRY TOP DATE PROCESSED STATUS MULTIPLE IN PARAM FILE
 ;
 N DA,DD,DIC,DO,X,Y
 ;
 S BGPDPD0=0
 S X=BGPBEGDT
 S DA(1)=1
 S DIC="^BGPGP1PM("_DA(1)_",7,"
 S DIC(0)=""
 D FILE^DICN
 Q:+Y'>0
 S BGPDPD0=+Y
 Q
CLEAN(BGPBEGDT,BGPENDDT) ;
 ;----- CLEAN ENTRIES OUT OF BGP 11 DATA* FILES
 ;      remove the entries sorted by the BEGINNING DATE
 ;      so that old entries won't interfere with this run
 ;
 N BGPD0,DA,DIK,BGPASU
 ;
 Q:$P(^BGPGP1PM(1,0),U,2)="G"  ;don't delete out national gpra
 S BGPD0=0 F  S BGPD0=$O(^BGPGPDCW("B",BGPBEGDT,BGPD0)) Q:'BGPD0  D
 . S BGPASU=$P(^BGPGPDCW(BGPD0,0),U,9)
 . I $G(BGPFACS(BGPENDDT,BGPASU))="" Q
 . Q:$P(^BGPGPDCW(BGPD0,0),U,12)'=1  ;DON'T DELETE OTHER NATIONAL, GPU, ETC.
 . S DA=BGPD0
 . S DIK="^BGPGPDCW("
 . D ^DIK
 ;
 S BGPD0=0 F  S BGPD0=$O(^BGPGPDPW("B",BGPBEGDT,BGPD0)) Q:'BGPD0  D
 . S BGPASU=$P(^BGPGPDPW(BGPD0,0),U,9)
 . I $G(BGPFACS(BGPENDDT,BGPASU))="" Q
 . Q:$P(^BGPGPDPW(BGPD0,0),U,12)'=1  ;DON'T DELETE OTHER NATIONAL, GPU, ETC.
 . S DA=BGPD0
 . S DIK="^BGPGPDPW("
 . D ^DIK
 ;
 S BGPD0=0 F  S BGPD0=$O(^BGPGPDBW("B",BGPBEGDT,BGPD0)) Q:'BGPD0  D
 . S BGPASU=$P(^BGPGPDBW(BGPD0,0),U,9)
 . I $G(BGPFACS(BGPENDDT,BGPASU))="" Q
 . Q:$P(^BGPGPDBW(BGPD0,0),U,12)'=1  ;DON'T DELETE OTHER NATIONAL, GPU, ETC.
 . S DA=BGPD0
 . S DIK="^BGPGPDBW("
 . D ^DIK
 Q
MOVEFL(BGPBEGDT,BGPFACS,BGPF,BGPDFILE) ;
 ;----- MOVE FILES TO SUBDIRECTORY WHEN DONE WITH THEM
 ;
 N BGP,BGPASU,BGPFILE
 ;
 S BGPASU=0
 F  S BGPASU=$O(BGPFACS(BGPBEGDT,BGPASU)) Q:BGPASU=""  D
 . S BGPFILE=BGPFACS(BGPBEGDT,BGPASU)
 . Q:BGPFILE']""
 . D MOVE1(BGPFILE)
 ;
 S BGP=0
 F  S BGP=$O(BGPF(BGP)) Q:'BGP  D
 . S BGPFILE=BGPF(BGP)
 . Q:BGPFILE']""
 . D MOVE1(BGPFILE)
 ;
 D MOVE1(BGPDFILE)
 D MOVE1(BGPFGNT1)
 D MOVE1(BGPFGNT2)
 D MOVE1(BGPFDEV1)
 D MOVE1(BGPFDEV2)
 D MOVE1(BGPFDEV3)
 Q
MOVE1(BGPFILE) ;
 ;----- MOVE FILE TO ANOTHER DIRECTORY
 ;
 N BGPDIR,BGPDIRTO,X
 ;
 S BGPDIR=$P($G(^BGPGP1PM(1,1)),U)
 S BGPDIRTO=$P($G(^BGPGP1PM(1,1)),U,2)
 Q:BGPDIRTO']""
 ;S X="mv /-Y "_BGPDIR_BGPFILE_" "_BGPDIRTO
 ;S X=$$JOBWAIT^%HOSTCMD(X)
 D MV^%ZISH(BGPDIR,BGPFILE,BGPDIRTO,BGPFILE)
 Q
REQUE(BGPBEGDT,BGPENDDT) ;
 ;----- REQUEUE THE JOB FOR NEXT DAY
 ;
 N ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
 ;
 S ZTRTN="DQ^BGPGP1UP"
 S ZTDESC="BGPGP1 PROCESS SITE GPRA FILES"
 S ZTIO=""
 S ZTDTH=$$FMADD^XLFDT($$NOW^XLFDT,+1)
 S ZTSAVE("BGPBEGDT")=""
 S ZTSAVE("BGPENDDT")=""
 D ^%ZTLOAD
 Q
CALC(BGPBEGDT,BGPENDDT) ;
 ;----- CALCULATE THE BEGINNING DATE OF THE REPORT
 ;
 ;Calculates the last day of the previous month based on today's
 ;date.  Calculates the report beginning date based on the last
 ;day of the previous month -364 days.  (The original BGP routines
 ;subtract -364 days to get the beginning date.)
 ;
 N BGPD,BGPDT,BGPM,BGPY,BGPT
 ;
 S BGPT=$P(^BGPGP1PM(1,0),U,2)
 I BGPT="T" D  Q
 .S BGPDT=$$FMADD^XLFDT(DT,-60)
 .S BGPY=$E(BGPDT,1,3)
 .S BGPM=+$E(BGPDT,4,5)
 .S BGPD=$P("31^28^31^30^31^30^31^31^30^31^30^31",U,BGPM)
 .I BGPM=2 S BGPD=BGPD+$$LEAP^XLFDT2(BGPY+1700)
 .S BGPD=$E("00",1,2-$L(BGPD))_BGPD
 .S BGPM=$E("00",1,2-$L(BGPM))_BGPM
 .S BGPENDDT=BGPY_BGPM_BGPD
 .S BGPBEGDT=$$FMADD^XLFDT(BGPENDDT,-364)
 S Y=$O(^BGPCTRL("B",2012,0))
 S Y=^BGPCTRL(Y,0)
 S BGPENDDT=$P(Y,U,9)
 S BGPBEGDT=$P(Y,U,8)
 Q
 ;original code for date
 S BGPDT=$$FMADD^XLFDT(DT,-60)
 S BGPY=$E(BGPDT,1,3)
 S BGPM=+$E(BGPDT,4,5)
 S BGPD=$P("31^28^31^30^31^30^31^31^30^31^30^31",U,BGPM)
 I BGPM=2 S BGPD=BGPD+$$LEAP^XLFDT2(BGPY)
 S BGPD=$E("00",1,2-$L(BGPD))_BGPD
 S BGPM=$E("00",1,2-$L(BGPM))_BGPM
 S BGPENDDT=BGPY_BGPM_BGPD
 S BGPBEGDT=$$FMADD^XLFDT(BGPENDDT,-364)
 Q
ATT(BGPDPD0) ;
 ;----- RETURNS NUMBER OF PROCESSING ATTEMPTS
 ;
 Q $P($G(^BGPGP1PM(1,7,+$G(BGPDPD0),0)),U,6)+1
 ;
READ(BGPPATH,BGPFILE,BGPOUT) ;
 ;----- READ CONTENTS OF DATA FILE AND PUT INTO ^TMP GLOBAL
 ;
 N BGPCNT,BGPEND,I,POP,X
 ;
 K ^TMP("BGPGPAM",$J,BGPFILE)
 S BGPOUT=0
 S BGPEND=0
 S BGPCNT=0
 D OPEN^%ZISH("FILE",BGPPATH,BGPFILE,"R")
 I POP D
 . S BGPOUT=1
 . S BGPERR="UNABLE TO OPEN FILE '"_BGPPATH_BGPFILE_"'"
 . ;S $ZE="<NOTOPEN>READ^BGPGP1UP"
 . ;D ^ZTER
 Q:BGPOUT
 F I=1:1 D  Q:BGPEND
 . U IO R X:DTIME
 . I $$STATUS^%ZISH S BGPEND=1
 . Q:BGPEND
 . S BGPCNT=BGPCNT+1
 . S ^TMP("BGPGPAM",$J,"FILE",I,0)=X
 . S ^TMP("BGPGPAM",$J,"FILE",0)=BGPCNT
 ;
 D CLOSE^%ZISH("FILE")
 Q
DATES(BGPDTS,DBEG,DEND) ;
 ;----- ASK DATE RANGE
 ; RETURNS DATES=BEGINDATE^ENDDATE
 ;
 ;      INPUT:
 ;      DBEG  =  DEFAULT BEGINNING DATE (OPTIONAL)
 ;      DEND  =  DEFAULT ENDING DATE(OPTIONAL)
 ;
D ;----- DATE LOOP
 ;
 N BEG,DIR,DIRUT,DTOUT,DUOUT,END,X,Y
 ;
 S BEG=$G(DBEG)
 I BEG S Y=BEG X ^DD("DD") S BEG=Y
 S END=$G(DEND)
 I END S Y=END X ^DD("DD") S END=Y
 S BGPDTS=""
 D EN^DDIOL("","","!")
 S DIR(0)="DO^::E"
 S DIR("A")="Select Beginning Date"
 I $G(BEG)]"" S DIR("B")=$G(BEG)
 D ^DIR
 Q:$D(DTOUT)!($D(DUOUT))!($D(DIRUT))
 Q:Y=""
 S BEG=Y
 S DIR("A")="Ending Date"
 S DIR("B")="TODAY"
 I $G(END)]"" S DIR("B")=$G(END)
 D ^DIR
 Q:$D(DTOUT)!($D(DUOUT))!($D(DIRUT))
 Q:Y=""
 S END=Y
 I END<BEG D  G D
 . D EN^DDIOL("ENDING DATE cannot be less than BEGINNING DATE","","*7,!")
 S BGPDTS=BEG_U_END
 K BEG,END
 Q
 ;
ALERTMM(BGPMSG,BGPBEGDT,BGPENDDT,BGPFACS,BGPF,BGPDFILE,BGPUSR) ;
 ;
 NEW BGPX,%,P,BGPTEXT,BGPASU,T,BGPFAC
 S BGPX=0 F  S BGPX=$O(^BGPGP1PM(1,99.2,BGPX)) Q:BGPX'=+BGPX  S P=$P($G(^BGPGP1PM(1,99.2,BGPX,0)),U,1) D
 .S XQA(P)=""
 .S XQAOPT=""
 .S XQAROU=""
 .S XQAFLG="D"
 .S BGPTEXT(1)=" "
 .S BGPTEXT(2)="Monthly GPRA report period date range:  "_$$FMTE^XLFDT(BGPBEGDT)_" to "_$$FMTE^XLFDT(BGPENDDT)
 .S BGPTEXT(3)="  "
 .S BGPTEXT(4)="The site GPRA files could not be uploaded because files are"
 .S BGPTEXT(5)="missing from the following facilities:"
 .S BGPASU=0,T=5
 .F  S BGPASU=$O(BGPFACS(BGPENDDT,BGPASU)) Q:BGPASU=""  D
 .. Q:BGPFACS(BGPENDDT,BGPASU)]""
 .. S BGPFAC=$O(^BGPGP1PM(1,9,"C",BGPASU,0))
 .. Q:'BGPFAC
 .. S BGPFAC=$P($G(^BGPGP1PM(1,9,BGPFAC,0)),U)
 .. I BGPFAC]"" S T=T+1 S BGPTEXT(T)=BGPASU_"   "_$$VAL^XBDIQ1(4,BGPFAC,.01)
 .S T=T+1
 .S BGPTEXT(T)="The aggregate excel files cannot be created until all files"
 .S T=T+1,BGPTEXT(T)="are received from all facilities."
 .S XQATEXT="BGPTEXT"
 .S XQAMSG="GPRA Auto Extract Upload Failed."
 .S XQAID="OR,"_DUZ_",46"
 .D SETUP^XQALERT
 .;now send mailman message
 .D MM
 Q
MM ;mailman message
 D GETRECIP
SUBJECT S XMSUB="* * * GPRA AUTO UPLOAD OF DATA * * *"
SENDER S XMDUZ="GPRA AUTO UPLOAD"
 S XMTEXT="BGPTEXT(",XMY(1)="",XMY(DUZ)=""
 D ^XMD
 Q
 ;
GETRECIP ;
 ;* * * Define key below to identify recipients * * *
 ;
 NEW CTR
 S CTR=0
 F  S CTR=$O(^BGPGP1PM(1,99.2,CTR)) Q:'CTR  S Y=$P($G(^BGPGP1PM(1,99.2,CTR,0)),U,1) I Y S XMY(Y)=""
 Q
ALERTMM1(BGPMSG,BGPBEGDT,BGPENDDT,BGPFACS,BGPF,BGPDFILE,BGPUSR) ;
 ;
 NEW BGPX,%,P,BGPTEXT,BGPASU,T,BGPFAC
 S BGPX=0 F  S BGPX=$O(^BGPGP1PM(1,99.2,BGPX)) Q:BGPX'=+BGPX  S P=$P($G(^BGPGP1PM(1,99.2,BGPX,0)),U,1) D
 .S XQA(P)=""
 .S XQAOPT=""
 .S XQAROU=""
 .S XQAFLG="D"
 .S BGPTEXT(1)="Monthly GPRA report period date range:  "_$$FMTE^XLFDT(BGPBEGDT)_" to "_$$FMTE^XLFDT(BGPENDDT)
 .;
 .S BGPTEXT(2)="The following aggregate excel files have been created:"
 .;
 .S BGP=0,C=3
 .F  S BGP=$O(BGPF(BGP)) Q:'BGP  D
 .. S C=C+1,BGPTEXT(C)=BGPF(BGP)
 .S C=C+1,BGPTEXT(C)=BGPFGNT1
 .S C=C+1,BGPTEXT(C)=BGPFGNT2
 .S C=C+1,BGPTEXT(C)=BGPFDEV1
 .S C=C+1,BGPTEXT(C)=BGPFDEV2
 .S C=C+1,BGPTEXT(C)=BGPFDEV3
 .S C=C+1,BGPTEXT(C)="The following data file for DeepSee has been created:"
 .S C=C+1,BGPTEXT(C)=BGPDFILE
 .S XQATEXT="BGPTEXT"
 .S XQAMSG="GPRA Auto Extract Upload Completed."
 .S XQAID="OR,"_DUZ_",46"
 .D SETUP^XQALERT
 .;now send mailman message
 .D MM
 Q