Search in sources :

Example 11 with Survey

use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.

the class ReceiptsRowBuildder method incrementCount.

@Override
protected int incrementCount(SurveyStock surveyStock, int newValue) {
    Survey survey = surveyStock.getSurvey();
    Date maxBalanceDate = Survey.getLastDateForSurveyType(Constants.SURVEY_RESET);
    if ((maxBalanceDate == null || Utils.dateGreaterOrEqualsThanDate(maxBalanceDate, survey.getEventDate())) && survey.getType().equals(Constants.SURVEY_RECEIPT)) {
        return newValue;
    }
    return 0;
}
Also used : Survey(org.eyeseetea.malariacare.data.database.model.Survey) Date(java.util.Date)

Example 12 with Survey

use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.

the class StatusRowBuilder method updateColumn.

@Override
protected Object updateColumn(Object oldValue, int surveyValue, SurveyStock surveyStock, int position) {
    Survey survey = surveyStock.getSurvey();
    Date maxBalanceDate = Survey.getLastDateForSurveyType(Constants.SURVEY_RESET);
    if (maxBalanceDate == null || Utils.dateGreaterOrEqualsThanDate(maxBalanceDate, survey.getEventDate())) {
        if (survey.getType() == Constants.SURVEY_RESET) {
            balanceSurvey[position] = surveyValue;
        } else if (survey.getType() == Constants.SURVEY_RECEIPT) {
            summationReceiptsUsed[position] += surveyValue;
        } else if (survey.getType() == Constants.SURVEY_ISSUE) {
            summationReceiptsUsed[position] -= surveyValue;
        }
        columnClasses.set(position + 1, getCSSForValues(position));
    }
    return "";
}
Also used : Survey(org.eyeseetea.malariacare.data.database.model.Survey) Date(java.util.Date)

Example 13 with Survey

use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.

the class DashboardActivityStrategy method sendSurvey.

@Override
public void sendSurvey() {
    Session.getMalariaSurvey().updateSurveyStatus();
    Survey stockSurvey = Session.getStockSurvey();
    if (stockSurvey != null) {
        Session.getStockSurvey().complete();
        Date eventDate = new Date();
        saveEventDate(Session.getMalariaSurvey(), eventDate);
        saveEventDate(Session.getStockSurvey(), eventDate);
        new CompletionSurveyUseCase().execute(Session.getMalariaSurvey().getId_survey());
    }
}
Also used : Survey(org.eyeseetea.malariacare.data.database.model.Survey) CompletionSurveyUseCase(org.eyeseetea.malariacare.domain.usecase.CompletionSurveyUseCase) Date(java.util.Date)

Example 14 with Survey

use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.

the class DashboardActivityStrategy method completeSurvey.

@Override
public void completeSurvey() {
    Date eventDate = new Date();
    //Complete malariaSurvey
    Survey survey = Session.getMalariaSurvey();
    saveEventDate(survey, eventDate);
    survey.updateSurveyStatus();
    //Complete stockSurvey
    survey = Session.getStockSurvey();
    saveEventDate(survey, eventDate);
    survey.complete();
}
Also used : Survey(org.eyeseetea.malariacare.data.database.model.Survey) Date(java.util.Date)

Example 15 with Survey

use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.

the class DashboardActivity method onSurveyBackPressed.

/**
     * It is called when the user press back in a surveyFragment
     */
private void onSurveyBackPressed() {
    //// FIXME: 09/03/2017 Refactor. If the survey is loading the survey should be closed at the end
    if (Session.isIsLoadingSurvey()) {
        Session.setShouldPressBackOnLoadSurvey(true);
        return;
    }
    Log.d(TAG, "onBackPressed");
    Survey survey = Session.getMalariaSurvey();
    if (!survey.isSent()) {
        int infoMessage = survey.isInProgress() ? R.string.survey_info_exit_delete : R.string.survey_info_exit;
        new AlertDialog.Builder(this).setTitle(R.string.survey_info_exit).setMessage(infoMessage).setNegativeButton(android.R.string.no, null).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int arg1) {
                //Reload data using service
                isBackPressed = true;
                closeSurveyFragment();
            }
        }).create().show();
    } else {
        closeSurveyFragment();
    }
}
Also used : Survey(org.eyeseetea.malariacare.data.database.model.Survey) DialogInterface(android.content.DialogInterface)

Aggregations

Survey (org.eyeseetea.malariacare.data.database.model.Survey)39 Date (java.util.Date)8 Intent (android.content.Intent)7 Value (org.eyeseetea.malariacare.data.database.model.Value)6 ArrayList (java.util.ArrayList)4 Program (org.eyeseetea.malariacare.data.database.model.Program)3 Question (org.eyeseetea.malariacare.data.database.model.Question)3 Session.getMalariaSurvey (org.eyeseetea.malariacare.data.database.utils.Session.getMalariaSurvey)3 Option (org.eyeseetea.malariacare.data.database.model.Option)2 OrgUnit (org.eyeseetea.malariacare.data.database.model.OrgUnit)2 EventExtended (org.eyeseetea.malariacare.data.sync.importer.models.EventExtended)2 ImportSummaryErrorException (org.eyeseetea.malariacare.domain.exception.ImportSummaryErrorException)2 DialogInterface (android.content.DialogInterface)1 NonNull (android.support.annotation.NonNull)1 View (android.view.View)1 ListView (android.widget.ListView)1 TableRow (android.widget.TableRow)1 Calendar (java.util.Calendar)1 HashSet (java.util.HashSet)1 CompositeScore (org.eyeseetea.malariacare.data.database.model.CompositeScore)1