/**
   * Attempts to load the specified patient. This function must be called AFTER the sections are set
   * AND before exporting
   *
   * @param demoNo as String
   * @return True if successful, else false
   */
  public boolean loadPatient(String demoNo) {
    if (isLoaded) {
      log.error("PatientExport object is already loaded with a patient");
      return false;
    }

    this.demographicNo = new Integer(demoNo);
    this.demographic = demographicDao.getDemographic(demoNo);
    if (this.demographic == null) {
      log.error("Demographic ".concat(demoNo).concat(" can't be loaded"));
      return false;
    }

    this.patientStatus = demographic.getPatientStatus();
    this.authorId = demographic.getProviderNo();

    if (exAllergiesAndAdverseReactions) {
      this.allergies = allergyDao.findAllergies(demographicNo);
    }

    if (exMedicationsAndTreatments) {
      this.drugs = drugDao.findByDemographicId(demographicNo);

      // Sort drugs by reverse chronological order & group by DIN by sorting
      Collections.reverse(drugs);
      Collections.sort(drugs, new sortByDin());
    }

    if (exImmunizations) {
      this.preventions = preventionDao.findNotDeletedByDemographicId(demographicNo);
    }

    if (exProblemList) {
      List<Dxresearch> tempProblems = dxResearchDao.getDxResearchItemsByPatient(demographicNo);
      this.problems = new ArrayList<Dxresearch>();
      for (Dxresearch problem : tempProblems) {
        if (problem.getStatus() != 'D' && problem.getCodingSystem().equals("icd9")) {
          this.problems.add(problem);
        }
      }
    }

    // TODO Temporarily hooked into Lab Results checkbox - consider creating unique checkbox on UI
    // down the road
    if (exLaboratoryResults) {
      this.labs = assembleLabs();
      this.measurements = parseMeasurements();
    }

    if (exRiskFactors || exPersonalHistory || exFamilyHistory || exAlertsAndSpecialNeeds) {
      parseCaseManagement();
    }

    this.isLoaded = true;
    log.debug("Loaded Demo: ".concat(demographicNo.toString()));
    return true;
  }
  @Override
  public List<String> populateText() {
    List<String> list = new ArrayList<String>();
    for (Dxresearch problem : problems) {
      if (problem.getCodingSystem().equals("icd9")) {
        ProblemsModel problemsModel = new ProblemsModel(problem);
        list.add(problemsModel.getTextSummary());
      }
    }

    return list;
  }
  @Override
  public void populate() {
    for (Dxresearch problem : problems) {
      if (problem.getCodingSystem().equals("icd9")) {
        Entry entry = new Entry(x_ActRelationshipEntry.DRIV, new BL(true));
        entry.setTemplateId(Arrays.asList(new II(bodyConstants.ENTRY_TEMPLATE_ID)));
        entry.setClinicalStatement(populateClinicalStatement(Arrays.asList(problem)));
        entries.add(entry);
      }
    }

    super.populate();
  }
  ProblemsPopulator(PatientExport patientExport) {
    bodyConstants = Problems.getConstants();
    if (patientExport.isLoaded()) {
      allProblems = patientExport.getProblems();
    }
    problems = new ArrayList<Dxresearch>();

    if (allProblems != null) {
      for (Dxresearch problem : allProblems) {
        if (problem.getStatus() != 'D' && problem.getCodingSystem().equalsIgnoreCase("icd9")) {
          this.problems.add(problem);
        }
      }
    }
  }