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

BGP7AUUP.m

Go to the documentation of this file.
BGP7AUUP ; IHS/CMI/LAB - UPLOAD SITE FILES, CREATE EXCEL FILES ;
 ;;17.1;IHS CLINICAL REPORTING;;MAY 10, 2017;Build 29
 ;
DESC ;----- ROUTINE DESCRIPTION
 ;;This routine processes the monthly GPRA files received from
 ;;the sites.  It creates the Excel fileUYYYY 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 CALC(.BGPBEGDT,.BGPENDDT)
 D EN(BGPBEGDT,BGPENDDT)
 ;
 S BGPY=0
 Q
MAN ;EP -- MANUALLY PROCESS
 ;
 W !!,"This option is used to aggregate all GPRA Extract files that have"
 W !,"been received from the facilities.",!!
 W !,"The process will run immediately.",!
 S DIR(0)="Y",DIR("A")="Do you wish to continue",DIR("B")="Y" KILL DA D ^DIR KILL DIR
 I $D(DIRUT) Q
 I 'Y Q
 N BGPBEGDT,BGPDTS,BGPENDDT,BGPMAN
 ;
 D CALC(.BGPBEGDT,.BGPENDDT)
 W !!,"Processing ",$$VAL^XBDIQ1(90245,1,.02)," for ",$$FMTE^XLFDT(BGPBEGDT),"-",$$FMTE^XLFDT(BGPENDDT),".",!
 S BGPMAN=1
 D EN(BGPBEGDT,BGPENDDT,BGPMAN)
 Q
