 %MACRO R08I0ED1(AGE=, SEX=, ICD10= );
 %**********************************************************************
 ***********************************************************************
 1 MACRO NAME:  R08I0ED1
                UDXG update V0123 for V08 model 

 2 PURPOSE:     age/sex edits on ICD10: some edits are mandatory,
                others - are based on MCE list to check
                if age or sex for a beneficiary is within the
                range of acceptable age/sex, if not- CC is set to
                -1.0 - invalid

 3 PARAMETERS:  AGE   - beneficiary age variable calculated by DOB
                        from a person level file
                SEX   - beneficiary SEX variable in a person level file
                ICD10 - diagnosis variable in a diagnosis file

 4 COMMENTS:    1. Age format AGEFMT0 and sex format SEXFMT0 are 
                   parameters in the main macro. They have to correspond
                   to the years of data

                2. If ICD10 code does not have any restriction on age
                   or sex then the corresponding format puts it in "-1"

                3. AGEL format sets lower limits for age
                   AGEU format sets upper limit for age
                   for specific edit categories:
                   "0"= "0 newborn (age 0)      "
                   "1"= "1 pediatric (age 0 -17)"
                   "2"= "2 maternity (age 9 -64)"
                   "3"= "3 adult (age 15+)      "

                4. SEDITS - parameter for the main macro
 **********************************************************************;
  %* no RTI edits in payment model V08;
     
  %* CME edits if needed (should be decided by a user by setting
     parameter SEDITS);
  %IF &SEDITS = 1 %THEN %DO;
     %* check if Age is within acceptable range;
     _TAGE=PUT(&ICD10, $&AGEFMT0..);
     IF _TAGE NE "-1" AND
        (&AGE < INPUT(PUT(_TAGE, $AGEL.),8.) OR
         &AGE > INPUT(PUT(_TAGE, $AGEU.),8.)) THEN RXCC="-1.0";

     %* check if Sex for a person is the one in the MCE file;
     _TSEX=PUT(&ICD10, $&SEXFMT0..);
     IF _TSEX NE "-1"  & _TSEX NE &SEX THEN RXCC="-1.0";

  %END;
 %MEND R08I0ED1;
