ROR ;HCIOFO/SG - CLINICAL CASE REGISTRIES ;1/26/07 4:54pm
;;1.5;CLINICAL CASE REGISTRIES;**1,3,22**;Feb 17, 2006;Build 17
;
;***************************************************************************
;***************************************************************************
; --- ROUTINE MODIFICATION LOG ---
;
;PKG/PATCH DATE DEVELOPER MODIFICATION
;----------- ---------- ----------- ----------------------------------------
;ROR*1.5*22 FEB 2014 T KOPP Added check for ROR VA IRM security key
; for nightly task job ROR TASK
;
;***************************************************************************
;
; LOCAL VARIABLE ------ DESCRIPTION
;
; RORCACHE In-memory cache
; RORERRDL Default error location
; RORERROR Error processing data
; RORPARM Task-wide constants and variables
;
; See the source code of the ^ROR02 routine for more details.
;
; ROREXT Regular data extraction (See ^ROREXT)
; RORHDT Historical data extraction (See ^RORHDT)
; RORLOG Log subsystem data (See ^RORLOG)
; RORUPD Registry update parameters (See ^RORUPD)
;
; TEMPORARY NODE ------ DESCRIPTION
;
; ^TMP("RORHDT") Control data of historical data extraction
; ^TMP("RORTMP") Temporary storage
; ^TMP("RORUPD") Registry update temporary data
;
; ^TMP(rtn_name) Temporary storage used by the rtn_name
; routine (mostly, the RPC's)
;
; ^TMP($J,"RORTMP-"_) Generic temporary storage used by ^RORTMP
;
; ^XTMP("RORHDT") Control data of historical data extraction
; ^XTMP("RORUPDJ") Registry update temporary data (multitask)
; ^XTMP("RORUPDR") Registry update temporary data (installation)
;
; See detailed description of the temporary global nodes in
; the source code of the ^ROR01 routine.
;
; NAMESPACE ----------- DESCRIPTION
;
; RORAPI* Supported APIs
; RORDD* Routines used by the Data Dictionary
; RORERR* Error processing
; ROREVT* Event protocols
; ROREX* Regular data extraction & transmission
; RORHDT* Historical data extraction
; RORHIV* HIV registry-specific routines
; RORHL* HL7 utilities
; RORKIDS* Low-level installation utilities (KIDS)
; RORLOCK* Locks and transactions
; RORLOG* Error recording
;
; RORPnnn* Patch installation routines (KIDS)
; nnn - patch number
; RORPUT* High-level installation utilities
;
; RORREP* Roll-and-scroll reports
; RORRP* Remote procedures
; RORSET* Registry setup routines
; RORTXT* Text resource routines
; RORUP* Registry update
; RORUTL* Utilities
; RORVM* Entry points for VistA menu options
; RORXnnn* XML reports (nnn - report code)
; RORXU* Utilities for XML reports
;
; DIALOG -------------- DESCRIPTION
;
; 7980000.* Various messages and templates
; 7981???.* Report templates (XSL)
;
; MENU OPTION --------- DESCRIPTION
;
; [ROR TASK] Registry update and data extraction option
; (must be scheduled; do not run it directly)
; [ROR SETUP] Registry Setup
; [RORHDT MAIN] Historical data extraction menu
; [RORMNT MAIN] Maintenance menu
;
; SPECIAL ENTRY POINT - DESCRIPTION
;
; ^RORUTL06 Menu for developer's utilities
; DISTPREP^RORUTL06 Prepares registry for KIDS distribution
; PRTMDE^RORUTL06 Prints the data element metadata
; VERIFY^RORUTL06 Checks the registry definition
;
; EXTRACT^RORUTL07 Data extraction & transmission in debug mode
; UPDATE^RORUTL07 Registry update in debug mode
;
; INITIALS ------------ DEVELOPER
;
; BH Brent Hicks
; CRT Cameron Taylor
; SG Sergey Gavrilov
;
Q
;
;***** RETURNS THE TEST BUILD NUMBER FOR THE DATA EXTRACTION
BUILD() ;
Q 1
;
;***** REGISTRY UPDATE AND DATA EXTRACTION TASK
;
; ZTQPARAM String that contains a list of registry names
; separated by commas. You must define the list as
; a value of the TASK PARAMETERS field during
; scheduling of the [ROR TASK] option that uses
; this entry point.
;
; The following task parameters are optional. They can be defined
; on the second page of the option scheduling form as the pairs of
; variable names and values. See description of the ROR TASK option
; for more details regarding these parameters.
;
; [RORFLCLR] Clear flags to control processing (default: "").
; [RORFLSET] Set flags to control processing (default: "EX").
;
; D Run the task(s) in Debug Mode #1
;
; E Use the event references (file #798.3)
;
; M Disable data extraction and HL7 messaging
;
; S Run the data extraction in single-task mode
;
; X Suspend the data extraction task in the
; same way as the registry update
;
; [RORMNTSK] Maximum number of the registry update subtasks.
; The default value of the parameter is "2-3-AUTO".
;
; [RORSUSP] Suspension parameters of the registry update and
; data extraction subtasks. The subtasks are not
; suspended by default.
;
TASK ;
N RORERROR ; Error processing data
N RORLOG ; Log subsystem constants & variables
N RORPARM ; Application parameters
;
N CNT,FLAGS,I,RC,RORKEY,RORSITE,RORT,RORUSER,REGLST,REGNAME,RORERRDL K ZTREQ
;--- Initialize constants and variables
D INIT^RORUTL01("ROR",1)
D CLEAR^RORERR("TASK^ROR",1)
S RC=$$SETUP^RORLOG()
S RC=$$OPEN^RORLOG(,7,"ROR TASK STARTED")
;
; Make sure user has the ROR VA IRM key
S RC=1
D OWNSKEY^XUSRB(.RORKEY,"ROR VA IRM",DUZ)
I '$G(RORKEY(0)) D S RC=-1
. N XMINSTR,XMY
. ; Quit if not a production environment
. Q:'$$CCRNTFY^RORUTL05(0)
. ; Send bulletin if user not assigned key
. S XMY("CCRAutoNotification@domain.ext")=""
. S RORSITE=$$SITE^RORUTL03()
. S RORUSER=$$GET1^DIQ(200,DUZ_",",.01)
. S RORT(1)="At station #"_$P(RORSITE,U)_" "_$P(RORSITE,U,2)_", the user running the ROR TASK nightly job"
. S RORT(2)="no longer has the appropriate keys to run this job. Contact the site to inform"
. S RORT(3)="them they must cancel the ROR TASK job and then must have it restarted by a user"
. S RORT(4)="who currently possesses the ROR VA IRM key."
. S RORT(5)=" "
. S RORT(6)="USER OF RECORD: "_RORUSER_" ("_DUZ_")"
. S XMINSTR("ADDR FLAGS")="I",XMINSTR("FROM")=.5
. D SENDMSG^XMXAPI(DUZ,"ROR TASK NIGHTLY JOB NEEDS ATTENTION","RORT",.XMY,.XMINSTR)
. ;File in the error log
. D ACVIOLTN^RORLOG(-113,"",RORUSER)
G:RC<0 ABORT
;--- Check and log the task parameters and force the <UNDEF>
;--- error in case of a missing/invalid critical value
I $$TASKPRMS^ROR10(.REGLST)<0 K ZTQPARAM S RC=ZTQPARAM
;--- Clear/Set the flags (override the default value)
S FLAGS=$TR("EX",RORFLCLR_RORFLSET)_RORFLSET
;--- Associate the log with the registries
S RC=$$SETRGLST^RORLOG(.REGLST)
;--- Enable debug mode if requested
S:FLAGS["D" RORPARM("DEBUG")=1
;
;--- Rebuild the "ACL" cross-reference
S RC=$$RNDXACL^RORUTL11()
;--- Remove inactive registries from the list
S RC=$$ARLST^RORUTL02(.REGLST) G:RC<0 ABORT
;--- Check the status of last HL7 message(s)
I FLAGS'["M" D G:RC<0 ABORT
. S RC=$$CHECKMSG^ROR10(.REGLST)
;
;--- Update the registries
S RC=$$UPDATE^RORUPD(.REGLST,RORMNTSK,RORSUSP,FLAGS)
;--- Process the errors
I RC<0 D G:RC<0 ABORT
. ;--- Quit if stop is requested (via the TaskMan User option)
. I RC=-42 D ALERT^RORUTL01(.REGLST,-42) S ZTSTOP=1 Q
. ;--- Do not send the alert for some warnings
. I RC=-28 S RC=0 Q
. ;--- Send the alert in case of other errors/warnings
. D ALERT^RORUTL01(.REGLST,-43,,,,"registry update")
. S RC=0
;
;--- Mark registry records 1 month after the installation so that
; the local registry data and demographic data will be resent
;--- to restore the data overwritten with the historical data
S RC=$$REMARK^RORUTL05(.REGLST,31)
;
;--- Perform the data extraction
S RC=$S(FLAGS'["M":$$EXTRACT^ROREXT(.REGLST,,RORSUSP,FLAGS),1:0)
;--- Process the errors
I RC<0 D G:RC<0 ABORT
. ;--- Quit if stop is requested (via the TaskMan User option)
. I RC=-42 D ALERT^RORUTL01(.REGLST,-42) S ZTSTOP=1 Q
. ;--- Do not send the alert for some warnings
. I RC=-28 S RC=0 Q
. ;--- Send the alert in case of other errors/warnings
. D ALERT^RORUTL01(.REGLST,-43,,,,"data extraction")
. S RC=0
;
;--- Purge the old tasks
S RC=$$PURGE^RORTSK02(14)
;--- Purge the old logs
S RC=$$PURGE^RORLOG01(31)
;--- Purge the old event references
S RC=$$EPDATE^RORUTL05()
S:RC>0 RC=$$PURGE^RORUPP02(RC)
;---
S ZTREQ="@"
ABORT ;
S I=$S($G(ZTREQ)="@":"COMPLETED",1:"ABORTED")
D CLOSE^RORLOG("ROR TASK "_I)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HROR 9575 printed Nov 22, 2024@16:51:28 Page 2
ROR ;HCIOFO/SG - CLINICAL CASE REGISTRIES ;1/26/07 4:54pm
+1 ;;1.5;CLINICAL CASE REGISTRIES;**1,3,22**;Feb 17, 2006;Build 17
+2 ;
+3 ;***************************************************************************
+4 ;***************************************************************************
+5 ; --- ROUTINE MODIFICATION LOG ---
+6 ;
+7 ;PKG/PATCH DATE DEVELOPER MODIFICATION
+8 ;----------- ---------- ----------- ----------------------------------------
+9 ;ROR*1.5*22 FEB 2014 T KOPP Added check for ROR VA IRM security key
+10 ; for nightly task job ROR TASK
+11 ;
+12 ;***************************************************************************
+13 ;
+14 ; LOCAL VARIABLE ------ DESCRIPTION
+15 ;
+16 ; RORCACHE In-memory cache
+17 ; RORERRDL Default error location
+18 ; RORERROR Error processing data
+19 ; RORPARM Task-wide constants and variables
+20 ;
+21 ; See the source code of the ^ROR02 routine for more details.
+22 ;
+23 ; ROREXT Regular data extraction (See ^ROREXT)
+24 ; RORHDT Historical data extraction (See ^RORHDT)
+25 ; RORLOG Log subsystem data (See ^RORLOG)
+26 ; RORUPD Registry update parameters (See ^RORUPD)
+27 ;
+28 ; TEMPORARY NODE ------ DESCRIPTION
+29 ;
+30 ; ^TMP("RORHDT") Control data of historical data extraction
+31 ; ^TMP("RORTMP") Temporary storage
+32 ; ^TMP("RORUPD") Registry update temporary data
+33 ;
+34 ; ^TMP(rtn_name) Temporary storage used by the rtn_name
+35 ; routine (mostly, the RPC's)
+36 ;
+37 ; ^TMP($J,"RORTMP-"_) Generic temporary storage used by ^RORTMP
+38 ;
+39 ; ^XTMP("RORHDT") Control data of historical data extraction
+40 ; ^XTMP("RORUPDJ") Registry update temporary data (multitask)
+41 ; ^XTMP("RORUPDR") Registry update temporary data (installation)
+42 ;
+43 ; See detailed description of the temporary global nodes in
+44 ; the source code of the ^ROR01 routine.
+45 ;
+46 ; NAMESPACE ----------- DESCRIPTION
+47 ;
+48 ; RORAPI* Supported APIs
+49 ; RORDD* Routines used by the Data Dictionary
+50 ; RORERR* Error processing
+51 ; ROREVT* Event protocols
+52 ; ROREX* Regular data extraction & transmission
+53 ; RORHDT* Historical data extraction
+54 ; RORHIV* HIV registry-specific routines
+55 ; RORHL* HL7 utilities
+56 ; RORKIDS* Low-level installation utilities (KIDS)
+57 ; RORLOCK* Locks and transactions
+58 ; RORLOG* Error recording
+59 ;
+60 ; RORPnnn* Patch installation routines (KIDS)
+61 ; nnn - patch number
+62 ; RORPUT* High-level installation utilities
+63 ;
+64 ; RORREP* Roll-and-scroll reports
+65 ; RORRP* Remote procedures
+66 ; RORSET* Registry setup routines
+67 ; RORTXT* Text resource routines
+68 ; RORUP* Registry update
+69 ; RORUTL* Utilities
+70 ; RORVM* Entry points for VistA menu options
+71 ; RORXnnn* XML reports (nnn - report code)
+72 ; RORXU* Utilities for XML reports
+73 ;
+74 ; DIALOG -------------- DESCRIPTION
+75 ;
+76 ; 7980000.* Various messages and templates
+77 ; 7981???.* Report templates (XSL)
+78 ;
+79 ; MENU OPTION --------- DESCRIPTION
+80 ;
+81 ; [ROR TASK] Registry update and data extraction option
+82 ; (must be scheduled; do not run it directly)
+83 ; [ROR SETUP] Registry Setup
+84 ; [RORHDT MAIN] Historical data extraction menu
+85 ; [RORMNT MAIN] Maintenance menu
+86 ;
+87 ; SPECIAL ENTRY POINT - DESCRIPTION
+88 ;
+89 ; ^RORUTL06 Menu for developer's utilities
+90 ; DISTPREP^RORUTL06 Prepares registry for KIDS distribution
+91 ; PRTMDE^RORUTL06 Prints the data element metadata
+92 ; VERIFY^RORUTL06 Checks the registry definition
+93 ;
+94 ; EXTRACT^RORUTL07 Data extraction & transmission in debug mode
+95 ; UPDATE^RORUTL07 Registry update in debug mode
+96 ;
+97 ; INITIALS ------------ DEVELOPER
+98 ;
+99 ; BH Brent Hicks
+100 ; CRT Cameron Taylor
+101 ; SG Sergey Gavrilov
+102 ;
+103 QUIT
+104 ;
+105 ;***** RETURNS THE TEST BUILD NUMBER FOR THE DATA EXTRACTION
BUILD() ;
+1 QUIT 1
+2 ;
+3 ;***** REGISTRY UPDATE AND DATA EXTRACTION TASK
+4 ;
+5 ; ZTQPARAM String that contains a list of registry names
+6 ; separated by commas. You must define the list as
+7 ; a value of the TASK PARAMETERS field during
+8 ; scheduling of the [ROR TASK] option that uses
+9 ; this entry point.
+10 ;
+11 ; The following task parameters are optional. They can be defined
+12 ; on the second page of the option scheduling form as the pairs of
+13 ; variable names and values. See description of the ROR TASK option
+14 ; for more details regarding these parameters.
+15 ;
+16 ; [RORFLCLR] Clear flags to control processing (default: "").
+17 ; [RORFLSET] Set flags to control processing (default: "EX").
+18 ;
+19 ; D Run the task(s) in Debug Mode #1
+20 ;
+21 ; E Use the event references (file #798.3)
+22 ;
+23 ; M Disable data extraction and HL7 messaging
+24 ;
+25 ; S Run the data extraction in single-task mode
+26 ;
+27 ; X Suspend the data extraction task in the
+28 ; same way as the registry update
+29 ;
+30 ; [RORMNTSK] Maximum number of the registry update subtasks.
+31 ; The default value of the parameter is "2-3-AUTO".
+32 ;
+33 ; [RORSUSP] Suspension parameters of the registry update and
+34 ; data extraction subtasks. The subtasks are not
+35 ; suspended by default.
+36 ;
TASK ;
+1 ; Error processing data
NEW RORERROR
+2 ; Log subsystem constants & variables
NEW RORLOG
+3 ; Application parameters
NEW RORPARM
+4 ;
+5 NEW CNT,FLAGS,I,RC,RORKEY,RORSITE,RORT,RORUSER,REGLST,REGNAME,RORERRDL
KILL ZTREQ
+6 ;--- Initialize constants and variables
+7 DO INIT^RORUTL01("ROR",1)
+8 DO CLEAR^RORERR("TASK^ROR",1)
+9 SET RC=$$SETUP^RORLOG()
+10 SET RC=$$OPEN^RORLOG(,7,"ROR TASK STARTED")
+11 ;
+12 ; Make sure user has the ROR VA IRM key
+13 SET RC=1
+14 DO OWNSKEY^XUSRB(.RORKEY,"ROR VA IRM",DUZ)
+15 IF '$GET(RORKEY(0))
Begin DoDot:1
+16 NEW XMINSTR,XMY
+17 ; Quit if not a production environment
+18 if '$$CCRNTFY^RORUTL05(0)
QUIT
+19 ; Send bulletin if user not assigned key
+20 SET XMY("CCRAutoNotification@domain.ext")=""
+21 SET RORSITE=$$SITE^RORUTL03()
+22 SET RORUSER=$$GET1^DIQ(200,DUZ_",",.01)
+23 SET RORT(1)="At station #"_$PIECE(RORSITE,U)_" "_$PIECE(RORSITE,U,2)_", the user running the ROR TASK nightly job"
+24 SET RORT(2)="no longer has the appropriate keys to run this job. Contact the site to inform"
+25 SET RORT(3)="them they must cancel the ROR TASK job and then must have it restarted by a user"
+26 SET RORT(4)="who currently possesses the ROR VA IRM key."
+27 SET RORT(5)=" "
+28 SET RORT(6)="USER OF RECORD: "_RORUSER_" ("_DUZ_")"
+29 SET XMINSTR("ADDR FLAGS")="I"
SET XMINSTR("FROM")=.5
+30 DO SENDMSG^XMXAPI(DUZ,"ROR TASK NIGHTLY JOB NEEDS ATTENTION","RORT",.XMY,.XMINSTR)
+31 ;File in the error log
+32 DO ACVIOLTN^RORLOG(-113,"",RORUSER)
End DoDot:1
SET RC=-1
+33 if RC<0
GOTO ABORT
+34 ;--- Check and log the task parameters and force the <UNDEF>
+35 ;--- error in case of a missing/invalid critical value
+36 IF $$TASKPRMS^ROR10(.REGLST)<0
KILL ZTQPARAM
SET RC=ZTQPARAM
+37 ;--- Clear/Set the flags (override the default value)
+38 SET FLAGS=$TRANSLATE("EX",RORFLCLR_RORFLSET)_RORFLSET
+39 ;--- Associate the log with the registries
+40 SET RC=$$SETRGLST^RORLOG(.REGLST)
+41 ;--- Enable debug mode if requested
+42 if FLAGS["D"
SET RORPARM("DEBUG")=1
+43 ;
+44 ;--- Rebuild the "ACL" cross-reference
+45 SET RC=$$RNDXACL^RORUTL11()
+46 ;--- Remove inactive registries from the list
+47 SET RC=$$ARLST^RORUTL02(.REGLST)
if RC<0
GOTO ABORT
+48 ;--- Check the status of last HL7 message(s)
+49 IF FLAGS'["M"
Begin DoDot:1
+50 SET RC=$$CHECKMSG^ROR10(.REGLST)
End DoDot:1
if RC<0
GOTO ABORT
+51 ;
+52 ;--- Update the registries
+53 SET RC=$$UPDATE^RORUPD(.REGLST,RORMNTSK,RORSUSP,FLAGS)
+54 ;--- Process the errors
+55 IF RC<0
Begin DoDot:1
+56 ;--- Quit if stop is requested (via the TaskMan User option)
+57 IF RC=-42
DO ALERT^RORUTL01(.REGLST,-42)
SET ZTSTOP=1
QUIT
+58 ;--- Do not send the alert for some warnings
+59 IF RC=-28
SET RC=0
QUIT
+60 ;--- Send the alert in case of other errors/warnings
+61 DO ALERT^RORUTL01(.REGLST,-43,,,,"registry update")
+62 SET RC=0
End DoDot:1
if RC<0
GOTO ABORT
+63 ;
+64 ;--- Mark registry records 1 month after the installation so that
+65 ; the local registry data and demographic data will be resent
+66 ;--- to restore the data overwritten with the historical data
+67 SET RC=$$REMARK^RORUTL05(.REGLST,31)
+68 ;
+69 ;--- Perform the data extraction
+70 SET RC=$SELECT(FLAGS'["M":$$EXTRACT^ROREXT(.REGLST,,RORSUSP,FLAGS),1:0)
+71 ;--- Process the errors
+72 IF RC<0
Begin DoDot:1
+73 ;--- Quit if stop is requested (via the TaskMan User option)
+74 IF RC=-42
DO ALERT^RORUTL01(.REGLST,-42)
SET ZTSTOP=1
QUIT
+75 ;--- Do not send the alert for some warnings
+76 IF RC=-28
SET RC=0
QUIT
+77 ;--- Send the alert in case of other errors/warnings
+78 DO ALERT^RORUTL01(.REGLST,-43,,,,"data extraction")
+79 SET RC=0
End DoDot:1
if RC<0
GOTO ABORT
+80 ;
+81 ;--- Purge the old tasks
+82 SET RC=$$PURGE^RORTSK02(14)
+83 ;--- Purge the old logs
+84 SET RC=$$PURGE^RORLOG01(31)
+85 ;--- Purge the old event references
+86 SET RC=$$EPDATE^RORUTL05()
+87 if RC>0
SET RC=$$PURGE^RORUPP02(RC)
+88 ;---
+89 SET ZTREQ="@"
ABORT ;
+1 SET I=$SELECT($GET(ZTREQ)="@":"COMPLETED",1:"ABORTED")
+2 DO CLOSE^RORLOG("ROR TASK "_I)
+3 QUIT