PhysViewRecordAction.java
01 package com.bea.medrec.actions;
02 
03 import com.bea.medrec.beans.RecordBean;
04 import com.bea.medrec.utils.ClientException;
05 import com.bea.medrec.utils.MedRecLog4jFactory;
06 import com.bea.medrec.value.Record;
07 import javax.servlet.http.HttpServletRequest;
08 import javax.servlet.http.HttpServletResponse;
09 import org.apache.log4j.Logger;
10 import org.apache.struts.action.ActionForm;
11 import org.apache.struts.action.ActionForward;
12 import org.apache.struts.action.ActionMapping;
13 
14 /**
15  <p>Controller to retrieve a particular medical record.</p>
16  *
17  @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
18  */
19 public class PhysViewRecordAction extends PhysBaseAction {
20 
21   private static Logger logger =
22       MedRecLog4jFactory.getLogger(PhysViewRecordAction.class.getName());
23 
24  /**
25   <p>Process the specified HTTP request, and create the corresponding HTTP
26   * response (or forward to another web component that will create it).
27   * Return an <code>ActionForward</code> instance describing where and how
28   * control should be forwarded.
29   <br>
30   * Retrieves a particular record.
31   </p>
32   *
33   @param mapping  The ActionMapping used to select this instance
34   @param form  The optional ActionForm bean for this request (if any)
35   @param request  The HTTP request we are processing
36   @param response  The HTTP response we are creating
37   */
38   public ActionForward executeAction(ActionMapping mapping,
39                                      ActionForm form,
40                                      HttpServletRequest request,
41                                      HttpServletResponse response)
42     throws ClientException, Exception
43   {
44     // Minimal check for valid session.
45     //super.checkSession(request, mapping);
46 
47     Record record = null;
48     RecordBean recordBean = null;
49     String recordId = request.getParameter("id");
50     logger.debug("RecId: "+recordId);
51 
52     try {
53       if (isEmpty(recordId)) {
54         logger.error("Record id null.");
55         throw new ClientException("Record not found.");
56       }
57 
58       // Pass record id to be retrieved.
59       record = getPhysicianSession().getRecord(Integer.valueOf(recordId));
60 
61       if (record == null) {
62         logger.error("Record not found.");
63         throw new ClientException("Record not found.");
64       }
65     }
66     catch(Exception e) {
67       throwClientException(e, mapping, "view.records.summary");
68     }
69 
70     // Convert record value object to presentation object.
71     recordBean = new RecordBean(record);
72 
73     // Let's see the record.
74     logger.debug(recordBean.toString());
75 
76     // Set on request to be display by view.
77     request.setAttribute(RECORD_BEAN, recordBean);
78 
79     return mapping.findForward("view.record");
80   }
81 }