public HttpResponseMessage AddCondition(int p_careplan_oid, System.Collections.Generic.IList <int> p_addressconditions_oids)
        {
            // CAD, CEN, returnValue
            CarePlanRESTCAD carePlanRESTCAD = null;
            CarePlanCEN     carePlanCEN     = null;

            try
            {
                SessionInitializeTransaction();


                carePlanRESTCAD = new CarePlanRESTCAD(session);
                carePlanCEN     = new CarePlanCEN(carePlanRESTCAD);

                // Relationer
                carePlanCEN.AddCondition(p_careplan_oid, p_addressconditions_oids);
                SessionCommit();
            }

            catch (Exception e)
            {
                SessionRollBack();

                if (e.GetType() == typeof(HttpResponseException))
                {
                    throw e;
                }
                else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto"))
                {
                    throw new HttpResponseException(HttpStatusCode.Forbidden);
                }
                else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.DataLayerException))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
            finally
            {
                SessionClose();
            }

            // Return 200 - OK
            return(this.Request.CreateResponse(HttpStatusCode.OK));
        }
Beispiel #2
0
        public HttpResponseMessage Destroy(int p_careplan_oid)
        {
            // CAD, CEN
            CarePlanRESTCAD carePlanRESTCAD = null;
            CarePlanCEN     carePlanCEN     = null;

            try
            {
                SessionInitializeTransaction();


                carePlanRESTCAD = new CarePlanRESTCAD(session);
                carePlanCEN     = new CarePlanCEN(carePlanRESTCAD);

                carePlanCEN.Destroy(p_careplan_oid);
                SessionCommit();
            }

            catch (Exception e)
            {
                SessionRollBack();

                if (e.GetType() == typeof(HttpResponseException))
                {
                    throw e;
                }
                else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto"))
                {
                    throw new HttpResponseException(HttpStatusCode.Forbidden);
                }
                else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.DataLayerException))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
            finally
            {
                SessionClose();
            }

            // Return 204 - No Content
            return(this.Request.CreateResponse(HttpStatusCode.NoContent));
        }
Beispiel #3
0
        public static CarePlanDTOA Convert(EntityEN en, NHibernate.ISession session = null)
        {
            CarePlanDTOA    dto             = null;
            CarePlanRESTCAD carePlanRESTCAD = null;
            CarePlanCEN     carePlanCEN     = null;
            CarePlanCP      carePlanCP      = null;

            if (en != null)
            {
                dto             = new CarePlanDTOA();
                carePlanRESTCAD = new CarePlanRESTCAD(session);
                carePlanCEN     = new CarePlanCEN(carePlanRESTCAD);
                carePlanCP      = new CarePlanCP(session);


                CarePlanEN enHijo = carePlanRESTCAD.ReadOIDDefault(en.Id);



                //
                // Attributes

                dto.Id = en.Id;

                dto.Name = en.Name;


                dto.Description = en.Description;


                //
                // TravesalLink

                /* Rol: CarePlan o--> CarePlanTemplate */
                dto.CarePlanTemplate = CarePlanTemplateAssembler.Convert((CarePlanTemplateEN)enHijo.Template, session);


                //
                // Service
            }

            return(dto);
        }
        public static CarePlanDTOA Convert(CarePlanEN en, NHibernate.ISession session = null)
        {
            CarePlanDTOA    dto             = null;
            CarePlanRESTCAD carePlanRESTCAD = null;
            CarePlanCEN     carePlanCEN     = null;
            CarePlanCP      carePlanCP      = null;

            if (en != null)
            {
                dto             = new CarePlanDTOA();
                carePlanRESTCAD = new CarePlanRESTCAD(session);
                carePlanCEN     = new CarePlanCEN(carePlanRESTCAD);
                carePlanCP      = new CarePlanCP(session);



                //
                // Attributes

                dto.Id = en.Id;

                dto.StartDate = en.StartDate;


                dto.EndDate = en.EndDate;


                dto.Status = en.Status;


                dto.Intent = en.Intent;


                dto.Title = en.Title;


                dto.Modified = en.Modified;


                //
                // TravesalLink

                /* Rol: CarePlan o--> CareActivity */
                dto.CareActivities = null;
                List <CareActivityEN> CareActivities = carePlanRESTCAD.CareActivities(en.Id).ToList();
                if (CareActivities != null)
                {
                    dto.CareActivities = new List <CareActivityDTOA>();
                    foreach (CareActivityEN entry in CareActivities)
                    {
                        dto.CareActivities.Add(CareActivityAssembler.Convert(entry, session));
                    }
                }

                /* Rol: CarePlan o--> VitalSign */
                dto.VitalSigns = null;
                List <VitalSignEN> VitalSigns = carePlanRESTCAD.VitalSigns(en.Id).ToList();
                if (VitalSigns != null)
                {
                    dto.VitalSigns = new List <VitalSignDTOA>();
                    foreach (VitalSignEN entry in VitalSigns)
                    {
                        dto.VitalSigns.Add(VitalSignAssembler.Convert(entry, session));
                    }
                }

                /* Rol: CarePlan o--> Goal */
                dto.Goals = null;
                List <GoalEN> Goals = carePlanRESTCAD.Goals(en.Id).ToList();
                if (Goals != null)
                {
                    dto.Goals = new List <GoalDTOA>();
                    foreach (GoalEN entry in Goals)
                    {
                        dto.Goals.Add(GoalAssembler.Convert(entry, session));
                    }
                }

                /* Rol: CarePlan o--> PatientProfileCare */
                dto.Patient = PatientProfileCareAssembler.Convert((PatientProfileEN)en.PatientProfile, session);


                //
                // Service
            }

            return(dto);
        }
