 * ------------------------------------------------------------------------------------ ;
 *  TITLE:  IQI Diagnosis Clinical Classifications Software Redefined (DXCCSR) Code --- ;
 *                                                                                  --- ;
 *  DESCRIPTION: Creates DXCCSR variables based on diagnoses present on admission   --- ;
 *                                                                                  --- ;
 *  VERSION: SAS QI v2024                                                           --- ;
 *  RELEASE DATE: JULY 2024                                                         --- ;
 * ------------------------------------------------------------------------------------ ;

%MACRO CREATE_CCSR;

%LET d_DXCCSR_list= 
d_DXCCSR_BLD001 d_DXCCSR_BLD003 d_DXCCSR_BLD004 d_DXCCSR_BLD006 d_DXCCSR_BLD007 d_DXCCSR_BLD008
d_DXCCSR_CIR001 d_DXCCSR_CIR003 d_DXCCSR_CIR004 d_DXCCSR_CIR005 d_DXCCSR_CIR006 d_DXCCSR_CIR007
d_DXCCSR_CIR008 d_DXCCSR_CIR009 d_DXCCSR_CIR010 d_DXCCSR_CIR011 d_DXCCSR_CIR013 d_DXCCSR_CIR014
d_DXCCSR_CIR015 d_DXCCSR_CIR016 d_DXCCSR_CIR017 d_DXCCSR_CIR018 d_DXCCSR_CIR019 d_DXCCSR_CIR020
d_DXCCSR_CIR021 d_DXCCSR_CIR023 d_DXCCSR_CIR024 d_DXCCSR_CIR025 d_DXCCSR_CIR026 d_DXCCSR_CIR027
d_DXCCSR_CIR028 d_DXCCSR_CIR029 d_DXCCSR_CIR030 d_DXCCSR_CIR031 d_DXCCSR_CIR032 d_DXCCSR_CIR033
d_DXCCSR_CIR036 d_DXCCSR_CIR039 d_DXCCSR_DEN003 d_DXCCSR_DIG004 d_DXCCSR_DIG005 d_DXCCSR_DIG006
d_DXCCSR_DIG007 d_DXCCSR_DIG008 d_DXCCSR_DIG010 d_DXCCSR_DIG012 d_DXCCSR_DIG013 d_DXCCSR_DIG014
d_DXCCSR_DIG016 d_DXCCSR_DIG018 d_DXCCSR_DIG019 d_DXCCSR_DIG020 d_DXCCSR_DIG021 d_DXCCSR_DIG022
d_DXCCSR_DIG023 d_DXCCSR_DIG024 d_DXCCSR_DIG025 d_DXCCSR_EAR004 d_DXCCSR_END001 d_DXCCSR_END002
d_DXCCSR_END003 d_DXCCSR_END005 d_DXCCSR_END007 d_DXCCSR_END008 d_DXCCSR_END009 d_DXCCSR_END010
d_DXCCSR_END011 d_DXCCSR_END015 d_DXCCSR_END016 d_DXCCSR_EXT017 d_DXCCSR_EYE005 d_DXCCSR_EYE010
d_DXCCSR_FAC009 d_DXCCSR_FAC014 d_DXCCSR_FAC015 d_DXCCSR_FAC022 d_DXCCSR_GEN001 d_DXCCSR_GEN002
d_DXCCSR_GEN003 d_DXCCSR_GEN004 d_DXCCSR_GEN005 d_DXCCSR_GEN006 d_DXCCSR_GEN007 d_DXCCSR_GEN008
d_DXCCSR_GEN009 d_DXCCSR_GEN012 d_DXCCSR_INF002 d_DXCCSR_INF003 d_DXCCSR_INF004 d_DXCCSR_INF007
d_DXCCSR_INF008 d_DXCCSR_INJ002 d_DXCCSR_INJ003 d_DXCCSR_INJ004 d_DXCCSR_INJ010 d_DXCCSR_INJ016
d_DXCCSR_INJ017 d_DXCCSR_INJ028 d_DXCCSR_INJ030 d_DXCCSR_INJ031 d_DXCCSR_INJ033 d_DXCCSR_INJ034
d_DXCCSR_INJ036 d_DXCCSR_INJ037 d_DXCCSR_MAL001 d_DXCCSR_MBD001 d_DXCCSR_MBD002 d_DXCCSR_MBD003
d_DXCCSR_MBD005 d_DXCCSR_MBD007 d_DXCCSR_MBD017 d_DXCCSR_MBD018 d_DXCCSR_MBD019 d_DXCCSR_MBD021
d_DXCCSR_MBD024 d_DXCCSR_MUS006 d_DXCCSR_MUS010 d_DXCCSR_MUS011 d_DXCCSR_MUS013 d_DXCCSR_MUS022
d_DXCCSR_MUS025 d_DXCCSR_MUS026 d_DXCCSR_MUS028 d_DXCCSR_MUS033 d_DXCCSR_MUS038 d_DXCCSR_NEO012
d_DXCCSR_NEO013 d_DXCCSR_NEO017 d_DXCCSR_NEO022 d_DXCCSR_NEO039 d_DXCCSR_NEO051 d_DXCCSR_NEO058
d_DXCCSR_NEO060 d_DXCCSR_NEO068 d_DXCCSR_NEO070 d_DXCCSR_NEO072 d_DXCCSR_NEO073 d_DXCCSR_NEO074
d_DXCCSR_NVS005 d_DXCCSR_NVS008 d_DXCCSR_NVS009 d_DXCCSR_NVS010 d_DXCCSR_NVS011 d_DXCCSR_NVS013
d_DXCCSR_NVS015 d_DXCCSR_NVS016 d_DXCCSR_NVS018 d_DXCCSR_NVS019 d_DXCCSR_NVS020 d_DXCCSR_RSP002
d_DXCCSR_RSP003 d_DXCCSR_RSP005 d_DXCCSR_RSP007 d_DXCCSR_RSP008 d_DXCCSR_RSP009 d_DXCCSR_RSP010
d_DXCCSR_RSP011 d_DXCCSR_RSP012 d_DXCCSR_RSP013 d_DXCCSR_RSP014 d_DXCCSR_RSP016 d_DXCCSR_SKN001
d_DXCCSR_SKN003 d_DXCCSR_SKN004 d_DXCCSR_SKN007 d_DXCCSR_SYM003 d_DXCCSR_SYM004 d_DXCCSR_SYM005
d_DXCCSR_SYM006 d_DXCCSR_SYM007 d_DXCCSR_SYM008 d_DXCCSR_SYM010 d_DXCCSR_SYM011 d_DXCCSR_SYM012
d_DXCCSR_SYM013 d_DXCCSR_SYM014 d_DXCCSR_SYM016 d_DXCCSR_SYM017 
;
%LET d_DXCCSR_cnt = 178;

