Exemplo n.º 1
0
  /**
   * Adds an allergy to the patient's records
   *
   * @param pid pid
   * @param ndcode ndcode
   * @return "Allergy Added", exception message, a list of invalid fields, or "" (only if
   *     description is null)
   * @throws FormValidationException
   * @throws ITrustException
   */
  public String updateAllergies(long pid, String description)
      throws FormValidationException, ITrustException {
    AllergyBean bean = new AllergyBean();
    bean.setPatientID(pid);
    bean.setDescription(description);
    AllergyBeanValidator abv = new AllergyBeanValidator();
    abv.validate(bean);

    // now, set the ndcode if it happens to exist for the description
    for (MedicationBean med : ndcodesDAO.getAllNDCodes()) {
      if (med.getDescription().equalsIgnoreCase(bean.getDescription())) {
        bean.setNDCode(med.getNDCode());
        break;
      }
    }

    String patientName = patientDAO.getName(pid);
    List<AllergyBean> allergies = allergyDAO.getAllergies(pid);
    for (AllergyBean current : allergies) {
      if (current.getDescription().equalsIgnoreCase(bean.getDescription())) {
        return "Allergy "
            + bean.getNDCode()
            + " - "
            + bean.getDescription()
            + " has already been added for "
            + patientName
            + ".";
      }
    }

    allergyDAO.addAllergy(bean);
    emailutil.sendEmail(makeEmail());
    /*
     * adding loop that checks for allergy conflicts. The loop runs through every prescription bean
     * and checks for conflict.
     */
    List<PrescriptionBean> beansRx = patientDAO.getCurrentPrescriptions(pid);
    for (int i = 0; i < beansRx.size(); i++) {
      if (beansRx.get(i).getMedication().getNDCode().equals(bean.getNDCode())) {
        return "Medication "
            + beansRx.get(i).getMedication().getNDCode()
            + " - "
            + beansRx.get(i).getMedication().getDescription()
            + " is currently prescribed to "
            + patientName
            + ".";
      }
    }

    // log that this was added
    loggingAction.logEvent(
        TransactionType.parse(6700),
        HCPUAP.getMID(),
        patient.getMID(),
        "An allergy record has been added: " + bean.getId());

    return "Allergy Added"; // If loop is successful, it will never reach here.
  }
Exemplo n.º 2
0
 public void testViewPersonnel() throws Exception {
   action = new ViewPersonnelAction(factory, 4L);
   PersonnelBean hcp = action.getPersonnel("9000000003");
   assertEquals(9000000003L, hcp.getMID());
 }
  public void testGetPersonnel() throws iTrustException {
    PersonnelBean pBean = action.getPersonnel(hcpId);

    assertEquals(hcpId, pBean.getMID());
  }