Beispiel #5
0
        public HttpResponseMessage ReadAll()
        {
            // CAD, CEN, EN, returnValue
            CarePlanRESTCAD carePlanRESTCAD = null;
            CarePlanCEN     carePlanCEN     = null;

            List <CarePlanEN>   carePlanEN  = null;
            List <CarePlanDTOA> returnValue = null;

            try
            {
                SessionInitializeWithoutTransaction();


                carePlanRESTCAD = new CarePlanRESTCAD(session);
                carePlanCEN     = new CarePlanCEN(carePlanRESTCAD);

                // Data
                // TODO: paginación

                carePlanEN = carePlanCEN.ReadAll(0, -1).ToList();

                // Convert return
                if (carePlanEN != null)
                {
                    returnValue = new List <CarePlanDTOA>();
                    foreach (CarePlanEN entry in carePlanEN)
                    {
                        returnValue.Add(CarePlanAssembler.Convert(entry, session));
                    }
                }
            }

            catch (Exception e)
            {
                if (e.GetType() == typeof(HttpResponseException))
                {
                    throw e;
                }
                else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto"))
                {
                    throw new HttpResponseException(HttpStatusCode.Forbidden);
                }
                else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.DataLayerException))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
            finally
            {
                SessionClose();
            }

            // Return 204 - Empty
            if (returnValue == null || returnValue.Count == 0)
            {
                return(this.Request.CreateResponse(HttpStatusCode.NoContent));
            }
            // Return 200 - OK
            else
            {
                return(this.Request.CreateResponse(HttpStatusCode.OK, returnValue));
            }
        }
Beispiel #6
0
        public HttpResponseMessage Modify(int idCarePlan, [FromBody] CarePlanDTO dto)
        {
            // CAD, CEN, returnValue
            CarePlanRESTCAD carePlanRESTCAD = null;
            CarePlanCEN     carePlanCEN     = null;
            CarePlanDTOA    returnValue     = null;

            // HTTP response
            HttpResponseMessage response = null;
            string uri = null;

            try
            {
                SessionInitializeTransaction();


                carePlanRESTCAD = new CarePlanRESTCAD(session);
                carePlanCEN     = new CarePlanCEN(carePlanRESTCAD);

                // Modify
                carePlanCEN.Modify(idCarePlan,
                                   dto.Name
                                   ,
                                   dto.Description
                                   );

                // Return modified object
                returnValue = CarePlanAssembler.Convert(carePlanRESTCAD.ReadOIDDefault(idCarePlan), session);

                SessionCommit();
            }

            catch (Exception e)
            {
                SessionRollBack();

                if (e.GetType() == typeof(HttpResponseException))
                {
                    throw e;
                }
                else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto"))
                {
                    throw new HttpResponseException(HttpStatusCode.Forbidden);
                }
                else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.DataLayerException))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
            finally
            {
                SessionClose();
            }

            // Return 404 - Not found
            if (returnValue == null)
            {
                return(this.Request.CreateResponse(HttpStatusCode.NotFound));
            }
            // Return 200 - OK
            else
            {
                response = this.Request.CreateResponse(HttpStatusCode.OK, returnValue);

                return(response);
            }
        }
