RORX013 ;HOIFO/SG - DIAGNOSIS CODES REPORT ;6/21/06 3:05pm
;;1.5;CLINICAL CASE REGISTRIES;**1,19,21,31,34**;Feb 17, 2006;Build 45
;
;******************************************************************************
;******************************************************************************
; --- ROUTINE MODIFICATION LOG ---
;
;PKG/PATCH DATE DEVELOPER MODIFICATION
;----------- ---------- ----------- ----------------------------------------
;ROR*1.5*19 FEB 2012 J SCOTT Support for ICD-10 Coding System.
;ROR*1.5*19 FEB 2012 J SCOTT Change entry point ICD9LST to ICDLST.
;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.
;ROR*1.5*34 SEP 2018 F TRAXLER Adding FUT_APPT and FUT_CLIN to HEADER
;******************************************************************************
;******************************************************************************
;
Q
;
;***** OUTPUTS THE REPORT HEADER
;
; PARTAG Reference (IEN) to the parent tag
;
; Return Values:
; <0 Error code
; >0 IEN of the HEADER element
;
;;ICDLST(#,CODE,DIAG,NP,NC)
;;PATIENTS(#,NAME,LAST4,DOD,ICN,PACT,PCP,FUT_APPT,FUT_CLIN,PTICDL(CODE,DIAG,DATE,SOURCE))^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
;;PATIENTS(#,NAME,LAST4,AGE,DOD,ICN,PACT,PCP,FUT_APPT,FUT_CLIN,PTICDL(CODE,DIAG,DATE,SOURCE))^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
;;PATIENTS(#,NAME,LAST4,DOB,DOD,ICN,PACT,PCP,FUT_APPT,FUT_CLIN,PTICDL(CODE,DIAG,DATE,SOURCE))^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^RORX013",HEADER)
Q $S(RC<0:RC,1:HEADER)
;
;
;***** COMPILES THE "DIAGNOSIS CODE" REPORT
; REPORT CODE: 013
;
; .RORTSK Task number and task parameters
;
; The ^TMP("VSIT",$J) global node is used by this function.
;
; @RORTMP@(
;
; "PAT", Number of patients
; DFN, Descriptor
; ^01: Las 4 digits of SSN
; ^02: Name
; ^03: Date of Death
; ^04: ICN
; ^05: Patient Care Team
; ^06: Primary Care Provider
; ^07: Age/DOB
; ^08: Future appt
; ^09: Future clinic
; ICDIEN, Earliest Code Descriptor
; ^01: Date
; ^02: Source ("I", "O", or "PB")
; "C") Quantity
; "I") Inpatient quantity
; "O") Outpatient quantity
; "PB") Problem List quantity
;
; "ICD", Totals
; ^01: Number of ICD codes
; ^02: Number of different codes
; ICDIEN, ICD Descriptor
; ^01: Code
; ^02: Diagnosis (current version)
; "C") Quantity
; "P") Number of unique patients
;
; Return Values:
; <0 Error code
; 0 Ok
;
ICDLST(RORTSK) ;
N ROREDT ; End date
N RORICDL ; Prepared list of ICD codes
N RORIGRP ; List of ICD groups
N RORREG ; Registry IEN
N RORSDT ; Start date
N RORTMP ; Closed root of the temporary buffer
;
N ECNT,RC,REPORT,SFLAGS,TMP
S RORICDL="",(ECNT,RC)=0
;--- Root node of the report
S REPORT=$$ADDVAL^RORTSK11(RORTSK,"REPORT")
Q:REPORT<0 REPORT
;
;--- Get and prepare the report parameters
S RORREG=$$PARAM^RORTSK01("REGIEN")
S RC=$$PARAMS(REPORT,.RORSDT,.ROREDT,.SFLAGS) Q:RC<0 RC
;
;--- Report header
S RC=$$HEADER(REPORT) Q:RC<0 RC
S RORTMP=$$ALLOC^RORTMP()
D
. ;--- Query the registry
. D TPPSETUP^RORTSK01(70)
. S RC=$$QUERY^RORX013A(SFLAGS)
. I RC Q:RC<0 S ECNT=ECNT+RC
. ;--- Sort the data
. D TPPSETUP^RORTSK01(10)
. S RC=$$SORT^RORX013A()
. I RC Q:RC<0 S ECNT=ECNT+RC
. ;--- Store the results
. D TPPSETUP^RORTSK01(20)
. S RC=$$STORE^RORX013C(REPORT)
. I RC Q:RC<0 S ECNT=ECNT+RC
;
;--- Cleanup
D FREE^RORTMP(RORTMP),FREE^RORTMP(RORICDL)
K ^TMP("VSIT",$J)
Q $S(RC<0:RC,ECNT>0:-43,1:0)
;
;***** 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
S PARAMS=$$PARAMS^RORXU002(.RORTSK,PARTAG,.STDT,.ENDT,.FLAGS)
Q:PARAMS<0 PARAMS
;--- Process the list of ICD codes
S TMP=$$ICDLST^RORXU008(.RORTSK,PARAMS,.RORICDL,.RORIGRP)
Q:TMP<0 TMP
;---
Q PARAMS
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORX013 5220 printed Feb 18, 2025@23:11 Page 2
RORX013 ;HOIFO/SG - DIAGNOSIS CODES REPORT ;6/21/06 3:05pm
+1 ;;1.5;CLINICAL CASE REGISTRIES;**1,19,21,31,34**;Feb 17, 2006;Build 45
+2 ;
+3 ;******************************************************************************
+4 ;******************************************************************************
+5 ; --- ROUTINE MODIFICATION LOG ---
+6 ;
+7 ;PKG/PATCH DATE DEVELOPER MODIFICATION
+8 ;----------- ---------- ----------- ----------------------------------------
+9 ;ROR*1.5*19 FEB 2012 J SCOTT Support for ICD-10 Coding System.
+10 ;ROR*1.5*19 FEB 2012 J SCOTT Change entry point ICD9LST to ICDLST.
+11 ;ROR*1.5*21 SEP 2013 T KOPP Add ICN column if Additional Identifier
+12 ; requested.
+13 ;ROR*1.5*31 MAY 2017 M FERRARESE Adding PACT ,PCP,and AGE/DOB as additional
+14 ; identifiers.
+15 ;ROR*1.5*34 SEP 2018 F TRAXLER Adding FUT_APPT and FUT_CLIN to HEADER
+16 ;******************************************************************************
+17 ;******************************************************************************
+18 ;
+19 QUIT
+20 ;
+21 ;***** OUTPUTS THE REPORT HEADER
+22 ;
+23 ; PARTAG Reference (IEN) to the parent tag
+24 ;
+25 ; Return Values:
+26 ; <0 Error code
+27 ; >0 IEN of the HEADER element
+28 ;
+1 ;;ICDLST(#,CODE,DIAG,NP,NC)
+2 ;;PATIENTS(#,NAME,LAST4,DOD,ICN,PACT,PCP,FUT_APPT,FUT_CLIN,PTICDL(CODE,DIAG,DATE,SOURCE))^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
+3 ;;PATIENTS(#,NAME,LAST4,AGE,DOD,ICN,PACT,PCP,FUT_APPT,FUT_CLIN,PTICDL(CODE,DIAG,DATE,SOURCE))^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
+4 ;;PATIENTS(#,NAME,LAST4,DOB,DOD,ICN,PACT,PCP,FUT_APPT,FUT_CLIN,PTICDL(CODE,DIAG,DATE,SOURCE))^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
+5 ;
+6 NEW HEADER,RC
+7 SET HEADER=$$HEADER^RORXU002(.RORTSK,PARTAG)
+8 if HEADER<0
QUIT HEADER
+9 SET RC=$$TBLDEF^RORXU002("HEADER^RORX013",HEADER)
+10 QUIT $SELECT(RC<0:RC,1:HEADER)
+11 ;
+12 ;
+13 ;***** COMPILES THE "DIAGNOSIS CODE" REPORT
+14 ; REPORT CODE: 013
+15 ;
+16 ; .RORTSK Task number and task parameters
+17 ;
+18 ; The ^TMP("VSIT",$J) global node is used by this function.
+19 ;
+20 ; @RORTMP@(
+21 ;
+22 ; "PAT", Number of patients
+23 ; DFN, Descriptor
+24 ; ^01: Las 4 digits of SSN
+25 ; ^02: Name
+26 ; ^03: Date of Death
+27 ; ^04: ICN
+28 ; ^05: Patient Care Team
+29 ; ^06: Primary Care Provider
+30 ; ^07: Age/DOB
+31 ; ^08: Future appt
+32 ; ^09: Future clinic
+33 ; ICDIEN, Earliest Code Descriptor
+34 ; ^01: Date
+35 ; ^02: Source ("I", "O", or "PB")
+36 ; "C") Quantity
+37 ; "I") Inpatient quantity
+38 ; "O") Outpatient quantity
+39 ; "PB") Problem List quantity
+40 ;
+41 ; "ICD", Totals
+42 ; ^01: Number of ICD codes
+43 ; ^02: Number of different codes
+44 ; ICDIEN, ICD Descriptor
+45 ; ^01: Code
+46 ; ^02: Diagnosis (current version)
+47 ; "C") Quantity
+48 ; "P") Number of unique patients
+49 ;
+50 ; Return Values:
+51 ; <0 Error code
+52 ; 0 Ok
+53 ;
ICDLST(RORTSK) ;
+1 ; End date
NEW ROREDT
+2 ; Prepared list of ICD codes
NEW RORICDL
+3 ; List of ICD groups
NEW RORIGRP
+4 ; Registry IEN
NEW RORREG
+5 ; Start date
NEW RORSDT
+6 ; Closed root of the temporary buffer
NEW RORTMP
+7 ;
+8 NEW ECNT,RC,REPORT,SFLAGS,TMP
+9 SET RORICDL=""
SET (ECNT,RC)=0
+10 ;--- Root node of the report
+11 SET REPORT=$$ADDVAL^RORTSK11(RORTSK,"REPORT")
+12 if REPORT<0
QUIT REPORT
+13 ;
+14 ;--- Get and prepare the report parameters
+15 SET RORREG=$$PARAM^RORTSK01("REGIEN")
+16 SET RC=$$PARAMS(REPORT,.RORSDT,.ROREDT,.SFLAGS)
if RC<0
QUIT RC
+17 ;
+18 ;--- Report header
+19 SET RC=$$HEADER(REPORT)
if RC<0
QUIT RC
+20 SET RORTMP=$$ALLOC^RORTMP()
+21 Begin DoDot:1
+22 ;--- Query the registry
+23 DO TPPSETUP^RORTSK01(70)
+24 SET RC=$$QUERY^RORX013A(SFLAGS)
+25 IF RC
if RC<0
QUIT
SET ECNT=ECNT+RC
+26 ;--- Sort the data
+27 DO TPPSETUP^RORTSK01(10)
+28 SET RC=$$SORT^RORX013A()
+29 IF RC
if RC<0
QUIT
SET ECNT=ECNT+RC
+30 ;--- Store the results
+31 DO TPPSETUP^RORTSK01(20)
+32 SET RC=$$STORE^RORX013C(REPORT)
+33 IF RC
if RC<0
QUIT
SET ECNT=ECNT+RC
End DoDot:1
+34 ;
+35 ;--- Cleanup
+36 DO FREE^RORTMP(RORTMP)
DO FREE^RORTMP(RORICDL)
+37 KILL ^TMP("VSIT",$JOB)
+38 QUIT $SELECT(RC<0:RC,ECNT>0:-43,1:0)
+39 ;
+40 ;***** OUTPUTS THE PARAMETERS TO THE REPORT
+41 ;
+42 ; PARTAG Reference (IEN) to the parent tag
+43 ;
+44 ; [.STDT] Start and end dates of the report
+45 ; [.ENDT] are returned via these parameters
+46 ;
+47 ; [.FLAGS] Flags for the $$SKIP^RORXU005 are
+48 ; returned via this parameter
+49 ;
+50 ; Return Values:
+51 ; <0 Error code
+52 ; >0 IEN of the PARAMETERS element
+53 ;
PARAMS(PARTAG,STDT,ENDT,FLAGS) ;
+1 NEW PARAMS,TMP
+2 SET PARAMS=$$PARAMS^RORXU002(.RORTSK,PARTAG,.STDT,.ENDT,.FLAGS)
+3 if PARAMS<0
QUIT PARAMS
+4 ;--- Process the list of ICD codes
+5 SET TMP=$$ICDLST^RORXU008(.RORTSK,PARAMS,.RORICDL,.RORIGRP)
+6 if TMP<0
QUIT TMP
+7 ;---
+8 QUIT PARAMS