Search in sources :

Example 26 with Question

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

the class OrgUnitToOptionConverter method convert.

public static void convert() {
    List<Question> questions = Question.getAllQuestionsWithOrgUnitDropdownList();
    if (questions.size() == 0) {
        return;
    }
    List<OrgUnit> orgUnits = OrgUnit.getAllOrgUnit();
    for (OrgUnit orgUnit : orgUnits) {
        addOUOptionToQuestions(questions, orgUnit);
    }
}
Also used : OrgUnit(org.eyeseetea.malariacare.data.database.model.OrgUnit) Question(org.eyeseetea.malariacare.data.database.model.Question)

Example 27 with Question

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

the class Treatment method getACTOptions.

public Answer getACTOptions(org.eyeseetea.malariacare.data.database.model.Treatment mainTreatment) {
    List<Option> options = new ArrayList<>();
    Answer answer = new Answer("stock");
    answer.setId_answer(Answer.DYNAMIC_STOCK_ANSWER_ID);
    //this options are never saved
    Option optionACT24 = new Option("ACT_x_24", "ACT_x_24", 0f, answer);
    optionACT24.setId_option(Question.getACT24Question().getId_question());
    optionACT24.setOptionAttribute(new OptionAttribute("c8b8c7", "question_images/p5_actx24.png"));
    Option optionACT12 = new Option("ACT_x_12", "ACT_x_12", 0f, answer);
    optionACT12.setId_option(Question.getACT12Question().getId_question());
    optionACT12.setOptionAttribute(new OptionAttribute("c8b8c7", "question_images/p5_actx12.png"));
    Option optionACT6 = new Option("ACT_x_6", "ACT_x_6", 0f, answer);
    optionACT6.setId_option(Question.getACT6Question().getId_question());
    optionACT6.setOptionAttribute(new OptionAttribute("c8b8c7", "question_images/p5_actx6.png"));
    Option optionACT18 = new Option("ACT_x_18", "ACT_x_18", 0f, answer);
    optionACT18.setId_option(Question.getACT18Question().getId_question());
    optionACT18.setOptionAttribute(new OptionAttribute("c8b8c7", "question_images/p5_actx18.png"));
    Question outStockQuestion = Question.getOutOfStockQuestion();
    Option optionOutStock = new Option("out_stock_option", "out_stock_option", 0f, outStockQuestion.getAnswer());
    optionOutStock.setOptionAttribute(new OptionAttribute("c8b8c7", "question_images/p6_stockout.png"));
    optionOutStock.setId_option(outStockQuestion.getId_question());
    List<org.eyeseetea.malariacare.data.database.model.Treatment> treatments = mainTreatment.getAlternativeTreatments();
    for (org.eyeseetea.malariacare.data.database.model.Treatment treatment : treatments) {
        List<Drug> alternativeDrugs = treatment.getDrugsForTreatment();
        for (Drug drug : alternativeDrugs) {
            if (drug.isACT24()) {
                optionACT24.setCode(treatment.getMessage().toString());
                options.add(optionACT24);
            } else if (drug.isACT18()) {
                optionACT18.setCode(treatment.getMessage().toString());
                options.add(optionACT18);
            } else if (drug.isACT12()) {
                optionACT12.setCode(treatment.getMessage().toString());
                options.add(optionACT12);
            } else if (drug.isACT6()) {
                optionACT6.setCode(treatment.getMessage().toString());
                options.add(optionACT6);
            }
        }
    }
    options.add(optionOutStock);
    answer.setOptions(options);
    return answer;
}
Also used : Drug(org.eyeseetea.malariacare.data.database.model.Drug) ArrayList(java.util.ArrayList) OptionAttribute(org.eyeseetea.malariacare.data.database.model.OptionAttribute) Answer(org.eyeseetea.malariacare.data.database.model.Answer) QuestionOption(org.eyeseetea.malariacare.data.database.model.QuestionOption) Option(org.eyeseetea.malariacare.data.database.model.Option) Question(org.eyeseetea.malariacare.data.database.model.Question)

Example 28 with Question

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

the class Treatment method getACTQuestionAnsweredNo.

public Question getACTQuestionAnsweredNo() {
    List<Question> questions = mStockSurvey.getQuestionsFromValues();
    Question actQuestion = null;
    for (Question question : questions) {
        if (isACT24Question(question) || isACT18Question(question) || isACT12Question(question) || isACT6Question(question)) {
            actQuestion = question;
            List<Value> values = mStockSurvey.getValuesFromDB();
            for (Value value : values) {
                if (value.getQuestion() == null) {
                    continue;
                }
                if (value.getQuestion().getId_question().equals(actQuestion.getId_question())) {
                    if (Float.parseFloat(value.getValue()) == 0) {
                        return actQuestion;
                    }
                }
            }
        }
    }
    return null;
}
Also used : Value(org.eyeseetea.malariacare.data.database.model.Value) Question(org.eyeseetea.malariacare.data.database.model.Question)

