RORX020A ;BPOIFO/ACS - RENAL FUNCTION BY RANGE (CONT.) ;5/20/11 12:11pm
;;1.5;CLINICAL CASE REGISTRIES;**10,14,15,21,31,33**;Feb 17, 2006;Build 81
;
Q
;******************************************************************************
;******************************************************************************
; --- ROUTINE MODIFICATION LOG ---
;
;PKG/PATCH DATE DEVELOPER MODIFICATION
;----------- ---------- ----------- ----------------------------------------
;ROR*1.5*14 APR 2011 A SAUNDERS HEADER: Added LOINCs to report header
;ROR*1.5*21 SEP 2013 T KOPP Added ICN as last report column if
; additional identifier option selected
;ROR*1.5*31 MAY 2017 M FERRARESE Adding PACT ,PCP,and AGE/DOB as additional
; identifiers.
;ROR*1.5*33 APR 2018 F TRAXLER Add FUT_APPT column if requested
;******************************************************************************
;******************************************************************************
;
;************************************************************************
;ADD THE HEADERS TO THE REPORT (EXTRINSIC FUNCTION)
;
;INPUT
; PARTAG Reference IEN to the 'report' parent XML tag
;
;OUTPUT
; <0 error
; >0 'Header' XML tag number or error code
;************************************************************************
N HEADER,RC,COL,COLUMNS,TMP S RC=0
;call to $$HEADER^RORXU002 will populate the report created date, task number,
;last registry update, and last data extraction.
S HEADER=$$HEADER^RORXU002(.RORTSK,PARTAG)
Q:HEADER<0 HEADER
;manually build the table definition(s) listed below
;PATIENTS(#,NAME,LAST4,AGE,DOD,TEST,DATE,RESULT,CRCL,EGFR)
S COLUMNS=$$ADDVAL^RORTSK11(RORTSK,"TBLDEF",,HEADER)
D ADDATTR^RORTSK11(RORTSK,COLUMNS,"NAME","PATIENTS")
D ADDATTR^RORTSK11(RORTSK,COLUMNS,"HEADER","1")
D ADDATTR^RORTSK11(RORTSK,COLUMNS,"FOOTER","1")
;--- Required columns
S AGETYPE=$$PARAM^RORTSK01("AGE_RANGE","TYPE") ; do not list Age if the selection is to list ALL ages
F COL="#","NAME","LAST4",AGETYPE,"DOD","TEST","DATE","RESULT" D
. Q:COL="ALL"
. S TMP=$$ADDVAL^RORTSK11(RORTSK,"COLUMN",,COLUMNS)
. D ADDATTR^RORTSK11(RORTSK,TMP,"NAME",COL)
;--- Additional columns
I RORDATA("IDLST")[1 D
. S TMP=$$ADDVAL^RORTSK11(RORTSK,"COLUMN",,COLUMNS)
. D ADDATTR^RORTSK11(RORTSK,TMP,"NAME","CRCL")
I RORDATA("IDLST")[2 D
. S TMP=$$ADDVAL^RORTSK11(RORTSK,"COLUMN",,COLUMNS)
. D ADDATTR^RORTSK11(RORTSK,TMP,"NAME","MDRD")
I RORDATA("IDLST")[3 D
. S TMP=$$ADDVAL^RORTSK11(RORTSK,"COLUMN",,COLUMNS)
. D ADDATTR^RORTSK11(RORTSK,TMP,"NAME","CKD")
;--- LOINC codes
N LTAG S LTAG=$$ADDVAL^RORTSK11(RORTSK,"LOINC_CODES",,PARTAG)
N CTAG S CTAG=$$ADDVAL^RORTSK11(RORTSK,"CODE",,LTAG)
D ADDATTR^RORTSK11(RORTSK,CTAG,"CODE","Creatinine: 15045-8, 21232-4, 2160-0")
;--- ICN
I $$PARAM^RORTSK01("PATIENTS","ICN") D ICNHDR^RORXU006(RORTSK,COLUMNS)
;--- PACT
I $$PARAM^RORTSK01("PATIENTS","PACT") D PACTHDR^RORXU006(RORTSK,COLUMNS)
;--- PCP
I $$PARAM^RORTSK01("PATIENTS","PCP") D PCPHDR^RORXU006(RORTSK,COLUMNS)
;--- Future Appt. PATCH 33
I $$PARAM^RORTSK01("OPTIONS","FUT_APPT") D APPTHDR^RORXU006(RORTSK,COLUMNS)
;---
Q $S(RC<0:RC,1:HEADER)
;
;*****************************************************************************
;INITIALIZE THE RANGE COUNTS TO 0
;
;INPUT
; RORDATA Array with ROR data
; RORDATA("RCNT") Number of ranges/groupings to initialize
;*****************************************************************************
INIT(RORDATA) ;
I $G(RORDATA("RCNT"))="" Q
N I
F I=1:1:RORDATA("RCNT") D
.I RORDATA("IDLST")[2 S RORDATA("NPMDRD",I)=0
.I RORDATA("IDLST")[3 S RORDATA("NPCKD",I)=0
Q
;
;*****************************************************************************
;OUTPUT REPORT 'RANGE' PARAMETERS, SET UP REPORT ID LIST (EXTRINISIC FUNCTION)
;
; PARTAG Reference (IEN) to the parent tag
;
; Return Values:
; RORDATA("IDLST") - list of IDs for tests requested
; RORDATA("RANGE") - 1 if range passed in for either test, else 0
; <0 Error code
; 0 Ok
;*****************************************************************************
PARAMS(PARTAG,RORDATA) ;
N PARAMS,DESC,TMP,RC,RANGE S RC=0
S RORDATA("RANGE")=0 ;initialize to 'no range passed in'
;--- Lab test ranges
I $D(RORTSK("PARAMS","LRGRANGES","C"))>1 D Q:RC<0 RC
. N GRC,ELEMENT,NODE,RTAG,RANGE
. S NODE=$NA(RORTSK("PARAMS","LRGRANGES","C"))
. S RTAG=$$ADDVAL^RORTSK11(RORTSK,"LRGRANGES",,PARTAG)
. S (GRC,RC)=0
. F S GRC=$O(@NODE@(GRC)) Q:GRC'>0 D Q:RC<0
. . S RANGE=0,DESC=$$RTEXT(GRC,.RORDATA)
. . S ELEMENT=$$ADDVAL^RORTSK11(RORTSK,"LRGRANGE",DESC,RTAG)
. . I ELEMENT<0 S RC=ELEMENT Q
. . D ADDATTR^RORTSK11(RORTSK,ELEMENT,"ID",GRC)
. . ;add the user-requested test ID to the test ID 'list'
. . S RORDATA("IDLST")=$G(RORDATA("IDLST"))_$S($G(RORDATA("IDLST"))'="":","_GRC,1:GRC)
. . ;--- Process the range values
. . S TMP=$G(@NODE@(GRC,"L"))
. . I TMP'="" D S RANGE=1
. . . D ADDATTR^RORTSK11(RORTSK,ELEMENT,"LOW",TMP)
. . S TMP=$G(@NODE@(GRC,"H"))
. . I TMP'="" D S RANGE=1
. . . D ADDATTR^RORTSK11(RORTSK,ELEMENT,"HIGH",TMP)
. . I RANGE D
. . . D ADDATTR^RORTSK11(RORTSK,ELEMENT,"RANGE",1)
. . . S RORDATA("RANGE")=1
;--- Success
;if user didn't select any tests, default to both tests
I $G(RORDATA("IDLST"))="" S RORDATA("IDLST")="1,2,3"
Q RC
;
;*****************************************************************************
;RETURN RANGE TEXT AND ADD RANGE VALUES TO RORDATA (EXTRINISIC FUNCTION)
;ID=1: MELD
;ID=2: MELD-Na
;
;INPUT:
; GRC Test ID number
; RORDATA - Array with ROR data
;
;OUTPUT:
; RORDATA("L",ID) - test ID low range
; RORDATA("H",ID) - test ID high range
; Description - <range>
;*****************************************************************************
RTEXT(GRC,RORDATA) ;
N RANGE,TMP
S RANGE=""
;--- Range
I $D(RORTSK("PARAMS","LRGRANGES","C",GRC))>1 D
. ;--- Low
. S TMP=$G(RORTSK("PARAMS","LRGRANGES","C",GRC,"L"))
. S RORDATA("L",GRC)=$G(TMP)
. S:TMP'="" RANGE=RANGE_" not less than "_TMP
. ;--- High
. S TMP=$G(RORTSK("PARAMS","LRGRANGES","C",GRC,"H"))
. S RORDATA("H",GRC)=$G(TMP)
. I TMP'="" D:RANGE'="" S RANGE=RANGE_" not greater than "_TMP
. . S RANGE=RANGE_" and"
;--- Description
S TMP=$G(RORTSK("PARAMS","LRGRANGES","C",GRC))
S:TMP="" TMP="Unknown ("_GRC_")"
Q TMP_" - "_$S(RANGE'="":"numeric results"_RANGE,1:"all results")
;
;************************************************************************
;DETERMINE IF THE SCORES ARE WITHIN THE REQUESTED RANGES (EXTRINSIC FUNCTION)
;If not in the range, exclude from report
;
;INPUT:
; RORDATA RORDATA("SCORE",I) contains computed test score for test ID 'I'
;
;OUTPUT:
; 1 include on report
; 0 exclude from report
;************************************************************************
INRANGE(RORDATA) ;
;if range exists for either test, and any result is considered 'invalid',
;then skip the range check and exclude data from report
;I $G(RORDATA("RANGE")),'$G(RORDATA("CALC")) Q 0
;if range does not exist for either test, and any result is considered 'invalid',
;then skip the range check and include data in the report
I '$G(RORDATA("RANGE")),'$G(RORDATA("CALC")) Q 1
;
;---Range Check
N I,RETURN S RETURN=1 ;default is set to 'within range'
S I=0 F S I=$O(RORDATA("SCORE",I)) Q:I="" D
. I $G(RORDATA("L",I))'="" D
.. ;if score is less than 'low' range, do not include on report
.. I $G(RORDATA("SCORE",I))<RORDATA("L",I) S RETURN=0
. I $G(RORDATA("H",I))'="" D
.. ;if score is higher than 'high' range, do not include on report
.. I $G(RORDATA("SCORE",I))>RORDATA("H",I) S RETURN=0
;
Q RETURN
;
;************************************************************************
;ADD 1 TO APPROPRIATE eGFR CATEGORY
;
;INPUT
; RORDATA Array with ROR data
;************************************************************************
MDRDCAT(RORDATA) ;
I '$G(RORDATA("SCORE",2)) Q ;quit if no score was calculated
I $G(RORDATA("SCORE",2))>89 S RORDATA("NPMDRD",1)=$G(RORDATA("NPMDRD",1))+1 Q
I $G(RORDATA("SCORE",2))>59 S RORDATA("NPMDRD",2)=$G(RORDATA("NPMDRD",2))+1 Q
I $G(RORDATA("SCORE",2))>29 S RORDATA("NPMDRD",3)=$G(RORDATA("NPMDRD",3))+1 Q
I $G(RORDATA("SCORE",2))>14 S RORDATA("NPMDRD",4)=$G(RORDATA("NPMDRD",4))+1 Q
S RORDATA("NPMDRD",5)=$G(RORDATA("NPMDRD",5))+1 Q
Q
;
;************************************************************************
;ADD 1 TO APPROPRIATE eGFR CATEGORY
;
;INPUT
; RORDATA Array with ROR data
;************************************************************************
CKDCAT(RORDATA) ;
I '$G(RORDATA("SCORE",3)) Q ;quit if no score was calculated
I $G(RORDATA("SCORE",3))>89 S RORDATA("NPCKD",1)=$G(RORDATA("NPCKD",1))+1 Q
I $G(RORDATA("SCORE",3))>59 S RORDATA("NPCKD",2)=$G(RORDATA("NPCKD",2))+1 Q
I $G(RORDATA("SCORE",3))>29 S RORDATA("NPCKD",3)=$G(RORDATA("NPCKD",3))+1 Q
I $G(RORDATA("SCORE",3))>14 S RORDATA("NPCKD",4)=$G(RORDATA("NPCKD",4))+1 Q
S RORDATA("NPCKD",5)=$G(RORDATA("NPCKD",5))+1 Q
Q
;*****************************************************************************
;ADD SUMMARY DATA TO THE REPORT (EXTRINSIC FUNCTION)
;
;INPUT
; RORTSK Task number and task parameters
; REPORT 'Report' XML tag number
; RORDATA Array with summary data:
; RORDATA("NP",1) - total count of patients in 1st range
; RORDATA("NP",2) - total count of patients in 2nd range
; RORDATA("NP",3) - total count of patients in 3rd range
; RORDATA("NP",4) - total count of patients in 4th range
; RORDATA("NP",5) - total count of patients in 5th range
;
;OUTPUT
; STAG XML 'summary' tag number or error code
;*****************************************************************************
SUMMARY(RORTSK,REPORT,RORDATA) ; Add the summary values to the report
N SUMMARY,I,STAG,RORTAG,RORNAME,RORRANGE
S SUMMARY=$$ADDVAL^RORTSK11(RORTSK,"SUMMARY",,REPORT)
Q:SUMMARY<0 SUMMARY
;add data for the summary entries
F I=1:1:RORDATA("RCNT") D Q:STAG<0
. S STAG=$$ADDVAL^RORTSK11(RORTSK,"DATA",,SUMMARY)
. Q:STAG<0
. ;get each value
. S RORTAG="S"_I S RORNAME=$P($T(@RORTAG),";;",2)
. S RORRANGE=$P($T(@RORTAG),";;",3)
. D ADDVAL^RORTSK11(RORTSK,"DESC",$G(RORNAME),STAG) ;severity
. D ADDVAL^RORTSK11(RORTSK,"VALUES",$G(RORRANGE),STAG) ;range
. D ADDVAL^RORTSK11(RORTSK,"NPMDRD",$G(RORDATA("NPMDRD",I)),STAG) ;count
. D ADDVAL^RORTSK11(RORTSK,"NPCKD",$G(RORDATA("NPCKD",I)),STAG) ;count
Q STAG
;************************************************************************
;eGFR by MDRD Categories and Values for the summary table.
;NOTE: the number of entries below must match the value of RORDATA("RCNT")
;************************************************************************
S1 ;;Normal or CKD1;;>=90 mL/min/1.73m
S2 ;;CKD2 (Mild);;60-89 mL/min/1.73m
S3 ;;CKD3 (Moderate);;30-59 mL/min/1.73m
S4 ;;CKD4 (Severe);;15-29 mL/min/1.73m
S5 ;;CKD5 (Kidney failure);;<15 mL/min/1.73m
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORX020A 11435 printed Nov 22, 2024@16:55:06 Page 2
RORX020A ;BPOIFO/ACS - RENAL FUNCTION BY RANGE (CONT.) ;5/20/11 12:11pm
+1 ;;1.5;CLINICAL CASE REGISTRIES;**10,14,15,21,31,33**;Feb 17, 2006;Build 81
+2 ;
+3 QUIT
+4 ;******************************************************************************
+5 ;******************************************************************************
+6 ; --- ROUTINE MODIFICATION LOG ---
+7 ;
+8 ;PKG/PATCH DATE DEVELOPER MODIFICATION
+9 ;----------- ---------- ----------- ----------------------------------------
+10 ;ROR*1.5*14 APR 2011 A SAUNDERS HEADER: Added LOINCs to report header
+11 ;ROR*1.5*21 SEP 2013 T KOPP Added ICN as last report column if
+12 ; additional identifier option selected
+13 ;ROR*1.5*31 MAY 2017 M FERRARESE Adding PACT ,PCP,and AGE/DOB as additional
+14 ; identifiers.
+15 ;ROR*1.5*33 APR 2018 F TRAXLER Add FUT_APPT column if requested
+16 ;******************************************************************************
+17 ;******************************************************************************
+18 ;
+19 ;************************************************************************
+20 ;ADD THE HEADERS TO THE REPORT (EXTRINSIC FUNCTION)
+21 ;
+22 ;INPUT
+23 ; PARTAG Reference IEN to the 'report' parent XML tag
+24 ;
+25 ;OUTPUT
+26 ; <0 error
+27 ; >0 'Header' XML tag number or error code
+28 ;************************************************************************
+1 NEW HEADER,RC,COL,COLUMNS,TMP
SET RC=0
+2 ;call to $$HEADER^RORXU002 will populate the report created date, task number,
+3 ;last registry update, and last data extraction.
+4 SET HEADER=$$HEADER^RORXU002(.RORTSK,PARTAG)
+5 if HEADER<0
QUIT HEADER
+6 ;manually build the table definition(s) listed below
+7 ;PATIENTS(#,NAME,LAST4,AGE,DOD,TEST,DATE,RESULT,CRCL,EGFR)
+8 SET COLUMNS=$$ADDVAL^RORTSK11(RORTSK,"TBLDEF",,HEADER)
+9 DO ADDATTR^RORTSK11(RORTSK,COLUMNS,"NAME","PATIENTS")
+10 DO ADDATTR^RORTSK11(RORTSK,COLUMNS,"HEADER","1")
+11 DO ADDATTR^RORTSK11(RORTSK,COLUMNS,"FOOTER","1")
+12 ;--- Required columns
+13 ; do not list Age if the selection is to list ALL ages
SET AGETYPE=$$PARAM^RORTSK01("AGE_RANGE","TYPE")
+14 FOR COL="#","NAME","LAST4",AGETYPE,"DOD","TEST","DATE","RESULT"
Begin DoDot:1
+15 if COL="ALL"
QUIT
+16 SET TMP=$$ADDVAL^RORTSK11(RORTSK,"COLUMN",,COLUMNS)
+17 DO ADDATTR^RORTSK11(RORTSK,TMP,"NAME",COL)
End DoDot:1
+18 ;--- Additional columns
+19 IF RORDATA("IDLST")[1
Begin DoDot:1
+20 SET TMP=$$ADDVAL^RORTSK11(RORTSK,"COLUMN",,COLUMNS)
+21 DO ADDATTR^RORTSK11(RORTSK,TMP,"NAME","CRCL")
End DoDot:1
+22 IF RORDATA("IDLST")[2
Begin DoDot:1
+23 SET TMP=$$ADDVAL^RORTSK11(RORTSK,"COLUMN",,COLUMNS)
+24 DO ADDATTR^RORTSK11(RORTSK,TMP,"NAME","MDRD")
End DoDot:1
+25 IF RORDATA("IDLST")[3
Begin DoDot:1
+26 SET TMP=$$ADDVAL^RORTSK11(RORTSK,"COLUMN",,COLUMNS)
+27 DO ADDATTR^RORTSK11(RORTSK,TMP,"NAME","CKD")
End DoDot:1
+28 ;--- LOINC codes
+29 NEW LTAG
SET LTAG=$$ADDVAL^RORTSK11(RORTSK,"LOINC_CODES",,PARTAG)
+30 NEW CTAG
SET CTAG=$$ADDVAL^RORTSK11(RORTSK,"CODE",,LTAG)
+31 DO ADDATTR^RORTSK11(RORTSK,CTAG,"CODE","Creatinine: 15045-8, 21232-4, 2160-0")
+32 ;--- ICN
+33 IF $$PARAM^RORTSK01("PATIENTS","ICN")
DO ICNHDR^RORXU006(RORTSK,COLUMNS)
+34 ;--- PACT
+35 IF $$PARAM^RORTSK01("PATIENTS","PACT")
DO PACTHDR^RORXU006(RORTSK,COLUMNS)
+36 ;--- PCP
+37 IF $$PARAM^RORTSK01("PATIENTS","PCP")
DO PCPHDR^RORXU006(RORTSK,COLUMNS)
+38 ;--- Future Appt. PATCH 33
+39 IF $$PARAM^RORTSK01("OPTIONS","FUT_APPT")
DO APPTHDR^RORXU006(RORTSK,COLUMNS)
+40 ;---
+41 QUIT $SELECT(RC<0:RC,1:HEADER)
+42 ;
+43 ;*****************************************************************************
+44 ;INITIALIZE THE RANGE COUNTS TO 0
+45 ;
+46 ;INPUT
+47 ; RORDATA Array with ROR data
+48 ; RORDATA("RCNT") Number of ranges/groupings to initialize
+49 ;*****************************************************************************
INIT(RORDATA) ;
+1 IF $GET(RORDATA("RCNT"))=""
QUIT
+2 NEW I
+3 FOR I=1:1:RORDATA("RCNT")
Begin DoDot:1
+4 IF RORDATA("IDLST")[2
SET RORDATA("NPMDRD",I)=0
+5 IF RORDATA("IDLST")[3
SET RORDATA("NPCKD",I)=0
End DoDot:1
+6 QUIT
+7 ;
+8 ;*****************************************************************************
+9 ;OUTPUT REPORT 'RANGE' PARAMETERS, SET UP REPORT ID LIST (EXTRINISIC FUNCTION)
+10 ;
+11 ; PARTAG Reference (IEN) to the parent tag
+12 ;
+13 ; Return Values:
+14 ; RORDATA("IDLST") - list of IDs for tests requested
+15 ; RORDATA("RANGE") - 1 if range passed in for either test, else 0
+16 ; <0 Error code
+17 ; 0 Ok
+18 ;*****************************************************************************
PARAMS(PARTAG,RORDATA) ;
+1 NEW PARAMS,DESC,TMP,RC,RANGE
SET RC=0
+2 ;initialize to 'no range passed in'
SET RORDATA("RANGE")=0
+3 ;--- Lab test ranges
+4 IF $DATA(RORTSK("PARAMS","LRGRANGES","C"))>1
Begin DoDot:1
+5 NEW GRC,ELEMENT,NODE,RTAG,RANGE
+6 SET NODE=$NAME(RORTSK("PARAMS","LRGRANGES","C"))
+7 SET RTAG=$$ADDVAL^RORTSK11(RORTSK,"LRGRANGES",,PARTAG)
+8 SET (GRC,RC)=0
+9 FOR
SET GRC=$ORDER(@NODE@(GRC))
if GRC'>0
QUIT
Begin DoDot:2
+10 SET RANGE=0
SET DESC=$$RTEXT(GRC,.RORDATA)
+11 SET ELEMENT=$$ADDVAL^RORTSK11(RORTSK,"LRGRANGE",DESC,RTAG)
+12 IF ELEMENT<0
SET RC=ELEMENT
QUIT
+13 DO ADDATTR^RORTSK11(RORTSK,ELEMENT,"ID",GRC)
+14 ;add the user-requested test ID to the test ID 'list'
+15 SET RORDATA("IDLST")=$GET(RORDATA("IDLST"))_$SELECT($GET(RORDATA("IDLST"))'="":","_GRC,1:GRC)
+16 ;--- Process the range values
+17 SET TMP=$GET(@NODE@(GRC,"L"))
+18 IF TMP'=""
Begin DoDot:3
+19 DO ADDATTR^RORTSK11(RORTSK,ELEMENT,"LOW",TMP)
End DoDot:3
SET RANGE=1
+20 SET TMP=$GET(@NODE@(GRC,"H"))
+21 IF TMP'=""
Begin DoDot:3
+22 DO ADDATTR^RORTSK11(RORTSK,ELEMENT,"HIGH",TMP)
End DoDot:3
SET RANGE=1
+23 IF RANGE
Begin DoDot:3
+24 DO ADDATTR^RORTSK11(RORTSK,ELEMENT,"RANGE",1)
+25 SET RORDATA("RANGE")=1
End DoDot:3
End DoDot:2
if RC<0
QUIT
End DoDot:1
if RC<0
QUIT RC
+26 ;--- Success
+27 ;if user didn't select any tests, default to both tests
+28 IF $GET(RORDATA("IDLST"))=""
SET RORDATA("IDLST")="1,2,3"
+29 QUIT RC
+30 ;
+31 ;*****************************************************************************
+32 ;RETURN RANGE TEXT AND ADD RANGE VALUES TO RORDATA (EXTRINISIC FUNCTION)
+33 ;ID=1: MELD
+34 ;ID=2: MELD-Na
+35 ;
+36 ;INPUT:
+37 ; GRC Test ID number
+38 ; RORDATA - Array with ROR data
+39 ;
+40 ;OUTPUT:
+41 ; RORDATA("L",ID) - test ID low range
+42 ; RORDATA("H",ID) - test ID high range
+43 ; Description - <range>
+44 ;*****************************************************************************
RTEXT(GRC,RORDATA) ;
+1 NEW RANGE,TMP
+2 SET RANGE=""
+3 ;--- Range
+4 IF $DATA(RORTSK("PARAMS","LRGRANGES","C",GRC))>1
Begin DoDot:1
+5 ;--- Low
+6 SET TMP=$GET(RORTSK("PARAMS","LRGRANGES","C",GRC,"L"))
+7 SET RORDATA("L",GRC)=$GET(TMP)
+8 if TMP'=""
SET RANGE=RANGE_" not less than "_TMP
+9 ;--- High
+10 SET TMP=$GET(RORTSK("PARAMS","LRGRANGES","C",GRC,"H"))
+11 SET RORDATA("H",GRC)=$GET(TMP)
+12 IF TMP'=""
if RANGE'=""
Begin DoDot:2
+13 SET RANGE=RANGE_" and"
End DoDot:2
SET RANGE=RANGE_" not greater than "_TMP
End DoDot:1
+14 ;--- Description
+15 SET TMP=$GET(RORTSK("PARAMS","LRGRANGES","C",GRC))
+16 if TMP=""
SET TMP="Unknown ("_GRC_")"
+17 QUIT TMP_" - "_$SELECT(RANGE'="":"numeric results"_RANGE,1:"all results")
+18 ;
+19 ;************************************************************************
+20 ;DETERMINE IF THE SCORES ARE WITHIN THE REQUESTED RANGES (EXTRINSIC FUNCTION)
+21 ;If not in the range, exclude from report
+22 ;
+23 ;INPUT:
+24 ; RORDATA RORDATA("SCORE",I) contains computed test score for test ID 'I'
+25 ;
+26 ;OUTPUT:
+27 ; 1 include on report
+28 ; 0 exclude from report
+29 ;************************************************************************
INRANGE(RORDATA) ;
+1 ;if range exists for either test, and any result is considered 'invalid',
+2 ;then skip the range check and exclude data from report
+3 ;I $G(RORDATA("RANGE")),'$G(RORDATA("CALC")) Q 0
+4 ;if range does not exist for either test, and any result is considered 'invalid',
+5 ;then skip the range check and include data in the report
+6 IF '$GET(RORDATA("RANGE"))
IF '$GET(RORDATA("CALC"))
QUIT 1
+7 ;
+8 ;---Range Check
+9 ;default is set to 'within range'
NEW I,RETURN
SET RETURN=1
+10 SET I=0
FOR
SET I=$ORDER(RORDATA("SCORE",I))
if I=""
QUIT
Begin DoDot:1
+11 IF $GET(RORDATA("L",I))'=""
Begin DoDot:2
+12 ;if score is less than 'low' range, do not include on report
+13 IF $GET(RORDATA("SCORE",I))<RORDATA("L",I)
SET RETURN=0
End DoDot:2
+14 IF $GET(RORDATA("H",I))'=""
Begin DoDot:2
+15 ;if score is higher than 'high' range, do not include on report
+16 IF $GET(RORDATA("SCORE",I))>RORDATA("H",I)
SET RETURN=0
End DoDot:2
End DoDot:1
+17 ;
+18 QUIT RETURN
+19 ;
+20 ;************************************************************************
+21 ;ADD 1 TO APPROPRIATE eGFR CATEGORY
+22 ;
+23 ;INPUT
+24 ; RORDATA Array with ROR data
+25 ;************************************************************************
MDRDCAT(RORDATA) ;
+1 ;quit if no score was calculated
IF '$GET(RORDATA("SCORE",2))
QUIT
+2 IF $GET(RORDATA("SCORE",2))>89
SET RORDATA("NPMDRD",1)=$GET(RORDATA("NPMDRD",1))+1
QUIT
+3 IF $GET(RORDATA("SCORE",2))>59
SET RORDATA("NPMDRD",2)=$GET(RORDATA("NPMDRD",2))+1
QUIT
+4 IF $GET(RORDATA("SCORE",2))>29
SET RORDATA("NPMDRD",3)=$GET(RORDATA("NPMDRD",3))+1
QUIT
+5 IF $GET(RORDATA("SCORE",2))>14
SET RORDATA("NPMDRD",4)=$GET(RORDATA("NPMDRD",4))+1
QUIT
+6 SET RORDATA("NPMDRD",5)=$GET(RORDATA("NPMDRD",5))+1
QUIT
+7 QUIT
+8 ;
+9 ;************************************************************************
+10 ;ADD 1 TO APPROPRIATE eGFR CATEGORY
+11 ;
+12 ;INPUT
+13 ; RORDATA Array with ROR data
+14 ;************************************************************************
CKDCAT(RORDATA) ;
+1 ;quit if no score was calculated
IF '$GET(RORDATA("SCORE",3))
QUIT
+2 IF $GET(RORDATA("SCORE",3))>89
SET RORDATA("NPCKD",1)=$GET(RORDATA("NPCKD",1))+1
QUIT
+3 IF $GET(RORDATA("SCORE",3))>59
SET RORDATA("NPCKD",2)=$GET(RORDATA("NPCKD",2))+1
QUIT
+4 IF $GET(RORDATA("SCORE",3))>29
SET RORDATA("NPCKD",3)=$GET(RORDATA("NPCKD",3))+1
QUIT
+5 IF $GET(RORDATA("SCORE",3))>14
SET RORDATA("NPCKD",4)=$GET(RORDATA("NPCKD",4))+1
QUIT
+6 SET RORDATA("NPCKD",5)=$GET(RORDATA("NPCKD",5))+1
QUIT
+7 QUIT
+8 ;*****************************************************************************
+9 ;ADD SUMMARY DATA TO THE REPORT (EXTRINSIC FUNCTION)
+10 ;
+11 ;INPUT
+12 ; RORTSK Task number and task parameters
+13 ; REPORT 'Report' XML tag number
+14 ; RORDATA Array with summary data:
+15 ; RORDATA("NP",1) - total count of patients in 1st range
+16 ; RORDATA("NP",2) - total count of patients in 2nd range
+17 ; RORDATA("NP",3) - total count of patients in 3rd range
+18 ; RORDATA("NP",4) - total count of patients in 4th range
+19 ; RORDATA("NP",5) - total count of patients in 5th range
+20 ;
+21 ;OUTPUT
+22 ; STAG XML 'summary' tag number or error code
+23 ;*****************************************************************************
SUMMARY(RORTSK,REPORT,RORDATA) ; Add the summary values to the report
+1 NEW SUMMARY,I,STAG,RORTAG,RORNAME,RORRANGE
+2 SET SUMMARY=$$ADDVAL^RORTSK11(RORTSK,"SUMMARY",,REPORT)
+3 if SUMMARY<0
QUIT SUMMARY
+4 ;add data for the summary entries
+5 FOR I=1:1:RORDATA("RCNT")
Begin DoDot:1
+6 SET STAG=$$ADDVAL^RORTSK11(RORTSK,"DATA",,SUMMARY)
+7 if STAG<0
QUIT
+8 ;get each value
+9 SET RORTAG="S"_I
SET RORNAME=$PIECE($TEXT(@RORTAG),";;",2)
+10 SET RORRANGE=$PIECE($TEXT(@RORTAG),";;",3)
+11 ;severity
DO ADDVAL^RORTSK11(RORTSK,"DESC",$GET(RORNAME),STAG)
+12 ;range
DO ADDVAL^RORTSK11(RORTSK,"VALUES",$GET(RORRANGE),STAG)
+13 ;count
DO ADDVAL^RORTSK11(RORTSK,"NPMDRD",$GET(RORDATA("NPMDRD",I)),STAG)
+14 ;count
DO ADDVAL^RORTSK11(RORTSK,"NPCKD",$GET(RORDATA("NPCKD",I)),STAG)
End DoDot:1
if STAG<0
QUIT
+15 QUIT STAG
+16 ;************************************************************************
+17 ;eGFR by MDRD Categories and Values for the summary table.
+18 ;NOTE: the number of entries below must match the value of RORDATA("RCNT")
+19 ;************************************************************************
S1 ;;Normal or CKD1;;>=90 mL/min/1.73m
S2 ;;CKD2 (Mild);;60-89 mL/min/1.73m
S3 ;;CKD3 (Moderate);;30-59 mL/min/1.73m
S4 ;;CKD4 (Severe);;15-29 mL/min/1.73m
S5 ;;CKD5 (Kidney failure);;<15 mL/min/1.73m