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

RABTCH2.m

Go to the documentation of this file.
  1. RABTCH2 ;HISC/GJC-Batch Report Option, delete by date ;2/6/97 09:34
  1. ;;5.0;Radiology/Nuclear Medicine;;Mar 16, 1998
  1. DELDT ; Delete a batch within a specified date range.
  1. ;*** Variable List ***
  1. ; ^TMP($J,"RA BTCHDEL DT",ien)--> ien's of the records to be deleted
  1. ;
  1. N DIROUT,DIRUT,DTOUT,DUOUT,RA,RADUZ,RAUPRT,RAXIT,X,Y
  1. S RADUZ=+$G(DUZ)
  1. I '$D(^XUSEC("RA MGR",RADUZ)) D Q
  1. . W !?5,"This option can only be used by those Radiology/Nuclear"
  1. . W " Medicine users that"
  1. . W !?5,"have access to the Radiology/Nuclear Medicine Manager's"
  1. . W " (RA MGR) key.",$C(7)
  1. . Q
  1. S (RA("%"),RA("DT"),RAUPRT)=0
  1. F D Q:RA("%")!(RAUPRT<0)
  1. . K ^TMP($J,"RA BTCHDEL DT"),RA("CNT") S RAXIT=0
  1. . K %DT S %DT="PEA",%DT(0)="-NOW"
  1. . S %DT("A")="Purge report batches printed before: "
  1. . S Y=$S('$D(DT):($$NOW^XLFDT()\1),1:DT) X ^DD("DD")
  1. . S %DT("B")=Y
  1. . W !!?5,"All batches up to the date you enter will be purged"
  1. . W !?5,"from the Report Batches file #74.2.",$C(7),!
  1. . D ^%DT K %DT
  1. . S:Y=-1 RA("%")=1,RA("DT")=Y
  1. . Q:RA("%") S RA("DTI")=Y_".9999"
  1. . X ^DD("DD") S RA("DTX")=Y
  1. . W ! S RAUPRT=$$YN(RA("DTX")) Q:RAUPRT<0
  1. . D SETMP
  1. . I '+$G(RA("CNT")) D Q
  1. .. W !!?5,"No "_$S(RAUPRT=1:"unprinted or ",1:"")_"printed batches exist before: ",RA("DTX"),"!"
  1. .. Q
  1. . D DISPLAY Q:RAXIT
  1. . W !!?5,"'",RA("DTX"),"', are you sure?",!
  1. . K DIR S DIR(0)="Y"
  1. . S DIR("?",1)="Enter 'Y' if this date is acceptable,"
  1. . S DIR("?")="or 'N' if you wish to select another date."
  1. . D ^DIR K DIR
  1. . S:$D(DIRUT) RA("DT")=-1
  1. . S:$D(DIRUT)!(+Y) RA("%")=1
  1. . Q
  1. I RA("DT")=-1!(RAUPRT<0) D KILL1 Q
  1. W !!?5,"There"_$S(+$G(RA("CNT"))>1:" are ",1:" is ")
  1. W +$G(RA("CNT"))," batch"
  1. W $S(+$G(RA("CNT"))>1:"es ",1:" ")
  1. W "selected to be deleted."
  1. W !?5,"Do you wish to task this job off to be completed"
  1. W !?5,"at a later time?",!
  1. K DIR S DIR(0)="Y"
  1. S DIR("?",1)="Enter 'Y' to task off the job and delete these batches at"
  1. S DIR("?")="a later date, or 'N' to delete these batches immediately."
  1. D ^DIR K DIR
  1. I $D(DIRUT) D KILL1 Q
  1. I +Y D
  1. . S ZTRTN="DEL^RABTCH2",ZTIO=""
  1. . S ZTDESC="Rad/Nuc Med Delete entries in the Report Batches (74.2) file up to "
  1. . S ZTDESC=ZTDESC_RA("DTX")
  1. . S ZTSAVE("^TMP($J,""RA BTCHDEL DT"",")=""
  1. . D ^%ZTLOAD
  1. . Q
  1. E D
  1. . W !?5,$C(7),"Beginning the interactive deletion process.",!
  1. . D DEL
  1. . W !?5,"The deletion process has successfully completed!"
  1. . Q
  1. KILL ; Kill and quit
  1. K ZTIO,ZTDESC,ZTRTN,ZTSAVE,ZTSK
  1. KILL1 K ^TMP($J,"RA BTCHDEL DT")
  1. K DDH,I,POP
  1. Q
  1. DEL ; $O through the ^TMP global to delete entries in 74.2!
  1. N DA,DIC,DIK S DIK="^RABTCH(74.2,",DA=0
  1. F S DA=$O(^TMP($J,"RA BTCHDEL DT",DA)) Q:DA'>0 D ^DIK
  1. Q
  1. DISPLAY ; Display selected Report Batches data
  1. N I,RA,RABTCH,RADTC,RADTP,RATXT,RAUSER S RA=0
  1. S RATXT="W !!?5,""The following Report Batches have been selected to be purged:"",!"
  1. W:$Y @IOF X RATXT
  1. F S RA=$O(^TMP($J,"RA BTCHDEL DT",RA)) Q:RA'>0 D Q:RAXIT
  1. . S RA(0)=$G(^RABTCH(74.2,RA,0)) Q:RA(0)']""
  1. . F I=1:1:4 S RA(I)=$P(RA(0),"^",I)
  1. . S RADTC=$$XTERNAL^RAUTL5(RA(2),$P($G(^DD(74.2,2,0)),"^",2))
  1. . S RAUSER=$$XTERNAL^RAUTL5(RA(3),$P($G(^DD(74.2,3,0)),"^",2))
  1. . S RADTP=$$XTERNAL^RAUTL5(RA(4),$P($G(^DD(74.2,4,0)),"^",2))
  1. . I $Y>(IOSL-4) S RAXIT=$$EOS^RAUTL5() Q:RAXIT W @IOF X RATXT
  1. . W !?3,"Batch: ",$P(RA(0),"^")
  1. . W ?39,"Date Created: ",$S(RADTC]"":RADTC,1:"Unknown")
  1. . W !?3,"User: ",$S(RAUSER]"":RAUSER,1:"Unknown")
  1. . W ?39,"Date Printed: ",$S(RADTP]"":RADTP,1:""),!
  1. . Q
  1. Q
  1. SETMP ; Set ^TMP($J,"RA BTCHDEL DT"). If only printed batches are selected,
  1. ; (RAUPRT=0) then just hit the 'E' xref. If both printed and unprinted
  1. ; batches are selected (RAUPRT=1) hit the Date/Time Batch Created 'F'
  1. ; xref.
  1. N RAXREF S RAXREF=$S(RAUPRT:"F",1:"E") S RA=0
  1. F S RA=$O(^RABTCH(74.2,RAXREF,RA)) Q:RA'>0!(RA'<RA("DTI")) D
  1. . S RA(1)=0
  1. . F S RA(1)=$O(^RABTCH(74.2,RAXREF,RA,RA(1))) Q:RA(1)'>0 D
  1. .. S RA("CNT")=+$G(RA("CNT"))+1
  1. .. S ^TMP($J,"RA BTCHDEL DT",RA(1))=""
  1. .. Q
  1. . Q
  1. Q
  1. YN(RADT) ; Yes/No prompt asking the user if unprinted batches are to be
  1. ; included as criteria for our batch deletion.
  1. ; Returns: 1 if yes, 0 if no, -1 if '^' or timeout
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y S DIR(0)="Y",DIR("B")="No"
  1. S DIR("A")="Want to include unprinted batches created before "_RADT
  1. S DIR("?",1)="Enter 'Yes' to delete printed and unprinted batches prior to "_RADT_"."
  1. S DIR("?")="Enter 'No' to delete only printed batches prior to "_RADT_"."
  1. D ^DIR S:$D(DIRUT) Y=-1
  1. Q Y