Esempio n. 1
0
  public void testSecondaryMIDUAP() throws Exception {
    tranDAO.logTransaction(TransactionType.PATIENT_CREATE, 9000000001L, 98L, "added information");
    List<TransactionBean> list = tranDAO.getAllTransactions();

    assertEquals(9000000001L, list.get(0).getLoggedInMID());
    assertEquals(98L, list.get(0).getSecondaryMID());
  }
Esempio n. 2
0
 public void testLogFull() throws Exception {
   tranDAO.logTransaction(TransactionType.OFFICE_VISIT_EDIT, 9000000000L, 1L, "added information");
   List<TransactionBean> list = tranDAO.getAllTransactions();
   assertEquals(9, list.size());
   assertEquals(9000000000L, list.get(0).getLoggedInMID());
   assertEquals(1L, list.get(0).getSecondaryMID());
   assertEquals("added information", list.get(0).getAddedInfo());
   assertEquals(TransactionType.OFFICE_VISIT_EDIT, list.get(0).getTransactionType());
 }
  /**
   * Returns a list of TransactionBeans between the two dates passed as params
   *
   * @param lowerDate the first date
   * @param upperDate the second date
   * @return list of TransactionBeans
   * @throws DBException
   * @throws FormValidationException
   */
  public List<TransactionBean> getAccesses(
      String lowerDate, String upperDate, String logMID, boolean getByRole)
      throws ITrustException, DBException, FormValidationException {
    List<TransactionBean> accesses; // stores the log entries
    List<PersonnelBean> dlhcps;

    // get the medical dependents for a signed in user. If the selected user is not the
    // signed in user or one of the dependents, then the user doesn't have access to the log
    List<PatientBean> patientRelatives = getRepresented(loggedInMID);

    long mid = loggedInMID;
    try {
      mid = Long.parseLong(logMID);
    } catch (Exception e) {
      // TODO
    }

    dlhcps = patientDAO.getDeclaredHCPs(mid);

    boolean midInScope = false;
    for (PatientBean pb : patientRelatives) {
      if (pb.getMID() == mid) midInScope = true;
    }
    if (mid != loggedInMID
        && !midInScope) { // the selected user in the form is out of scope and can't be shown to the
                          // user
      throw new FormValidationException("Log to View.");
    }

    // user has either 0 or 1 DLHCP's. Get one if exists so it can be filtered from results
    long dlhcpID = -1;
    if (!dlhcps.isEmpty()) dlhcpID = dlhcps.get(0).getMID();

    if (lowerDate == null || upperDate == null)
      return transDAO.getAllRecordAccesses(mid, dlhcpID, getByRole);

    try {
      Date lower = new SimpleDateFormat("MM/dd/yyyy").parse(lowerDate);
      Date upper = new SimpleDateFormat("MM/dd/yyyy").parse(upperDate);

      if (lower.after(upper))
        throw new FormValidationException("Start date must be before end date!");
      accesses = transDAO.getRecordAccesses(mid, dlhcpID, lower, upper, getByRole);
    } catch (ParseException e) {
      throw new FormValidationException("Enter dates in MM/dd/yyyy");
    }
    return accesses;
  }
Esempio n. 4
0
 public void testGetAllTransactions() throws Exception {
   List<TransactionBean> list = tranDAO.getAllTransactions();
   assertEquals(8, list.size());
   // that last one inserted should be last because it was backdated
   assertEquals(1L, list.get(3).getLoggedInMID());
   assertEquals(TransactionType.DEMOGRAPHICS_EDIT, list.get(3).getTransactionType());
 }
Esempio n. 5
0
 /**
  * Updates a lab procedure
  *
  * @param b the procedure to update
  * @throws DBException
  * @throws FormValidationException
  */
 public void updateProcedure(LabProcedureBean b) throws DBException, FormValidationException {
   validator.validate(b);
   // need to check if status is what's being changed - if new status!=old status send email
   if (!b.getStatus().equals(lpDAO.getLabProcedure(b.getProcedureID()).getStatus())) {
     new EmailUtil(factory).sendEmail(makeEmail(b));
   }
   lpDAO.updateLabProcedure(b);
   transDAO.logTransaction(
       TransactionType.ENTER_EDIT_LAB_PROCEDURE,
       loggedInMID,
       b.getPid(),
       "UAP updated procedure id: " + b.getProcedureID());
 }
 /**
  * Retrieves a PersonnelBean for the mid passed as a param
  *
  * @param input the mid for which the PersonnelBean will be returned
  * @return PersonnelBean
  * @throws iTrustException
  */
 public PersonnelBean getPersonnel(String input) throws iTrustException {
   try {
     long mid = Long.valueOf(input);
     PersonnelBean personnel = personnelDAO.getPersonnel(mid);
     if (personnel != null) {
       transDAO.logTransaction(
           TransactionType.ENTER_EDIT_DEMOGRAPHICS,
           loggedInMID,
           mid,
           Messages.getString("ViewPersonnelAction.0") + mid); // $NON-NLS-1$
       return personnel;
     } else throw new iTrustException(Messages.getString("ViewPersonnelAction.1")); // $NON-NLS-1$
   } catch (NumberFormatException e) {
     e.printStackTrace();
     throw new iTrustException(Messages.getString("ViewPersonnelAction.2")); // $NON-NLS-1$
   }
 }
Esempio n. 7
0
 /**
  * Returns a list of all the lab procedures
  *
  * @param id MID of the UAP viewing the procedures
  * @return a list of all the lab procedures for that UAP
  * @throws DBException
  */
 public List<LabProcedureBean> viewProcedures(long id) throws DBException {
   transDAO.logTransaction(
       TransactionType.VIEW_LAB_PROCEDURE, loggedInMID, id, "UAP viewed procedures");
   return lpDAO.getAllLabProceduresDate(id);
 }