Exemple #1
0
        public void UnassignPractitioner(int p_Diary_OID, System.Collections.Generic.IList <int> p_practitioner_OIDs)
        {
            try
            {
                SessionInitializeTransaction();
                ChroniGenNHibernate.EN.Chroni.DiaryEN diaryEN = null;
                diaryEN = (DiaryEN)session.Load(typeof(DiaryEN), p_Diary_OID);

                ChroniGenNHibernate.EN.Chroni.PractitionerEN practitionerENAux = null;
                if (diaryEN.Practitioner != null)
                {
                    foreach (int item in p_practitioner_OIDs)
                    {
                        practitionerENAux = (ChroniGenNHibernate.EN.Chroni.PractitionerEN)session.Load(typeof(ChroniGenNHibernate.EN.Chroni.PractitionerEN), item);
                        if (diaryEN.Practitioner.Contains(practitionerENAux) == true)
                        {
                            diaryEN.Practitioner.Remove(practitionerENAux);
                            practitionerENAux.Diary.Remove(diaryEN);
                        }
                        else
                        {
                            throw new ModelException("The identifier " + item + " in p_practitioner_OIDs you are trying to unrelationer, doesn't exist in DiaryEN");
                        }
                    }
                }

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

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


            finally
            {
                SessionClose();
            }
        }
Exemple #2
0
        public void AssignPractitioner(int p_Diary_OID, System.Collections.Generic.IList <int> p_practitioner_OIDs)
        {
            ChroniGenNHibernate.EN.Chroni.DiaryEN diaryEN = null;
            try
            {
                SessionInitializeTransaction();
                diaryEN = (DiaryEN)session.Load(typeof(DiaryEN), p_Diary_OID);
                ChroniGenNHibernate.EN.Chroni.PractitionerEN practitionerENAux = null;
                if (diaryEN.Practitioner == null)
                {
                    diaryEN.Practitioner = new System.Collections.Generic.List <ChroniGenNHibernate.EN.Chroni.PractitionerEN>();
                }

                foreach (int item in p_practitioner_OIDs)
                {
                    practitionerENAux = new ChroniGenNHibernate.EN.Chroni.PractitionerEN();
                    practitionerENAux = (ChroniGenNHibernate.EN.Chroni.PractitionerEN)session.Load(typeof(ChroniGenNHibernate.EN.Chroni.PractitionerEN), item);
                    practitionerENAux.Diary.Add(diaryEN);

                    diaryEN.Practitioner.Add(practitionerENAux);
                }


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

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


            finally
            {
                SessionClose();
            }
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            DiaryEN t = obj as DiaryEN;

            if (t == null)
            {
                return(false);
            }
            if (Identifier.Equals(t.Identifier))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public void UnassignDiary(int p_Patient_OID, int p_diary_OID)
        {
            try
            {
                SessionInitializeTransaction();
                ChroniGenNHibernate.EN.Chroni.PatientEN patientEN = null;
                patientEN = (PatientEN)session.Load(typeof(PatientEN), p_Patient_OID);

                if (patientEN.Diary.Identifier == p_diary_OID)
                {
                    patientEN.Diary = null;
                    ChroniGenNHibernate.EN.Chroni.DiaryEN diaryEN = (ChroniGenNHibernate.EN.Chroni.DiaryEN)session.Load(typeof(ChroniGenNHibernate.EN.Chroni.DiaryEN), p_diary_OID);
                    diaryEN.Patient = null;
                }
                else
                {
                    throw new ModelException("The identifier " + p_diary_OID + " in p_diary_OID you are trying to unrelationer, doesn't exist in PatientEN");
                }

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

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


            finally
            {
                SessionClose();
            }
        }
        public int New_(string p_nif, bool p_active, string p_name, string p_surnames, ChroniGenNHibernate.Enumerated.Chroni.GenderEnum p_gender, Nullable <DateTime> p_birthDate, bool p_deceased, string p_address, string p_email, string p_phone, ChroniGenNHibernate.Enumerated.Chroni.MaritalStatusEnum p_maritalStatus, string p_photo, System.Collections.Generic.IList <int> p_location, ChroniGenNHibernate.EN.Chroni.DiaryEN p_diary, String p_password)
        {
            PatientEN patientEN = null;
            int       oid;

            //Initialized PatientEN
            patientEN     = new PatientEN();
            patientEN.Nif = p_nif;

            patientEN.Active = p_active;

            patientEN.Name = p_name;

            patientEN.Surnames = p_surnames;

            patientEN.Gender = p_gender;

            patientEN.BirthDate = p_birthDate;

            patientEN.Deceased = p_deceased;

            patientEN.Address = p_address;

            patientEN.Email = p_email;

            patientEN.Phone = p_phone;

            patientEN.MaritalStatus = p_maritalStatus;

            patientEN.Photo = p_photo;


            patientEN.Location = new System.Collections.Generic.List <ChroniGenNHibernate.EN.Chroni.LocationEN>();
            if (p_location != null)
            {
                foreach (int item in p_location)
                {
                    ChroniGenNHibernate.EN.Chroni.LocationEN en = new ChroniGenNHibernate.EN.Chroni.LocationEN();
                    en.Identifier = item;
                    patientEN.Location.Add(en);
                }
            }

            else
            {
                patientEN.Location = new System.Collections.Generic.List <ChroniGenNHibernate.EN.Chroni.LocationEN>();
            }

            patientEN.Diary = p_diary;

            patientEN.Password = Utils.Util.GetEncondeMD5(p_password);

            //Call to PatientCAD

            oid = _IPatientCAD.New_(patientEN);
            return(oid);
        }
 public DiaryEN(DiaryEN diary)
 {
     this.init(Identifier, diary.Observation, diary.Patient, diary.Practitioner);
 }