ROREXT ;HCIOFO/SG - DATA EXTRACTION & TRANSMISSION ; 11/1/05 3:08pm
;;1.5;CLINICAL CASE REGISTRIES;**18**;Feb 17, 2006;Build 25
;*************************************************************************
; --- ROUTINE MODIFICATION LOG ---
;
;PKG/PATCH DATE DEVELOPER MODIFICATION
;----------- ---------- ----------- ----------------------------------------
;ROR*1.5*18 APR 2012 C RAY Added logic to prevent data
; transmission if registry is local
;***********************************************************************
;
; ROREXT -------------- DATA EXTRACTION DESCRIPTOR
;
; ROREXT("DTAR", Data is extracted only in those areas that
; are listed here. If a data area time frame
; is provided, then it is merged with the
; regular time frame(s) for that area.
; DataArea) "" or Data Area Time Frame
; ^01: Start Date (FileMan)
; ^02: End Date (FileMan)
;
; ROREXT("DXBEG") Start date of the data extraction (opt'l)
; If this node is defined and greater than
; zero, data extraction starts from this date
; (instead of individual start date for each
; patient in the registry).
;
; ROREXT("DXEND") End date of the data extraction
; (these nodes are set by $$PREPARE^ROREXPR).
;
; ROREXT("EXTRDAYS") Extraction period for a new patient
;
; ROREXT("FLAGS") Flags to control processing (see the
; TASK^ROR for possible values).
;
; ROREXT("HDTIEN") When a historical data extraction is
; performed, this node stores IEN of
; the record of the ROR HISTORICAL DATA
; EXTRACTION file (#799.6).
;
; ROREXT("HL7BUF") Closed root of the buffer where the HL7
; message is constructed. By default, the
; ^TMP("HLS",$J) is used.
;
; ROREXT("HL7CNT") Counter of the messages in the batch
; ROREXT("HL7DT") Date of the batch message creation (FileMan)
; ROREXT("HL7MID") Message ID of the "stub" message
; ROREXT("HL7MTIEN") IEN in the File #772 for the "stub" message
; ROREXT("HL7PROT") Name of the event driver protocol
;
; ROREXT("HL7PTR") Subscript of the last occupied sub-node of
; the message buffer (see the "HL7BUF").
; Value of the variable is incremented before
; storing the segment.
;
; ROREXT("HL7SID",
; SegName) The next value of the Set ID for this kind
; of segments. The $$CREATE^RORHL7 function
; resets the Set ID's to 1 for all supported
; segments.
;
; ROREXT("HL7SIZE") Current size of the HL7 batch
; ^1: Current size (in bytes)
; ^2: 1 if maximum size has been reached
;
; ROREXT("LD",
; 1) Number of lag days for the data extraction
;
; ROREXT("MAXHL7SIZE") Maximum size (in bytes) of an HL7 message
;
; ROREXT("MSGBLD",
; RegIEN) Message builder call-back entry point (opt'l)
;
; ROREXT("NBM") Number of batch messages generated for
; the current protocol
;
; ROREXT("PATCH",
; PatchName) Defined if the patch is installed
;
; ROREXT("SUSPEND") DATA EXTRACTION SUSPENSION PARAMETERS
; ^1: Suspension start time (FileMan)
; ^2: Suspension end time (FileMan)
;
; For example, to suspend the data extraction
; from 7:00 until 18:00 this node should have
; the following value: ".07^.18".
;
; ROREXT("VERSION") ROR version/patch installed at the site
; ^1: Version number (e.g. 1.0)
; ^2: Latest patch number (e.g. 5)
; ^3: Patch installation date (FileMan)
;
; RORHL --------------- HL7 ENVIRONMENT VARIABLES
;
; RORHL This local array contains HL7 environment
; variables initialized by INIT^HLFNC2 ("FS",
; "ECH" and others).
;
; RORLRC -------------- LIST OF EXTRACTED LAB RESULTS
;
; RORLRC( Either a list of codes of a Lab results to
; extract or "*" for all results (see the LA7SC
; parameter of the GCPR^LA7QRY entry point)
; Seq#) Lab result code
; ^1: Result code
; ^2: Coding system ("LN" or "NLT")
;
Q
;
;***** PERFORMS THE DATA EXTRACTION
;
; .REGLST Reference to a local array containing registry
; names as subscripts and registry IENs as values
;
; [DXBEG] Data extraction start date (individual start
; date for each patient by default).
; Time part of the parameter value is ignored.
;
; [SUSPEND] Subtask suspension parameters:
; See description of the ROREXT("SUSPEND") node
; for details.
;
; [FLAGS] Flags to control processing.
; See description of the TASK^ROR for
; possible values of the flags.
;
; Return Values:
; <0 Error code (see MSGLIST^RORERR20)
; 0 Ok
;
N ROREXT ; Data extraction descriptor
N ROREXTSV ; Backup copy of the descriptor
;
N CNT,ERRCNT,PGRLST,RC,REGIEN,REGNAME,RORGLST,RORMSG,RORPROT,TMP,ZTDESC,ZTDTH,ZTRTN,ZTSAVE
D CLEAR^RORERR("EXTRACT^ROREXT")
S (ERRCNT,RC)=0
;
;=== Prepare the common parameters
S:$G(DXBEG)>0 ROREXT("DXBEG")=DXBEG
S ROREXT("FLAGS")=$$UP^XLFSTR($G(FLAGS))
;--- Enable task suspension if requested
I $G(SUSPEND)>0 S:ROREXT("FLAGS")["X" ROREXT("SUSPEND")=SUSPEND
;
;=== Group the registries by the HL7 protocol name
S REGNAME=""
F S REGNAME=$O(REGLST(REGNAME)) Q:REGNAME="" D
. ;--- Get the registry IEN
. S REGIEN=+REGLST(REGNAME)
. I REGIEN'>0 D Q:REGIEN'>0
. . S REGIEN=$$REGIEN^RORUTL02(REGNAME)
. ;--- Do not transmit data for local registries
. Q:'+($P($G(^ROR(798.1,REGIEN,0)),U,11))
. ;--- Get the HL7 protocol name
. S RORPROT=$$GET1^DIQ(798.1,REGIEN_",",13,"E",,"RORMSG")
. D:$G(DIERR) DBS^RORERR("RORMSG",-9,,,798.1,REGIEN_",")
. I RORPROT="" D S ERRCNT=ERRCNT+1 Q
. . D ERROR^RORERR(-25,,REGNAME)
. ;--- Create the reference
. S PGRLST(RORPROT,REGNAME)=REGIEN
;
;=== Data extraction
M ROREXTSV=ROREXT
S RORPROT="",RC=0
F CNT=1:1 S RORPROT=$O(PGRLST(RORPROT)) Q:RORPROT="" D Q:RC<0
. ;--- Prepare the task-specific parameters
. K RORGLST M RORGLST=PGRLST(RORPROT)
. S ROREXT("HL7PROT")=RORPROT
. ;--- Single-task data extraction (if requested)
. I ROREXT("FLAGS")["S" D Q
. . S TMP=$$INTEXT^ROREXT01(.RORGLST)
. . I TMP<0 S:TMP=-42 RC=TMP S ERRCNT=ERRCNT+1
. . K ROREXT M ROREXT=ROREXTSV
. ;--- Otherwise, start a separate task
. S ZTRTN="TASK^ROREXT",ZTIO=""
. S ZTDTH=$$FMADD^XLFDT($$NOW^XLFDT,,,,(CNT-1)*30)
. S ZTDESC="CCR Data Extraction ("_RORPROT_")"
. F TMP="ROREXT(","RORGLST(","RORPARM(" S ZTSAVE(TMP)=""
. D ^%ZTLOAD
. ;--- Log the action
. D LOG^RORERR(-94,,,ZTSK)
;
;=== Error processing
Q $S(RC<0:RC,ERRCNT>0:-43,1:0)
;
;***** ENTRY POINT FOR DATA EXTRACTION TASK
;
; ROREXT Data extraction descriptor
; RORGLST List of registry names and IENs
; RORPARM Task-wide constants and variables
;
TASK ;
N RORERRDL ; Default error location
N RORERROR ; Error processing data
;
N RC,TMP K ZTREQ
;--- Initialize the variables
D CLEAR^RORERR("TASK^ROREXT",1)
;--- Disable debug output (task has no output device)
S:$G(RORPARM("DEBUG"))>1 RORPARM("DEBUG")=1
;--- Data extraction
S RC=$$INTEXT^ROREXT01(.RORGLST,ZTSK)
;--- Error processing and notifications
S:RC<0 ZTSTOP=1
I RC=-42 D ALERT^RORUTL01(.RORGLST,-42) Q
D:RC<0 ALERT^RORUTL01(.RORGLST,-43,,,,"data extraction")
S ZTREQ="@"
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HROREXT 8516 printed Nov 22, 2024@16:51:40 Page 2
ROREXT ;HCIOFO/SG - DATA EXTRACTION & TRANSMISSION ; 11/1/05 3:08pm
+1 ;;1.5;CLINICAL CASE REGISTRIES;**18**;Feb 17, 2006;Build 25
+2 ;*************************************************************************
+3 ; --- ROUTINE MODIFICATION LOG ---
+4 ;
+5 ;PKG/PATCH DATE DEVELOPER MODIFICATION
+6 ;----------- ---------- ----------- ----------------------------------------
+7 ;ROR*1.5*18 APR 2012 C RAY Added logic to prevent data
+8 ; transmission if registry is local
+9 ;***********************************************************************
+10 ;
+11 ; ROREXT -------------- DATA EXTRACTION DESCRIPTOR
+12 ;
+13 ; ROREXT("DTAR", Data is extracted only in those areas that
+14 ; are listed here. If a data area time frame
+15 ; is provided, then it is merged with the
+16 ; regular time frame(s) for that area.
+17 ; DataArea) "" or Data Area Time Frame
+18 ; ^01: Start Date (FileMan)
+19 ; ^02: End Date (FileMan)
+20 ;
+21 ; ROREXT("DXBEG") Start date of the data extraction (opt'l)
+22 ; If this node is defined and greater than
+23 ; zero, data extraction starts from this date
+24 ; (instead of individual start date for each
+25 ; patient in the registry).
+26 ;
+27 ; ROREXT("DXEND") End date of the data extraction
+28 ; (these nodes are set by $$PREPARE^ROREXPR).
+29 ;
+30 ; ROREXT("EXTRDAYS") Extraction period for a new patient
+31 ;
+32 ; ROREXT("FLAGS") Flags to control processing (see the
+33 ; TASK^ROR for possible values).
+34 ;
+35 ; ROREXT("HDTIEN") When a historical data extraction is
+36 ; performed, this node stores IEN of
+37 ; the record of the ROR HISTORICAL DATA
+38 ; EXTRACTION file (#799.6).
+39 ;
+40 ; ROREXT("HL7BUF") Closed root of the buffer where the HL7
+41 ; message is constructed. By default, the
+42 ; ^TMP("HLS",$J) is used.
+43 ;
+44 ; ROREXT("HL7CNT") Counter of the messages in the batch
+45 ; ROREXT("HL7DT") Date of the batch message creation (FileMan)
+46 ; ROREXT("HL7MID") Message ID of the "stub" message
+47 ; ROREXT("HL7MTIEN") IEN in the File #772 for the "stub" message
+48 ; ROREXT("HL7PROT") Name of the event driver protocol
+49 ;
+50 ; ROREXT("HL7PTR") Subscript of the last occupied sub-node of
+51 ; the message buffer (see the "HL7BUF").
+52 ; Value of the variable is incremented before
+53 ; storing the segment.
+54 ;
+55 ; ROREXT("HL7SID",
+56 ; SegName) The next value of the Set ID for this kind
+57 ; of segments. The $$CREATE^RORHL7 function
+58 ; resets the Set ID's to 1 for all supported
+59 ; segments.
+60 ;
+61 ; ROREXT("HL7SIZE") Current size of the HL7 batch
+62 ; ^1: Current size (in bytes)
+63 ; ^2: 1 if maximum size has been reached
+64 ;
+65 ; ROREXT("LD",
+66 ; 1) Number of lag days for the data extraction
+67 ;
+68 ; ROREXT("MAXHL7SIZE") Maximum size (in bytes) of an HL7 message
+69 ;
+70 ; ROREXT("MSGBLD",
+71 ; RegIEN) Message builder call-back entry point (opt'l)
+72 ;
+73 ; ROREXT("NBM") Number of batch messages generated for
+74 ; the current protocol
+75 ;
+76 ; ROREXT("PATCH",
+77 ; PatchName) Defined if the patch is installed
+78 ;
+79 ; ROREXT("SUSPEND") DATA EXTRACTION SUSPENSION PARAMETERS
+80 ; ^1: Suspension start time (FileMan)
+81 ; ^2: Suspension end time (FileMan)
+82 ;
+83 ; For example, to suspend the data extraction
+84 ; from 7:00 until 18:00 this node should have
+85 ; the following value: ".07^.18".
+86 ;
+87 ; ROREXT("VERSION") ROR version/patch installed at the site
+88 ; ^1: Version number (e.g. 1.0)
+89 ; ^2: Latest patch number (e.g. 5)
+90 ; ^3: Patch installation date (FileMan)
+91 ;
+92 ; RORHL --------------- HL7 ENVIRONMENT VARIABLES
+93 ;
+94 ; RORHL This local array contains HL7 environment
+95 ; variables initialized by INIT^HLFNC2 ("FS",
+96 ; "ECH" and others).
+97 ;
+98 ; RORLRC -------------- LIST OF EXTRACTED LAB RESULTS
+99 ;
+100 ; RORLRC( Either a list of codes of a Lab results to
+101 ; extract or "*" for all results (see the LA7SC
+102 ; parameter of the GCPR^LA7QRY entry point)
+103 ; Seq#) Lab result code
+104 ; ^1: Result code
+105 ; ^2: Coding system ("LN" or "NLT")
+106 ;
+107 QUIT
+108 ;
+109 ;***** PERFORMS THE DATA EXTRACTION
+110 ;
+111 ; .REGLST Reference to a local array containing registry
+112 ; names as subscripts and registry IENs as values
+113 ;
+114 ; [DXBEG] Data extraction start date (individual start
+115 ; date for each patient by default).
+116 ; Time part of the parameter value is ignored.
+117 ;
+118 ; [SUSPEND] Subtask suspension parameters:
+119 ; See description of the ROREXT("SUSPEND") node
+120 ; for details.
+121 ;
+122 ; [FLAGS] Flags to control processing.
+123 ; See description of the TASK^ROR for
+124 ; possible values of the flags.
+125 ;
+126 ; Return Values:
+127 ; <0 Error code (see MSGLIST^RORERR20)
+128 ; 0 Ok
+129 ;
+1 ; Data extraction descriptor
NEW ROREXT
+2 ; Backup copy of the descriptor
NEW ROREXTSV
+3 ;
+4 NEW CNT,ERRCNT,PGRLST,RC,REGIEN,REGNAME,RORGLST,RORMSG,RORPROT,TMP,ZTDESC,ZTDTH,ZTRTN,ZTSAVE
+5 DO CLEAR^RORERR("EXTRACT^ROREXT")
+6 SET (ERRCNT,RC)=0
+7 ;
+8 ;=== Prepare the common parameters
+9 if $GET(DXBEG)>0
SET ROREXT("DXBEG")=DXBEG
+10 SET ROREXT("FLAGS")=$$UP^XLFSTR($GET(FLAGS))
+11 ;--- Enable task suspension if requested
+12 IF $GET(SUSPEND)>0
if ROREXT("FLAGS")["X"
SET ROREXT("SUSPEND")=SUSPEND
+13 ;
+14 ;=== Group the registries by the HL7 protocol name
+15 SET REGNAME=""
+16 FOR
SET REGNAME=$ORDER(REGLST(REGNAME))
if REGNAME=""
QUIT
Begin DoDot:1
+17 ;--- Get the registry IEN
+18 SET REGIEN=+REGLST(REGNAME)
+19 IF REGIEN'>0
Begin DoDot:2
+20 SET REGIEN=$$REGIEN^RORUTL02(REGNAME)
End DoDot:2
if REGIEN'>0
QUIT
+21 ;--- Do not transmit data for local registries
+22 if '+($PIECE($GET(^ROR(798.1,REGIEN,0)),U,11))
QUIT
+23 ;--- Get the HL7 protocol name
+24 SET RORPROT=$$GET1^DIQ(798.1,REGIEN_",",13,"E",,"RORMSG")
+25 if $GET(DIERR)
DO DBS^RORERR("RORMSG",-9,,,798.1,REGIEN_",")
+26 IF RORPROT=""
Begin DoDot:2
+27 DO ERROR^RORERR(-25,,REGNAME)
End DoDot:2
SET ERRCNT=ERRCNT+1
QUIT
+28 ;--- Create the reference
+29 SET PGRLST(RORPROT,REGNAME)=REGIEN
End DoDot:1
+30 ;
+31 ;=== Data extraction
+32 MERGE ROREXTSV=ROREXT
+33 SET RORPROT=""
SET RC=0
+34 FOR CNT=1:1
SET RORPROT=$ORDER(PGRLST(RORPROT))
if RORPROT=""
QUIT
Begin DoDot:1
+35 ;--- Prepare the task-specific parameters
+36 KILL RORGLST
MERGE RORGLST=PGRLST(RORPROT)
+37 SET ROREXT("HL7PROT")=RORPROT
+38 ;--- Single-task data extraction (if requested)
+39 IF ROREXT("FLAGS")["S"
Begin DoDot:2
+40 SET TMP=$$INTEXT^ROREXT01(.RORGLST)
+41 IF TMP<0
if TMP=-42
SET RC=TMP
SET ERRCNT=ERRCNT+1
+42 KILL ROREXT
MERGE ROREXT=ROREXTSV
End DoDot:2
QUIT
+43 ;--- Otherwise, start a separate task
+44 SET ZTRTN="TASK^ROREXT"
SET ZTIO=""
+45 SET ZTDTH=$$FMADD^XLFDT($$NOW^XLFDT,,,,(CNT-1)*30)
+46 SET ZTDESC="CCR Data Extraction ("_RORPROT_")"
+47 FOR TMP="ROREXT(","RORGLST(","RORPARM("
SET ZTSAVE(TMP)=""
+48 DO ^%ZTLOAD
+49 ;--- Log the action
+50 DO LOG^RORERR(-94,,,ZTSK)
End DoDot:1
if RC<0
QUIT
+51 ;
+52 ;=== Error processing
+53 QUIT $SELECT(RC<0:RC,ERRCNT>0:-43,1:0)
+54 ;
+55 ;***** ENTRY POINT FOR DATA EXTRACTION TASK
+56 ;
+57 ; ROREXT Data extraction descriptor
+58 ; RORGLST List of registry names and IENs
+59 ; RORPARM Task-wide constants and variables
+60 ;
TASK ;
+1 ; Default error location
NEW RORERRDL
+2 ; Error processing data
NEW RORERROR
+3 ;
+4 NEW RC,TMP
KILL ZTREQ
+5 ;--- Initialize the variables
+6 DO CLEAR^RORERR("TASK^ROREXT",1)
+7 ;--- Disable debug output (task has no output device)
+8 if $GET(RORPARM("DEBUG"))>1
SET RORPARM("DEBUG")=1
+9 ;--- Data extraction
+10 SET RC=$$INTEXT^ROREXT01(.RORGLST,ZTSK)
+11 ;--- Error processing and notifications
+12 if RC<0
SET ZTSTOP=1
+13 IF RC=-42
DO ALERT^RORUTL01(.RORGLST,-42)
QUIT
+14 if RC<0
DO ALERT^RORUTL01(.RORGLST,-43,,,,"data extraction")
+15 SET ZTREQ="@"
+16 QUIT