RORX022 ;BPOIFO/CLR - LAB DAA MONITOR REPORT ;4/9/09 9:40am
;;1.5;CLINICAL CASE REGISTRIES;**17,21,31**;Feb 17, 2006;Build 62
;
;******************************************************************************
;******************************************************************************
; --- ROUTINE MODIFICATION LOG ---
;
;PKG/PATCH DATE DEVELOPER MODIFICATION
;----------- ---------- ----------- ----------------------------------------
;ROR*1.5*21 SEP 2013 T KOPP Add ICN column if Additional Identifier
; requested.
;ROR*1.5*31 MAY 2017 M FERRARESE Adding PACT ,PCP,and AGE/DOB as additional
; identifiers.
;******************************************************************************
;******************************************************************************
;
Q
;
;***** OUTPUTS THE REPORT HEADER
;
; PARTAG Reference (IEN) to the parent tag
;
; Return Values:
; <0 Error code
; >0 IEN of the HEADER element
;
;;DRUGS(#,NAME,LAST4,DAA_FILL,FILL_DATE,RXNAME,DAYSPLY)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
;;DRUGS(#,NAME,LAST4,AGE,DAA_FILL,FILL_DATE,RXNAME,DAYSPLY)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
;;DRUGS(#,NAME,LAST4,DOB,DAA_FILL,FILL_DATE,RXNAME,DAYSPLY)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
;;LABTESTS(#,NAME,LAST4,DAA_FILL,DATE,LTNAME,RESULT,WKS_LAB)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
;;LABTESTS(#,NAME,LAST4,AGE,DAA_FILL,DATE,LTNAME,RESULT,WKS_LAB)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
;;LABTESTS(#,NAME,LAST4,DOB,DAA_FILL,DATE,LTNAME,RESULT,WKS_LAB)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
;;PATIENTS(#,NAME,LAST4,ICN,PACT,PCP)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
;;PATIENTS(#,NAME,LAST4,AGE,ICN,PACT,PCP)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
;;PATIENTS(#,NAME,LAST4,DOB,ICN,PACT,PCP)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
;
N HEADER,RC
S HEADER=$$HEADER^RORXU002(.RORTSK,PARTAG)
Q:HEADER<0 HEADER
S RC=$$TBLDEF^RORXU002("HEADER^RORX022",HEADER)
Q $S(RC<0:RC,1:HEADER)
;
;***** OUTPUTS THE PARAMETERS TO THE REPORT
;
; PARTAG Reference (IEN) to the parent tag
;
; [.STDT] Start and end dates of the report
; [.ENDT] are returned via these parameters
;
; [.FLAGS] Flags for the $$SKIP^RORXU005 are
; returned via this parameter
;
; Return Values:
; <0 Error code
; >0 IEN of the PARAMETERS element
;
PARAMS(PARTAG,STDT,ENDT,FLAGS) ;
N PARAMS,TMP,ELEMENT
S PARAMS=$$PARAMS^RORXU002(.RORTSK,PARTAG,.STDT,.ENDT,.FLAGS)
Q:PARAMS<0 PARAMS
;report specific parameters
S ELEMENT=$$ADDVAL^RORTSK11(RORTSK,"WEEKS_AFTER",$$PARAM^RORTSK01("WEEKS_AFTER"),PARAMS)
Q:ELEMENT<0 ELEMENT
I $$PARAM^RORTSK01("WEEKS_AFTER","MOST_RECENT") D
. D ADDATTR^RORTSK11(RORTSK,ELEMENT,"MOST_RECENT",$$PARAM^RORTSK01("WEEKS_AFTER","MOST_RECENT"))
;--- Process the list of Lab tests
D Q:TMP<0 TMP
. S TMP=$$LTLST^RORXU006(.RORTSK,PARAMS,.RORLTST,"RORLTRV")
Q PARAMS
;
;
;***** COMPILES THE "DAA LAB MONITOR" REPORT
; REPORT CODE: 022
;
;INPUT
; .RORTSK Task number and task parameters
;
; Below is a sample RORTSK input array for utilization in 2003, most recent
; scores, BMI range from 30 to 45:
;
; RORTSK=nnn (task number)
; RORTSK("EP")="$$DAAMON^RORX022"
; RORTSK("PARAMS","DATE_RANGE_3","A","END")=3031231
; RORTSK("PARAMS","DATE_RANGE_3","A","START")=3030101
; RORTSK("PARAMS","ICD9FILT","A","FILTER")="ALL"
; RORTSK("PARAMS","LRGRANGES","C",1)=""
; RORTSK("PARAMS","LRGRANGES","C",1,"H")=45
; RORTSK("PARAMS","LRGRANGES","C",1,"L")=30
; RORTSK("PARAMS","OPTIONS","A","COMPLETE")=1
; RORTSK("PARAMS","OPTIONS","A","MOST_RECENT")=1
; RORTSK("PARAMS","PATIENTS","A","DE_AFTER")=1
; RORTSK("PARAMS","PATIENTS","A","DE_BEFORE")=1
; RORTSK("PARAMS","PATIENTS","A","DE_DURING")=1
; RORTSK("PARAMS","REGIEN")=1
;
; If the user selected an 'as of' date = 12/31/2005:
; RORTSK("PARAMS","OPTIONS","A","MOST_RECENT")=1
; is replaced with:
; RORTSK("PARAMS","OPTIONS","A","MAX_DATE")=3051231
;
;
; The ^TMP("RORX022",$J) global node is used by this function.
;
; ^TMP("RORX022",$J,
; "PAT",
; DFN, Patient descriptor
; ^01: Last 4 digits of SSN
; ^02: Patient name
; ^03: Date of 1st DAA fill
; ^04: National ICN
; ^05: Age/DOB
; "LR",
; TestName,
; TestIEN
; Inv Date) Result
; ^01: Test result
; ^02: # wks since 1st DAA fill
; "RX",
; Inv Date,
; DrugName,
; DrugIEN,
; RX#,
; Index)Days Supply
; ^05:Days Supply
;
; Return Values:
; <0 Error code
; 0 Ok
;
DAAMON(RORTSK) ;
N RORLTST ; Closed root of the list of lab tests for the
; ; Lab search API
N RORLTRV ; Closed root of the list of lab tests with ranges
N RORREG ; Registry IEN
N RORXEDT ; Pharmacy end date
N RORXL ; Closed root of the drug list for the pharmacy
; ; search API or "*" if all drugs were selected
N RORXSDT ; Pharmacy start date
N LTMREC ; Baseline result request
;
N ECNT,NSPT,RC,REPORT,SFLAGS,TMP
S (RORXL,RORLTST)="",(ECNT,RC)=0
K ^TMP("RORX022",$J)
;--- Root node of the report
S REPORT=$$ADDVAL^RORTSK11(RORTSK,"REPORT")
Q:REPORT<0 REPORT
;
D
. ;--- Get and prepare the report parameters
. S RORREG=$$PARAM^RORTSK01("REGIEN") ; Registry IEN
. S RC=$$PARAMS(REPORT,.RORXSDT,.RORXEDT,.SFLAGS) Q:RC<0
. ;--- Report header
. S RC=$$HEADER(REPORT) Q:RC<0
. ;--- Query the registry
. D TPPSETUP^RORTSK01(80)
. S RC=$$QUERY^RORX022A(SFLAGS,.RORTSK,.NSPT)
. I RC Q:RC<0 S ECNT=ECNT+RC
. ;--- Store the results
. D TPPSETUP^RORTSK01(20)
. S RC=$$STORE^RORX022A(REPORT,.RORTSK,NSPT)
. I RC Q:RC<0 S ECNT=ECNT+RC
;
K ^TMP("RORX022",$J)
D FREE^RORTMP(RORLTST)
;
Q $S(RC<0:RC,ECNT>0:-43,1:0)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORX022 6436 printed Nov 22, 2024@16:55:10 Page 2
RORX022 ;BPOIFO/CLR - LAB DAA MONITOR REPORT ;4/9/09 9:40am
+1 ;;1.5;CLINICAL CASE REGISTRIES;**17,21,31**;Feb 17, 2006;Build 62
+2 ;
+3 ;******************************************************************************
+4 ;******************************************************************************
+5 ; --- ROUTINE MODIFICATION LOG ---
+6 ;
+7 ;PKG/PATCH DATE DEVELOPER MODIFICATION
+8 ;----------- ---------- ----------- ----------------------------------------
+9 ;ROR*1.5*21 SEP 2013 T KOPP Add ICN column if Additional Identifier
+10 ; requested.
+11 ;ROR*1.5*31 MAY 2017 M FERRARESE Adding PACT ,PCP,and AGE/DOB as additional
+12 ; identifiers.
+13 ;******************************************************************************
+14 ;******************************************************************************
+15 ;
+16 QUIT
+17 ;
+18 ;***** OUTPUTS THE REPORT HEADER
+19 ;
+20 ; PARTAG Reference (IEN) to the parent tag
+21 ;
+22 ; Return Values:
+23 ; <0 Error code
+24 ; >0 IEN of the HEADER element
+25 ;
+1 ;;DRUGS(#,NAME,LAST4,DAA_FILL,FILL_DATE,RXNAME,DAYSPLY)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
+2 ;;DRUGS(#,NAME,LAST4,AGE,DAA_FILL,FILL_DATE,RXNAME,DAYSPLY)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
+3 ;;DRUGS(#,NAME,LAST4,DOB,DAA_FILL,FILL_DATE,RXNAME,DAYSPLY)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
+4 ;;LABTESTS(#,NAME,LAST4,DAA_FILL,DATE,LTNAME,RESULT,WKS_LAB)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
+5 ;;LABTESTS(#,NAME,LAST4,AGE,DAA_FILL,DATE,LTNAME,RESULT,WKS_LAB)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
+6 ;;LABTESTS(#,NAME,LAST4,DOB,DAA_FILL,DATE,LTNAME,RESULT,WKS_LAB)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
+7 ;;PATIENTS(#,NAME,LAST4,ICN,PACT,PCP)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
+8 ;;PATIENTS(#,NAME,LAST4,AGE,ICN,PACT,PCP)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
+9 ;;PATIENTS(#,NAME,LAST4,DOB,ICN,PACT,PCP)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
+10 ;
+11 NEW HEADER,RC
+12 SET HEADER=$$HEADER^RORXU002(.RORTSK,PARTAG)
+13 if HEADER<0
QUIT HEADER
+14 SET RC=$$TBLDEF^RORXU002("HEADER^RORX022",HEADER)
+15 QUIT $SELECT(RC<0:RC,1:HEADER)
+16 ;
+17 ;***** OUTPUTS THE PARAMETERS TO THE REPORT
+18 ;
+19 ; PARTAG Reference (IEN) to the parent tag
+20 ;
+21 ; [.STDT] Start and end dates of the report
+22 ; [.ENDT] are returned via these parameters
+23 ;
+24 ; [.FLAGS] Flags for the $$SKIP^RORXU005 are
+25 ; returned via this parameter
+26 ;
+27 ; Return Values:
+28 ; <0 Error code
+29 ; >0 IEN of the PARAMETERS element
+30 ;
PARAMS(PARTAG,STDT,ENDT,FLAGS) ;
+1 NEW PARAMS,TMP,ELEMENT
+2 SET PARAMS=$$PARAMS^RORXU002(.RORTSK,PARTAG,.STDT,.ENDT,.FLAGS)
+3 if PARAMS<0
QUIT PARAMS
+4 ;report specific parameters
+5 SET ELEMENT=$$ADDVAL^RORTSK11(RORTSK,"WEEKS_AFTER",$$PARAM^RORTSK01("WEEKS_AFTER"),PARAMS)
+6 if ELEMENT<0
QUIT ELEMENT
+7 IF $$PARAM^RORTSK01("WEEKS_AFTER","MOST_RECENT")
Begin DoDot:1
+8 DO ADDATTR^RORTSK11(RORTSK,ELEMENT,"MOST_RECENT",$$PARAM^RORTSK01("WEEKS_AFTER","MOST_RECENT"))
End DoDot:1
+9 ;--- Process the list of Lab tests
+10 Begin DoDot:1
+11 SET TMP=$$LTLST^RORXU006(.RORTSK,PARAMS,.RORLTST,"RORLTRV")
End DoDot:1
if TMP<0
QUIT TMP
+12 QUIT PARAMS
+13 ;
+14 ;
+15 ;***** COMPILES THE "DAA LAB MONITOR" REPORT
+16 ; REPORT CODE: 022
+17 ;
+18 ;INPUT
+19 ; .RORTSK Task number and task parameters
+20 ;
+21 ; Below is a sample RORTSK input array for utilization in 2003, most recent
+22 ; scores, BMI range from 30 to 45:
+23 ;
+24 ; RORTSK=nnn (task number)
+25 ; RORTSK("EP")="$$DAAMON^RORX022"
+26 ; RORTSK("PARAMS","DATE_RANGE_3","A","END")=3031231
+27 ; RORTSK("PARAMS","DATE_RANGE_3","A","START")=3030101
+28 ; RORTSK("PARAMS","ICD9FILT","A","FILTER")="ALL"
+29 ; RORTSK("PARAMS","LRGRANGES","C",1)=""
+30 ; RORTSK("PARAMS","LRGRANGES","C",1,"H")=45
+31 ; RORTSK("PARAMS","LRGRANGES","C",1,"L")=30
+32 ; RORTSK("PARAMS","OPTIONS","A","COMPLETE")=1
+33 ; RORTSK("PARAMS","OPTIONS","A","MOST_RECENT")=1
+34 ; RORTSK("PARAMS","PATIENTS","A","DE_AFTER")=1
+35 ; RORTSK("PARAMS","PATIENTS","A","DE_BEFORE")=1
+36 ; RORTSK("PARAMS","PATIENTS","A","DE_DURING")=1
+37 ; RORTSK("PARAMS","REGIEN")=1
+38 ;
+39 ; If the user selected an 'as of' date = 12/31/2005:
+40 ; RORTSK("PARAMS","OPTIONS","A","MOST_RECENT")=1
+41 ; is replaced with:
+42 ; RORTSK("PARAMS","OPTIONS","A","MAX_DATE")=3051231
+43 ;
+44 ;
+45 ; The ^TMP("RORX022",$J) global node is used by this function.
+46 ;
+47 ; ^TMP("RORX022",$J,
+48 ; "PAT",
+49 ; DFN, Patient descriptor
+50 ; ^01: Last 4 digits of SSN
+51 ; ^02: Patient name
+52 ; ^03: Date of 1st DAA fill
+53 ; ^04: National ICN
+54 ; ^05: Age/DOB
+55 ; "LR",
+56 ; TestName,
+57 ; TestIEN
+58 ; Inv Date) Result
+59 ; ^01: Test result
+60 ; ^02: # wks since 1st DAA fill
+61 ; "RX",
+62 ; Inv Date,
+63 ; DrugName,
+64 ; DrugIEN,
+65 ; RX#,
+66 ; Index)Days Supply
+67 ; ^05:Days Supply
+68 ;
+69 ; Return Values:
+70 ; <0 Error code
+71 ; 0 Ok
+72 ;
DAAMON(RORTSK) ;
+1 ; Closed root of the list of lab tests for the
NEW RORLTST
+2 ; ; Lab search API
+3 ; Closed root of the list of lab tests with ranges
NEW RORLTRV
+4 ; Registry IEN
NEW RORREG
+5 ; Pharmacy end date
NEW RORXEDT
+6 ; Closed root of the drug list for the pharmacy
NEW RORXL
+7 ; ; search API or "*" if all drugs were selected
+8 ; Pharmacy start date
NEW RORXSDT
+9 ; Baseline result request
NEW LTMREC
+10 ;
+11 NEW ECNT,NSPT,RC,REPORT,SFLAGS,TMP
+12 SET (RORXL,RORLTST)=""
SET (ECNT,RC)=0
+13 KILL ^TMP("RORX022",$JOB)
+14 ;--- Root node of the report
+15 SET REPORT=$$ADDVAL^RORTSK11(RORTSK,"REPORT")
+16 if REPORT<0
QUIT REPORT
+17 ;
+18 Begin DoDot:1
+19 ;--- Get and prepare the report parameters
+20 ; Registry IEN
SET RORREG=$$PARAM^RORTSK01("REGIEN")
+21 SET RC=$$PARAMS(REPORT,.RORXSDT,.RORXEDT,.SFLAGS)
if RC<0
QUIT
+22 ;--- Report header
+23 SET RC=$$HEADER(REPORT)
if RC<0
QUIT
+24 ;--- Query the registry
+25 DO TPPSETUP^RORTSK01(80)
+26 SET RC=$$QUERY^RORX022A(SFLAGS,.RORTSK,.NSPT)
+27 IF RC
if RC<0
QUIT
SET ECNT=ECNT+RC
+28 ;--- Store the results
+29 DO TPPSETUP^RORTSK01(20)
+30 SET RC=$$STORE^RORX022A(REPORT,.RORTSK,NSPT)
+31 IF RC
if RC<0
QUIT
SET ECNT=ECNT+RC
End DoDot:1
+32 ;
+33 KILL ^TMP("RORX022",$JOB)
+34 DO FREE^RORTMP(RORLTST)
+35 ;
+36 QUIT $SELECT(RC<0:RC,ECNT>0:-43,1:0)