RORHDT03 ;HCIOFO/SG - MANIPULATIONS WITH EXTRACTION TASKS ; 1/23/06 8:40am
;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
;
Q
;
;***** STARTS THE DATA EXTRACTION TASK
;
; HDEIEN Data Extract IEN
; TASKIEN Task IEN
; FAM File Access Mode:
; "A" Append new messages to the file
; "O" Overwrite the file
; "N" Modify file name and create a new file
; [ZTDTH] Start date/time
;
; Return Values:
; <0 Error code
; 0 Ok
; 1 Start time has not been entered
; 2 Already running or pending
;
START(HDEIEN,TASKIEN,FAM,ZTDTH) ;
N IENS,PARAMS,RC,RORFDA,RORMSG,STATUS,TASK,TMP
N ZTCPU,ZTDESC,ZTIO,ZTKIL,ZTPRI,ZTRTN,ZTSAVE,ZTSK,ZTSYNC,ZTUCI
;--- Check status of the task
S STATUS=+$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN,3)
Q:(STATUS=1)!(STATUS=2)!(STATUS=102) 2
;--- Start/schedule the task
S PARAMS("PARAMS","HDEIEN")=HDEIEN
S PARAMS("PARAMS","TASKIEN")=TASKIEN
S PARAMS("PARAMS","FAM")=FAM
S ZTDESC="CCR HDE Task #"_TASKIEN
S TASK=$$CREATE^RORTSK(1,"TASK^RORHDT03",,,,,.PARAMS)
Q:TASK<0 TASK
W !,"Task #"_TASK_" has been scheduled."
;--- Update task number
S IENS=(+TASKIEN)_","_(+HDEIEN)_","
S RORFDA(799.64,IENS,.02)=TASK
D FILE^DIE(,"RORFDA","RORMSG")
Q:$G(DIERR) $$DBS^RORERR("RORMSG",-9,,,799.64,IENS)
;--- Update the last known task status
S TMP=$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN)
;--- Success
Q 0
;
;***** STOPS THE DATA EXTRACTION TASK
;
; HDEIEN Data Extract IEN
; TASKIEN Task IEN
;
; Return Values:
; <0 Error code
; 0 Ok
;
STOP(HDEIEN,TASKIEN) ;
N RC,STATUS,TASK,TMP
;--- Get status of the task
S STATUS=+$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN)
Q:STATUS<0 STATUS
;--- Stop the task if it is running, pending, or suspended
I (STATUS=1)!(STATUS=2)!(STATUS=102) D Q:$G(RC)<0 RC
. S TASK=$$TASKNUM^RORHDTUT(HDEIEN,TASKIEN)
. I TASK<0 S RC=+TASK Q
. S RC=$$DEQUEUE^RORTSK(TASK)
. W:'RC !,"The task #"_TASK_" has been stopped/unscheduled."
. ;--- Update the last known task status
. S STATUS=+$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN)
;--- Task is stopping
D:STATUS=103
. W !,"The task #"_TASK_" has not responded to the stop request yet."
Q 0
;
;***** HISTORICAL DATA EXTRACTION TASK
;
; RORTSK Task number and task parameters
;
TASK ;
N RORERRDL ; Default error location
N RORERROR ; Error processing data
N RORLOG ; Log susbsystem data
N RORPARM ; Application parameters
;
N BUF,COUNTERS,FAM,HDEIEN,I,IENS,INFO,RC,REGLST,REGNAME,RORBUF,RORMSG,TASKIEN,TMP
S RORTSK=ZTSK
S HDEIEN=+$$PARAM^RORTSK01("HDEIEN")
S TASKIEN=+$$PARAM^RORTSK01("TASKIEN")
;--- Initialize constants and variables
D INIT^RORUTL01("RORHDT"),CLEAR^RORERR("TASK^RORHDT03")
;S RORPARM("DEBUG")=1 ; Remove the first ';' to start in debug mode
S RORPARM("ERR")=1 ; Enable enhanced error processing
S RORPARM("LOG")=1 ; Enable error recording
;--- Wait until the task record is created
S TMP=$$TRWAIT^RORTSK01(RORTSK)
;--- Open the task log
S TMP=$$SETUP^RORLOG()
S TMP=$$OPEN^RORLOG(,4,"HDE TASK #"_RORTSK_" STARTED")
D
. ;--- Initialize the task
. S RC=$$INIT^RORTSK01(RORTSK,$$LOGIEN^RORLOG) Q:RC<0
. ;--- Load parameters of the data extraction
. S IENS=(+HDEIEN)_","
. D GETS^DIQ(799.6,IENS,"3*","I","RORBUF","RORMSG")
. D:$G(DIERR) DBS^RORERR("RORMSG",-9,,,799.6,IENS)
. ;--- Compile the list of registries
. S I=""
. F S I=$O(RORBUF(799.63,I)) Q:I="" D
. . S REGNAME=$G(RORBUF(799.63,I,.01,"I")) Q:REGNAME=""
. . S TMP=$$REGIEN^RORUTL02(REGNAME)
. . S:TMP>0 REGLST(REGNAME)=TMP
. ;--- Associate the log with the registries
. S RC=$$SETRGLST^RORLOG(.REGLST)
. ;---
. S TMP=$$PARAM^RORTSK01("FAM")
. S RC=$$EXTRACT^RORHDT04(.REGLST,HDEIEN,TASKIEN,TMP)
. S:RC'<0 COUNTERS=RC
;
;--- Post-processing
S TMP=$$EXIT^RORTSK01(RC)
;--- Close the log
S TMP="HDE TASK #"_RORTSK_$S(RC<0:" ABORTED",1:" COMPLETED")
D CLOSE^RORLOG(TMP,$G(COUNTERS))
D:'$G(RORPARM("DEBUG")) INIT^RORUTL01("RORHDT")
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORHDT03 4162 printed Nov 22, 2024@16:51:48 Page 2
RORHDT03 ;HCIOFO/SG - MANIPULATIONS WITH EXTRACTION TASKS ; 1/23/06 8:40am
+1 ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
+2 ;
+3 QUIT
+4 ;
+5 ;***** STARTS THE DATA EXTRACTION TASK
+6 ;
+7 ; HDEIEN Data Extract IEN
+8 ; TASKIEN Task IEN
+9 ; FAM File Access Mode:
+10 ; "A" Append new messages to the file
+11 ; "O" Overwrite the file
+12 ; "N" Modify file name and create a new file
+13 ; [ZTDTH] Start date/time
+14 ;
+15 ; Return Values:
+16 ; <0 Error code
+17 ; 0 Ok
+18 ; 1 Start time has not been entered
+19 ; 2 Already running or pending
+20 ;
START(HDEIEN,TASKIEN,FAM,ZTDTH) ;
+1 NEW IENS,PARAMS,RC,RORFDA,RORMSG,STATUS,TASK,TMP
+2 NEW ZTCPU,ZTDESC,ZTIO,ZTKIL,ZTPRI,ZTRTN,ZTSAVE,ZTSK,ZTSYNC,ZTUCI
+3 ;--- Check status of the task
+4 SET STATUS=+$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN,3)
+5 if (STATUS=1)!(STATUS=2)!(STATUS=102)
QUIT 2
+6 ;--- Start/schedule the task
+7 SET PARAMS("PARAMS","HDEIEN")=HDEIEN
+8 SET PARAMS("PARAMS","TASKIEN")=TASKIEN
+9 SET PARAMS("PARAMS","FAM")=FAM
+10 SET ZTDESC="CCR HDE Task #"_TASKIEN
+11 SET TASK=$$CREATE^RORTSK(1,"TASK^RORHDT03",,,,,.PARAMS)
+12 if TASK<0
QUIT TASK
+13 WRITE !,"Task #"_TASK_" has been scheduled."
+14 ;--- Update task number
+15 SET IENS=(+TASKIEN)_","_(+HDEIEN)_","
+16 SET RORFDA(799.64,IENS,.02)=TASK
+17 DO FILE^DIE(,"RORFDA","RORMSG")
+18 if $GET(DIERR)
QUIT $$DBS^RORERR("RORMSG",-9,,,799.64,IENS)
+19 ;--- Update the last known task status
+20 SET TMP=$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN)
+21 ;--- Success
+22 QUIT 0
+23 ;
+24 ;***** STOPS THE DATA EXTRACTION TASK
+25 ;
+26 ; HDEIEN Data Extract IEN
+27 ; TASKIEN Task IEN
+28 ;
+29 ; Return Values:
+30 ; <0 Error code
+31 ; 0 Ok
+32 ;
STOP(HDEIEN,TASKIEN) ;
+1 NEW RC,STATUS,TASK,TMP
+2 ;--- Get status of the task
+3 SET STATUS=+$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN)
+4 if STATUS<0
QUIT STATUS
+5 ;--- Stop the task if it is running, pending, or suspended
+6 IF (STATUS=1)!(STATUS=2)!(STATUS=102)
Begin DoDot:1
+7 SET TASK=$$TASKNUM^RORHDTUT(HDEIEN,TASKIEN)
+8 IF TASK<0
SET RC=+TASK
QUIT
+9 SET RC=$$DEQUEUE^RORTSK(TASK)
+10 if 'RC
WRITE !,"The task #"_TASK_" has been stopped/unscheduled."
+11 ;--- Update the last known task status
+12 SET STATUS=+$$TASKSTAT^RORHDTUT(HDEIEN,TASKIEN)
End DoDot:1
if $GET(RC)<0
QUIT RC
+13 ;--- Task is stopping
+14 if STATUS=103
Begin DoDot:1
+15 WRITE !,"The task #"_TASK_" has not responded to the stop request yet."
End DoDot:1
+16 QUIT 0
+17 ;
+18 ;***** HISTORICAL DATA EXTRACTION TASK
+19 ;
+20 ; RORTSK Task number and task parameters
+21 ;
TASK ;
+1 ; Default error location
NEW RORERRDL
+2 ; Error processing data
NEW RORERROR
+3 ; Log susbsystem data
NEW RORLOG
+4 ; Application parameters
NEW RORPARM
+5 ;
+6 NEW BUF,COUNTERS,FAM,HDEIEN,I,IENS,INFO,RC,REGLST,REGNAME,RORBUF,RORMSG,TASKIEN,TMP
+7 SET RORTSK=ZTSK
+8 SET HDEIEN=+$$PARAM^RORTSK01("HDEIEN")
+9 SET TASKIEN=+$$PARAM^RORTSK01("TASKIEN")
+10 ;--- Initialize constants and variables
+11 DO INIT^RORUTL01("RORHDT")
DO CLEAR^RORERR("TASK^RORHDT03")
+12 ;S RORPARM("DEBUG")=1 ; Remove the first ';' to start in debug mode
+13 ; Enable enhanced error processing
SET RORPARM("ERR")=1
+14 ; Enable error recording
SET RORPARM("LOG")=1
+15 ;--- Wait until the task record is created
+16 SET TMP=$$TRWAIT^RORTSK01(RORTSK)
+17 ;--- Open the task log
+18 SET TMP=$$SETUP^RORLOG()
+19 SET TMP=$$OPEN^RORLOG(,4,"HDE TASK #"_RORTSK_" STARTED")
+20 Begin DoDot:1
+21 ;--- Initialize the task
+22 SET RC=$$INIT^RORTSK01(RORTSK,$$LOGIEN^RORLOG)
if RC<0
QUIT
+23 ;--- Load parameters of the data extraction
+24 SET IENS=(+HDEIEN)_","
+25 DO GETS^DIQ(799.6,IENS,"3*","I","RORBUF","RORMSG")
+26 if $GET(DIERR)
DO DBS^RORERR("RORMSG",-9,,,799.6,IENS)
+27 ;--- Compile the list of registries
+28 SET I=""
+29 FOR
SET I=$ORDER(RORBUF(799.63,I))
if I=""
QUIT
Begin DoDot:2
+30 SET REGNAME=$GET(RORBUF(799.63,I,.01,"I"))
if REGNAME=""
QUIT
+31 SET TMP=$$REGIEN^RORUTL02(REGNAME)
+32 if TMP>0
SET REGLST(REGNAME)=TMP
End DoDot:2
+33 ;--- Associate the log with the registries
+34 SET RC=$$SETRGLST^RORLOG(.REGLST)
+35 ;---
+36 SET TMP=$$PARAM^RORTSK01("FAM")
+37 SET RC=$$EXTRACT^RORHDT04(.REGLST,HDEIEN,TASKIEN,TMP)
+38 if RC'<0
SET COUNTERS=RC
End DoDot:1
+39 ;
+40 ;--- Post-processing
+41 SET TMP=$$EXIT^RORTSK01(RC)
+42 ;--- Close the log
+43 SET TMP="HDE TASK #"_RORTSK_$SELECT(RC<0:" ABORTED",1:" COMPLETED")
+44 DO CLOSE^RORLOG(TMP,$GET(COUNTERS))
+45 if '$GET(RORPARM("DEBUG"))
DO INIT^RORUTL01("RORHDT")
+46 QUIT