package edu.pdx.oss.asthmacontrol;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.EditText;

public class ScoreActivity extends AppCompatActivity {
    EditText DAYS_ASTHMA_TIME_TEXT, SCORE_ASTHMA_TIME_TEXT, DAYS_ASTHMA_BREATH_TEXT, SCORE_ASTHMA_BREATH_TEXT, DAYS_ASTHMA_SYMPTOMS_TEXT, SCORE_ASTHMA_SYMPTOMS_TEXT,  DAYS_ASTHMA_MEDICATION_TEXT, SCORE_ASTHMA_MEDICATION_TEXT;
    Context ctx = this;
    Integer numberOfDays;
    Integer score;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_score);
        DatabaseOperations dop = new DatabaseOperations(ctx);

        DAYS_ASTHMA_TIME_TEXT = (EditText) findViewById(R.id.daysText1);
        SCORE_ASTHMA_TIME_TEXT = (EditText) findViewById(R.id.scoreText1);
        DAYS_ASTHMA_BREATH_TEXT = (EditText) findViewById(R.id.daysText2);
        SCORE_ASTHMA_BREATH_TEXT = (EditText) findViewById(R.id.scoreText2);
        DAYS_ASTHMA_SYMPTOMS_TEXT = (EditText) findViewById(R.id.daysText3);
        SCORE_ASTHMA_SYMPTOMS_TEXT = (EditText) findViewById(R.id.scoreText3);
        DAYS_ASTHMA_MEDICATION_TEXT = (EditText) findViewById(R.id.daysText4);
        SCORE_ASTHMA_MEDICATION_TEXT = (EditText) findViewById(R.id.scoreText4);

        numberOfDays = dop.getNumberOfDaysFromAsthmaTime(dop);
        DAYS_ASTHMA_TIME_TEXT.setText(numberOfDays.toString());
        score = getScoreFromAsthmaTime();
        SCORE_ASTHMA_TIME_TEXT.setText(score.toString());

        numberOfDays = dop.getNumberOfDaysFromAsthmaBreath(dop);
        DAYS_ASTHMA_BREATH_TEXT.setText(numberOfDays.toString());
        score = getScoreFromAsthmaBreath();
        SCORE_ASTHMA_BREATH_TEXT.setText(score.toString());

        numberOfDays = dop.getNumberOfDaysFromAsthmaSymptoms(dop);
        DAYS_ASTHMA_SYMPTOMS_TEXT.setText(numberOfDays.toString());
        score = getScoreFromAsthmaSymptoms();
        SCORE_ASTHMA_SYMPTOMS_TEXT.setText(score.toString());

        numberOfDays = dop.getNumberOfDaysFromAsthmaMedication(dop);
        DAYS_ASTHMA_MEDICATION_TEXT.setText(numberOfDays.toString());

    }

    public Integer getScoreFromAsthmaTime(){
       if (numberOfDays == 28)
           score = 1;
       else if ((numberOfDays >=22) && (numberOfDays<=27))
           score = 2;
       else if ((numberOfDays >=8) && (numberOfDays<=21))
           score = 3;
       else if ((numberOfDays >=1) && (numberOfDays<=20))
           score = 4;
       else
           score = 5;

       return score;
    }

    public Integer getScoreFromAsthmaBreath(){
        if (numberOfDays == 28)
            score = 1;
        else if ((numberOfDays >=9) && (numberOfDays<=27))
            score = 3;
        else if ((numberOfDays >=1) && (numberOfDays<=8))
            score = 4;
        else
            score = 5;

        return score;
    }

    public Integer getScoreFromAsthmaSymptoms (){
        if ((numberOfDays >=16) && (numberOfDays<=28))
            score = 1;
        else if ((numberOfDays >=7) && (numberOfDays<=15))
            score = 2;
        else if ((numberOfDays >=3) && (numberOfDays<=6))
            score = 3;
        else if ((numberOfDays >=1) && (numberOfDays<=2))
            score = 4;
        else
            score = 5;

        return score;
    }



}

@@ -2206,24 +2206,136 @@
 toString());
+%0A        score = getScoreFromAsthmaMedication();%0A        SCORE_ASTHMA_MEDICATION_TEXT.setText(score.toString());
 %0A%0A    %7D%0A%0A   
@@ -3502,12 +3502,345 @@
 %0A    %7D%0A%0A
-%0A
+    public Integer getScoreFromAsthmaMedication ()%7B%0A        if (numberOfDays == 28)%0A            score = 1;%0A        else if ((numberOfDays %3E=7) && (numberOfDays%3C=14))%0A            score = 3;%0A        else if ((numberOfDays %3E=1) && (numberOfDays%3C=6))%0A            score = 4;%0A        else%0A            score = 5;%0A%0A        return score;%0A    %7D
 %0A%7D%0A

Add a method to return a score based on when the patient has used rescue inhaler or nebulizer medication (such as albuterol)