01 package com.bea.medrec.actions;
02
03 import com.bea.medrec.beans.PatientBean;
04 import com.bea.medrec.beans.RecordBean;
05 import com.bea.medrec.beans.PrescriptionBean;
06 import com.bea.medrec.utils.BeanHelper;
07 import com.bea.medrec.utils.ClientException;
08 import com.bea.medrec.utils.MedRecLog4jFactory;
09 import com.bea.medrec.utils.MedRecWebAppUtils;
10 import com.bea.medrec.value.RecordsSummary;
11 import com.bea.medrec.value.Record;
12 import javax.servlet.http.HttpServletRequest;
13 import javax.servlet.http.HttpServletResponse;
14 import org.apache.log4j.Logger;
15 import org.apache.struts.action.ActionForm;
16 import org.apache.struts.action.ActionForward;
17 import org.apache.struts.action.ActionMapping;
18
19 /**
20 * <p>Retrieves all records for a patient. Records are returned
21 * in abbreviated form in order to display a summary of
22 * each record.</p>
23 *
24 * @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
25 */
26 public class ViewRecordsSummaryAction extends PatientBaseAction {
27
28 private static Logger logger =
29 MedRecLog4jFactory.getLogger(ViewRecordsSummaryAction.class.getName());
30
31 /**
32 * <p>Process the specified HTTP request, and create the corresponding HTTP
33 * response (or forward to another web component that will create it).
34 * Return an <code>ActionForward</code> instance describing where and how
35 * control should be forwarded.
36 * <br>
37 * Retrieves a patients entire medical record history.
38 * Information includes summarized views of records and prescriptions.
39 * </p>
40 *
41 * @param mapping The ActionMapping used to select this instance
42 * @param form The optional ActionForm bean for this request (if any)
43 * @param request The HTTP request we are processing
44 * @param response The HTTP response we are creating
45 */
46 public ActionForward executeAction(ActionMapping mapping,
47 ActionForm form,
48 HttpServletRequest request,
49 HttpServletResponse response)
50 throws ClientException, Exception
51 {
52 logger.debug("Getting patients record summary.");
53 PatientBean patientBean = (PatientBean)getSessionAttribute(request,
54 PATIENT_BEAN);
55 Integer patientId = null;
56 RecordsSummary recordsSummary = null;
57
58 if (MedRecWebAppUtils.isNotEmpty(patientBean.getId())) {
59 logger.debug("Patient Id: "+patientBean.getId());
60
61 try {
62 patientId = Integer.valueOf(patientBean.getId());
63 recordsSummary = getRecordSession().getRecordsSummary(patientId);
64 }
65 catch(Exception e) {
66 throwClientException(e, mapping, "search.results");
67 }
68 logger.debug("Found records: "+recordsSummary.toString());
69 logger.debug("Setting recordBeans on request");
70 request.setAttribute(RECORD_BEANS,
71 toBeanArray(recordsSummary.getRecords(),
72 com.bea.medrec.beans.RecordBean.class));
73 logger.debug("Setting prescriptionBeans on request");
74 request.setAttribute(PRESCRIPTION_BEANS,
75 toBeanArray(recordsSummary.getPrescriptions(),
76 com.bea.medrec.beans.PrescriptionBean.class));
77 }
78
79 return mapping.findForward("view.records.summary");
80 }
81 }
|