コード例 #1
0
  /**
   * Adds the new user. Event is logged.
   *
   * @param p bean containing the information for the new user
   * @return MID of the new user.
   * @throws FormValidationException
   * @throws iTrustException
   */
  public long add(PersonnelBean p) throws FormValidationException, iTrustException {
    new AddPersonnelValidator().validate(p);
    long newMID = personnelDAO.addEmptyPersonnel(Role.ER);
    p.setMID(newMID);
    personnelDAO.editPersonnel(p);
    String pwd = authDAO.addUser(newMID, Role.ER, RandomPassword.getRandomPassword());
    p.setPassword(pwd);

    return newMID;
  }
コード例 #2
0
 /** Sets up defaults */
 @Override
 protected void setUp() throws Exception {
   // Step 0. Initialize the mocks and other necessary objects.
   super.initMocks();
   // Step 1. Initialize any other classes we need.
   personnel = new PersonnelBean();
   personnel.setFirstName("Cosmo");
   personnel.setLastName("Kramer");
   personnel.setEmail("*****@*****.**");
   personnel.setRole(Role.HCP);
 }
コード例 #3
0
ファイル: EditPHRAction.java プロジェクト: bsundar2/iTrust
  /**
   * 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.
  }
コード例 #4
0
ファイル: EditPHRAction.java プロジェクト: bsundar2/iTrust
  /**
   * Creates a fake e-mail to notify the user that their records have been altered.
   *
   * @return the e-mail to be sent
   * @throws DBException
   */
  private Email makeEmail() throws DBException {

    Email email = new Email();
    List<PatientBean> reps = patientDAO.getRepresenting(patient.getMID());

    List<String> toAddrs = new ArrayList<String>();
    toAddrs.add(patient.getEmail());
    for (PatientBean r : reps) {
      toAddrs.add(r.getEmail());
    }

    email.setFrom("*****@*****.**");
    email.setToList(toAddrs); // patient and personal representative
    email.setSubject(String.format("Your medical records have been altered"));
    email.setBody(
        "Health care professional "
            + HCPUAP.getFullName()
            + " has altered your medical records. "
            + "She is not on your list of designated health care professionals.");
    return email;
  }
コード例 #5
0
 public void testViewPersonnel() throws Exception {
   action = new ViewPersonnelAction(factory, 4L);
   PersonnelBean hcp = action.getPersonnel("9000000003");
   assertEquals(9000000003L, hcp.getMID());
 }
コード例 #6
0
  public void testGetPersonnel() throws iTrustException {
    PersonnelBean pBean = action.getPersonnel(hcpId);

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