Skip to content
Snippets Groups Projects
Commit c0a5d37e authored by htmoss2's avatar htmoss2
Browse files

Merge branch 'UC91.2' into 'master'

Uc91.2

See merge request !4
parents 5638b67d d25030fb
No related branches found
No related tags found
1 merge request!4Uc91.2
<%@include file="/global.jsp" %>
<%
pageTitle = "iTrust - Pre-Registered Patient Home";
%>
<%@include file="/header.jsp" %>
<%@include file="/footer.jsp" %>
<div class="panel panel-default">
<div class="panel-heading" anim-type="collapse" anim-target="#edit-menu">
<h2 class="panel-title">Please wait for HCP approval to access account features.</h2>
</div>
</div>
......@@ -43,7 +43,7 @@ function fillLoginFields(u,p) {
<br /><br />
<a style="font-size: 80%;" href="/iTrust/util/resetPassword.jsp">Reset Password</a>
<a> </a>
<a style="font-size: 80%;" href="/iTrust/util/PreRegisterPatient.jsp">Pre-Register</a>
<a style="font-size: 80%;" href="/iTrust/util/PreRegisterPatient.jsp" id="preregister_link">Pre-Register</a>
</form>
<%
......
<%@taglib prefix="itrust" uri="/WEB-INF/tags.tld"%>
<%@page errorPage="/auth/exceptionHandler.jsp"%>
<%@page import="edu.ncsu.csc.itrust.action.AddPreRegisteredPatientAction"%>
<%@page import="edu.ncsu.csc.itrust.BeanBuilder"%>
<%@page import="edu.ncsu.csc.itrust.beans.PatientBean"%>
<%@page import="edu.ncsu.csc.itrust.beans.forms.HealthRecordForm"%>
<%@page import="edu.ncsu.csc.itrust.exception.FormValidationException"%>
<%@include file="/global.jsp" %>
<%
pageTitle = "iTrust - Add Patient";
%>
<%@include file="/header.jsp" %>
<%
boolean formIsFilled = request.getParameter("formIsFilled") != null && request.getParameter("formIsFilled").equals("true");
if (formIsFilled) {
PatientBean p = new BeanBuilder<PatientBean>().build(request.getParameterMap(), new PatientBean());
HealthRecordForm h = new BeanBuilder<HealthRecordForm>().build(request.getParameterMap(), new HealthRecordForm());
long mid = new PreRegisterPatientAction(prodDAO).addPatient(p);
String name = "<Name>";
if (p != null) {
name = p.getFullName();
}
%>
<div><%=s%></div>
<%
}
%>
<div align=center>
<form action="PreRegisterPatient.jsp" method="post">
<input type="hidden" name="formIsFilled" value="true"> <br />
<br />
<div style="width: 50%; text-align:left;">Please enter in the name of the Pre-registered
patient, with a valid email address. If the user does not have an email
address, use the hospital's email address, [insert pre-defined email],
to recover the password.</div>
<br />
<br />
<table class="fTable">
<tr>
<th colspan=2 style="text-align:center">Pre-registered Patient Information</th>
</tr>
<tr>
<td class="subHeaderVertical">First name:</td>
<td><input type="text" name="firstName" required> *</td>
</tr>
<tr>
<td class="subHeaderVertical">Last Name:</td>
<td><input type="text" name="lastName" required> *</td>>
</tr>
<tr>
<td class="subHeaderVertical">Email:</td>
<td><input type="text" name="email" required> *</td>
</tr>
<tr>
<td class="subHeaderVertical">Password:</td>
<td><input type="password" name="password" required> *</td>
</tr>
<tr>
<td class="subHeaderVertical">Verify Password:</td>
<td><input type="password" name="verifyPassword" required> *</td>
</tr>
<tr>
<td class="subHeaderVertical">Address:</td>
<td> <input name="streetAddress1" type="text"><br />
<input name="streetAddress2" type="text"></td>
</tr>
<tr>
<td class="subHeaderVertical">City:</td>
<td> <input name="city" type="text"></td>
</tr>
<tr>
<td class="subHeaderVertical">State:</td>
<td><itrust:state name="state" value="AK" /></td>
</tr>
<tr>
<td class="subHeaderVertical">Zip:</td>
<td> <input type="text" name="zip" maxlength="10" size="10"></td>
</tr>
<tr>
<td class="subHeaderVertical">Phone:</td>
<td> <input type="text" name="phone" size="12" maxlength="12"></td>
</tr>
<tr>
<td class="subHeaderVertical">Height:</td>
<td><input type="text" name="height" value="0"></td>
</tr>
<tr>
<td class="subHeaderVertical">Weight:</td>
<td><input type="text" name="weight" value="0"></td>
</tr>
<tr>
<td class="subHeaderVertical">Smoker:</td>
<td><input type="radio" id="smoker_yes" name="isSmoker" value="true">
<label for="smoker_yes">Yes</label>
<br>
<input type="radio" id="smoker_no" name="isSmoker" value="false">
<label for="smoker_no">No</label><br></td>
</tr>
<br/>
<tr>
<th colspan=2 style="text-align:center">Insurance Information</th>
</tr>
<tr>
<td class="subHeaderVertical">Insurance Provider Name:</td>
<td> <input type="text" name="icName"></td>
</tr>
<tr>
<td class="subHeaderVertical">Insurance Provider Address:</td>
<td><input name="icAddress1" type="text"><br />
<input name="icAddress2" type="text"></td>
</tr>
<tr>
<td class="subHeaderVertical">City:</td>
<td> <input name="icCity" type="text"></td>
</tr>
<tr>
<td class="subHeaderVertical">State:</td>
<td><itrust:state name="icState" value="AK" /></td>
</tr>
<tr>
<td class="subHeaderVertical">Zip:</td>
<td> <input type="text" name="icZip" maxlength="10" size="10"></td>
</tr>
<tr>
<td class="subHeaderVertical">Insurance Provider Phone:</td>
<td><input type="text" name="icPhone"></td>
</tr>
</table>
<br />
<input type="submit" style="font-size: 16pt; font-weight: bold;" value="Patient Pre-Register">
</form>
<br />
</div>
<%@include file="/footer.jsp" %>
<%@taglib prefix="itrust" uri="/WEB-INF/tags.tld"%>
<%@page errorPage="/auth/exceptionHandler.jsp"%>
<%@page import="edu.ncsu.csc.itrust.action.AddPreRegisteredPatientAction"%>
<%@page import="edu.ncsu.csc.itrust.BeanBuilder"%>
<%@page import="edu.ncsu.csc.itrust.beans.PatientBean"%>
<%@page import="edu.ncsu.csc.itrust.exception.FormValidationException"%>
<%@page import="edu.ncsu.csc.itrust.exception.ITrustException"%>
<%@include file="/global.jsp" %>
<%
pageTitle = "iTrust - PreRegister Patient";
%>
<%@include file="/header.jsp" %>
<%
boolean formIsFilled = request.getParameter("formIsFilled") != null && request.getParameter("formIsFilled").equals("true");
if (formIsFilled) {
//This page is not actually a "page", it just adds a user and forwards.
PatientBean p = new BeanBuilder<PatientBean>().build(request.getParameterMap(), new PatientBean());
try {
long newMID = 021700L;
newMID = new AddPreRegisteredPatientAction(DAOFactory.getProductionInstance(), newMID).addPatient(p);
session.setAttribute("pid", Long.toString(newMID));
String fullname;
String password;
password = p.getPassword();
fullname = p.getFullName();
loggingAction.logEvent(TransactionType.PATIENT_CREATE, newMID, newMID, "");
%>
<div align=center>
<span class="iTrustMessage">New Pre-registered Prepatient <%= StringEscapeUtils.escapeHtml("" + (fullname)) %> successfully added!</span>
<br /><br />
<table class="fTable">
<tr>
<th colspan=2>New Pre-registered Patient Information</th>
</tr>
<tr>
<td class="subHeaderVertical">MID:</td>
<td><%= StringEscapeUtils.escapeHtml("" + (newMID)) %></td>
<td></td>
</tr>
<tr>
<td class="subHeaderVertical">Temporary Password:</td>
<td><%= StringEscapeUtils.escapeHtml("" + (password)) %></td>
<td></td>
</tr>
</table>
<br />Please get this information to <b><%= StringEscapeUtils.escapeHtml("" + (fullname)) %></b>!
</div>
<%
} catch(FormValidationException e){
%>
<div align=center>
<span class="iTrustError"> <%= StringEscapeUtils.escapeHtml(e.getMessage()) %></span>
<!-- StringEscapeUtils.escapeHtml(e.getMessage()) -->
</div>
<%
} catch (ITrustException e) {
%>
<div align=center>
<span class="iTrustError"> <%= StringEscapeUtils.escapeHtml(e.getMessage()) %></span>
<!-- StringEscapeUtils.escapeHtml(e.getMessage()) -->
</div>
<%
}
}
%>
<div align=center>
<form action="PreRegisterPatient.jsp" method="post"> <!-- Which page DIRECT to -->
<input type="hidden" name="formIsFilled" value="true"> <br />
<br />
<div style="width: 50%; text-align:left;">Please enter in the name of the Pre-registered
patient, with a valid email address. If the user does not have an email
address, use the hospital's email address, [insert pre-defined email],
to recover the password.</div>
<br />
<br />
<table class="fTable">
<tr>
<th colspan=2 style="text-align:center">Pre-registered Patient Information</th>
</tr>
<tr>
<td class="subHeaderVertical">First name:</td>
<td><input type="text" name="firstName" required> *</td>
</tr>
<tr>
<td class="subHeaderVertical">Last Name:</td>
<td><input type="text" name="lastName" required> *</td>>
</tr>
<tr>
<td class="subHeaderVertical">Email:</td>
<td><input type="text" name="email" required> *</td>
</tr>
<tr>
<td class="subHeaderVertical">Password:</td>
<td><input type="password" name="password" required> *</td>
</tr>
<tr>
<td class="subHeaderVertical">Verify Password:</td>
<td><input type="password" name="verifyPassword" required> *</td>
</tr>
<tr>
<td class="subHeaderVertical">Address:</td>
<td> <input name="streetAddress1" type="text"><br />
<input name="streetAddress2" type="text"></td>
</tr>
<tr>
<td class="subHeaderVertical">City:</td>
<td> <input name="city" type="text"></td>
</tr>
<tr>
<td class="subHeaderVertical">State:</td>
<td><itrust:state name="state" value="AK" /></td>
</tr>
<tr>
<td class="subHeaderVertical">Zip:</td>
<td> <input type="text" name="zip" maxlength="10" size="10"></td>
</tr>
<tr>
<td class="subHeaderVertical">Phone:</td>
<td> <input type="text" name="phone" size="12" maxlength="12"></td>
</tr>
<tr>
<td class="subHeaderVertical">Height:</td>
<td><input type="text" name="height"></td>
</tr>
<tr>
<td class="subHeaderVertical">Weight:</td>
<td><input type="text" name="weight"></td>
</tr>
<tr>
<td class="subHeaderVertical">Smoker:</td>
<td><input type="radio" id="smoker_yes" name="isSmoker" value="true">
<label for="smoker_yes">Yes</label>
<br>
<input type="radio" id="smoker_no" name="isSmoker" value="false">
<label for="smoker_no">No</label><br>
</td>
</tr>
<br/>
<tr>
<th colspan=2 style="text-align:center">Insurance Information</th>
</tr>
<tr>
<td class="subHeaderVertical">Insurance Provider Name:</td>
<td> <input type="text" name="icName"></td>
</tr>
<tr>
<td class="subHeaderVertical">Insurance Provider Address:</td>
<td><input name="icAddress1" type="text"><br />
<input name="icAddress2" type="text"></td>
</tr>
<tr>
<td class="subHeaderVertical">City:</td>
<td> <input name="icCity" type="text"></td>
</tr>
<tr>
<td class="subHeaderVertical">State:</td>
<td><itrust:state name="icState" value="AK" /></td>
</tr>
<tr>
<td class="subHeaderVertical">Zip:</td>
<td> <input type="text" name="icZip" maxlength="10" size="10"></td>
</tr>
<tr>
<td class="subHeaderVertical">Insurance Provider Phone:</td>
<td><input type="text" name="icPhone"></td>
</tr>
</table>
<br />
<input type="submit" style="font-size: 16pt; font-weight: bold;" value="Patient Pre-Register" id="submit_preregister">
</form>
<br />
</div>
<%@include file="/footer.jsp" %>
......@@ -49,7 +49,12 @@ public class AddPreRegisteredPatientAction {
public long addPatient(PatientBean p) throws FormValidationException, ITrustException {
new AddPatientValidator().validate(p);
new AddPatientValidator().validate(p);
// Make sure the email is unique
if (patientDAO.isEmailInUse(p.getEmail())) {
throw new ITrustException("This email is already in use. Please use another email address.");
}
long newMID = patientDAO.addEmptyPatient(); // the new added row id in the database
p.setMID(newMID);
......
......@@ -222,7 +222,29 @@ public class PatientDAO {
} finally {
DBUtil.closeConnection(conn, ps);
}
}
}
public boolean isEmailInUse(String email) throws DBException {
Connection conn = null;
PreparedStatement ps = null;
boolean emailInUse = false;
try {
conn = factory.getConnection();
ps = conn.prepareStatement("SELECT * FROM patients WHERE email=?");
ps.setString(1, email);
ResultSet rs;
rs = ps.executeQuery();
emailInUse = rs.next();
rs.close();
ps.close();
} catch (SQLException e) {
throw new DBException(e);
} finally {
DBUtil.closeConnection(conn, ps);
}
return emailInUse;
}
public void addHistory(long pid, long hcpid) throws DBException {
Connection conn = null;
......
package edu.ncsu.csc.itrust.selenium;
import org.openqa.selenium.*;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import edu.ncsu.csc.itrust.enums.TransactionType;
public class PreRegisterPatientTest extends iTrustSeleniumTest {
protected WebDriver driver;
@Override
protected void setUp() throws Exception {
super.setUp();
gen.clearAllTables();
gen.standardData();
driver = new HtmlUnitDriver();
driver.manage().timeouts().implicitlyWait(DEFAULT_TIMEOUT, TimeUnit.SECONDS);
}
private void goToPreRegister() {
// Go to preregister page
driver.get(ADDRESS);
driver.findElement(By.id("preregister_link")).click();
}
public void testPreRegisterPatientButton() throws Exception {
goToPreRegister();
assertEquals("iTrust - PreRegister Patient", driver.getTitle());
}
public void testPreRegisterPatientSuccessRequired() throws Exception {
goToPreRegister();
// Fill the form
driver.findElement(By.xpath("//input[@name='firstName']")).sendKeys("fname");
driver.findElement(By.xpath("//input[@name='lastName']")).sendKeys("lname");
driver.findElement(By.xpath("//input[@name='email']")).sendKeys("name@email.com");
driver.findElement(By.xpath("//input[@name='password']")).sendKeys("Password123");
driver.findElement(By.xpath("//input[@name='verifyPassword']")).sendKeys("Password123");
// Submit
driver.findElement(By.id("submit_preregister")).click();
assertTrue(driver.findElement(By.xpath("//body")).getText().contains("New Pre-registered Patient Information"));
}
public void testMissingElements() {
goToPreRegister();
// Check that all elements have the required attribute
assertTrue(
Boolean.parseBoolean(driver.findElement(By.xpath("//input[@name='firstName']")).getAttribute("required"))
&& Boolean.parseBoolean(driver.findElement(By.xpath("//input[@name='lastName']")).getAttribute("required"))
&& Boolean.parseBoolean(driver.findElement(By.xpath("//input[@name='email']")).getAttribute("required"))
&& Boolean.parseBoolean(driver.findElement(By.xpath("//input[@name='password']")).getAttribute("required"))
&& Boolean.parseBoolean(driver.findElement(By.xpath("//input[@name='verifyPassword']")).getAttribute("required"))
);
// Make sure that the form does not submit
driver.findElement(By.xpath("//input[@name='firstName']")).sendKeys("");
driver.findElement(By.xpath("//input[@name='lastName']")).sendKeys("lname");
driver.findElement(By.xpath("//input[@name='email']")).sendKeys("name@email.com");
driver.findElement(By.xpath("//input[@name='password']")).sendKeys("Password123");
driver.findElement(By.xpath("//input[@name='verifyPassword']")).sendKeys("Password123");
driver.findElement(By.id("submit_preregister")).click();
assertFalse(driver.findElement(By.xpath("//body")).getText().contains("New Pre-registered Patient Information"));
}
public void testInvalidName() {
goToPreRegister();
driver.findElement(By.xpath("//input[@name='firstName']")).sendKeys("123abc");
driver.findElement(By.xpath("//input[@name='lastName']")).sendKeys("lname");
driver.findElement(By.xpath("//input[@name='email']")).sendKeys("name@email.com");
driver.findElement(By.xpath("//input[@name='password']")).sendKeys("Password123");
driver.findElement(By.xpath("//input[@name='verifyPassword']")).sendKeys("Password123");
driver.findElement(By.id("submit_preregister")).click();
assertTrue(driver.findElement(By.xpath("//body")).getText().contains("This form has not been validated correctly"));
}
public void testInvalidEmail() {
goToPreRegister();
driver.findElement(By.xpath("//input[@name='firstName']")).sendKeys("fname");
driver.findElement(By.xpath("//input[@name='lastName']")).sendKeys("lname");
driver.findElement(By.xpath("//input[@name='email']")).sendKeys("not-an-email");
driver.findElement(By.xpath("//input[@name='password']")).sendKeys("Password123");
driver.findElement(By.xpath("//input[@name='verifyPassword']")).sendKeys("Password123");
driver.findElement(By.id("submit_preregister")).click();
assertTrue(driver.findElement(By.xpath("//body")).getText().contains("This form has not been validated correctly"));
}
}
\ No newline at end of file
......@@ -95,4 +95,35 @@ public class AddPreRegisterPatientActionTest extends TestCase {
}
}
/**
* Ensure that duplicate emails are not allowed
*/
public void testPreRegisterPatientDuplicateEmail() throws Exception {
PatientBean p2 = new PatientBean();
p2.setFirstName("Jiminy");
p2.setLastName("Cricket");
p2.setEmail("make.awish@gmail.com");
p2.setPassword("password");
action.addPatient(p2);
PatientBean p3 = new PatientBean();
p3.setFirstName("Make");
p3.setLastName("AWish");
p3.setEmail("make.awish@gmail.com");
p3.setPassword("password");
try {
action.addPatient(p3);
fail("Duplicate email");
} catch (ITrustException e) { }
}
/**
* Check that invalid names are not allowed
*/
public void testPreRegisterPatientInvalidName() throws Exception {
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment