コード例 #1
0
        public int New_(string p_name, string p_manufacturer, string p_description, ChroniGenNHibernate.Enumerated.Chroni.FormEnum p_form, double p_rate, string p_dosage, ChroniGenNHibernate.Enumerated.Chroni.MedicationStatusEnum p_status, bool p_isOverTheCounter)
        {
            MedicationEN medicationEN = null;
            int          oid;

            //Initialized MedicationEN
            medicationEN      = new MedicationEN();
            medicationEN.Name = p_name;

            medicationEN.Manufacturer = p_manufacturer;

            medicationEN.Description = p_description;

            medicationEN.Form = p_form;

            medicationEN.Rate = p_rate;

            medicationEN.Dosage = p_dosage;

            medicationEN.Status = p_status;

            medicationEN.IsOverTheCounter = p_isOverTheCounter;

            //Call to MedicationCAD

            oid = _IMedicationCAD.New_(medicationEN);
            return(oid);
        }
コード例 #2
0
        public int New_(MedicationEN medication)
        {
            try
            {
                SessionInitializeTransaction();

                session.Save(medication);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is ChroniGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new ChroniGenNHibernate.Exceptions.DataLayerException("Error in MedicationCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(medication.Identifier);
        }
コード例 #3
0
        public void SetStatus(int p_oid, ChroniGenNHibernate.Enumerated.Chroni.MedicationStatusEnum p_status)
        {
            /*PROTECTED REGION ID(ChroniGenNHibernate.CEN.Chroni_Medication_setStatus) ENABLED START*/

            // Write here your custom code...

            MedicationCAD medicationCAD = new MedicationCAD();
            MedicationCEN medicationCEN = new MedicationCEN(medicationCAD);

            if (p_oid > 0)
            {
                MedicationEN medication = medicationCEN.ReadOID(p_oid);

                if (medication != null)
                {
                    if (p_status > 0)
                    {
                        medication.Status = p_status;
                        medicationCAD.Modify(medication);
                    }
                }
            }

            /*PROTECTED REGION END*/
        }
コード例 #4
0
        public void SetRate(int p_oid, double p_rate)
        {
            /*PROTECTED REGION ID(ChroniGenNHibernate.CEN.Chroni_Medication_setRate) ENABLED START*/

            // Write here your custom code...

            MedicationCAD medicationCAD = new MedicationCAD();
            MedicationCEN medicationCEN = new MedicationCEN(medicationCAD);

            if (p_oid > 0)
            {
                MedicationEN medication = medicationCEN.ReadOID(p_oid);

                if (medication != null)
                {
                    if (p_rate >= 0)
                    {
                        medication.Rate = p_rate;
                        medicationCAD.Modify(medication);
                    }
                }
            }

            /*PROTECTED REGION END*/
        }
コード例 #5
0
        public static MedicationEN Convert(MedicationDTO dto)
        {
            MedicationEN newinstance = null;

            try
            {
                if (dto != null)
                {
                    newinstance = new MedicationEN();



                    if (dto.CareActivity_oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.ICareActivityCAD careActivityCAD = new MoSIoTGenNHibernate.CAD.MosIoT.CareActivityCAD();

                        newinstance.CareActivity = careActivityCAD.ReadOIDDefault(dto.CareActivity_oid);
                    }
                    newinstance.ProductReference = dto.ProductReference;
                    newinstance.Name             = dto.Name;
                    newinstance.Manufacturer     = dto.Manufacturer;
                    newinstance.Description      = dto.Description;
                    newinstance.Dosage           = dto.Dosage;
                    newinstance.Form             = dto.Form;
                    newinstance.MedicationCode   = dto.MedicationCode;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(newinstance);
        }
コード例 #6
0
        public void SetDosage(int p_oid, string p_dosage)
        {
            /*PROTECTED REGION ID(ChroniGenNHibernate.CEN.Chroni_Medication_setDosage) ENABLED START*/

            // Write here your custom code...

            MedicationCAD medicationCAD = new MedicationCAD();
            MedicationCEN medicationCEN = new MedicationCEN(medicationCAD);

            if (p_oid > 0)
            {
                MedicationEN medication = medicationCEN.ReadOID(p_oid);

                if (medication != null)
                {
                    if (!string.IsNullOrEmpty(p_dosage))
                    {
                        medication.Dosage = p_dosage;
                        medicationCAD.Modify(medication);
                    }
                }
            }

            /*PROTECTED REGION END*/
        }
コード例 #7
0
        public int New_(int p_careActivity, int p_productReference, string p_name, string p_manufacturer, string p_description, string p_dosage, MoSIoTGenNHibernate.Enumerated.MosIoT.FormTypeEnum p_form, string p_medicationCode)
        {
            MedicationEN medicationEN = null;
            int          oid;

            //Initialized MedicationEN
            medicationEN = new MedicationEN();

            if (p_careActivity != -1)
            {
                // El argumento p_careActivity -> Property careActivity es oid = false
                // Lista de oids productReference
                medicationEN.CareActivity    = new MoSIoTGenNHibernate.EN.MosIoT.CareActivityEN();
                medicationEN.CareActivity.Id = p_careActivity;
            }

            medicationEN.ProductReference = p_productReference;

            medicationEN.Name = p_name;

            medicationEN.Manufacturer = p_manufacturer;

            medicationEN.Description = p_description;

            medicationEN.Dosage = p_dosage;

            medicationEN.Form = p_form;

            medicationEN.MedicationCode = p_medicationCode;

            //Call to MedicationCAD

            oid = _IMedicationCAD.New_(medicationEN);
            return(oid);
        }
コード例 #8
0
//Sin e: ReadOID
//Con e: MedicationEN
        public MedicationEN ReadOID(int productReference
                                    )
        {
            MedicationEN medicationEN = null;

            try
            {
                SessionInitializeTransaction();
                medicationEN = (MedicationEN)session.Get(typeof(MedicationEN), productReference);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is MoSIoTGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in MedicationCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(medicationEN);
        }
コード例 #9
0
        public int New_(MedicationEN medication)
        {
            try
            {
                SessionInitializeTransaction();
                if (medication.CareActivity != null)
                {
                    // Argumento OID y no colección.
                    medication.CareActivity = (MoSIoTGenNHibernate.EN.MosIoT.CareActivityEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.CareActivityEN), medication.CareActivity.Id);

                    medication.CareActivity.Medication
                        = medication;
                }

                session.Save(medication);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is MoSIoTGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in MedicationCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(medication.ProductReference);
        }
コード例 #10
0
        public MedicationEN ReadOIDDefault(int identifier
                                           )
        {
            MedicationEN medicationEN = null;

            try
            {
                SessionInitializeTransaction();
                medicationEN = (MedicationEN)session.Get(typeof(MedicationEN), identifier);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is ChroniGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new ChroniGenNHibernate.Exceptions.DataLayerException("Error in MedicationCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(medicationEN);
        }
コード例 #11
0
        public void Destroy(int identifier
                            )
        {
            try
            {
                SessionInitializeTransaction();
                MedicationEN medicationEN = (MedicationEN)session.Load(typeof(MedicationEN), identifier);
                session.Delete(medicationEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is ChroniGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new ChroniGenNHibernate.Exceptions.DataLayerException("Error in MedicationCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
コード例 #12
0
        public MedicationEN ReadOID(int identifier
                                    )
        {
            MedicationEN medicationEN = null;

            medicationEN = _IMedicationCAD.ReadOID(identifier);
            return(medicationEN);
        }
コード例 #13
0
        public MedicationEN ReadOID(int productReference
                                    )
        {
            MedicationEN medicationEN = null;

            medicationEN = _IMedicationCAD.ReadOID(productReference);
            return(medicationEN);
        }
コード例 #14
0
// Modify default (Update all attributes of the class)

        public void ModifyDefault(MedicationEN medication)
        {
            try
            {
                SessionInitializeTransaction();
                MedicationEN medicationEN = (MedicationEN)session.Load(typeof(MedicationEN), medication.Identifier);

                medicationEN.Name = medication.Name;


                medicationEN.Manufacturer = medication.Manufacturer;


                medicationEN.Description = medication.Description;


                medicationEN.Form = medication.Form;


                medicationEN.Rate = medication.Rate;


                medicationEN.Dosage = medication.Dosage;


                medicationEN.Status = medication.Status;


                medicationEN.IsOverTheCounter = medication.IsOverTheCounter;



                session.Update(medicationEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is ChroniGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new ChroniGenNHibernate.Exceptions.DataLayerException("Error in MedicationCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
コード例 #15
0
        public static MedicationDTOA Convert(MedicationEN en, NHibernate.ISession session = null)
        {
            MedicationDTOA    dto = null;
            MedicationRESTCAD medicationRESTCAD = null;
            MedicationCEN     medicationCEN     = null;
            MedicationCP      medicationCP      = null;

            if (en != null)
            {
                dto = new MedicationDTOA();
                medicationRESTCAD = new MedicationRESTCAD(session);
                medicationCEN     = new MedicationCEN(medicationRESTCAD);
                medicationCP      = new MedicationCP(session);



                //
                // Attributes

                dto.ProductReference = en.ProductReference;

                dto.Name = en.Name;


                dto.Description = en.Description;


                dto.Manufacturer = en.Manufacturer;


                dto.Dosage = en.Dosage;


                dto.Form = en.Form;


                dto.MedicationCode = en.MedicationCode;


                //
                // TravesalLink


                //
                // Service
            }

            return(dto);
        }
コード例 #16
0
        public void Modify(int p_Medication_OID, string p_name, string p_manufacturer, string p_description, string p_dosage, MoSIoTGenNHibernate.Enumerated.MosIoT.FormTypeEnum p_form, string p_medicationCode)
        {
            MedicationEN medicationEN = null;

            //Initialized MedicationEN
            medicationEN = new MedicationEN();
            medicationEN.ProductReference = p_Medication_OID;
            medicationEN.Name             = p_name;
            medicationEN.Manufacturer     = p_manufacturer;
            medicationEN.Description      = p_description;
            medicationEN.Dosage           = p_dosage;
            medicationEN.Form             = p_form;
            medicationEN.MedicationCode   = p_medicationCode;
            //Call to MedicationCAD

            _IMedicationCAD.Modify(medicationEN);
        }
コード例 #17
0
// Modify default (Update all attributes of the class)

        public void ModifyDefault(MedicationEN medication)
        {
            try
            {
                SessionInitializeTransaction();
                MedicationEN medicationEN = (MedicationEN)session.Load(typeof(MedicationEN), medication.ProductReference);


                medicationEN.Name = medication.Name;


                medicationEN.Manufacturer = medication.Manufacturer;


                medicationEN.Description = medication.Description;


                medicationEN.Dosage = medication.Dosage;


                medicationEN.Form = medication.Form;


                medicationEN.MedicationCode = medication.MedicationCode;

                session.Update(medicationEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is MoSIoTGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in MedicationCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
コード例 #18
0
        public void Modify(int p_Medication_OID, string p_name, string p_manufacturer, string p_description, ChroniGenNHibernate.Enumerated.Chroni.FormEnum p_form, double p_rate, string p_dosage, ChroniGenNHibernate.Enumerated.Chroni.MedicationStatusEnum p_status, bool p_isOverTheCounter)
        {
            MedicationEN medicationEN = null;

            //Initialized MedicationEN
            medicationEN                  = new MedicationEN();
            medicationEN.Identifier       = p_Medication_OID;
            medicationEN.Name             = p_name;
            medicationEN.Manufacturer     = p_manufacturer;
            medicationEN.Description      = p_description;
            medicationEN.Form             = p_form;
            medicationEN.Rate             = p_rate;
            medicationEN.Dosage           = p_dosage;
            medicationEN.Status           = p_status;
            medicationEN.IsOverTheCounter = p_isOverTheCounter;
            //Call to MedicationCAD

            _IMedicationCAD.Modify(medicationEN);
        }
コード例 #19
0
        public MedicationEN Medications(int id)
        {
            MedicationEN result = null;

            try
            {
                SessionInitializeTransaction();


                String sql = @"select self.Medication FROM CareActivityEN self " +
                             "where self.Id = :p_Id";
                IQuery query = session.CreateQuery(sql).SetParameter("p_Id", id);



                result = query.UniqueResult <MedicationEN>();

                SessionCommit();
            }

            catch (Exception ex)
            {
                SessionRollBack();
                if (ex is MoSIoTGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in CareActivityRESTCAD.", ex);
            }

            finally
            {
                SessionClose();
            }

            return(result);
        }
コード例 #20
0
        public HttpResponseMessage ReadOID(int idMedication)
        {
            // CAD, CEN, EN, returnValue
            MedicationRESTCAD medicationRESTCAD = null;
            MedicationCEN     medicationCEN     = null;
            MedicationEN      medicationEN      = null;
            MedicationDTOA    returnValue       = null;

            try
            {
                SessionInitializeWithoutTransaction();


                medicationRESTCAD = new MedicationRESTCAD(session);
                medicationCEN     = new MedicationCEN(medicationRESTCAD);

                // Data
                medicationEN = medicationCEN.ReadOID(idMedication);

                // Convert return
                if (medicationEN != null)
                {
                    returnValue = MedicationAssembler.Convert(medicationEN, 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));
            }
        }