GUIDQ ;EP -- gui entry point for manual
 D CALC(.BGPBEGDT,.BGPENDDT)
 S BGPMAN=1
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
 I $P($G(^BGPGP1PM(1,7,BGPDPD0,0)),U,4)=1 D:$G(BGPMAN)  Q
 .W !!,"Those files for the 1st Friday in "
 .S X=+$E($P(^BGPGP1PM(1,7,BGPDPD0,0),U,9),4,5)
 .;
 .S X=$P($T(MON+X),";;",2)
 .W X," were already successfully uploaded and",!,"processed on ",$$FMTE^XLFDT($P(^BGPGP1PM(1,7,BGPDPD0,0),U,9)),!
 ;quit trying to process after 5 tries
 Q:$P($G(^BGPGP1PM(1,7,BGPDPD0,0)),U,6)>50
 ;
 S BGPPATH=$P($G(^BGPGP1PM(1,1)),U)
 Q:BGPPATH']""
 ;
 ;
 K ^TMP("BGPGPAM",$J,"FILE")
 K BGPLIST S BGPLIST="",X=$$LIST^%ZISH(BGPPATH,"BGPAM140*",.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"
 . K ^TMP("BGPGPAM",$J,"FILE")
 . I $G(BGPMAN) D  Q
 . . W !,BGPERR
 . . D MSG1^BGP7AU1M(BGPBEGDT,BGPENDDT,.BGPFACS)
 . ;SEND EMAIL/ALERT THAT FILES ARE NOT ALL THERE
 . D ALERTMM(1,BGPBEGDT,BGPENDDT,.BGPFACS,.BGPF,BGPDFILE)
 . I '$G(BGPMAN) D REQUE(BGPBEGDT,BGPENDDT)
 . D STAT(BGPDPD0,BGPBEGDT,$G(BGPENDDT),$$NOW^XLFDT,2,BGPERR,$$ATT(BGPDPD0))
 Q:BGPOUT
 ;
 ;upload all files into the BGP 17 DATA* files
 D UPLOAD(BGPPATH,BGPBEGDT,BGPENDDT,.BGPFACS)
 ;
 ;create the 5 excel files
 D EN^BGP7AU1A(BGPBEGDT,BGPENDDT,.BGPEND,.BGPF)
 ;
 ;upload the 5 excel files into BGPGP1 GPRA FLAT 
 D EN^BGP7AU1R(.BGPF)
 ;
 ;create data dump text file
 ;
 ;ihs/cmi/maw gui failing here on BGPEND
 D EN^BGP7AU1D(BGPBEGDT,BGPEND,.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  Q
 . W !,"ALL FILES SUCCESSFULLY CREATED AND EMAIL MESSAGE SENT"
 ;REQUEUE
 NEW BGPDT,BGPX,BGPY
 S X=DT F  S X=$$FMADD^XLFDT(X,1) Q:$E(X,6,7)="01"
 S BGPDT=X
 ;get next "second Friday" in this month
 S BGPY=0
 D
 . S X=BGPDT D DW^%DTC I X="FRIDAY" S BGPY=BGPY+1
 . F  D  Q:BGPY=2
 . . S (X,BGPDT)=$$FMADD^XLFDT(BGPDT,1)
 . . D DW^%DTC
 . . Q:X'="FRIDAY"
 . . S BGPY=BGPY+1
 S BGPX=BGPDT_".12"
 S ZTDTH=BGPX
 ;S ZTSAVE("BGP*")=""
 S ZTRTN="AUTO^BGP7AUUP"
 S ZTDESC="BGP7 AUTO GPRA AREA AGGREGATE"
 S ZTIO=""
 D ^%ZTLOAD
 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^BGP7AUUL(BGPPATH,BGPFILE)
 Q
SEND(BGPDFILE) ;----- SEND DATA DUMP FILE TO DEEPSEE SERVER
 ;
 ;***need ip address, username, password
 ;
 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'["BGPAM150"
 . S BGPFILE="BGPAM150"_$P(BGPDATA,"BGPAM150",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(^BGPGPDCG("B",BGPBEGDT,BGPD0)) Q:'BGPD0  D
 . S BGPASU=$P(^BGPGPDCG(BGPD0,0),U,9)
 . I $G(BGPFACS(BGPENDDT,BGPASU))="" Q
 . Q:$P(^BGPGPDCG(BGPD0,0),U,12)'=1  ;DON'T DELETE OTHER NATIONAL, GPU, ETC.
 . S DA=BGPD0
 . S DIK="^BGPGPDCG("
 . D ^DIK
 ;
 S BGPD0=0 F  S BGPD0=$O(^BGPGPDPG("B",BGPBEGDT,BGPD0)) Q:'BGPD0  D
 . S BGPASU=$P(^BGPGPDPG(BGPD0,0),U,9)
 . I $G(BGPFACS(BGPENDDT,BGPASU))="" Q
 . Q:$P(^BGPGPDPG(BGPD0,0),U,12)'=1  ;DON'T DELETE OTHER NATIONAL, GPU, ETC.
 . S DA=BGPD0
 . S DIK="^BGPGPDPG("
 . D ^DIK
 ;
 S BGPD0=0 F  S BGPD0=$O(^BGPGPDBG("B",BGPBEGDT,BGPD0)) Q:'BGPD0  D
 . S BGPASU=$P(^BGPGPDBG(BGPD0,0),U,9)
 . I $G(BGPFACS(BGPENDDT,BGPASU))="" Q
 . Q:$P(^BGPGPDBG(BGPD0,0),U,12)'=1  ;DON'T DELETE OTHER NATIONAL, GPU, ETC.
 . S DA=BGPD0
 . S DIK="^BGPGPDBG("
 . 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(BGPFGNT3)
 D MOVE1(BGPFGNT4)
 D MOVE1(BGPFGNT5)
 D MOVE1(BGPFDEV1)
 D MOVE1(BGPFDEV2)
 D MOVE1(BGPFDEV3)
 D MOVE1(BGPFDEV4)
 Q
MOVE1(BGPFILE) ;
 ;----- MOVE FILE TO ANOTHER DIR
 ;
 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 ZTSAVE("BGP*")=""
 S ZTDTH=$$FMADD^XLFDT($$NOW^XLFDT,+1)
 S ZTRTN="AUTO^BGP7AUUP"
 S ZTDESC="BGP7 AUTO GPRA AREA AGGREGATE"
 S ZTIO=""
 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",2017,0))
 S Y=^BGPCTRL(Y,0)
 ;S BGPENDDT=$P(Y,U,9)
 ;S BGPBEGDT=$P(Y,U,8)
 S BGPBEGDT=$S(+$E(DT,4,7)<701:$E(DT,1,3)-1_"0701",1:$E(DT,1,3)_"0701")
 S BGPENDDT=$S(+$E(DT,4,7)<701:$E(DT,1,3)_"0630",1:$E(DT,1,3)+1_"0630")
 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
 ;
 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_"'"
 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
 .D MM
 Q
MM ;mailman
 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)=BGPFGNT3
 .S C=C+1,BGPTEXT(C)=BGPFGNT4
 .S C=C+1,BGPTEXT(C)=BGPFGNT5
 .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)=BGPFDEV4
 .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
SCH ;EP - called from option to schedule the area aggregate for the next "2nd Friday"
 D SCH^BGP7AUUL
 Q
XIT ;EP
 D EN^XBVK("BGP")
 Q
MON ;;
1 ;;JANUARY
2 ;;FEBRUARY
3 ;;MARCH
4 ;;APRIL
5 ;;MAY
6 ;;JUNE
7 ;;JULY
8 ;;AUGUST
9 ;;SEPTEMBER
10 ;;OCTOBER
11 ;;NOVEMBER
12 ;;DECEMBER