Skip to content

Instantly share code, notes, and snippets.

@stephenroller
Created February 18, 2009 07:59
Show Gist options
  • Save stephenroller/66252 to your computer and use it in GitHub Desktop.
Save stephenroller/66252 to your computer and use it in GitHub Desktop.
diff -u -N iTrust/httptests/edu/ncsu/csc/itrust/http/DetermineOperationalProfileTest.java iTrust/httptests/edu/ncsu/csc/itrust/http/DetermineOperationalProfileTest.java
--- iTrust/httptests/edu/ncsu/csc/itrust/http/DetermineOperationalProfileTest.java 2009-01-28 04:16:15.000000912 -0500
+++ iTrust/httptests/edu/ncsu/csc/itrust/http/DetermineOperationalProfileTest.java 2009-02-18 02:11:12.000000142 -0500
@@ -47,9 +47,9 @@
assertEquals("0", table.getCellAsText(1, 5));//was 0
assertEquals("0%", table.getCellAsText(1,6));//was 0
//now check the totals are correct
- assertEquals("Totals", table.getCellAsText(36, 0));
- assertEquals("3", table.getCellAsText(36, 1));//was 4
- assertEquals("2", table.getCellAsText(36, 3));//was 3
- assertEquals("1", table.getCellAsText(36, 5));
+ assertEquals("Totals", table.getCellAsText(37, 0));
+ assertEquals("3", table.getCellAsText(37, 2));//was 4
+ assertEquals("2", table.getCellAsText(37, 3));//was 3
+ assertEquals("1", table.getCellAsText(37, 5));
}
}
diff -u -N /dev/null iTrust/httptests/edu/ncsu/csc/itrust/http/ViewExpiredPrescriptionRecordsTest.java
--- /dev/null 1969-12-31 19:00:00.000000000 -0500
+++ iTrust/httptests/edu/ncsu/csc/itrust/http/ViewExpiredPrescriptionRecordsTest.java 2009-02-18 23:28:06.000000559 -0500
@@ -0,0 +1,62 @@
+package edu.ncsu.csc.itrust.http;
+
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebResponse;
+
+public class ViewExpiredPrescriptionRecordsTest extends iTrustHTTPTest {
+ protected void setUp() throws Exception {
+ super.setUp();
+ gen.clearAllTables();
+ gen.standardData();
+ gen.expired_prescriptions_data();
+ }
+
+ protected void tearDown() throws Exception {
+ gen.remove_expired_prescriptions_data();
+ super.tearDown();
+ }
+
+ public void testViewPrescription() throws Exception {
+ // Login as Patient 2
+ WebConversation wc = login("2", "pw");
+ WebResponse wr = wc.getCurrentPage();
+ wr = wr.getLinkWith("My Expired Prescription Reports").click();
+ assertEquals("iTrust - Get My Expired Prescription Reports", wr.getTitle());
+
+ // Report title
+ assertTrue(wr.getText().contains("Andy Programmer"));
+
+ // Medications from the existing data
+ assertTrue(wr.getText().contains("06/10/2007"));
+ assertTrue(wr.getText().contains("10/10/2006"));
+ assertTrue(wr.getText().contains("10/11/2006"));
+ assertTrue(wr.getText().contains("Kelly Doctor"));
+ assertTrue(wr.getText().contains("00904-2407"));
+
+ // Prescription that expired yesterday
+ assertTrue(wr.getText().contains("08109-6"));
+ assertTrue(wr.getText().contains("01/02/2004"));
+ assertTrue(wr.getText().contains("12/03/2005"));
+
+ // Prescription that expires today (should not show)
+ assertFalse(wr.getText().contains("64764-1512"));
+ assertFalse(wr.getText().contains("02/03/2004"));
+ assertFalse(wr.getText().contains("01/02/1985"));
+
+ // Prescription that expires tomorrow (should not show)
+ assertFalse(wr.getText().contains("64764-1512"));
+ assertFalse(wr.getText().contains("03/04/2004"));
+
+ // Ensure clicking on the HCP's name gives correct information.
+ wr = wr.getLinkWith("Kelly Doctor").click();
+ assertTrue(wr.getText().contains("Kelly Doctor"));
+ assertTrue(wr.getText().contains("surgeon"));
+ assertTrue(wr.getText().contains("4321 My Road St"));
+ assertTrue(wr.getText().contains("PO BOX 2"));
+ assertTrue(wr.getText().contains("CityName"));
+ assertTrue(wr.getText().contains("NY"));
+ assertTrue(wr.getText().contains("12345-1234"));
+ assertTrue(wr.getText().contains("999-888-7777"));
+ assertTrue(wr.getText().contains("kdoctor@iTrust.org"));
+ }
+}
diff -u -N iTrust/src/edu/ncsu/csc/itrust/dao/mysql/PatientDAO.java iTrust/src/edu/ncsu/csc/itrust/dao/mysql/PatientDAO.java
--- iTrust/src/edu/ncsu/csc/itrust/dao/mysql/PatientDAO.java 2009-01-28 04:16:17.000000301 -0500
+++ iTrust/src/edu/ncsu/csc/itrust/dao/mysql/PatientDAO.java 2009-02-17 18:20:00.000000667 -0500
@@ -563,6 +563,36 @@
DBUtil.closeConnection(conn, ps);
}
}
+
+ /**
+ * Return a list of all prescriptions for a patient
+ *
+ * @param patientID
+ * @return
+ * @throws DBException
+ */
+ public List<PrescriptionBean> getExpiredPrescriptions(long patientID) throws DBException {
+ Connection conn = null;
+ PreparedStatement ps = null;
+ try {
+ if (patientID == 0L) throw new SQLException("pid cannot be 0");
+ conn = factory.getConnection();
+ ps = conn.prepareStatement("Select * From OVMedication,NDCodes,OfficeVisits "
+ + "Where OfficeVisits.PatientID = ? AND OVMedication.VisitID = "
+ + "OfficeVisits.ID AND NDCodes.Code=OVMedication.NDCode "
+ + "AND endDate < CURDATE()"
+ + "ORDER BY startDate DESC;");
+ ps.setLong(1, patientID);
+ ResultSet rs = ps.executeQuery();
+ return prescriptionLoader.loadList(rs);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ throw new DBException(e);
+ } finally {
+ DBUtil.closeConnection(conn, ps);
+ }
+ }
+
/**
* Return a list of prescriptions which are currently prescribed for a patient
diff -u -N iTrust/WebRoot/auth/patient/menu.jsp iTrust/WebRoot/auth/patient/menu.jsp
--- iTrust/WebRoot/auth/patient/menu.jsp 2009-01-28 04:16:14.000000758 -0500
+++ iTrust/WebRoot/auth/patient/menu.jsp 2009-02-11 12:33:46.000000020 -0500
@@ -9,6 +9,7 @@
<a href="/iTrust/auth/patient/viewVisitedHCPs.jsp">My Providers</a><br />
<a href="/iTrust/auth/patient/viewMyRecords.jsp">View My Records</a><br />
<a href="/iTrust/auth/patient/viewPrescriptionRecords.jsp">Prescription Records</a><br />
+ <a href="/iTrust/auth/patient/viewExpiredPrescriptionRecords.jsp">My Expired Prescription Reports</a><br />
</div>
<div class="menu_category">
<span>Messaging</span><br />
diff -u -N iTrust/httptests/edu/ncsu/csc/itrust/http/CreateHCPTest.java iTrust/httptests/edu/ncsu/csc/itrust/http/CreateHCPTest.java
--- iTrust/httptests/edu/ncsu/csc/itrust/http/CreateHCPTest.java 2009-01-28 15:15:19.000000645 -0500
+++ iTrust/httptests/edu/ncsu/csc/itrust/http/CreateHCPTest.java 2009-02-18 02:26:28.000000060 -0500
@@ -44,7 +44,8 @@
form.setParameter("email", "laurie-- at @ ncsu dot . edu");
wr = form.submit();
// edit the hcp
- wr = wr.getLinkWith("Continue").click();
+ assertEquals("iTrust - Add HCP", wr.getTitle());
+ wr = wr.getLinkWith("Continue to personnel information.").click();
assertEquals("iTrust - Edit Personnel", wr.getTitle());
form = wr.getForms()[0];
form.setParameter("streetAddress1", "900 Main Campus Dr");
diff -u -N /dev/null iTrust/WebRoot/auth/patient/viewExpiredPrescriptionRecords.jsp
--- /dev/null 1969-12-31 19:00:00.000000000 -0500
+++ iTrust/WebRoot/auth/patient/viewExpiredPrescriptionRecords.jsp 2009-02-17 18:27:47.000000249 -0500
@@ -0,0 +1,81 @@
+<%@taglib uri="/WEB-INF/tags.tld" prefix="itrust"%>
+<%@page errorPage="/auth/exceptionHandler.jsp"%>
+
+<%@page import="java.util.List"%>
+<%@page import="java.util.ArrayList"%>
+<%@page import="edu.ncsu.csc.itrust.enums.TransactionType"%>
+<%@page import="edu.ncsu.csc.itrust.dao.DAOFactory"%>
+<%@page import="edu.ncsu.csc.itrust.action.ViewPrescriptionRecordsAction"%>
+<%@page import="edu.ncsu.csc.itrust.beans.PatientBean" %>
+<%@page import="edu.ncsu.csc.itrust.beans.PersonnelBean" %>
+<%@page import="edu.ncsu.csc.itrust.beans.PrescriptionBean" %>
+<%@page import="edu.ncsu.csc.itrust.beans.OfficeVisitBean" %>
+<%@page import="edu.ncsu.csc.itrust.dao.mysql.PatientDAO" %>
+<%@page import="edu.ncsu.csc.itrust.dao.mysql.OfficeVisitDAO" %>
+
+<%@include file="/global.jsp"%>
+
+<%
+ pageTitle = "iTrust - Get My Expired Prescription Reports";
+ PatientBean patient = new PatientDAO(prodDAO).getPatient(loggedInMID.longValue());
+ ViewPrescriptionRecordsAction action = new ViewPrescriptionRecordsAction(prodDAO, loggedInMID.longValue());
+ List<PrescriptionBean> prescriptions = action.getExpiredPrescriptionsForPatient(loggedInMID.longValue());
+
+%>
+
+<%@include file="/header.jsp"%>
+<div align="center">
+<table class="fTable">
+ <tr>
+ <th colspan="5"><%= patient.getFullName() %></th>
+ </tr>
+<%
+ if (prescriptions.size() == 0) {
+%>
+ <tr>
+ <td colspan=4>
+ <i>No prescriptions found</i>
+ </td>
+ </tr>
+<%
+ } else {
+%>
+ <tr class="subHeader">
+ <td>ND Code</td>
+ <td>Description</td>
+ <td>Prescribed</td>
+ <td>Duration</td>
+ <td>Prescribing HCP</td>
+ </tr>
+<% int index = 0;
+ List<PersonnelBean> personnelList = new ArrayList<PersonnelBean>();
+ for (PrescriptionBean prescription : prescriptions) {
+ OfficeVisitBean ovb = new OfficeVisitDAO(prodDAO).getOfficeVisit(prescription.getVisitID());
+%>
+ <tr>
+ <td ><%=prescription.getMedication().getNDCodeFormatted() %></td>
+ <td ><%=prescription.getMedication().getDescription() %></td>
+ <td ><%=ovb.getVisitDateStr() %></td>
+ <td ><%=prescription.getStartDateStr() %> to <%=prescription.getEndDateStr() %></td>
+ <td >
+ <%
+ PersonnelBean doctor = action.getPrescribingDoctor(prescription);
+ personnelList.add(doctor);
+ %>
+ <a href="/iTrust/auth/viewPersonnel.jsp?personnel=<%= index %>">
+ <%= doctor.getFullName() %>
+ </a>
+ </td>
+ </tr>
+<%
+
+ session.setAttribute("personnelList", personnelList);
+ index++;
+ }
+ }
+
+%>
+ </table>
+</div>
+
+<%@include file="/footer.jsp"%>
diff -u -N iTrust/src/edu/ncsu/csc/itrust/enums/TransactionType.java iTrust/src/edu/ncsu/csc/itrust/enums/TransactionType.java
--- iTrust/src/edu/ncsu/csc/itrust/enums/TransactionType.java 2009-01-28 04:16:16.000000287 -0500
+++ iTrust/src/edu/ncsu/csc/itrust/enums/TransactionType.java 2009-02-03 17:42:06.000000007 -0500
@@ -35,7 +35,8 @@
VIEW_OFFICE_VISIT(37, "View Office Visit"),
ADD_PRESCRIPTION(38, "Add Prescription"),
UPDATE_OFFICE_VISIT(39, "Update an Office Visit"),
- SEND_MESSAGE(40, "Send a Message");
+ SEND_MESSAGE(40, "Send a Message"),
+ VIEW_EXPIRED_PRESCRIPTIONS(41, "View my expired prescriptions");
// S1, S3, S5, S7, S8, S14, S16, S19, S21, S22.
diff -u -N iTrust/unittests/edu/ncsu/csc/itrust/datagenerators/TestDataGenerator.java iTrust/unittests/edu/ncsu/csc/itrust/datagenerators/TestDataGenerator.java
--- iTrust/unittests/edu/ncsu/csc/itrust/datagenerators/TestDataGenerator.java 2009-01-28 04:16:16.000000864 -0500
+++ iTrust/unittests/edu/ncsu/csc/itrust/datagenerators/TestDataGenerator.java 2009-02-18 22:57:45.000000078 -0500
@@ -198,6 +198,14 @@
new DBBuilder(factory).executeSQLFile(DIR + "/immunization.sql");
}
+ public void expired_prescriptions_data() throws FileNotFoundException, IOException, SQLException {
+ new DBBuilder(factory).executeSQLFile(DIR + "/addprescriptions.sql");
+ }
+
+ public void remove_expired_prescriptions_data() throws FileNotFoundException, IOException, SQLException {
+ new DBBuilder(factory).executeSQLFile(DIR + "/removeprescriptions.sql");
+ }
+
public void standardData() throws FileNotFoundException, IOException, SQLException {
cptCodes();
icd9cmCodes();
diff -u -N iTrust/src/edu/ncsu/csc/itrust/action/ViewPrescriptionRecordsAction.java iTrust/src/edu/ncsu/csc/itrust/action/ViewPrescriptionRecordsAction.java
--- iTrust/src/edu/ncsu/csc/itrust/action/ViewPrescriptionRecordsAction.java 2009-01-28 04:16:16.000000677 -0500
+++ iTrust/src/edu/ncsu/csc/itrust/action/ViewPrescriptionRecordsAction.java 2009-02-18 01:51:24.000000022 -0500
@@ -123,4 +123,24 @@
transDAO.logTransaction(TransactionType.VIEW_PRESCRIPTION_REPORT, loggedInMID);
return patientDAO.getPrescriptions(patientID);
}
+
+ public List<PrescriptionBean> getExpiredPrescriptionsForPatient(long patientID) throws iTrustException
+ {
+ if (loggedInMID == patientID) {
+ transDAO.logTransaction(TransactionType.VIEW_EXPIRED_PRESCRIPTIONS, loggedInMID);
+ return patientDAO.getExpiredPrescriptions(patientID);
+ }
+
+ PatientBean patient = patientDAO.getPatient(patientID);
+ ArrayList<String> toList = new ArrayList<String>();
+ toList.add(patient.getEmail());
+ Email email = new Email();
+ email.setToList(toList);
+ email.setFrom("noreply@itrust.com");
+ email.setSubject("Undesignated Personnel Have Accessed Your Expired Prescription Records");
+ email.setBody("An undesignated HCP or UAP has accessed your expired prescription records. For more information, please log in to iTrust.");
+ emailer.sendEmail(email);
+ transDAO.logTransaction(TransactionType.VIEW_EXPIRED_PRESCRIPTIONS, loggedInMID);
+ return new ArrayList<PrescriptionBean>();
+ }
}
diff -u -N iTrust/.project iTrust/.project
--- iTrust/.project 2009-01-28 15:15:19.000000630 -0500
+++ iTrust/.project 2009-01-29 17:29:16.000000500 -0500
@@ -11,11 +11,6 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.ibm.team.coverage.ide.core.instrumentationBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
@@ -37,6 +32,5 @@
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>net.sourceforge.metrics.nature</nature>
- <nature>com.ibm.team.coverage.ide.core.instrumentedProject</nature>
</natures>
</projectDescription>
diff -u -N iTrust/src/edu/ncsu/csc/itrust/validate/ValidationFormat.java iTrust/src/edu/ncsu/csc/itrust/validate/ValidationFormat.java
--- iTrust/src/edu/ncsu/csc/itrust/validate/ValidationFormat.java 2009-01-28 15:15:19.000000598 -0500
+++ iTrust/src/edu/ncsu/csc/itrust/validate/ValidationFormat.java 2009-02-18 02:25:58.000000140 -0500
@@ -12,7 +12,7 @@
NAME("[\\sa-zA-Z'-]{1,20}", "Up to 20 Letters, space, ' and -"), DATE("[\\d]{2}/[\\d]{2}/[\\d]{4}",
"MM/DD/YYYY"), PHONE_NUMBER("[\\d]{3}-[\\d]{3}-[\\d]{4}", "xxx-xxx-xxxx"), MID("[\\d]{1,10}",
"Between 1 and 10 digits"), ROLE("^(?:admin|hcp|uap|test)$",
- "must be one of {admin, hcp, uap, test}"), EMAIL("[a-zA-Z0-9@_.\\s]{1,30}",
+ "must be one of {admin, hcp, uap, test}"), EMAIL("[a-zA-Z0-9@_.\\-\\s]{1,30}",
"Up to 30 alphanumeric characters and symbols . , space , and _ @"), // ^(?=[^@]+@[^@]+(?:\\.[^@.]+)+)[a-zA-Z0-9@_.]{1,30}$
QUESTION("[a-zA-Z0-9?\\-'.\\s]{1,50}", "Up to 50 alphanumeric characters and symbols ?-'."),
ANSWER("[a-zA-Z0-9\\s]{1,30}", "Up to 30 alphanumeric characters"),
diff -u -N iTrust/src/edu/ncsu/csc/itrust/beans/PrescriptionBean.java iTrust/src/edu/ncsu/csc/itrust/beans/PrescriptionBean.java
--- iTrust/src/edu/ncsu/csc/itrust/beans/PrescriptionBean.java 2009-01-28 04:16:16.000000848 -0500
+++ iTrust/src/edu/ncsu/csc/itrust/beans/PrescriptionBean.java 2009-02-18 23:39:18.000000278 -0500
@@ -107,5 +107,4 @@
public void setId(long id) {
this.id = id;
}
-
}
diff -u -N iTrust/unittests/edu/ncsu/csc/itrust/action/ViewPrescriptionRecordsActionTest.java iTrust/unittests/edu/ncsu/csc/itrust/action/ViewPrescriptionRecordsActionTest.java
--- iTrust/unittests/edu/ncsu/csc/itrust/action/ViewPrescriptionRecordsActionTest.java 2009-01-28 04:16:17.000000192 -0500
+++ iTrust/unittests/edu/ncsu/csc/itrust/action/ViewPrescriptionRecordsActionTest.java 2009-02-18 23:33:24.000000001 -0500
@@ -17,11 +17,11 @@
@Override
protected void setUp() throws Exception {
+ super.setUp();
gen = new TestDataGenerator();
gen.clearAllTables();
- gen.standardData();
+ gen.standardData();
}
-
public void testGetPatient() throws Exception {
action = new ViewPrescriptionRecordsAction(factory, 9000000000L);
PatientBean patient = action.getPatient(1L);
@@ -67,4 +67,31 @@
assertEquals("009042407", prescriptions.get(1).getMedication().getNDCode());
assertEquals("647641512", prescriptions.get(2).getMedication().getNDCode());
}
+
+ public void testGetExpiredPrescriptionsForPatient() throws Exception {
+ // Extra data is needed to test edge cases
+ gen.expired_prescriptions_data();
+
+ // Log in as patient 2
+ action = new ViewPrescriptionRecordsAction(factory, 2L);
+ // Get the expired prescriptions
+ List<PrescriptionBean> expPrescriptions = action.getExpiredPrescriptionsForPatient(2L);
+ assertEquals(3, expPrescriptions.size());
+ assertEquals("009042407", expPrescriptions.get(0).getMedication().getNDCode());
+ assertEquals("009042407", expPrescriptions.get(1).getMedication().getNDCode());
+ assertEquals("081096", expPrescriptions.get(2).getMedication().getNDCode());
+
+ // Patient 1 should not have any expired prescriptions.
+ action = new ViewPrescriptionRecordsAction(factory, 1L);
+ expPrescriptions = action.getExpiredPrescriptionsForPatient(1L);
+ assertEquals(0, expPrescriptions.size());
+
+ // HCPs should not be able to view expired prescriptions either
+ action = new ViewPrescriptionRecordsAction(factory, 9000000000L);
+ expPrescriptions = action.getExpiredPrescriptionsForPatient(2L);
+ assertEquals(0, expPrescriptions.size());
+
+ // Remove the extra rows we added
+ gen.remove_expired_prescriptions_data();
+ }
}
\ No newline at end of file
diff -u -N /dev/null iTrust/sql/data/addprescriptions.sql
--- /dev/null 1969-12-31 19:00:00.000000000 -0500
+++ iTrust/sql/data/addprescriptions.sql 2009-02-18 23:24:22.000000928 -0500
@@ -0,0 +1,8 @@
+INSERT INTO OfficeVisits(id,visitDate,HCPID,notes,HospitalID,PatientID)
+VALUES (961,'1985-1-2',9000000000,'Yet another office visit.','',2),
+ (962,'2005-12-3',9000000003,'Yet another office visit.','',2);
+
+INSERT INTO OVMedication(NDCode, VisitID, StartDate,EndDate,Dosage,Instructions)
+ VALUES ('081096', 962, '2004-01-02', ADDDATE(CURDATE(), -1), 5, 'Take hourly'),
+ ('647641512', 961, '2004-02-03', CURDATE(), 5, 'Take minutely'),
+ ('647641512', 961, '2004-03-04', ADDDATE(CURDATE(), 1), 5, 'Take secondly');
diff -u -N /dev/null iTrust/sql/data/removePrescriptions.sql
--- /dev/null 1969-12-31 19:00:00.000000000 -0500
+++ iTrust/sql/data/removePrescriptions.sql 2009-02-18 23:05:00.000000529 -0500
@@ -0,0 +1,9 @@
+DELETE FROM OfficeVisits
+ WHERE id=961 OR
+ id=962
+ LIMIT 2;
+
+DELETE FROM OVMedication
+ WHERE VisitID=961 OR
+ VisitID=962
+ LIMIT 3;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment