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

RORX020A.m

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