Beispiel #1
0
    def percent_without_incident_in_period(self, params, incident_table):
        """
        Percent of ppts enrolled during period who did not have an incident
        in the period

        Args:
            params (tuple): start date and end date in format 'YYYY-MM-DD'
            incident_table(str): table in database to use as incident

        Returns:
            float: Percent of ppts enrolled during period who did not have an incident
                in the period
        """
        params = list(params) + list(params)
        query = f"""SELECT COUNT(*)
        FROM enrollment e
        WHERE NOT EXISTS (SELECT 1 
        FROM {incident_table} it
        WHERE it.member_id = e.member_id
        AND date_time_occurred BETWEEN ? AND ?)
        AND (e.disenrollment_date >= ?
            OR e.disenrollment_date IS NULL)
        AND e.enrollment_date <= ?;"""

        enrollment = Enrollment(self.db_filepath)

        return round(
            (self.single_value_query(query, params) /
             enrollment.census_during_period(params[:2]) * 100),
            2,
        )
Beispiel #2
0
    def no_hosp_admission_last_year(self, params):
        """
        Percent of ppts who do not have a recorded acute hospital admissions
        within the year prior to the provided end date.
        
        Args:
            params (tuple): start date and end date in format 'YYYY-MM-DD'

        Returns:
            float: Percent of ppts who do not have an admission in period
        """
        params = [params[1]] + list(params)

        query = """SELECT COUNT(*)
        FROM enrollment
        WHERE NOT EXISTS (SELECT 1
        FROM acute
        WHERE acute.member_id = enrollment.member_id
        AND acute.admission_date >= date(?, '-1 years'))
        AND (disenrollment_date >= ?
            OR disenrollment_date IS NULL)
        AND enrollment_date <= ?;
        """

        enrollment = Enrollment(self.db_filepath)
        return round(
            (self.single_value_query(query, params) /
             enrollment.census_during_period(params[1:]) * 100),
            2,
        )
Beispiel #3
0
    def percent_without_incident_overall(self, params, incident_table):
        """
        Percent of ppts enrolled during period who never have an incident

        Args:
            params (tuple): start date and end date in format 'YYYY-MM-DD'
            incident_table(str): table in database to use as incident

        Returns:
            float: Percent of ppts enrolled during period who never have an incident
        """
        query = f"""SELECT COUNT(*)
        FROM enrollment e
        WHERE NOT EXISTS (SELECT *
        FROM {incident_table} it
        WHERE it.member_id = e.member_id)
        AND (e.disenrollment_date >= ?
            OR e.disenrollment_date IS NULL)
        AND e.enrollment_date <= ?;"""

        enrollment = Enrollment(self.db_filepath)
        return round(
            (self.single_value_query(query, params) /
             enrollment.census_during_period(params) * 100),
            2,
        )
 def over_six_chronic_conditions_percent(self, params):
     e = Enrollment(self.db_filepath)
     return round(
         (self.over_six_chronic_conditions_count(params) /
          e.census_during_period(params) * 100),
         2,
     )
    def percent_attending_dc(self, params):
        """
        Percent of ppts who are indicated to attend the day center in Cognify,
        enrolled during the period.

        Args:
            params (tuple): start date and end date in format 'YYYY-MM-DD'

        Returns:
            float: percent of enrolled ppts who are indicated to attend the day center
        """
        e = Enrollment(self.db_filepath)
        return round(
            self.attending_day_center(params) /
            e.census_during_period(params) * 100, 2)
    def living_in_community_percent(self, params):
        """
        Percent of ppts who are not in a SNF, enrolled during the period
        Does not account for ppts in the hospital.

        Args:
            params (tuple): start date and end date in format 'YYYY-MM-DD'

        Returns:
            float: percent of enrolled ppts who are not in a SNF
        """
        e = Enrollment(self.db_filepath)
        return round(
            self.living_in_community(params) / e.census_during_period(params) *
            100, 2)
    def age_above_65(self, params):
        """
        Number of ppts above the age of 65 at the end date of ppts enrolled
        during the period

        Args:
            params (tuple): start date and end date in format 'YYYY-MM-DD'

        Returns:
            int: number of ppts above the age of 65
        """

        enrollment = Enrollment(self.db_filepath)
        return enrollment.census_during_period(params) - self.age_below_65(
            params)
    def percent_dual(self, params):
        """
        Calculates the percent of ppts enrolled in the program
        during the period that have both Medicare and medicaid

        Args:
            params (tuple): start date and end date in format 'YYYY-MM-DD'

        Returns:
            float: percent of ppts in period with both Medicare and medicaid
        """

        enrollment = Enrollment(self.db_filepath)
        return (round(
            self.dual_count(params) / enrollment.census_during_period(params),
            2) * 100)
    def percent_private_pay(self, params):
        """
        Calculates the percent of ppts enrolled in the program
        during the period that don't have medicaid or medicare

        Args:
            params (tuple): start date and end date in format 'YYYY-MM-DD'

        Returns:
            float: percent of ppts in period without medicaid and medicare
        """

        enrollment = Enrollment(self.db_filepath)
        return (round(
            self.private_pay_count(params) /
            enrollment.census_during_period(params),
            2,
        ) * 100)
Beispiel #10
0
    def ppts_in_utl_percent(self, params, utilization_table):
        """
        Count of admissions with a discharge date that is null or
        greater than the start date and an admission_date less than the end date
        divided by the census in the period multiplied by 100

        Args:
            params (tuple): start date and end date in format 'YYYY-MM-DD'
            utilization_table(str): table in database to use as utilization

        Returns:
            int: percent of enrolled ppts in the utilization type
        """
        e = Enrollment(self.db_filepath)
        return round(
            self.ppts_in_utl(params, utilization_table) /
            e.census_during_period(params) * 100,
            2,
        )
Beispiel #11
0
    def no_hosp_admission_since_enrollment(self, params):
        """
        Percent of ppts who do not have a recorded acute hospital admissions.

        Args:
            params (tuple): start date and end date in format 'YYYY-MM-DD'

        Returns:
            float: Percent of ppts who do not have a recorded acute hospital admissions.
        """
        query = """SELECT COUNT(*)
        FROM enrollment
        WHERE NOT EXISTS (SELECT 1
        FROM acute
        WHERE  acute.member_id = enrollment.member_id)
        AND (disenrollment_date >= ?
            OR disenrollment_date IS NULL)
        AND enrollment_date <= ?;"""
        enrollment = Enrollment(self.db_filepath)
        return round(
            (self.single_value_query(query, params) /
             enrollment.census_during_period(params) * 100),
            2,
        )
 def behavorial_dx_percent(self, params):
     e = Enrollment(self.db_filepath)
     return round(
         (self.behavorial_dx_count(params) / e.census_during_period(params))
         * 100, 2)
 def percent_female(self, params):
     e = Enrollment(self.db_filepath)
     return round(
         self.female_count(params) / e.census_during_period(params) * 100,
         2)
 def percent_age_below_65(self, params):
     e = Enrollment(self.db_filepath)
     return round(
         self.age_below_65(params) / e.census_during_period(params) * 100,
         2)