RORHDTAC ;HCIOFO/SG - DATA EXTRACTION ACTION CONFIRMATIONS ; 3/14/06 11:07am
;;1.5;CLINICAL CASE REGISTRIES;**1**;Feb 17, 2006;Build 24
;
Q
;
;***** CONFIRMATION TO CREATE A NEW TASK TABLE
;
; HDEIEN Data Extract IEN
;
; Return Values:
; <0 Error code
; 0 Ok
; 1 Cancel
;
CREATE(HDEIEN) ;
N DA,DIR,DIROUT,DIRUT,DTOUT,DUOUT,IENS,RC,RORBUF,RORMSG,X,Y
;--- Display status of the data extract
S RC=$$STATUS^RORHDT01(HDEIEN) Q:RC<0 RC
;--- Check if registry task table is not empty
S IENS=","_(+HDEIEN)_","
D LIST^DIC(799.64,IENS,"@","Q",1,,,"B",,,"RORBUF","RORMSG")
Q:$G(DIERR) $$DBS^RORERR("RORMSG",-9,,,799.64,IENS)
;--- Ask for a confirmation to overwrite
I $G(RORBUF("DILIST",0))>0 D Q:RC 1
. K DIR S DIR(0)="Y"
. S DIR("A")="Overwrite the existing task table"
. S DIR("B")="NO"
. W ! D ^DIR S RC=$D(DIRUT)!'$G(Y)
Q 0
;
;***** CONFIRMATIONS TO START THE TASK
;
; HDEIEN Data Extract IEN
; TASKIEN Task IEN
; .FAM File Access Mode is returned via this parameter
; .SDT Start Date/Time is returned via this parameter
;
; Return Values:
; <0 Error code
; 0 Ok
; 1 Cancel
;
START(HDEIEN,TASKIEN,FAM,SDT) ;
N DA,DIR,DIROUT,DIRUT,DTOUT,DUOUT,FILE,OUTDIR,RC,RORDST,RORSRC,STATUS,X,Y
S FAM="",SDT=""
;--- Check status of the task
S STATUS=+$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN)
I STATUS=1 D Q:RC $S(RC<0:RC,1:1)
. K DIR S DIR(0)="Y"
. S DIR("A")="The task is pending. Do you want to reschedule it"
. S DIR("B")="NO"
. D ^DIR S RC=$D(DIRUT)!'$G(Y)
. S:'RC RC=$$STOP^RORHDT03(HDEIEN,TASKIEN)
I STATUS=2 D Q 1
. W !,"The task is running already"
I STATUS=3 D Q:RC 1
. K DIR S DIR(0)="Y"
. S DIR("A")="The task is completed. Do you want to rerun it"
. S DIR("B")="NO"
. D ^DIR S RC=$D(DIRUT)!'$G(Y)
;--- Ask the user for the start date/time
K DIR
S X=$$FMADD^XLFDT($$DT^XLFDT,30)
S DIR(0)="D^NOW:"_X_":AEFNRSX",DIR("B")="NOW"
S DIR("A")="Run the task"
D ^DIR Q:$D(DIRUT)!'$G(Y) 1
S SDT=+Y
;--- Check if the output file exists already
S RC=$$TASKFILE^RORHDTUT(HDEIEN,TASKIEN,.OUTDIR,.FILE) Q:RC<0 RC
S RORSRC(FILE)=""
S RC=$$LIST^%ZISH(OUTDIR,"RORSRC","RORDST")
I RC S:$D(RORDST)>1 FAM="N"
;--- Generate the new file name
I FAM["N" D Q:RC<0 RC
. S RC=$$NEWFILE^RORHDTUT(HDEIEN,TASKIEN,.FILE)
. W:'RC !,"Data will be written to the '"_FILE_"' file."
;---
Q 0
;
;***** CONFIRMATION TO STOP THE TASK
;
; HDEIEN Data Extract IEN
; TASKIEN Task IEN
;
; Return Values:
; <0 Error code
; 0 Stop the task
; 1 Cancel
;
STOP(HDEIEN,TASKIEN) ;
N DA,DIR,DIROUT,DIRUT,DTOUT,DUOUT,IENS,STATUS,X,Y,ZTSK
;--- Check status of the task
S STATUS=+$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN)
;--- Quit if the task is not running, pending, nor suspended
Q:(STATUS'=1)&(STATUS'=2)&(STATUS'=102) 1
;--- Get the task number
S IENS=(+TASKIEN)_","_(+HDEIEN)_","
S ZTSK=$$GET1^DIQ(799.64,IENS,.02,,,"RORMSG")
Q:$G(DIERR) $$DBS^RORERR("RORMSG",-9,,,799.64,IENS)
;--- Ask for the final confirmation
K DIR S DIR(0)="Y"
S DIR("A")=$S(STATUS=1:"Dequeue",1:"Stop")_" the task #"_ZTSK
S DIR("B")="NO"
D ^DIR
Q $D(DIRUT)!'$G(Y)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORHDTAC 3318 printed Nov 22, 2024@16:51:52 Page 2
RORHDTAC ;HCIOFO/SG - DATA EXTRACTION ACTION CONFIRMATIONS ; 3/14/06 11:07am
+1 ;;1.5;CLINICAL CASE REGISTRIES;**1**;Feb 17, 2006;Build 24
+2 ;
+3 QUIT
+4 ;
+5 ;***** CONFIRMATION TO CREATE A NEW TASK TABLE
+6 ;
+7 ; HDEIEN Data Extract IEN
+8 ;
+9 ; Return Values:
+10 ; <0 Error code
+11 ; 0 Ok
+12 ; 1 Cancel
+13 ;
CREATE(HDEIEN) ;
+1 NEW DA,DIR,DIROUT,DIRUT,DTOUT,DUOUT,IENS,RC,RORBUF,RORMSG,X,Y
+2 ;--- Display status of the data extract
+3 SET RC=$$STATUS^RORHDT01(HDEIEN)
if RC<0
QUIT RC
+4 ;--- Check if registry task table is not empty
+5 SET IENS=","_(+HDEIEN)_","
+6 DO LIST^DIC(799.64,IENS,"@","Q",1,,,"B",,,"RORBUF","RORMSG")
+7 if $GET(DIERR)
QUIT $$DBS^RORERR("RORMSG",-9,,,799.64,IENS)
+8 ;--- Ask for a confirmation to overwrite
+9 IF $GET(RORBUF("DILIST",0))>0
Begin DoDot:1
+10 KILL DIR
SET DIR(0)="Y"
+11 SET DIR("A")="Overwrite the existing task table"
+12 SET DIR("B")="NO"
+13 WRITE !
DO ^DIR
SET RC=$DATA(DIRUT)!'$GET(Y)
End DoDot:1
if RC
QUIT 1
+14 QUIT 0
+15 ;
+16 ;***** CONFIRMATIONS TO START THE TASK
+17 ;
+18 ; HDEIEN Data Extract IEN
+19 ; TASKIEN Task IEN
+20 ; .FAM File Access Mode is returned via this parameter
+21 ; .SDT Start Date/Time is returned via this parameter
+22 ;
+23 ; Return Values:
+24 ; <0 Error code
+25 ; 0 Ok
+26 ; 1 Cancel
+27 ;
START(HDEIEN,TASKIEN,FAM,SDT) ;
+1 NEW DA,DIR,DIROUT,DIRUT,DTOUT,DUOUT,FILE,OUTDIR,RC,RORDST,RORSRC,STATUS,X,Y
+2 SET FAM=""
SET SDT=""
+3 ;--- Check status of the task
+4 SET STATUS=+$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN)
+5 IF STATUS=1
Begin DoDot:1
+6 KILL DIR
SET DIR(0)="Y"
+7 SET DIR("A")="The task is pending. Do you want to reschedule it"
+8 SET DIR("B")="NO"
+9 DO ^DIR
SET RC=$DATA(DIRUT)!'$GET(Y)
+10 if 'RC
SET RC=$$STOP^RORHDT03(HDEIEN,TASKIEN)
End DoDot:1
if RC
QUIT $SELECT(RC<0:RC,1:1)
+11 IF STATUS=2
Begin DoDot:1
+12 WRITE !,"The task is running already"
End DoDot:1
QUIT 1
+13 IF STATUS=3
Begin DoDot:1
+14 KILL DIR
SET DIR(0)="Y"
+15 SET DIR("A")="The task is completed. Do you want to rerun it"
+16 SET DIR("B")="NO"
+17 DO ^DIR
SET RC=$DATA(DIRUT)!'$GET(Y)
End DoDot:1
if RC
QUIT 1
+18 ;--- Ask the user for the start date/time
+19 KILL DIR
+20 SET X=$$FMADD^XLFDT($$DT^XLFDT,30)
+21 SET DIR(0)="D^NOW:"_X_":AEFNRSX"
SET DIR("B")="NOW"
+22 SET DIR("A")="Run the task"
+23 DO ^DIR
if $DATA(DIRUT)!'$GET(Y)
QUIT 1
+24 SET SDT=+Y
+25 ;--- Check if the output file exists already
+26 SET RC=$$TASKFILE^RORHDTUT(HDEIEN,TASKIEN,.OUTDIR,.FILE)
if RC<0
QUIT RC
+27 SET RORSRC(FILE)=""
+28 SET RC=$$LIST^%ZISH(OUTDIR,"RORSRC","RORDST")
+29 IF RC
if $DATA(RORDST)>1
SET FAM="N"
+30 ;--- Generate the new file name
+31 IF FAM["N"
Begin DoDot:1
+32 SET RC=$$NEWFILE^RORHDTUT(HDEIEN,TASKIEN,.FILE)
+33 if 'RC
WRITE !,"Data will be written to the '"_FILE_"' file."
End DoDot:1
if RC<0
QUIT RC
+34 ;---
+35 QUIT 0
+36 ;
+37 ;***** CONFIRMATION TO STOP THE TASK
+38 ;
+39 ; HDEIEN Data Extract IEN
+40 ; TASKIEN Task IEN
+41 ;
+42 ; Return Values:
+43 ; <0 Error code
+44 ; 0 Stop the task
+45 ; 1 Cancel
+46 ;
STOP(HDEIEN,TASKIEN) ;
+1 NEW DA,DIR,DIROUT,DIRUT,DTOUT,DUOUT,IENS,STATUS,X,Y,ZTSK
+2 ;--- Check status of the task
+3 SET STATUS=+$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN)
+4 ;--- Quit if the task is not running, pending, nor suspended
+5 if (STATUS'=1)&(STATUS'=2)&(STATUS'=102)
QUIT 1
+6 ;--- Get the task number
+7 SET IENS=(+TASKIEN)_","_(+HDEIEN)_","
+8 SET ZTSK=$$GET1^DIQ(799.64,IENS,.02,,,"RORMSG")
+9 if $GET(DIERR)
QUIT $$DBS^RORERR("RORMSG",-9,,,799.64,IENS)
+10 ;--- Ask for the final confirmation
+11 KILL DIR
SET DIR(0)="Y"
+12 SET DIR("A")=$SELECT(STATUS=1:"Dequeue",1:"Stop")_" the task #"_ZTSK
+13 SET DIR("B")="NO"
+14 DO ^DIR
+15 QUIT $DATA(DIRUT)!'$GET(Y)