source: FOIAVistA/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORHDTAC.m@ 1169

Last change on this file since 1169 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 3.1 KB
Line 
1RORHDTAC ;HCIOFO/SG - DATA EXTRACTION ACTION CONFIRMATIONS ; 3/14/06 11:07am
2 ;;1.5;CLINICAL CASE REGISTRIES;**1**;Feb 17, 2006;Build 24
3 ;
4 Q
5 ;
6 ;***** CONFIRMATION TO CREATE A NEW TASK TABLE
7 ;
8 ; HDEIEN Data Extract IEN
9 ;
10 ; Return Values:
11 ; <0 Error code
12 ; 0 Ok
13 ; 1 Cancel
14 ;
15CREATE(HDEIEN) ;
16 N DA,DIR,DIROUT,DIRUT,DTOUT,DUOUT,IENS,RC,RORBUF,RORMSG,X,Y
17 ;--- Display status of the data extract
18 S RC=$$STATUS^RORHDT01(HDEIEN) Q:RC<0 RC
19 ;--- Check if registry task table is not empty
20 S IENS=","_(+HDEIEN)_","
21 D LIST^DIC(799.64,IENS,"@","Q",1,,,"B",,,"RORBUF","RORMSG")
22 Q:$G(DIERR) $$DBS^RORERR("RORMSG",-9,,,799.64,IENS)
23 ;--- Ask for a confirmation to overwrite
24 I $G(RORBUF("DILIST",0))>0 D Q:RC 1
25 . K DIR S DIR(0)="Y"
26 . S DIR("A")="Overwrite the existing task table"
27 . S DIR("B")="NO"
28 . W ! D ^DIR S RC=$D(DIRUT)!'$G(Y)
29 Q 0
30 ;
31 ;***** CONFIRMATIONS TO START THE TASK
32 ;
33 ; HDEIEN Data Extract IEN
34 ; TASKIEN Task IEN
35 ; .FAM File Access Mode is returned via this parameter
36 ; .SDT Start Date/Time is returned via this parameter
37 ;
38 ; Return Values:
39 ; <0 Error code
40 ; 0 Ok
41 ; 1 Cancel
42 ;
43START(HDEIEN,TASKIEN,FAM,SDT) ;
44 N DA,DIR,DIROUT,DIRUT,DTOUT,DUOUT,FILE,OUTDIR,RC,RORDST,RORSRC,STATUS,X,Y
45 S FAM="",SDT=""
46 ;--- Check status of the task
47 S STATUS=+$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN)
48 I STATUS=1 D Q:RC $S(RC<0:RC,1:1)
49 . K DIR S DIR(0)="Y"
50 . S DIR("A")="The task is pending. Do you want to reschedule it"
51 . S DIR("B")="NO"
52 . D ^DIR S RC=$D(DIRUT)!'$G(Y)
53 . S:'RC RC=$$STOP^RORHDT03(HDEIEN,TASKIEN)
54 I STATUS=2 D Q 1
55 . W !,"The task is running already"
56 I STATUS=3 D Q:RC 1
57 . K DIR S DIR(0)="Y"
58 . S DIR("A")="The task is completed. Do you want to rerun it"
59 . S DIR("B")="NO"
60 . D ^DIR S RC=$D(DIRUT)!'$G(Y)
61 ;--- Ask the user for the start date/time
62 K DIR
63 S X=$$FMADD^XLFDT($$DT^XLFDT,30)
64 S DIR(0)="D^NOW:"_X_":AEFNRSX",DIR("B")="NOW"
65 S DIR("A")="Run the task"
66 D ^DIR Q:$D(DIRUT)!'$G(Y) 1
67 S SDT=+Y
68 ;--- Check if the output file exists already
69 S RC=$$TASKFILE^RORHDTUT(HDEIEN,TASKIEN,.OUTDIR,.FILE) Q:RC<0 RC
70 S RORSRC(FILE)=""
71 S RC=$$LIST^%ZISH(OUTDIR,"RORSRC","RORDST")
72 I RC S:$D(RORDST)>1 FAM="N"
73 ;--- Generate the new file name
74 I FAM["N" D Q:RC<0 RC
75 . S RC=$$NEWFILE^RORHDTUT(HDEIEN,TASKIEN,.FILE)
76 . W:'RC !,"Data will be written to the '"_FILE_"' file."
77 ;---
78 Q 0
79 ;
80 ;***** CONFIRMATION TO STOP THE TASK
81 ;
82 ; HDEIEN Data Extract IEN
83 ; TASKIEN Task IEN
84 ;
85 ; Return Values:
86 ; <0 Error code
87 ; 0 Stop the task
88 ; 1 Cancel
89 ;
90STOP(HDEIEN,TASKIEN) ;
91 N DA,DIR,DIROUT,DIRUT,DTOUT,DUOUT,IENS,STATUS,X,Y,ZTSK
92 ;--- Check status of the task
93 S STATUS=+$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN)
94 ;--- Quit if the task is not running, pending, nor suspended
95 Q:(STATUS'=1)&(STATUS'=2)&(STATUS'=102) 1
96 ;--- Get the task number
97 S IENS=(+TASKIEN)_","_(+HDEIEN)_","
98 S ZTSK=$$GET1^DIQ(799.64,IENS,.02,,,"RORMSG")
99 Q:$G(DIERR) $$DBS^RORERR("RORMSG",-9,,,799.64,IENS)
100 ;--- Ask for the final confirmation
101 K DIR S DIR(0)="Y"
102 S DIR("A")=$S(STATUS=1:"Dequeue",1:"Stop")_" the task #"_ZTSK
103 S DIR("B")="NO"
104 D ^DIR
105 Q $D(DIRUT)!'$G(Y)
Note: See TracBrowser for help on using the repository browser.