Example 29 with Question

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

the class Treatment method getQuestionsForTreatment.

private List<Question> getQuestionsForTreatment(org.eyeseetea.malariacare.data.database.model.Treatment treatment) {
    List<Question> questions = new ArrayList<>();
    List<Drug> drugs = treatment.getDrugsForTreatment();
    Question treatmentQuestion = new Question();
    treatmentQuestion.setOutput(Constants.QUESTION_LABEL);
    treatmentQuestion.setForm_name(treatment.getDiagnosis().toString());
    treatmentQuestion.setHelp_text(treatment.getMessage().toString());
    treatmentQuestion.setCompulsory(Question.QUESTION_NOT_COMPULSORY);
    treatmentQuestion.setHeader(Header.DYNAMIC_TREATMENT_HEADER_ID);
    questions.add(treatmentQuestion);
    for (Drug drug : drugs) {
        Question question = Question.findByUID(drug.getQuestion_code());
        if (question != null) {
            if (isPq(question)) {
                question.setForm_name(getPqTitleDose(DrugCombination.getDose(treatment, drug)));
            } else if (isCq(question)) {
                question.setForm_name(getCqTitleDose(DrugCombination.getDose(treatment, drug)));
            }
            doseByQuestion.put(question.getId_question(), DrugCombination.getDose(treatment, drug));
            questions.add(question);
        }
        if (!questions.isEmpty()) {
            Log.d(TAG, "Question: " + questions.get(questions.size() - 1) + "\n");
        }
    }
    return questions;
}
Also used : Drug(org.eyeseetea.malariacare.data.database.model.Drug) ArrayList(java.util.ArrayList) Question(org.eyeseetea.malariacare.data.database.model.Question)

Example 30 with Question

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

the class UpdateDB method updateAndAddQuestions.

public static void updateAndAddQuestions(Context context) throws IOException {
    FileCsvs fileCsvs = new FileCsvs();
    fileCsvs.saveCsvFromAssetsToFile(PopulateDB.QUESTIONS_CSV);
    List<Question> questionsDB = Question.getAllQuestions();
    HashMap<Long, Header> headerHashMap = RelationsIdCsvDB.getHeaderFKRelationCsvDB(context);
    HashMap<Long, Answer> answerHashMap = RelationsIdCsvDB.getAnswerFKRelationCsvDB(context);
    CSVReader reader = new CSVReader(new InputStreamReader(context.openFileInput(PopulateDB.QUESTIONS_CSV)), PopulateDB.SEPARATOR, PopulateDB.QUOTECHAR);
    String[] line;
    int i = 0;
    //Save new option name for each option
    while ((line = reader.readNext()) != null) {
        if (i < questionsDB.size()) {
            PopulateRow.populateQuestion(line, headerHashMap, answerHashMap, questionsDB.get(i)).save();
        } else {
            PopulateRow.populateQuestion(line, headerHashMap, answerHashMap, null).insert();
        }
        i++;
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) CSVReader(com.opencsv.CSVReader) Answer(org.eyeseetea.malariacare.data.database.model.Answer) Header(org.eyeseetea.malariacare.data.database.model.Header) Question(org.eyeseetea.malariacare.data.database.model.Question)

Aggregations

Question (org.eyeseetea.malariacare.data.database.model.Question)58 Option (org.eyeseetea.malariacare.data.database.model.Option)15 Value (org.eyeseetea.malariacare.data.database.model.Value)15 CSVReader (com.opencsv.CSVReader)11 InputStreamReader (java.io.InputStreamReader)11 ArrayList (java.util.ArrayList)7 QuestionOption (org.eyeseetea.malariacare.data.database.model.QuestionOption)7 View (android.view.View)6 Answer (org.eyeseetea.malariacare.data.database.model.Answer)5 Match (org.eyeseetea.malariacare.data.database.model.Match)5 ImageRadioButtonOption (org.eyeseetea.malariacare.views.option.ImageRadioButtonOption)5 AOptionQuestionView (org.eyeseetea.malariacare.views.question.AOptionQuestionView)5 IQuestionView (org.eyeseetea.malariacare.views.question.IQuestionView)5 DynamicStockImageRadioButtonSingleQuestionView (org.eyeseetea.malariacare.views.question.singlequestion.DynamicStockImageRadioButtonSingleQuestionView)5 TableRow (android.widget.TableRow)4 TreatmentMatch (org.eyeseetea.malariacare.data.database.model.TreatmentMatch)4 IImageQuestionView (org.eyeseetea.malariacare.views.question.IImageQuestionView)4 IMultiQuestionView (org.eyeseetea.malariacare.views.question.IMultiQuestionView)4 NumberRadioButtonMultiquestionView (org.eyeseetea.malariacare.views.question.multiquestion.NumberRadioButtonMultiquestionView)4 ImageRadioButtonSingleQuestionView (org.eyeseetea.malariacare.views.question.singlequestion.ImageRadioButtonSingleQuestionView)4