MedRecRMWebServices.java
001 package com.bea.medrec.webservices;
002 
003 import com.bea.medrec.controller.PatientSession;
004 import com.bea.medrec.controller.RecordSession;
005 import com.bea.medrec.utils.MedRecLog4jFactory;
006 import com.bea.medrec.value.Patient;
007 import com.bea.medrec.value.Record;
008 import javax.jws.WebMethod;
009 import javax.jws.WebService;
010 import javax.jws.soap.SOAPBinding;
011 import org.apache.log4j.Logger;
012 import weblogic.jws.AsyncResponseBean;
013 import weblogic.jws.Policy;
014 import weblogic.jws.WLHttpTransport;
015 
016 // Standard JWS annotation that specifies that the name of the Web Service is
017 // "MedRecRMWebServices", its public service name is "MedRecRMWebServices", and the
018 // targetNamespace used in the generated WSDL is "http://www.bea.com/medrec"
019 @WebService(name = "MedRecRMWebServicesPortType",
020     serviceName = "MedRecRMWebServices",
021     targetNamespace = "http://www.bea.com/medrec")
022 
023 // Standard JWS annotation that specifies this is a document-literal-wrapped
024 // Web Service
025 @SOAPBinding(style=SOAPBinding.Style.DOCUMENT,
026              use=SOAPBinding.Use.LITERAL,
027              parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
028 
029 // WebLogic Web Services use WS-Policy files to enable a destination endpoint
030 // to describe and advertise its reliable messaging capabilities and requirements.
031 // The WS-Policy specification provides a general purpose model and syntax to
032 // describe and communicate the policies of a Web service.
033 // These WS-Policy files are XML files that describe features such as the
034 // version of the WS-ReliableMessaging specification that is supported, the
035 // source endpoint's retransmission interval, the destination endpoint's
036 // acknowledgment interval, and so on.  REVIEWME - review comment
037 @Policy(uri="MedRecRMServicePolicy.xml", attachToWsdl=true)
038 
039 // FIXME - need comment here
040 @AsyncResponseBean()
041 
042 // WebLogic-specific JWS annotation that specifies the port name is
043 // "MedRecRMWebServices", and the context path and service URI used to build
044 // the URI of the Web Service is "ws_rm_medrec/MedRecWebServices"
045 @WLHttpTransport(portName = "MedRecRMWebServicesPort",
046     contextPath = "ws_rm_medrec",
047     serviceUri = "MedRecRMWebServices")
048 
049 /**
050  <p>MedRecWebServices provides an interface for all MedRec Web services.</p>
051  *
052  @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
053  */
054 public class MedRecRMWebServices extends MedRecBaseWebServices {
055   private static Logger logger =
056       MedRecLog4jFactory.getLogger(MedRecRMWebServices.class.getName());
057 
058   //  A D D   R E C O R D
059   /**
060    <p>Accesses MedRec Web service adding a record, including
061    * vital signs and prescriptions.</p>
062    *
063    @param pRecordVO
064    @return Record
065    */
066   @WebMethod()
067   public Record addRecord(Record pRecordVOthrows Exception {
068     logger.info("Adding record.");
069     logger.debug(pRecordVO.toString());
070 
071     // Declare local variables.
072     RecordSession recordSession = null;
073     Record newRecord = null;
074 
075     try {
076       recordSession = getRecordSession();
077       newRecord = recordSession.addRecord(pRecordVO);
078     catch (Exception e) {
079       logger.error(e);
080       throw e;
081     }
082 
083     return newRecord;
084   }
085 
086   //  R E G I S T E R   P A T I E N T
087   /**
088    <p>Accesses MedRec Web service adding a new active patient.</p>
089    *
090    @param pPatientVO
091    @param pPassword
092    @return Patient
093    */
094   @WebMethod()
095   public Patient registerPatient(Patient pPatientVO,
096                                  String pPassword)
097     throws Exception {
098     logger.info("Adding patient.");
099     logger.debug(pPatientVO.toString());
100 
101     // Declare local variables.
102     PatientSession patientSession = null;
103     Patient newPatient = null;
104 
105     try {
106       patientSession = getPatientSession();
107       if (patientSession.findPatientByEmail(pPatientVO.getEmail()) != null) {
108         throw new Exception("User "+pPatientVO.getEmail()+" already exists.");
109       }
110       logger.debug("Creating new account for patient.");
111       newPatient = patientSession.processActiveRegistration(pPatientVO,
112           pPassword);
113     catch (Exception e) {
114       logger.error(e);
115       throw e;
116     }
117 
118     return newPatient;
119   }
120 
121   //  U P D A T E   P A T I E N T
122   /**
123    <p>Accesses MedRec Web service to update patient info.</p>
124    *
125    @param pPatientVO
126    @return Patient
127    */
128   @WebMethod()
129   public Patient updatePatient(Patient pPatientVOthrows Exception {
130     logger.info("Updating patient.");
131     logger.debug(pPatientVO.toString());
132 
133     // Declare local variables.
134     PatientSession patientSession = null;
135     Patient updatedPatient = null;
136 
137     try {
138       patientSession = getPatientSession();
139       updatedPatient = patientSession.updatePatient(pPatientVO);
140     catch (Exception e) {
141       logger.error(e);
142       throw e;
143     }
144 
145     return updatedPatient;
146   }
147 }