Beispiel #7
0
        public HttpResponseMessage New_([FromBody] CarePlanDTO dto)
        {
            // CAD, CEN, returnValue, returnOID
            CarePlanRESTCAD carePlanRESTCAD = null;
            CarePlanCEN     carePlanCEN     = null;
            CarePlanDTOA    returnValue     = null;
            int             returnOID       = -1;

            // HTTP response
            HttpResponseMessage response = null;
            string uri = null;

            try
            {
                SessionInitializeTransaction();


                carePlanRESTCAD = new CarePlanRESTCAD(session);
                carePlanCEN     = new CarePlanCEN(carePlanRESTCAD);

                // Create
                returnOID = carePlanCEN.New_(
                    dto.Name                                                                                     //Atributo Primitivo: p_name
                    ,
                    //Atributo OID: p_scenario
                    // attr.estaRelacionado: true
                    dto.Scenario_oid                     // association role

                    , dto.Description                    //Atributo Primitivo: p_description
                    ,
                    //Atributo OID: p_template
                    // attr.estaRelacionado: true
                    dto.Template_oid                     // association role

                    );
                SessionCommit();

                // Convert return
                returnValue = CarePlanAssembler.Convert(carePlanRESTCAD.ReadOIDDefault(returnOID), session);
            }

            catch (Exception e)
            {
                SessionRollBack();

                if (e.GetType() == typeof(HttpResponseException))
                {
                    throw e;
                }
                else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto"))
                {
                    throw new HttpResponseException(HttpStatusCode.Forbidden);
                }
                else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.DataLayerException))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
            finally
            {
                SessionClose();
            }

            // Return 201 - Created
            response = this.Request.CreateResponse(HttpStatusCode.Created, returnValue);

            // Location Header

            /*
             * Dictionary<string, object> routeValues = new Dictionary<string, object>();
             *
             * // TODO: y rolPaths
             * routeValues.Add("id", returnOID);
             *
             * uri = Url.Link("GetOIDCarePlan", routeValues);
             * response.Headers.Location = new Uri(uri);
             */

            return(response);
        }
Beispiel #8
0
        public HttpResponseMessage ReadOID(int idCarePlan)
        {
            // CAD, CEN, EN, returnValue
            CarePlanRESTCAD carePlanRESTCAD = null;
            CarePlanCEN     carePlanCEN     = null;
            CarePlanEN      carePlanEN      = null;
            CarePlanDTOA    returnValue     = null;

            try
            {
                SessionInitializeWithoutTransaction();


                carePlanRESTCAD = new CarePlanRESTCAD(session);
                carePlanCEN     = new CarePlanCEN(carePlanRESTCAD);

                // Data
                carePlanEN = carePlanCEN.ReadOID(idCarePlan);

                // Convert return
                if (carePlanEN != null)
                {
                    returnValue = CarePlanAssembler.Convert(carePlanEN, session);
                }
            }

            catch (Exception e)
            {
                if (e.GetType() == typeof(HttpResponseException))
                {
                    throw e;
                }
                else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto"))
                {
                    throw new HttpResponseException(HttpStatusCode.Forbidden);
                }
                else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.DataLayerException))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
            finally
            {
                SessionClose();
            }

            // Return 404 - Not found
            if (returnValue == null)
            {
                return(this.Request.CreateResponse(HttpStatusCode.NotFound));
            }
            // Return 200 - OK
            else
            {
                return(this.Request.CreateResponse(HttpStatusCode.OK, returnValue));
            }
        }