Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ROR

ROR.m

Go to the documentation of this file.
  1. 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
  1. ;
  1. ;***************************************************************************
  1. ;***************************************************************************
  1. ; --- ROUTINE MODIFICATION LOG ---
  1. ;
  1. ;PKG/PATCH DATE DEVELOPER MODIFICATION
  1. ;----------- ---------- ----------- ----------------------------------------
  1. ;ROR*1.5*22 FEB 2014 T KOPP Added check for ROR VA IRM security key
  1. ; for nightly task job ROR TASK
  1. ;
  1. ;***************************************************************************
  1. ;
  1. ; LOCAL VARIABLE ------ DESCRIPTION
  1. ;
  1. ; RORCACHE In-memory cache
  1. ; RORERRDL Default error location
  1. ; RORERROR Error processing data
  1. ; RORPARM Task-wide constants and variables
  1. ;
  1. ; See the source code of the ^ROR02 routine for more details.
  1. ;
  1. ; ROREXT Regular data extraction (See ^ROREXT)
  1. ; RORHDT Historical data extraction (See ^RORHDT)
  1. ; RORLOG Log subsystem data (See ^RORLOG)
  1. ; RORUPD Registry update parameters (See ^RORUPD)
  1. ;
  1. ; TEMPORARY NODE ------ DESCRIPTION
  1. ;
  1. ; ^TMP("RORHDT") Control data of historical data extraction
  1. ; ^TMP("RORTMP") Temporary storage
  1. ; ^TMP("RORUPD") Registry update temporary data
  1. ;
  1. ; ^TMP(rtn_name) Temporary storage used by the rtn_name
  1. ; routine (mostly, the RPC's)
  1. ;
  1. ; ^TMP($J,"RORTMP-"_) Generic temporary storage used by ^RORTMP
  1. ;
  1. ; ^XTMP("RORHDT") Control data of historical data extraction
  1. ; ^XTMP("RORUPDJ") Registry update temporary data (multitask)
  1. ; ^XTMP("RORUPDR") Registry update temporary data (installation)
  1. ;
  1. ; See detailed description of the temporary global nodes in
  1. ; the source code of the ^ROR01 routine.
  1. ;
  1. ; NAMESPACE ----------- DESCRIPTION
  1. ;
  1. ; RORAPI* Supported APIs
  1. ; RORDD* Routines used by the Data Dictionary
  1. ; RORERR* Error processing
  1. ; ROREVT* Event protocols
  1. ; ROREX* Regular data extraction & transmission
  1. ; RORHDT* Historical data extraction
  1. ; RORHIV* HIV registry-specific routines
  1. ; RORHL* HL7 utilities
  1. ; RORKIDS* Low-level installation utilities (KIDS)
  1. ; RORLOCK* Locks and transactions
  1. ; RORLOG* Error recording
  1. ;
  1. ; RORPnnn* Patch installation routines (KIDS)
  1. ; nnn - patch number
  1. ; RORPUT* High-level installation utilities
  1. ;
  1. ; RORREP* Roll-and-scroll reports
  1. ; RORRP* Remote procedures
  1. ; RORSET* Registry setup routines
  1. ; RORTXT* Text resource routines
  1. ; RORUP* Registry update
  1. ; RORUTL* Utilities
  1. ; RORVM* Entry points for VistA menu options
  1. ; RORXnnn* XML reports (nnn - report code)
  1. ; RORXU* Utilities for XML reports
  1. ;
  1. ; DIALOG -------------- DESCRIPTION
  1. ;
  1. ; 7980000.* Various messages and templates
  1. ; 7981???.* Report templates (XSL)
  1. ;
  1. ; MENU OPTION --------- DESCRIPTION
  1. ;
  1. ; [ROR TASK] Registry update and data extraction option
  1. ; (must be scheduled; do not run it directly)
  1. ; [ROR SETUP] Registry Setup
  1. ; [RORHDT MAIN] Historical data extraction menu
  1. ; [RORMNT MAIN] Maintenance menu
  1. ;
  1. ; SPECIAL ENTRY POINT - DESCRIPTION
  1. ;
  1. ; ^RORUTL06 Menu for developer's utilities
  1. ; DISTPREP^RORUTL06 Prepares registry for KIDS distribution
  1. ; PRTMDE^RORUTL06 Prints the data element metadata
  1. ; VERIFY^RORUTL06 Checks the registry definition
  1. ;
  1. ; EXTRACT^RORUTL07 Data extraction & transmission in debug mode
  1. ; UPDATE^RORUTL07 Registry update in debug mode
  1. ;
  1. ; INITIALS ------------ DEVELOPER
  1. ;
  1. ; BH Brent Hicks
  1. ; CRT Cameron Taylor
  1. ; SG Sergey Gavrilov
  1. ;
  1. Q
  1. ;
  1. ;***** RETURNS THE TEST BUILD NUMBER FOR THE DATA EXTRACTION
  1. BUILD() ;
  1. Q 1
  1. ;
  1. ;***** REGISTRY UPDATE AND DATA EXTRACTION TASK
  1. ;
  1. ; ZTQPARAM String that contains a list of registry names
  1. ; separated by commas. You must define the list as
  1. ; a value of the TASK PARAMETERS field during
  1. ; scheduling of the [ROR TASK] option that uses
  1. ; this entry point.
  1. ;
  1. ; The following task parameters are optional. They can be defined
  1. ; on the second page of the option scheduling form as the pairs of
  1. ; variable names and values. See description of the ROR TASK option
  1. ; for more details regarding these parameters.
  1. ;
  1. ; [RORFLCLR] Clear flags to control processing (default: "").
  1. ; [RORFLSET] Set flags to control processing (default: "EX").
  1. ;
  1. ; D Run the task(s) in Debug Mode #1
  1. ;
  1. ; E Use the event references (file #798.3)
  1. ;
  1. ; M Disable data extraction and HL7 messaging
  1. ;
  1. ; S Run the data extraction in single-task mode
  1. ;
  1. ; X Suspend the data extraction task in the
  1. ; same way as the registry update
  1. ;
  1. ; [RORMNTSK] Maximum number of the registry update subtasks.
  1. ; The default value of the parameter is "2-3-AUTO".
  1. ;
  1. ; [RORSUSP] Suspension parameters of the registry update and
  1. ; data extraction subtasks. The subtasks are not
  1. ; suspended by default.
  1. ;
  1. TASK ;
  1. N RORERROR ; Error processing data
  1. N RORLOG ; Log subsystem constants & variables
  1. N RORPARM ; Application parameters
  1. ;
  1. N CNT,FLAGS,I,RC,RORKEY,RORSITE,RORT,RORUSER,REGLST,REGNAME,RORERRDL K ZTREQ
  1. ;--- Initialize constants and variables
  1. D INIT^RORUTL01("ROR",1)
  1. D CLEAR^RORERR("TASK^ROR",1)
  1. S RC=$$SETUP^RORLOG()
  1. S RC=$$OPEN^RORLOG(,7,"ROR TASK STARTED")
  1. ;
  1. ; Make sure user has the ROR VA IRM key
  1. S RC=1
  1. D OWNSKEY^XUSRB(.RORKEY,"ROR VA IRM",DUZ)
  1. I '$G(RORKEY(0)) D S RC=-1
  1. . N XMINSTR,XMY
  1. . ; Quit if not a production environment
  1. . Q:'$$CCRNTFY^RORUTL05(0)
  1. . ; Send bulletin if user not assigned key
  1. . S XMY("CCRAutoNotification@domain.ext")=""
  1. . S RORSITE=$$SITE^RORUTL03()
  1. . S RORUSER=$$GET1^DIQ(200,DUZ_",",.01)
  1. . S RORT(1)="At station #"_$P(RORSITE,U)_" "_$P(RORSITE,U,2)_", the user running the ROR TASK nightly job"
  1. . S RORT(2)="no longer has the appropriate keys to run this job. Contact the site to inform"
  1. . S RORT(3)="them they must cancel the ROR TASK job and then must have it restarted by a user"
  1. . S RORT(4)="who currently possesses the ROR VA IRM key."
  1. . S RORT(5)=" "
  1. . S RORT(6)="USER OF RECORD: "_RORUSER_" ("_DUZ_")"
  1. . S XMINSTR("ADDR FLAGS")="I",XMINSTR("FROM")=.5
  1. . D SENDMSG^XMXAPI(DUZ,"ROR TASK NIGHTLY JOB NEEDS ATTENTION","RORT",.XMY,.XMINSTR)
  1. . ;File in the error log
  1. . D ACVIOLTN^RORLOG(-113,"",RORUSER)
  1. G:RC<0 ABORT
  1. ;--- Check and log the task parameters and force the <UNDEF>
  1. ;--- error in case of a missing/invalid critical value
  1. I $$TASKPRMS^ROR10(.REGLST)<0 K ZTQPARAM S RC=ZTQPARAM
  1. ;--- Clear/Set the flags (override the default value)
  1. S FLAGS=$TR("EX",RORFLCLR_RORFLSET)_RORFLSET
  1. ;--- Associate the log with the registries
  1. S RC=$$SETRGLST^RORLOG(.REGLST)
  1. ;--- Enable debug mode if requested
  1. S:FLAGS["D" RORPARM("DEBUG")=1
  1. ;
  1. ;--- Rebuild the "ACL" cross-reference
  1. S RC=$$RNDXACL^RORUTL11()
  1. ;--- Remove inactive registries from the list
  1. S RC=$$ARLST^RORUTL02(.REGLST) G:RC<0 ABORT
  1. ;--- Check the status of last HL7 message(s)
  1. I FLAGS'["M" D G:RC<0 ABORT
  1. . S RC=$$CHECKMSG^ROR10(.REGLST)
  1. ;
  1. ;--- Update the registries
  1. S RC=$$UPDATE^RORUPD(.REGLST,RORMNTSK,RORSUSP,FLAGS)
  1. ;--- Process the errors
  1. I RC<0 D G:RC<0 ABORT
  1. . ;--- Quit if stop is requested (via the TaskMan User option)
  1. . I RC=-42 D ALERT^RORUTL01(.REGLST,-42) S ZTSTOP=1 Q
  1. . ;--- Do not send the alert for some warnings
  1. . I RC=-28 S RC=0 Q
  1. . ;--- Send the alert in case of other errors/warnings
  1. . D ALERT^RORUTL01(.REGLST,-43,,,,"registry update")
  1. . S RC=0
  1. ;
  1. ;--- Mark registry records 1 month after the installation so that
  1. ; the local registry data and demographic data will be resent
  1. ;--- to restore the data overwritten with the historical data
  1. S RC=$$REMARK^RORUTL05(.REGLST,31)
  1. ;
  1. ;--- Perform the data extraction
  1. S RC=$S(FLAGS'["M":$$EXTRACT^ROREXT(.REGLST,,RORSUSP,FLAGS),1:0)
  1. ;--- Process the errors
  1. I RC<0 D G:RC<0 ABORT
  1. . ;--- Quit if stop is requested (via the TaskMan User option)
  1. . I RC=-42 D ALERT^RORUTL01(.REGLST,-42) S ZTSTOP=1 Q
  1. . ;--- Do not send the alert for some warnings
  1. . I RC=-28 S RC=0 Q
  1. . ;--- Send the alert in case of other errors/warnings
  1. . D ALERT^RORUTL01(.REGLST,-43,,,,"data extraction")
  1. . S RC=0
  1. ;
  1. ;--- Purge the old tasks
  1. S RC=$$PURGE^RORTSK02(14)
  1. ;--- Purge the old logs
  1. S RC=$$PURGE^RORLOG01(31)
  1. ;--- Purge the old event references
  1. S RC=$$EPDATE^RORUTL05()
  1. S:RC>0 RC=$$PURGE^RORUPP02(RC)
  1. ;---
  1. S ZTREQ="@"
  1. ABORT ;
  1. S I=$S($G(ZTREQ)="@":"COMPLETED",1:"ABORTED")
  1. D CLOSE^RORLOG("ROR TASK "_I)
  1. Q