%* Initialize CCSRs ;
%DO J = 1 %TO &d_DXCCSR_cnt.;
  %LET d_var = %SCAN(&d_DXCCSR_list., &J.);
  attrib &d_var. length = 3;
  &d_var. = 0;
%END;

%* Scan each DX ;
%* Count the DXCCSR if the DXCCSR diagnosis is present on admission or POA exempt;
do i = 1 to &NDX;
  if not missing(DX{i}) then do;
    attrib POA_yes length = 3 label = 'DX is POA or POA exempt';
    poa_yes=0;
    select(ICDVER) ;
      %DO ICDVER_ = 41 %TO 33 %BY -1;
         when (&ICDVER_.) do; 
           if (DXPOA{i} IN ('Y','W') AND put(DX{i},$poaxmpt_v&ICDVER_.fmt.)='0') OR (put(DX{i},$poaxmpt_v&ICDVER_.fmt.)='1') then POA_yes = 1;
         end; /* end when */
      %END;  
    end; /* end select */
    %DO J = 1 %TO &d_DXCCSR_cnt.;
      %LET d_var   = %SCAN(&d_DXCCSR_list., &J.);
      %LET CCSRVAL = %SCAN(&d_var.,3,"_");
      if put(DX{i},$&CCSRVAL.FMT.)='1' AND poa_yes then &d_var. = 1;
    %END;
  end; /* end if not missing DX */
end; /* end of do DX */

%MEND CREATE_CCSR;

%CREATE_CCSR;

