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

BDWRXP.m

Go to the documentation of this file.
  1. 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
  1. ;
  1. ;
  1. ;
  1. ;this routine will go back to the beginning of the fiscal year and mark
  1. ;visits for export that did not export already
  1. ;
  1. ;
  1. MAIN ;-- this is the main routine driver
  1. S BDWFY=$$FY(DT)
  1. D LOOK(BDWFY_"0930.9999",(DT-.0001))
  1. D EOJ
  1. Q
  1. ;
  1. FY(BDWDT) ;-- lets find out the fiscal year based on DT passed in
  1. N BDWYR,BDWMO,BDWFY
  1. S BDWYR=$E(BDWDT,1,3)
  1. S BDWMO=$E(BDWDT,4,5)
  1. S BDWFY=BDWYR
  1. I BDWMO="01" S BDWFY=BDWYR-1
  1. I BDWMO="02" S BDWFY=BDWYR-1
  1. I BDWMO="03" S BDWFY=BDWYR-1
  1. I BDWMO="04" S BDWFY=BDWYR-1
  1. I BDWMO="05" S BDWFY=BDWYR-1
  1. I BDWMO="06" S BDWFY=BDWYR-1
  1. I BDWMO="07" S BDWFY=BDWYR-1
  1. I BDWMO="08" S BDWFY=BDWYR-1
  1. I BDWMO="09" S BDWFY=BDWYR-1
  1. Q BDWFY
  1. ;
  1. LOOK(BDWBEG,BDWEND) ;-- look through all visits for the fiscal year until today and mark for export
  1. N BDWDA,BDWCNT
  1. S BDWCNT=0
  1. I $G(BDWINT) W !,"Searching"
  1. S BDWDA=BDWBEG F S BDWDA=$O(^AUPNVSIT("B",BDWDA)) Q:'BDWDA!(BDWDA>BDWEND) D
  1. . S BDWIEN=0 F S BDWIEN=$O(^AUPNVSIT("B",BDWDA,BDWIEN)) Q:'BDWIEN D
  1. .. S BDWCNT=BDWCNT+1
  1. .. I $G(BDWINT),BDWCNT=50 D
  1. ... W "."
  1. ... S BDWCNT=0
  1. .. N BDWREC,BDWREC1,BDWVCDT,BDWUSER,BDWVEDT
  1. .. S BDWREC=$G(^AUPNVSIT(BDWIEN,0))
  1. .. S BDWUSER=$P(BDWREC,U,23) ;created by user
  1. .. I BDWUSER Q:BDWUSER=.5 ;screen out postmaster for MFI sites
  1. .. S BDWREC1=$G(^AUPNVSIT(BDWIEN,11))
  1. .. S BDWVCDT=$P(BDWREC,U,2) ;visit creation date
  1. .. S BDWVEDT=$P(BDWREC,U,13) ;visit last update
  1. .. Q:'BDWVCDT
  1. .. Q:'BDWVEDT
  1. .. Q:$P(BDWREC,U,11) ;visit deleted
  1. .. Q:$P(BDWREC1,U,6) ;already exported
  1. .. Q:$D(^AUPNVSIT("ADWO",BDWVCDT,BDWIEN)) ;xref already set
  1. .. Q:$D(^AUPNVSIT("ADWO",BDWVEDT,BDWIEN)) ;xref already set
  1. .. ;N BDWFDA,BDWIENS,BDWERR
  1. .. ;S BDWIENS=BDWIEN_","
  1. .. ;S BDWFDA(9000010,BDWIENS,.13)=DT
  1. .. S BDWRXP=1 ;flag to tell trigger not to fire
  1. .. ;D FILE^DIE("K","BDWFDA","BDWERR(1)")
  1. .. D ^XBFMK S DIE="^AUPNVSIT(",DA=BDWIEN,DR=".13////"_DT D ^DIE K DIE,DA,DR
  1. .. K BDWRXP
  1. Q
  1. ;
  1. EOJ ;-- end of job
  1. D EN^XBVK("BDW")
  1. K DIR
  1. D ^XBFMK
  1. Q
  1. ;
  1. ASK ;-- ask the dates for the run
  1. N BDWFY,BDW3FY
  1. S BDWFY=$$FY(DT) ;get fiscal year
  1. S BDW3FY=($E(BDWFY,1,3)-3)_"0930.9999" ; get begin date for last 3 full fys per dr. stan griffith
  1. S BDWFD=$$FMADD^XLFDT($P(BDW3FY,"."),1) ;earliest date for reader call
  1. W !!,"This option can be used to flag visits for export "
  1. W !,"that have not previously been exported to the National Data Warehouse.",!
  1. W !,"You will be asked to enter a beginning and ending date. The system will"
  1. W !,"review all visits in that date range and if the visit has never been"
  1. W !,"exported to the NDW it will flag it for export on the next export."
  1. W !!,"The earliest date you can enter for this option is ",$$FMTE^XLFDT(BDWFD),".",!!
  1. ;S %DT="AEP",%DT(0)=BDW3FY,%DT("A")="Enter Begin Date: "
  1. ;D ^%DT
  1. ;I Y<0 K BDWBG,%DT
  1. ;S BDWBG=+Y_.9999
  1. ;S %DT="AE",%DT(0)="-NOW",%DT("A")="Enter End Date: "
  1. ;D ^%DT
  1. ;I Y<0 K BDWBG,%DT
  1. ;S BDWED=+Y_.9999
  1. ;K %DT
  1. BD ;get beginning date
  1. S (BDWBG,BDWED)=""
  1. 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)
  1. D ^DIR K DIR S:$D(DUOUT) DIRUT=1
  1. I $D(DIRUT) Q
  1. S BDWBG=Y
  1. ED ;
  1. S DIR(0)="DA^"_BDWBG_":"_DT_":EP",DIR("A")="Enter Ending Date: " D ^DIR K DIR,DA S:$D(DUOUT) DIRUT=1
  1. I $D(DIRUT) Q
  1. I Y<BDWBG W !,"Ending date must be greater than or equal to beginning date!" G ED
  1. S BDWED=Y
  1. Q
  1. ;
  1. INTER ;-- interactive run
  1. S BDWINT=1
  1. D ASK
  1. I '$G(BDWBG)!('$G(BDWED)) W !!,"Beginning and ending dates not selected.",! D PAUSE,EOJ Q
  1. D LOOK(BDWBG,BDWED)
  1. D EOJ
  1. Q
  1. ;
  1. PAUSE ;
  1. K DIR S DIR(0)="E",DIR("A")="Press enter: " D ^DIR K DIR
  1. Q