from canvas_workflow_kit import events
from canvas_workflow_kit.protocol import (
    ClinicalQualityMeasure,
    ProtocolResult,
    STATUS_DUE
)
from canvas_workflow_kit.value_set.v{year} import {value_sets}


class {class_name}(ClinicalQualityMeasure):
    """
    {title}
    """

    title = '{title}'

    version = '{year}-v1'

    description = '{description}'

    information = '{information_link}'

    identifiers = ['CMS{class_name}']

    types = {types}

    responds_to_event_types = [
        events.HEALTH_MAINTENANCE,
    ]

    authors = [
        {authors}
    ]

    references = [
        {references}
    ]

    funding_source = '{funding_source}'


    def in_denominator(self):
        """
        Patients in the initial population.

        """
        pass

    def in_numerator(self):
        """
        Patients that have already been notified.
        """
        pass


    def compute_results(self):
        """
        """
        result = ProtocolResult()
        if self.in_denominator():
            if self.in_numerator():
                result.status = STATUS_SATISFIED
            else:
                result.due_in = -1
                result.status = STATUS_DUE
                result.add_narrative(
                    f'{{self.patient.first_name}} has at least two eGFR measurements < 60 ml/min '
                    f'over the last two years suggesting renal disease. '
                    f'There is no associated condition on the Conditions List.')
                title = (f'Consider updating the Conditions List to include kidney '
                         f'related problems as clinically appropriate')
                result.add_recommendation(
                    Recommendation(
                        key='HCC002v2_RECOMMEND_DIAGNOSE',
                        rank=1,
                        button='Diagnose',
                        title=title,
                        narrative=result.narrative,
                        command={{'key': 'diagnose'}}))
        return result
