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

Merge branch 'UC91.1' into 'master'

Uc91.1

See merge request !3
parents 74c07b21 0bf0d424
No related branches found
No related tags found
1 merge request!3Uc91.1
......@@ -84,7 +84,11 @@
</security-role>
<security-role>
<role-name>tester</role-name>
</security-role>
</security-role>
<security-role>
<role-name>preRegisteredPatient</role-name>
</security-role>
<!-- Define all role-based authorization folders
......@@ -95,6 +99,7 @@
/auth/admin/* - JSPs for Administrators only
/auth/staff/* - JSPs for only hospital staff (hcps, uaps, admin, lt)
/auth/patient/* - JSPs for patients only
/auth/preRegisteredPatient/* - JSPs for preRegisteredPatients only
/auth/lt/* - JSPs for LTs only
If any user attempts to access a folder that their role is not authorized for,
......@@ -126,6 +131,9 @@
<role-name>tester</role-name>
<role-name>pha</role-name>
<role-name>lt</role-name>
<role-name>preRegisteredPatient</role-name>
</auth-constraint>
</security-constraint>
......@@ -278,6 +286,23 @@
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>PreRegisteredPatient Only</display-name>
<web-resource-collection>
<web-resource-name>
Only PreRegisteredPatient are Allowed
</web-resource-name>
<!-- Define the context-relative URL(s) to be protected -->
<url-pattern>/auth/preRegisteredPatient/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<!-- Anyone with one of the listed roles may access this area -->
<role-name>preRegisteredPatient</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>PHA Only</display-name>
<web-resource-collection>
......
......@@ -17,10 +17,17 @@ if(request.getUserPrincipal() != null) {
long mid = Long.valueOf(request.getUserPrincipal().getName());
if (request.isUserInRole("patient")) {
response.sendRedirect("patient/home.jsp");
return;
}
else if (request.isUserInRole("preRegisteredPatient")) {
response.sendRedirect("preRegisteredPatient/home.jsp");
return;
}
else if (request.isUserInRole("uap")) {
response.sendRedirect("uap/home.jsp");
return;
......@@ -53,14 +60,13 @@ if(request.getUserPrincipal() != null) {
session.invalidate();
response.sendRedirect("/iTrust/");
}
else if (mid == 0)
{
else if (mid == 0) {
session.invalidate();
}
else {
else {
response.sendRedirect("errors/noaccess.jsp");
}
}
%>
......@@ -34,6 +34,10 @@ try {
userRole = (String) session.getAttribute("userRole");
if (userRole == null) {
if (request.isUserInRole("preRegisteredPatient")) {
userRole = "preRegisteredPatient";
}
if (request.isUserInRole("patient")) {
userRole = "patient";
}
......
......@@ -42,6 +42,8 @@ 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>
</form>
<%
......@@ -61,6 +63,8 @@ function fillLoginFields(u,p) {
<input type="submit" value="Login"><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>
</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" %>
......@@ -4,7 +4,7 @@ CREATE TABLE users(
Password VARCHAR(200),
Salt VARCHAR(200) DEFAULT '',
openID VARCHAR(200),
Role enum('patient','admin','hcp','uap','er','tester','pha', 'lt') NOT NULL DEFAULT 'admin',
Role enum('patient','admin','hcp','uap','er','tester','pha', 'lt', 'preRegisteredPatient') NOT NULL DEFAULT 'admin',
sQuestion VARCHAR(100) DEFAULT '',
sAnswer VARCHAR(30) DEFAULT '',
isDependent tinyint(1) unsigned NOT NULL default '0',
......
package edu.ncsu.csc.itrust.action;
import edu.ncsu.csc.itrust.RandomPassword;
import edu.ncsu.csc.itrust.beans.PatientBean;
import edu.ncsu.csc.itrust.dao.DAOFactory;
import edu.ncsu.csc.itrust.dao.mysql.PatientDAO;
import edu.ncsu.csc.itrust.dao.mysql.AuthDAO;
import edu.ncsu.csc.itrust.enums.Role;
import edu.ncsu.csc.itrust.exception.FormValidationException;
import edu.ncsu.csc.itrust.exception.ITrustException;
import edu.ncsu.csc.itrust.validate.AddPatientValidator;
/**
* Used for Add Pre-registered Patient page (PreRegisterPatient.jsp). This just adds an empty patient, creates an entered password for
* that patient.
*
* Very similar to {@link AddOfficeVisitAction}
*
*
*/
public class AddPreRegisteredPatientAction {
private PatientDAO patientDAO;
private AuthDAO authDAO;
private long loggedInMID;
/**
* Just the factory and logged in MID
*
* @param factory
* @param loggedInMID
*/
public AddPreRegisteredPatientAction(DAOFactory factory, long loggedInMID) {
this.patientDAO = factory.getPatientDAO();
this.loggedInMID = loggedInMID;
this.authDAO = factory.getAuthDAO();
}
/**
* Creates a new patient, returns the new MID. Adds a new user to the table with a
* preRegisteredPatient role
*
* @param p patient to be created
* @return the new MID of the patient
* @throws FormValidationException if the patient is not successfully validated
* @throws ITrustException
*/
public long addPatient(PatientBean p) throws FormValidationException, ITrustException {
new AddPatientValidator().validate(p);
long newMID = patientDAO.addEmptyPatient(); // the new added row id in the database
p.setMID(newMID);
String pwd = authDAO.addUser(newMID, Role.PREREGISTEREDPATIENT, p.getPassword());
p.setPassword(pwd);
patientDAO.editPatient(p, loggedInMID);
return newMID;
}
}
package edu.ncsu.csc.itrust.enums;
/**
* The iTrust user roles: Patient, ER, HCP, UAP, LT, PHA, Administrator and Tester.
* The iTrust user roles: Pre-registered Patient, Patient, ER, HCP, UAP, LT, PHA, Administrator and Tester.
* Consult the requirements for the contextual meanings of these individual choices.
*/
public enum Role {
/**PRE-REGISTERED PATIENT*/
PREREGISTEREDPATIENT("preRegisteredPatient", "Patients", 0L),
/**PATIENT*/
PATIENT("patient", "Patients", 0L),
/**ER*/
......
/**
* Tests for AddPatientAction
*/
package edu.ncsu.csc.itrust.unit.action;
import junit.framework.TestCase;
import edu.ncsu.csc.itrust.action.AddPreRegisteredPatientAction;
import edu.ncsu.csc.itrust.beans.PatientBean;
import edu.ncsu.csc.itrust.dao.DAOFactory;
import edu.ncsu.csc.itrust.dao.mysql.AuthDAO;
import edu.ncsu.csc.itrust.dao.mysql.PatientDAO;
import edu.ncsu.csc.itrust.unit.datagenerators.TestDataGenerator;
import edu.ncsu.csc.itrust.unit.testutils.TestDAOFactory;
import edu.ncsu.csc.itrust.exception.FormValidationException;
import edu.ncsu.csc.itrust.exception.ITrustException;
import edu.ncsu.csc.itrust.enums.Role;
public class AddPreRegisterPatientActionTest extends TestCase {
private DAOFactory factory = TestDAOFactory.getTestInstance();
private PatientDAO patientDAO = TestDAOFactory.getTestInstance().getPatientDAO();
private AuthDAO authDAO = TestDAOFactory.getTestInstance().getAuthDAO();
private TestDataGenerator gen = new TestDataGenerator();
private AddPreRegisteredPatientAction action;
/**
* Sets up defaults
*/
@Override
protected void setUp() throws Exception {
gen.clearAllTables();
action = new AddPreRegisteredPatientAction(factory, 0L);
}
/**
* Test adding a patient with correct information.
*/
public void testPreRegisterPatientAction() throws Exception {
PatientBean p = new PatientBean();
p.setFirstName("Jiminy");
p.setLastName("Cricket");
p.setEmail("make.awish@gmail.com");
p.setPassword("password");
p.setStreetAddress1("SA1");
p.setStreetAddress2("SA2");
p.setZip("12345");
p.setCity("Champaign");
p.setState("IL");
p.setPhone("1234567890");
p.setIcAddress1("ICA1");
p.setIcAddress2("ICA2");
p.setIcZip("54321");
p.setIcCity("Urbana");
p.setIcState("AK");
p.setIcPhone("1122334455");
long mid = action.addPatient(p);
PatientBean p2 = patientDAO.getPatient(mid);
assertEquals(p.getFirstName(), p2.getFirstName());
assertEquals(p.getLastName(), p2.getLastName());
assertEquals(p.getEmail(), p2.getEmail());
assertEquals(p.getStreetAddress1(), p2.getStreetAddress1());
assertEquals(p.getStreetAddress2(), p2.getStreetAddress2());
assertEquals(p.getZip(), p2.getZip());
assertEquals(p.getCity(), p2.getCity());
assertEquals(p.getState(), p2.getState());
assertEquals(p.getPhone(), p2.getPhone());
assertEquals(p.getIcAddress1(), p2.getIcAddress1());
assertEquals(p.getIcAddress2(), p2.getIcAddress2());
assertEquals(p.getIcZip(), p2.getIcZip());
assertEquals(p.getIcCity(), p2.getIcCity());
assertEquals(p.getIcState(), p.getIcState());
assertEquals(p.getIcPhone(), p.getIcPhone());
assertEquals(Role.PREREGISTEREDPATIENT, authDAO.getUserRole(mid));
}
/**
* Ensure that invalid emails are not allowed
*/
public void testPreRegisterPatientInvalidEmail() throws Exception {
PatientBean p = new PatientBean();
p.setFirstName("Jiminy");
p.setLastName("Cricket");
p.setEmail("1234");
p.setPassword("password");
// maybe not needed
try {
action.addPatient(p);
fail("Invalid email");
} catch (FormValidationException e) {
}
}
}
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