/*
   * [{"IDpatient": "12-09-1000.Bayoumy","firstname": "Mohamed","lastname": "Bayoumy","dateofbirth": "12-09-1000"},
   * {"IDpatient": "12-02-1500.Omran","firstname": "Ahmed","lastname": "Omran","dateofbirth": "12-02-1500"}]
   *
   */
  public void parseJSONPatient(String JSON) {
    String IDpatient, firstname, lastname, dateofbirth;
    JSONParser parser = new JSONParser();
    try {
      Object obj = parser.parse(JSON);
      JSONArray array = (JSONArray) obj;
      for (int i = 0; i < array.size(); i++) {
        JSONObject everyQuestion = (JSONObject) array.get(i);

        IDpatient = everyQuestion.get("IDPatient").toString();
        firstname = everyQuestion.get("firstname").toString();
        lastname = everyQuestion.get("lastname").toString();
        dateofbirth = everyQuestion.get("dateofbirth").toString();

        FeedbackFunctionality addToTable =
            new FeedbackFunctionality(IDpatient, firstname, lastname, dateofbirth);
        try {
          addToTable.addpatients();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
    } catch (ParseException pe) {
    }
  }
  public void parseJSONFeedback(String JSON) {
    String answer, patientID;
    int questionID, questionnaire;
    JSONParser parser = new JSONParser();
    try {
      Object obj = parser.parse(JSON);
      JSONArray array = (JSONArray) obj;
      for (int i = 0; i < array.size(); i++) {
        JSONObject everyQuestion = (JSONObject) array.get(i);

        answer = everyQuestion.get("Answer").toString();
        questionID = Integer.parseInt(everyQuestion.get("QuestionID").toString());
        patientID = everyQuestion.get("PatientID").toString();
        questionnaire = Integer.parseInt(everyQuestion.get("QuestionnaireID").toString());
        FeedbackFunctionality addToTable =
            new FeedbackFunctionality(questionnaire, patientID, questionID, answer);
        try {
          addToTable.addfeedback();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
    } catch (ParseException pe) {
    }
  }