source: WorldVistAEHR/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORHDT03.m@ 1240

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

initial load of WorldVistAEHR

File size: 3.9 KB
Line 
1RORHDT03 ;HCIOFO/SG - MANIPULATIONS WITH EXTRACTION TASKS ; 1/23/06 8:40am
2 ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
3 ;
4 Q
5 ;
6 ;***** STARTS THE DATA EXTRACTION TASK
7 ;
8 ; HDEIEN Data Extract IEN
9 ; TASKIEN Task IEN
10 ; FAM File Access Mode:
11 ; "A" Append new messages to the file
12 ; "O" Overwrite the file
13 ; "N" Modify file name and create a new file
14 ; [ZTDTH] Start date/time
15 ;
16 ; Return Values:
17 ; <0 Error code
18 ; 0 Ok
19 ; 1 Start time has not been entered
20 ; 2 Already running or pending
21 ;
22START(HDEIEN,TASKIEN,FAM,ZTDTH) ;
23 N IENS,PARAMS,RC,RORFDA,RORMSG,STATUS,TASK,TMP
24 N ZTCPU,ZTDESC,ZTIO,ZTKIL,ZTPRI,ZTRTN,ZTSAVE,ZTSK,ZTSYNC,ZTUCI
25 ;--- Check status of the task
26 S STATUS=+$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN,3)
27 Q:(STATUS=1)!(STATUS=2)!(STATUS=102) 2
28 ;--- Start/schedule the task
29 S PARAMS("PARAMS","HDEIEN")=HDEIEN
30 S PARAMS("PARAMS","TASKIEN")=TASKIEN
31 S PARAMS("PARAMS","FAM")=FAM
32 S ZTDESC="CCR HDE Task #"_TASKIEN
33 S TASK=$$CREATE^RORTSK(1,"TASK^RORHDT03",,,,,.PARAMS)
34 Q:TASK<0 TASK
35 W !,"Task #"_TASK_" has been scheduled."
36 ;--- Update task number
37 S IENS=(+TASKIEN)_","_(+HDEIEN)_","
38 S RORFDA(799.64,IENS,.02)=TASK
39 D FILE^DIE(,"RORFDA","RORMSG")
40 Q:$G(DIERR) $$DBS^RORERR("RORMSG",-9,,,799.64,IENS)
41 ;--- Update the last known task status
42 S TMP=$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN)
43 ;--- Success
44 Q 0
45 ;
46 ;***** STOPS THE DATA EXTRACTION TASK
47 ;
48 ; HDEIEN Data Extract IEN
49 ; TASKIEN Task IEN
50 ;
51 ; Return Values:
52 ; <0 Error code
53 ; 0 Ok
54 ;
55STOP(HDEIEN,TASKIEN) ;
56 N RC,STATUS,TASK,TMP
57 ;--- Get status of the task
58 S STATUS=+$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN)
59 Q:STATUS<0 STATUS
60 ;--- Stop the task if it is running, pending, or suspended
61 I (STATUS=1)!(STATUS=2)!(STATUS=102) D Q:$G(RC)<0 RC
62 . S TASK=$$TASKNUM^RORHDTUT(HDEIEN,TASKIEN)
63 . I TASK<0 S RC=+TASK Q
64 . S RC=$$DEQUEUE^RORTSK(TASK)
65 . W:'RC !,"The task #"_TASK_" has been stopped/unscheduled."
66 . ;--- Update the last known task status
67 . S STATUS=+$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN)
68 ;--- Task is stopping
69 D:STATUS=103
70 . W !,"The task #"_TASK_" has not responded to the stop request yet."
71 Q 0
72 ;
73 ;***** HISTORICAL DATA EXTRACTION TASK
74 ;
75 ; RORTSK Task number and task parameters
76 ;
77TASK ;
78 N RORERRDL ; Default error location
79 N RORERROR ; Error processing data
80 N RORLOG ; Log susbsystem data
81 N RORPARM ; Application parameters
82 ;
83 N BUF,COUNTERS,FAM,HDEIEN,I,IENS,INFO,RC,REGLST,REGNAME,RORBUF,RORMSG,TASKIEN,TMP
84 S RORTSK=ZTSK
85 S HDEIEN=+$$PARAM^RORTSK01("HDEIEN")
86 S TASKIEN=+$$PARAM^RORTSK01("TASKIEN")
87 ;--- Initialize constants and variables
88 D INIT^RORUTL01("RORHDT"),CLEAR^RORERR("TASK^RORHDT03")
89 ;S RORPARM("DEBUG")=1 ; Remove the first ';' to start in debug mode
90 S RORPARM("ERR")=1 ; Enable enhanced error processing
91 S RORPARM("LOG")=1 ; Enable error recording
92 ;--- Wait until the task record is created
93 S TMP=$$TRWAIT^RORTSK01(RORTSK)
94 ;--- Open the task log
95 S TMP=$$SETUP^RORLOG()
96 S TMP=$$OPEN^RORLOG(,4,"HDE TASK #"_RORTSK_" STARTED")
97 D
98 . ;--- Initialize the task
99 . S RC=$$INIT^RORTSK01(RORTSK,$$LOGIEN^RORLOG) Q:RC<0
100 . ;--- Load parameters of the data extraction
101 . S IENS=(+HDEIEN)_","
102 . D GETS^DIQ(799.6,IENS,"3*","I","RORBUF","RORMSG")
103 . D:$G(DIERR) DBS^RORERR("RORMSG",-9,,,799.6,IENS)
104 . ;--- Compile the list of registries
105 . S I=""
106 . F S I=$O(RORBUF(799.63,I)) Q:I="" D
107 . . S REGNAME=$G(RORBUF(799.63,I,.01,"I")) Q:REGNAME=""
108 . . S TMP=$$REGIEN^RORUTL02(REGNAME)
109 . . S:TMP>0 REGLST(REGNAME)=TMP
110 . ;--- Associate the log with the registries
111 . S RC=$$SETRGLST^RORLOG(.REGLST)
112 . ;---
113 . S TMP=$$PARAM^RORTSK01("FAM")
114 . S RC=$$EXTRACT^RORHDT04(.REGLST,HDEIEN,TASKIEN,TMP)
115 . S:RC'<0 COUNTERS=RC
116 ;
117 ;--- Post-processing
118 S TMP=$$EXIT^RORTSK01(RC)
119 ;--- Close the log
120 S TMP="HDE TASK #"_RORTSK_$S(RC<0:" ABORTED",1:" COMPLETED")
121 D CLOSE^RORLOG(TMP,$G(COUNTERS))
122 D:'$G(RORPARM("DEBUG")) INIT^RORUTL01("RORHDT")
123 Q
Note: See TracBrowser for help on using the repository browser.