BDWRXP ;cmi/anch/maw - BDW Mark Visit for Export that didn't export already 8/8/2007 10:14:44 AM
;;1.0;IHS DATA WAREHOUSE;**1,2**;JAN 23, 2006
;
;
;
;this routine will go back to the beginning of the fiscal year and mark
;visits for export that did not export already
;
;
MAIN ;-- this is the main routine driver
S BDWFY=$$FY(DT)
D LOOK(BDWFY_"0930.9999",(DT-.0001))
D EOJ
Q
;
FY(BDWDT) ;-- lets find out the fiscal year based on DT passed in
N BDWYR,BDWMO,BDWFY
S BDWYR=$E(BDWDT,1,3)
S BDWMO=$E(BDWDT,4,5)
S BDWFY=BDWYR
I BDWMO="01" S BDWFY=BDWYR-1
I BDWMO="02" S BDWFY=BDWYR-1
I BDWMO="03" S BDWFY=BDWYR-1
I BDWMO="04" S BDWFY=BDWYR-1
I BDWMO="05" S BDWFY=BDWYR-1
I BDWMO="06" S BDWFY=BDWYR-1
I BDWMO="07" S BDWFY=BDWYR-1
I BDWMO="08" S BDWFY=BDWYR-1
I BDWMO="09" S BDWFY=BDWYR-1
Q BDWFY
;
LOOK(BDWBEG,BDWEND) ;-- look through all visits for the fiscal year until today and mark for export
N BDWDA,BDWCNT
S BDWCNT=0
I $G(BDWINT) W !,"Searching"
S BDWDA=BDWBEG F S BDWDA=$O(^AUPNVSIT("B",BDWDA)) Q:'BDWDA!(BDWDA>BDWEND) D
. S BDWIEN=0 F S BDWIEN=$O(^AUPNVSIT("B",BDWDA,BDWIEN)) Q:'BDWIEN D
.. S BDWCNT=BDWCNT+1
.. I $G(BDWINT),BDWCNT=50 D
... W "."
... S BDWCNT=0
.. N BDWREC,BDWREC1,BDWVCDT,BDWUSER,BDWVEDT
.. S BDWREC=$G(^AUPNVSIT(BDWIEN,0))
.. S BDWUSER=$P(BDWREC,U,23) ;created by user
.. I BDWUSER Q:BDWUSER=.5 ;screen out postmaster for MFI sites
.. S BDWREC1=$G(^AUPNVSIT(BDWIEN,11))
.. S BDWVCDT=$P(BDWREC,U,2) ;visit creation date
.. S BDWVEDT=$P(BDWREC,U,13) ;visit last update
.. Q:'BDWVCDT
.. Q:'BDWVEDT
.. Q:$P(BDWREC,U,11) ;visit deleted
.. Q:$P(BDWREC1,U,6) ;already exported
.. Q:$D(^AUPNVSIT("ADWO",BDWVCDT,BDWIEN)) ;xref already set
.. Q:$D(^AUPNVSIT("ADWO",BDWVEDT,BDWIEN)) ;xref already set
.. ;N BDWFDA,BDWIENS,BDWERR
.. ;S BDWIENS=BDWIEN_","
.. ;S BDWFDA(9000010,BDWIENS,.13)=DT
.. S BDWRXP=1 ;flag to tell trigger not to fire
.. ;D FILE^DIE("K","BDWFDA","BDWERR(1)")
.. D ^XBFMK S DIE="^AUPNVSIT(",DA=BDWIEN,DR=".13////"_DT D ^DIE K DIE,DA,DR
.. K BDWRXP
Q
;
EOJ ;-- end of job
D EN^XBVK("BDW")
K DIR
D ^XBFMK
Q
;
ASK ;-- ask the dates for the run
N BDWFY,BDW3FY
S BDWFY=$$FY(DT) ;get fiscal year
S BDW3FY=($E(BDWFY,1,3)-3)_"0930.9999" ; get begin date for last 3 full fys per dr. stan griffith
S BDWFD=$$FMADD^XLFDT($P(BDW3FY,"."),1) ;earliest date for reader call
W !!,"This option can be used to flag visits for export "
W !,"that have not previously been exported to the National Data Warehouse.",!
W !,"You will be asked to enter a beginning and ending date. The system will"
W !,"review all visits in that date range and if the visit has never been"
W !,"exported to the NDW it will flag it for export on the next export."
W !!,"The earliest date you can enter for this option is ",$$FMTE^XLFDT(BDWFD),".",!!
;S %DT="AEP",%DT(0)=BDW3FY,%DT("A")="Enter Begin Date: "
;D ^%DT
;I Y<0 K BDWBG,%DT
;S BDWBG=+Y_.9999
;S %DT="AE",%DT(0)="-NOW",%DT("A")="Enter End Date: "
;D ^%DT
;I Y<0 K BDWBG,%DT
;S BDWED=+Y_.9999
;K %DT
BD ;get beginning date
S (BDWBG,BDWED)=""
S DIR(0)="D^"_BDWFD_":"_DT_":EP",DIR("A")="Enter Beginning Date",DIR("?")="Enter the beginning visit date. It must be after "_$$FMTE^XLFDT(BDWFD)
D ^DIR K DIR S:$D(DUOUT) DIRUT=1
I $D(DIRUT) Q
S BDWBG=Y
ED ;
S DIR(0)="DA^"_BDWBG_":"_DT_":EP",DIR("A")="Enter Ending Date: " D ^DIR K DIR,DA S:$D(DUOUT) DIRUT=1
I $D(DIRUT) Q
I Y<BDWBG W !,"Ending date must be greater than or equal to beginning date!" G ED
S BDWED=Y
Q
;
INTER ;-- interactive run
S BDWINT=1
D ASK
I '$G(BDWBG)!('$G(BDWED)) W !!,"Beginning and ending dates not selected.",! D PAUSE,EOJ Q
D LOOK(BDWBG,BDWED)
D EOJ
Q
;
PAUSE ;
K DIR S DIR(0)="E",DIR("A")="Press enter: " D ^DIR K DIR
Q
BDWRXP ;cmi/anch/maw - BDW Mark Visit for Export that didn't export already 8/8/2007 10:14:44 AM
+1 ;;1.0;IHS DATA WAREHOUSE;**1,2**;JAN 23, 2006
+2 ;
+3 ;
+4 ;
+5 ;this routine will go back to the beginning of the fiscal year and mark
+6 ;visits for export that did not export already
+7 ;
+8 ;
MAIN ;-- this is the main routine driver
+1 SET BDWFY=$$FY(DT)
+2 DO LOOK(BDWFY_"0930.9999",(DT-.0001))
+3 DO EOJ
+4 QUIT
+5 ;
FY(BDWDT) ;-- lets find out the fiscal year based on DT passed in
+1 NEW BDWYR,BDWMO,BDWFY
+2 SET BDWYR=$EXTRACT(BDWDT,1,3)
+3 SET BDWMO=$EXTRACT(BDWDT,4,5)
+4 SET BDWFY=BDWYR
+5 IF BDWMO="01"
SET BDWFY=BDWYR-1
+6 IF BDWMO="02"
SET BDWFY=BDWYR-1
+7 IF BDWMO="03"
SET BDWFY=BDWYR-1
+8 IF BDWMO="04"
SET BDWFY=BDWYR-1
+9 IF BDWMO="05"
SET BDWFY=BDWYR-1
+10 IF BDWMO="06"
SET BDWFY=BDWYR-1
+11 IF BDWMO="07"
SET BDWFY=BDWYR-1
+12 IF BDWMO="08"
SET BDWFY=BDWYR-1
+13 IF BDWMO="09"
SET BDWFY=BDWYR-1
+14 QUIT BDWFY
+15 ;
LOOK(BDWBEG,BDWEND) ;-- look through all visits for the fiscal year until today and mark for export
+1 NEW BDWDA,BDWCNT
+2 SET BDWCNT=0
+3 IF $GET(BDWINT)
WRITE !,"Searching"
+4 SET BDWDA=BDWBEG
FOR
SET BDWDA=$ORDER(^AUPNVSIT("B",BDWDA))
IF 'BDWDA!(BDWDA>BDWEND)
QUIT
Begin DoDot:1
+5 SET BDWIEN=0
FOR
SET BDWIEN=$ORDER(^AUPNVSIT("B",BDWDA,BDWIEN))
IF 'BDWIEN
QUIT
Begin DoDot:2
+6 SET BDWCNT=BDWCNT+1
+7 IF $GET(BDWINT)
IF BDWCNT=50
Begin DoDot:3
+8 WRITE "."
+9 SET BDWCNT=0
End DoDot:3
+10 NEW BDWREC,BDWREC1,BDWVCDT,BDWUSER,BDWVEDT
+11 SET BDWREC=$GET(^AUPNVSIT(BDWIEN,0))
+12 ;created by user
SET BDWUSER=$PIECE(BDWREC,U,23)
+13 ;screen out postmaster for MFI sites
IF BDWUSER
IF BDWUSER=.5
QUIT
+14 SET BDWREC1=$GET(^AUPNVSIT(BDWIEN,11))
+15 ;visit creation date
SET BDWVCDT=$PIECE(BDWREC,U,2)
+16 ;visit last update
SET BDWVEDT=$PIECE(BDWREC,U,13)
+17 IF 'BDWVCDT
QUIT
+18 IF 'BDWVEDT
QUIT
+19 ;visit deleted
IF $PIECE(BDWREC,U,11)
QUIT
+20 ;already exported
IF $PIECE(BDWREC1,U,6)
QUIT
+21 ;xref already set
IF $DATA(^AUPNVSIT("ADWO",BDWVCDT,BDWIEN))
QUIT
+22 ;xref already set
IF $DATA(^AUPNVSIT("ADWO",BDWVEDT,BDWIEN))
QUIT
+23 ;N BDWFDA,BDWIENS,BDWERR
+24 ;S BDWIENS=BDWIEN_","
+25 ;S BDWFDA(9000010,BDWIENS,.13)=DT
+26 ;flag to tell trigger not to fire
SET BDWRXP=1
+27 ;D FILE^DIE("K","BDWFDA","BDWERR(1)")
+28 DO ^XBFMK
SET DIE="^AUPNVSIT("
SET DA=BDWIEN
SET DR=".13////"_DT
DO ^DIE
KILL DIE,DA,DR
+29 KILL BDWRXP
End DoDot:2
End DoDot:1
+30 QUIT
+31 ;
EOJ ;-- end of job
+1 DO EN^XBVK("BDW")
+2 KILL DIR
+3 DO ^XBFMK
+4 QUIT
+5 ;
ASK ;-- ask the dates for the run
+1 NEW BDWFY,BDW3FY
+2 ;get fiscal year
SET BDWFY=$$FY(DT)
+3 ; get begin date for last 3 full fys per dr. stan griffith
SET BDW3FY=($EXTRACT(BDWFY,1,3)-3)_"0930.9999"
+4 ;earliest date for reader call
SET BDWFD=$$FMADD^XLFDT($PIECE(BDW3FY,"."),1)
+5 WRITE !!,"This option can be used to flag visits for export "
+6 WRITE !,"that have not previously been exported to the National Data Warehouse.",!
+7 WRITE !,"You will be asked to enter a beginning and ending date. The system will"
+8 WRITE !,"review all visits in that date range and if the visit has never been"
+9 WRITE !,"exported to the NDW it will flag it for export on the next export."
+10 WRITE !!,"The earliest date you can enter for this option is ",$$FMTE^XLFDT(BDWFD),".",!!
+11 ;S %DT="AEP",%DT(0)=BDW3FY,%DT("A")="Enter Begin Date: "
+12 ;D ^%DT
+13 ;I Y<0 K BDWBG,%DT
+14 ;S BDWBG=+Y_.9999
+15 ;S %DT="AE",%DT(0)="-NOW",%DT("A")="Enter End Date: "
+16 ;D ^%DT
+17 ;I Y<0 K BDWBG,%DT
+18 ;S BDWED=+Y_.9999
+19 ;K %DT
BD ;get beginning date
+1 SET (BDWBG,BDWED)=""
+2 SET DIR(0)="D^"_BDWFD_":"_DT_":EP"
SET DIR("A")="Enter Beginning Date"
SET DIR("?")="Enter the beginning visit date. It must be after "_$$FMTE^XLFDT(BDWFD)
+3 DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+4 IF $DATA(DIRUT)
QUIT
+5 SET BDWBG=Y
ED ;
+1 SET DIR(0)="DA^"_BDWBG_":"_DT_":EP"
SET DIR("A")="Enter Ending Date: "
DO ^DIR
KILL DIR,DA
IF $DATA(DUOUT)
SET DIRUT=1
+2 IF $DATA(DIRUT)
QUIT
+3 IF Y<BDWBG
WRITE !,"Ending date must be greater than or equal to beginning date!"
GOTO ED
+4 SET BDWED=Y
+5 QUIT
+6 ;
INTER ;-- interactive run
+1 SET BDWINT=1
+2 DO ASK
+3 IF '$GET(BDWBG)!('$GET(BDWED))
WRITE !!,"Beginning and ending dates not selected.",!
DO PAUSE
DO EOJ
QUIT
+4 DO LOOK(BDWBG,BDWED)
+5 DO EOJ
+6 QUIT
+7 ;
PAUSE ;
+1 KILL DIR
SET DIR(0)="E"
SET DIR("A")="Press enter: "
DO ^DIR
KILL DIR
+2 QUIT