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;
    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);

        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());


    }

    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 = 1;

       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;
    }


}

@@ -1744,16 +1744,124 @@
 ing());%0A
+        score = getScoreFromAsthmaSymptoms();%0A        SCORE_ASTHMA_SYMPTOMS_TEXT.setText(score.toString());%0A
 %0A%0A    %7D%0A
@@ -2231,17 +2231,17 @@
 score = 
-1
+5
 ;%0A%0A     
@@ -2587,18 +2587,457 @@
  score;%0A
-
     %7D%0A%0A
+    public Integer getScoreFromAsthmaSymptoms ()%7B%0A        if ((numberOfDays %3E=16) && (numberOfDays%3C=28))%0A            score = 1;%0A        else if ((numberOfDays %3E=7) && (numberOfDays%3C=15))%0A            score = 2;%0A        else if ((numberOfDays %3E=3) && (numberOfDays%3C=6))%0A            score = 3;%0A        else if ((numberOfDays %3E=1) && (numberOfDays%3C=2))%0A            score = 4;%0A        else%0A            score = 5;%0A%0A        return score;%0A    %7D%0A%0A%0A
 %0A%7D%0A

Add a method for returning a score based on when symptoms (wheezing, coughing, shortness of breath, chest tightness, or pain) wake the patient up at night or earlier than usual in the morning