public void testInvalidData()
     throws CSVFormatException, AddPatientFileException, FileNotFoundException {
   DAOFactory prodDAO = DAOFactory.getProductionInstance();
   AuthDAO authDAO = prodDAO.getAuthDAO();
   InputStream testFile = new FileInputStream(fileDirectory + "HCPPatientUploadInvalidData.csv");
   AddPatientFileAction apfa = new AddPatientFileAction(testFile, null, 0);
   assertEquals(1, apfa.getPatients().size());
   assertTrue(apfa.getErrors().hasErrors());
 }
Example #2
0
 /**
  * The super class validates the patient id
  *
  * @param factory The DAOFactory used to create the DAOs for this action.
  * @param loggedInMID The MID of the user who is authorizing this action.
  * @param pidString The MID of the patient being edited.
  * @throws ITrustException
  */
 public EditPatientAction(DAOFactory factory, long loggedInMID, String pidString)
     throws ITrustException {
   super(factory, pidString);
   this.patientDAO = factory.getPatientDAO();
   this.personnelDAO = factory.getPersonnelDAO();
   this.authDAO = factory.getAuthDAO();
   this.loggedInMID = loggedInMID;
   emailutil = new EmailUtil(factory);
 }
 public void testInvalidHeader()
     throws CSVFormatException, AddPatientFileException, FileNotFoundException {
   DAOFactory prodDAO = DAOFactory.getProductionInstance();
   AuthDAO authDAO = prodDAO.getAuthDAO();
   InputStream testFile = new FileInputStream(fileDirectory + "HCPPatientUploadInvalidField.csv");
   try {
     new AddPatientFileAction(testFile, null, 0);
   } catch (AddPatientFileException e) {
     return;
   }
   assertTrue(false);
 }
 /**
  * Accepts the DAO factory and the CSV stream from the view and parses it.
  *
  * @param factory The DAO factory
  * @param loggedInMID The MID of the HCP
  * @param CSVStream The CSV stream uploaded by the user
  * @throws CSVFormatException
  * @throws AddPatientFileExceptionTest
  */
 public AddPatientFileAction(InputStream CSVStream, DAOFactory factory, long loggedInMID)
     throws CSVFormatException, AddPatientFileException {
   if (factory != null) {
     this.patientDAO = factory.getPatientDAO();
     this.loggedInMID = loggedInMID;
     this.authDAO = factory.getAuthDAO();
   }
   CSVParser parser = new CSVParser(CSVStream);
   CSVHeader = parser.getHeader();
   CSVData = parser.getData();
   errors = parser.getErrors();
   buildMappings(CSVHeader);
   try {
     createPatients();
   } catch (DBException e) {
     throw new AddPatientFileException("Database error while adding new patients!");
   }
 }
Example #5
0
 /**
  * Sets up the defaults for the class
  *
  * @param factory factory for creating the defaults.
  * @param loggedInMID person currently logged in
  * @author Andy Meneely
  */
 public AddERespAction(DAOFactory factory, long loggedInMID) {
   this.personnelDAO = factory.getPersonnelDAO();
   this.authDAO = factory.getAuthDAO();
   this.transDAO = factory.getTransactionDAO();
   this.loggedInMID = loggedInMID;
 }