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

RORX018.m

Go to the documentation of this file.
  1. RORX018 ;BPOIFO/ACS - BMI BY RANGE REPORT ;11/1/09
  1. ;;1.5;CLINICAL CASE REGISTRIES;**10,13,19,21,31,33,34,39**;Feb 17, 2006;Build 4
  1. ;
  1. ;
  1. ; This routine uses the following IAs:
  1. ;
  1. ; #4290 ^PXRMINDX(120.5 (controlled)
  1. ; #3647 $$EN^GMVPXRM (controlled)
  1. ; #5047 $$GETIEN^GMVGETVT (supported)
  1. ;
  1. ;******************************************************************************
  1. ;******************************************************************************
  1. ; --- ROUTINE MODIFICATION LOG ---
  1. ;
  1. ;PKG/PATCH DATE DEVELOPER MODIFICATION
  1. ;----------- ---------- ----------- ----------------------------------------
  1. ;ROR*1.5*10 MAR 2010 A SAUNDERS Routine created
  1. ;ROR*1.5*13 DEC 2010 A SAUNDERS User can select specific patients,
  1. ; clinics, or divisions for the report.
  1. ; Modified XML tags for sort.
  1. ;ROR*1.5*19 FEB 2012 K GUPTA Support for ICD-10 Coding System
  1. ;ROR*1.5*21 SEP 2013 T KOPP Add ICN column if Additional Identifier
  1. ; requested.
  1. ;ROR*1.5*31 MAY 2017 M FERRARESE Adding PACT, PCP, and AGE/DOB as additional
  1. ; identifiers.
  1. ;ROR*1.5*33 JAN 2018 M FERRARESE Adding Future Appointment date/time
  1. ;
  1. ;ROR*1.5*34 SEP 2018 M FERRARESE Adding Future Appointment clinic name
  1. ;ROR*1.5*39 JUN 2021 F TRAXLER Replace real SSN with zeroes.
  1. ;******************************************************************************
  1. ;******************************************************************************
  1. Q
  1. ;*****************************************************************************
  1. ;COMPILE THE "BMI BY RANGE" REPORT
  1. ;REPORT CODE: 018
  1. ;
  1. ;Called by entry "BMI by Range" in ROR REPORT PARAMETERS (#799.34)
  1. ;
  1. ;INPUT
  1. ; RORTSK Task number and task parameters
  1. ;
  1. ; Below is a sample RORTSK input array for utilization in 2003, most recent
  1. ; scores, BMI range from 30 to 45:
  1. ;
  1. ; RORTSK=nnn (task number)
  1. ; RORTSK("EP")="$$BMIRANGE^RORX018"
  1. ; RORTSK("PARAMS","AGE_RANGE","A","TYPE")=ALL
  1. ; RORTSK("PARAMS","AGE_RANGE","A","TYPE")=DOB
  1. ; RORTSK("PARAMS","AGE_RANGE","A","END")=3031231
  1. ; RORTSK("PARAMS","AGE_RANGE","A","START")=3030101
  1. ; RORTSK("PARAMS","AGE_RANGE","A","TYPE")=AGE
  1. ; RORTSK("PARAMS","AGE_RANGE","A","END")=3031231
  1. ; RORTSK("PARAMS","AGE_RANGE","A","START")=3030101
  1. ; RORTSK("PARAMS","DATE_RANGE_3","A","END")=3031231
  1. ; RORTSK("PARAMS","DATE_RANGE_3","A","START")=3030101
  1. ; RORTSK("PARAMS","ICD9FILT","A","FILTER")="ALL"
  1. ; RORTSK("PARAMS","LRGRANGES","C",1)=""
  1. ; RORTSK("PARAMS","LRGRANGES","C",1,"H")=45
  1. ; RORTSK("PARAMS","LRGRANGES","C",1,"L")=30
  1. ; RORTSK("PARAMS","OPTIONS","A","COMPLETE")=1
  1. ; RORTSK("PARAMS","OPTIONS","A","FUT_APPT")=365 PATCH 33
  1. ; RORTSK("PARAMS","OPTIONS","A","MOST_RECENT")=1
  1. ; RORTSK("PARAMS","PATIENTS","A","DE_AFTER")=1
  1. ; RORTSK("PARAMS","PATIENTS","A","DE_BEFORE")=1
  1. ; RORTSK("PARAMS","PATIENTS","A","DE_DURING")=1
  1. ; RORTSK("PARAMS","REGIEN")=1
  1. ;
  1. ; If the user selected an 'as of' date = 12/31/2005:
  1. ; RORTSK("PARAMS","OPTIONS","A","MOST_RECENT")=1
  1. ; is replaced with:
  1. ; RORTSK("PARAMS","OPTIONS","A","MAX_DATE")=3051231
  1. ;
  1. ;OUTPUT
  1. ; <0 Error code
  1. ; 0 Ok
  1. ;*****************************************************************************
  1. BMIRANGE(RORTSK) ;
  1. N RORDATA ; array to hold ROR data and summary totals
  1. N RORREG ; Registry IEN
  1. N RORSDT ; report start date
  1. N ROREDT ; report end date
  1. N RORPTIEN ; IEN of patient in the ROR registry
  1. N DFN ; DFN of patient in the PATIENT file (#2)
  1. N RORCDLIST ; Flag to indicate whether a clinic or division list exists
  1. N RORCDSTDT ; Start date for clinic/division utilization search
  1. N RORCDENDT ; End date for clinic/division utilization search
  1. ;
  1. N REPORT,PARAMS,SFLAGS,RC,CNT,ECNT,UTSDT,UTEDT,SKIPSDT,SKIPEDT,RORBODY,RORPTN
  1. N RCC,FLAG,TMP,DFN,SKIP
  1. ;--- Establish the root XML Node of the report and put into output
  1. S REPORT=$$ADDVAL^RORTSK11(RORTSK,"REPORT")
  1. Q:REPORT<0 REPORT
  1. ;
  1. ;--- Get registry IEN
  1. S RORREG=$$PARAM^RORTSK01("REGIEN") ; Registry IEN
  1. ;
  1. ;--- Set standard report parameters data into output:
  1. ;registry, comment, patients (before, during, after), options (summary vs.
  1. ;complete), other registries, and other diagnoses
  1. S PARAMS=$$PARAMS^RORXU002(.RORTSK,REPORT,.RORSDT,.ROREDT,.SFLAGS) Q:PARAMS<0 PARAMS
  1. ;
  1. ;--- Add range parameters to output
  1. S RC=$$PARAMS^RORX018A(PARAMS,.RORDATA) Q:RC<0 RC
  1. ;
  1. ;--- Put report header data into output:
  1. ;report creation date, task number, last registry update date, and
  1. ;last data extraction date
  1. S RC=$$HEADER(REPORT) Q:RC<0 RC
  1. ;
  1. ;--- Set the number of BMI ranges and initialize their values to 0
  1. S RORDATA("RCNT")=6 D INIT(.RORDATA)
  1. ;
  1. ;--- Get GMRV VITAL TYPE pointer for HEIGHT and WEIGHT
  1. S RORDATA("HGTP")=$$GETIEN^GMVGETVT("HEIGHT",1)
  1. S RORDATA("WGTP")=$$GETIEN^GMVGETVT("WEIGHT",1)
  1. I '$G(RORDATA("HGTP")) Q -1
  1. I '$G(RORDATA("WGTP")) Q -1
  1. ;
  1. ;--- 'Most recent' vs. max date requested
  1. S RORDATA("DATE")=0
  1. I $$PARAM^RORTSK01("OPTIONS","MOST_RECENT") S RORDATA("DATE")=DT_.9
  1. I '$G(RORDATA("DATE")) S RORDATA("DATE")=$$PARAM^RORTSK01("OPTIONS","MAX_DATE")_.9
  1. ;
  1. ;--- Summary vs. complete report requested
  1. S RORDATA("SUMMARY")=0
  1. I $$PARAM^RORTSK01("OPTIONS","SUMMARY") S RORDATA("SUMMARY")=1
  1. ;
  1. ;--- Future Appointments patch 33
  1. S RORDATA("DAYS")=0
  1. I $$PARAM^RORTSK01("OPTIONS","FUT_APPT") S RORDATA("DAYS")=$$PARAM^RORTSK01("OPTIONS","FUT_APPT")
  1. ;
  1. ;--- Get BMI range requested (there is currently only 1 BMI test)
  1. S I=0 F S I=$O(RORTSK("PARAMS","LRGRANGES","C",I)) Q:I="" D
  1. . S RORDATA("L",I)=$G(RORTSK("PARAMS","LRGRANGES","C",I,"L")) ;low BMI range
  1. . S RORDATA("H",I)=$G(RORTSK("PARAMS","LRGRANGES","C",I,"H")) ;high BMI range
  1. ;
  1. ;--- Create 'patients' table
  1. S RORBODY=$$ADDVAL^RORTSK11(RORTSK,"PATIENTS",,REPORT)
  1. D ADDATTR^RORTSK11(RORTSK,RORBODY,"TABLE","PATIENTS")
  1. ;
  1. ;--- Get utilization date range (always sent in)
  1. S (CNT,ECNT,RC)=0,SKIPEDT=ROREDT,SKIPSDT=RORSDT
  1. S UTSDT=$$PARAM^RORTSK01("DATE_RANGE_3","START")\1
  1. S UTEDT=$$PARAM^RORTSK01("DATE_RANGE_3","END")\1
  1. ; Combined date range
  1. S SKIPSDT=$$DTMIN^RORUTL18(SKIPSDT,$G(UTSDT))
  1. S SKIPEDT=$$DTMAX^RORUTL18(SKIPEDT,$G(UTEDT))
  1. ;
  1. ;--- Number of patients in the registry - used for calculating the
  1. ;task progress percentage - shown on the GUI screen
  1. S RORPTN=$$REGSIZE^RORUTL02(+RORREG) S:RORPTN<0 RORPTN=0
  1. ;
  1. ;=== Set up Clinic/Division list parameters
  1. S RORCDLIST=$$CDPARMS^RORXU001(.RORTSK,.RORCDSTDT,.RORCDENDT,1)
  1. ;
  1. ;--- Get registry records
  1. S (CNT,RORPTIEN,RC)=0
  1. S FLAG=$G(RORTSK("PARAMS","ICDFILT","A","FILTER"))
  1. F S RORPTIEN=$O(^RORDATA(798,"AC",RORREG,RORPTIEN)) Q:RORPTIEN'>0 D Q:RC<0
  1. . ;--- Calculate 'progress' for the GUI display
  1. . S TMP=$S(RORPTN>0:CNT/RORPTN,1:"")
  1. . S RC=$$LOOP^RORTSK01(TMP) Q:RC<0
  1. . S CNT=CNT+1
  1. . ;--- Get patient DFN
  1. . S DFN=$$PTIEN^RORUTL01(RORPTIEN) Q:DFN'>0
  1. . ;check for patient list and quit if not on list
  1. . I $D(RORTSK("PARAMS","PATIENTS","C")),'$D(RORTSK("PARAMS","PATIENTS","C",DFN)) Q
  1. . ;--- Check if the patient should be skipped
  1. . Q:$$SKIP^RORXU005(RORPTIEN,SFLAGS,SKIPSDT,SKIPEDT)
  1. . ;--- Check if patient has passed the ICD filter
  1. . S RCC=0
  1. . I FLAG'="ALL" D
  1. . . S RCC=$$ICD^RORXU010(DFN)
  1. . I (FLAG="INCLUDE")&(RCC=0) Q
  1. . I (FLAG="EXCLUDE")&(RCC=1) Q
  1. . ;
  1. . ;--- Check for Clinic or Division list and quit if not in list
  1. . I RORCDLIST,'$$CDUTIL^RORXU001(.RORTSK,DFN,RORCDSTDT,RORCDENDT) Q
  1. . ;
  1. . ;--- Check for any utilization in the corresponding date range
  1. . S SKIP=0 I $G(UTSDT)>0 D
  1. .. N UTIL K TMP S TMP("ALL")=1
  1. .. S UTIL=+$$UTIL^RORXU003(UTSDT,UTEDT,DFN,.TMP)
  1. .. S:'UTIL SKIP=1
  1. . ;--- Skip the patient if they have no utilization in the range
  1. . Q:$G(SKIP)
  1. . ;
  1. . ;--- For each patient, process the registry record
  1. . I $$PATIENT(DFN,RORBODY,.RORDATA)<0 S ECNT=ECNT+1 ;error count
  1. ;
  1. ;--- Always create BMI summary report
  1. S RC=$$SUMMARY(RORTSK,REPORT,.RORDATA) Q:RC<0 RC
  1. K ^TMP("RORX018",$J)
  1. Q $S(RC<0:RC,ECNT>0:-43,1:0)
  1. ;
  1. ;*****************************************************************************
  1. ;ADD THE PATIENT DATA TO THE REPORT
  1. ;
  1. ;INPUT
  1. ; DFN Patient DFN in PATIENT file (#2)
  1. ; PTAG Reference IEN to the 'body' parent XML tag
  1. ; RORDATA Array with ROR data
  1. ;
  1. ;OUTPUT
  1. ; 1 ok
  1. ; <0 error
  1. ;*****************************************************************************
  1. PATIENT(DFN,PTAG,RORDATA) ;
  1. I $$CALCBMI(DFN,PTAG,.RORDATA)<0 Q 0 ;calculate the BMI
  1. I '$$INRANGE(.RORDATA) Q 0 ;if range sent, BMI must be in the requested range
  1. D BMICAT(.RORDATA) ;add 1 to appropriate category count
  1. Q:RORDATA("SUMMARY") 1 ;stop if only the 'summary' report was requested
  1. ;
  1. ;--- Get patient data and put into the report
  1. N VADM,VA,RORDOD,BTAG,HTAG,WTAG,AGE,AGETYPE
  1. D VADEM^RORUTL05(DFN,1) S VA("BID")="0000"
  1. ;--- The <PATIENT> tag
  1. S PTAG=$$ADDVAL^RORTSK11(RORTSK,"PATIENT",,PTAG,,DFN)
  1. I PTAG<0 Q PTAG
  1. ;
  1. ;
  1. ;--- Patient Name
  1. D ADDVAL^RORTSK11(RORTSK,"NAME",VADM(1),PTAG,1)
  1. ;
  1. ;--- Last 4 digits of the SSN
  1. D ADDVAL^RORTSK11(RORTSK,"LAST4",VA("BID"),PTAG,2)
  1. ;
  1. ;--- Patient age/DOB
  1. S AGETYPE=$$PARAM^RORTSK01("AGE_RANGE","TYPE") I AGETYPE'="ALL" D
  1. . S AGE=$S(AGETYPE="AGE":$P(VADM(4),U),AGETYPE="DOB":$$DATE^RORXU002($P(VADM(3),U)\1),1:"")
  1. . D ADDVAL^RORTSK11(RORTSK,AGETYPE,AGE,PTAG,1)
  1. ;
  1. ;--- Date of death
  1. S RORDOD=$$DATE^RORXU002($P(VADM(6),U)\1)
  1. D ADDVAL^RORTSK11(RORTSK,"DOD",$G(RORDOD),PTAG,1)
  1. ;--- 'BMIDATA' tag
  1. S BTAG=$$ADDVAL^RORTSK11(RORTSK,"BMIDATA",,PTAG)
  1. Q:BTAG<0 BTAG
  1. ;--- Height tag
  1. S HTAG=$$ADDVAL^RORTSK11(RORTSK,"HEIGHT",,BTAG)
  1. Q:HTAG<0 HTAG
  1. ;--- Date Height Taken
  1. D ADDVAL^RORTSK11(RORTSK,"DATE",$G(RORDATA("HDATE")),HTAG)
  1. ;--- Height value
  1. D ADDVAL^RORTSK11(RORTSK,"RESULT",$G(RORDATA("HGT")),HTAG)
  1. ;--- Weight tag
  1. S WTAG=$$ADDVAL^RORTSK11(RORTSK,"WEIGHT",,BTAG)
  1. Q:WTAG<0 WTAG
  1. ;--- Date Weight Taken
  1. D ADDVAL^RORTSK11(RORTSK,"DATE",$G(RORDATA("WDATE")),WTAG)
  1. ;--- Weight value
  1. D ADDVAL^RORTSK11(RORTSK,"RESULT",$G(RORDATA("WGT")),WTAG)
  1. ;--- Calculated BMI value goes on PATIENT tag
  1. D ADDVAL^RORTSK11(RORTSK,"BMI",$G(RORDATA("SCORE",1)),PTAG,3)
  1. ; --- ICN if selected must be last column on report
  1. I $$PARAM^RORTSK01("PATIENTS","ICN") D ICNDATA^RORXU006(.RORTSK,DFN,PTAG)
  1. ;
  1. ; --- PACT if selected may be one of the last columns on report
  1. I $$PARAM^RORTSK01("PATIENTS","PACT") D PACTDATA^RORXU006(.RORTSK,DFN,PTAG)
  1. ;
  1. ; --- PCP if selected may be one of the last columns on report
  1. I $$PARAM^RORTSK01("PATIENTS","PCP") D PCPDATA^RORXU006(.RORTSK,DFN,PTAG)
  1. ;
  1. ;--- If only patients with future appointments ; PATCH 33
  1. I $$PARAM^RORTSK01("OPTIONS","FUT_APPT") D FUTAPPT^RORXU006(.RORTSK,DFN,RORDATA("DAYS"),PTAG)
  1. Q 1
  1. ;
  1. ;*****************************************************************************
  1. ;CALCULATE THE BMI FOR CURRENT PATIENT
  1. ;
  1. ;INPUT
  1. ; DFN Patient DFN in PATIENT file (#2)
  1. ; PTAG Reference IEN to the 'body' parent XML tag
  1. ; RORDATA Array with ROR data
  1. ;
  1. ;OUTPUT
  1. ; 1 BMI calculated successfully
  1. ; -1 Patient does not have vital measurements or BMI is out of range
  1. ; RORDATA Array with ROR data:
  1. ; RORDATA("WGT") - weight measurement
  1. ; RORDATA("WDATE") - date of weight measurement
  1. ; RORDATA("HGT") - height measurement
  1. ; RORDATA("HDATE") - date of height measurement
  1. ; RORDATA("SCORE",N) - calculated BMI value for test N
  1. ;*****************************************************************************
  1. CALCBMI(DFN,PTAG,RORDATA) ;
  1. ;-- get vital measurements for BMI calculation
  1. S RORDATA("CALC")=1 ;default - the score for this patient should be calculated
  1. N RORDATE,I,RORVMDT,RORVMIEN,RORARY,TMP1,TMP2,TMP3
  1. K RORDATA("HGT"),RORDATA("WGT"),RORDATA("SCORE",1)
  1. S RORDATE=RORDATA("DATE")
  1. F I="HGTP","WGTP" D ;height and weight pointers
  1. . ;get vital measurement date and IEN
  1. . S RORVMDT=$O(^PXRMINDX(120.5,"PI",DFN,RORDATA(I),RORDATE),-1) ;vm date
  1. . Q:$G(RORVMDT)=""
  1. . S RORVMIEN=$O(^PXRMINDX(120.5,"PI",DFN,RORDATA(I),RORVMDT,0)) ;vm IEN
  1. . Q:$G(RORVMIEN)=""
  1. . ;call API to get patient's vital measurement value
  1. . K RORARY D EN^GMVPXRM(.RORARY,RORVMIEN,"I")
  1. . ; set values into RORDATA("WGT"), ("HGT"), ("WDATE"), & ("HDATE")
  1. . S RORDATA($E(I,1,3))=$G(RORARY(7)),RORDATA($E(I,1)_"DATE")=$P(RORVMDT,".",1)
  1. ;quit if height or weight is not > 0
  1. I (($G(RORDATA("HGT"))'>0)!($G(RORDATA("WGT"))'>0)) Q -1
  1. ;strip out characters "IN", ",E"
  1. I ((RORDATA("HGT")["IN")!(RORDATA("HGT")[",E")) S RORDATA("HGT")=+RORDATA("HGT")
  1. ;mark as 'invalid' if height not between 36 and 96 inches
  1. I ((RORDATA("HGT")<36)!(RORDATA("HGT")>96)) D Q 1
  1. . S RORDATA("CALC")=0 ;no score calculations can be done on 'invalid' data
  1. . S RORDATA("HGT")=RORDATA("HGT")_"*"
  1. ;mark as 'invalid' if height contains "CM", or "'" or double quote
  1. I ((RORDATA("HGT")["CM")!(RORDATA("HGT")["'")!(RORDATA("HGT")["""")) D Q 1
  1. . S RORDATA("CALC")=0 ;no score calculations can be done on 'invalid' data
  1. . S RORDATA("HGT")=RORDATA("HGT")_"*"
  1. ;
  1. ;BMI calculation: (weight * 703) / (height*height)
  1. S TMP1=703*($G(RORDATA("WGT")))
  1. S TMP2=$G(RORDATA("HGT"))*($G(RORDATA("HGT")))
  1. S TMP3=TMP1/TMP2
  1. S RORDATA("SCORE",1)=$J(TMP3,0,1) ;round to 1 decimal point
  1. Q 1
  1. ;
  1. ;************************************************************************
  1. ;DETERMINE IF THE SCORE IS WITHIN THE REQUESTED RANGE
  1. ;
  1. ;INPUT:
  1. ; RORDATA RORDATA("SCORE",I) contains computed test score for test ID 'I'
  1. ;
  1. ;OUTPUT:
  1. ; 1 computed test score in range
  1. ; 0 computed test score not in range
  1. ;************************************************************************
  1. INRANGE(RORDATA) ;
  1. ;if range exists for the 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 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. N I,RETURN S RETURN=1 ;default is set to 'within range'
  1. S I=0
  1. F S I=$O(RORDATA("SCORE",I)) Q:I="" D
  1. . I $G(RORDATA("L",I))'="" D
  1. .. I $G(RORDATA("SCORE",I))<RORDATA("L",I) S RETURN=0
  1. . I $G(RORDATA("H",I))'="" D
  1. .. I $G(RORDATA("SCORE",I))>RORDATA("H",I) S RETURN=0
  1. Q RETURN
  1. ;
  1. ;*****************************************************************************
  1. ;ADD 1 TO APPROPRIATE BMI CATEGORY
  1. ;
  1. ;INPUT
  1. ; RORDATA Array with ROR data
  1. ; RORDATA("SCORE",N) - calculated BMI value for test N
  1. ;OUTPUT
  1. ; RORDATA("NP",N) - incremented by 1 if BMI in Nth range
  1. ;
  1. ;*****************************************************************************
  1. BMICAT(RORDATA) ;
  1. I '$G(RORDATA("SCORE",1)) Q
  1. I $G(RORDATA("SCORE",1))<18.5 S RORDATA("NP",1)=$G(RORDATA("NP",1))+1 Q
  1. I $G(RORDATA("SCORE",1))<25 S RORDATA("NP",2)=$G(RORDATA("NP",2))+1 Q
  1. I $G(RORDATA("SCORE",1))<30 S RORDATA("NP",3)=$G(RORDATA("NP",3))+1 Q
  1. I $G(RORDATA("SCORE",1))<35 S RORDATA("NP",4)=$G(RORDATA("NP",4))+1 Q
  1. I $G(RORDATA("SCORE",1))<40 S RORDATA("NP",5)=$G(RORDATA("NP",5))+1 Q
  1. I $G(RORDATA("SCORE",1))>39 S RORDATA("NP",6)=$G(RORDATA("NP",6))+1 Q
  1. Q
  1. ;
  1. ;*****************************************************************************
  1. ;ADD THE SUMMARY DATA TO THE REPORT
  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",N) - total count of patients in Nth range
  1. ;
  1. ;OUTPUT
  1. ; DATA 'Data' XML tag number or error code
  1. ;*****************************************************************************
  1. SUMMARY(RORTSK,REPORT,RORDATA) ; Add the summary values to the report
  1. N SUMMARY,I,STAG,RORCATNUM,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 RORCATNUM="S"_I S RORNAME=$P($T(@RORCATNUM),";;",2)
  1. . S RORRANGE=$P($T(@RORCATNUM),";;",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,"NP",$G(RORDATA("NP",I)),STAG) ;count
  1. Q STAG
  1. ;
  1. ;*****************************************************************************
  1. ;RETURN RANGE TEXT
  1. ;
  1. ; GRC Test ID
  1. ;
  1. ; Return Values:
  1. ; Description - <range>
  1. ;*****************************************************************************
  1. RTEXT(GRC) ;
  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:TMP'="" RANGE=RANGE_" not less than "_TMP
  1. . ;--- High
  1. . S TMP=$G(RORTSK("PARAMS","LRGRANGES","C",GRC,"H"))
  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. ;ADD THE HEADERS TO THE REPORT
  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. ;;PATIENTS(#,NAME,LAST4,AGE,DOD,VITAL,DATE,RESULT,BMI,ICN,PACT,PCP,FUT_APPT,FUT_CLIN)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="AGE"
  1. ;;PATIENTS(#,NAME,LAST4,DOB,DOD,VITAL,DATE,RESULT,BMI,ICN,PACT,PCP,FUT_APPT,FUT_CLIN)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="DOB"
  1. ;;PATIENTS(#,NAME,LAST4,DOD,VITAL,DATE,RESULT,BMI,ICN,PACT,PCP,FUT_APPT,FUT_CLIN)^I $$PARAM^RORTSK01("AGE_RANGE","TYPE")="ALL"
  1. ;
  1. N HEADER,RC
  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. ;automatically build the table defintion(s) listed under the header tag above
  1. S RC=$$TBLDEF^RORXU002("HEADER^RORX018",HEADER)
  1. Q $S(RC<0:RC,1:HEADER)
  1. ;
  1. ;*****************************************************************************
  1. ;INITIALIZE THE NUMBER OF PATIENTS IN EACH CATEGORY TO 0
  1. ;
  1. ;INPUT
  1. ; RORDATA Array with ROR data
  1. ; RORDATA("RCNT") Number of categories to initialize
  1. ;*****************************************************************************
  1. INIT(RORDATA) ;
  1. I $G(RORDATA("RCNT"))="" Q
  1. F I=1:1:RORDATA("RCNT") D
  1. . S RORDATA("NP",I)=0
  1. Q
  1. ;
  1. ;*****************************************************************************
  1. ;BMI Categories and Values for the summary table.
  1. ;NOTE: the number of entries below must match the value of RORDATA("RCNT")
  1. ;*****************************************************************************
  1. S1 ;;Underweight;;<18.5
  1. S2 ;;Normal weight;;18.5-24.9
  1. S3 ;;Overweight;;25.0-29.99
  1. S4 ;;Class I Obesity;;30.0-34.9
  1. S5 ;;Class II Obesity;;35-39.9
  1. S6 ;;Class III Obesity;;>=40