Exemple #1
0
        public void UnassignPatient(int p_RelatedPerson_OID, System.Collections.Generic.IList <int> p_patient_OIDs)
        {
            try
            {
                SessionInitializeTransaction();
                ChroniGenNHibernate.EN.Chroni.RelatedPersonEN relatedPersonEN = null;
                relatedPersonEN = (RelatedPersonEN)session.Load(typeof(RelatedPersonEN), p_RelatedPerson_OID);

                ChroniGenNHibernate.EN.Chroni.PatientEN patientENAux = null;
                if (relatedPersonEN.Patient != null)
                {
                    foreach (int item in p_patient_OIDs)
                    {
                        patientENAux = (ChroniGenNHibernate.EN.Chroni.PatientEN)session.Load(typeof(ChroniGenNHibernate.EN.Chroni.PatientEN), item);
                        if (relatedPersonEN.Patient.Contains(patientENAux) == true)
                        {
                            relatedPersonEN.Patient.Remove(patientENAux);
                            patientENAux.RelatedPerson.Remove(relatedPersonEN);
                        }
                        else
                        {
                            throw new ModelException("The identifier " + item + " in p_patient_OIDs you are trying to unrelationer, doesn't exist in RelatedPersonEN");
                        }
                    }
                }

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

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


            finally
            {
                SessionClose();
            }
        }
Exemple #2
0
        public void AssignPatient(int p_RelatedPerson_OID, System.Collections.Generic.IList <int> p_patient_OIDs)
        {
            ChroniGenNHibernate.EN.Chroni.RelatedPersonEN relatedPersonEN = null;
            try
            {
                SessionInitializeTransaction();
                relatedPersonEN = (RelatedPersonEN)session.Load(typeof(RelatedPersonEN), p_RelatedPerson_OID);
                ChroniGenNHibernate.EN.Chroni.PatientEN patientENAux = null;
                if (relatedPersonEN.Patient == null)
                {
                    relatedPersonEN.Patient = new System.Collections.Generic.List <ChroniGenNHibernate.EN.Chroni.PatientEN>();
                }

                foreach (int item in p_patient_OIDs)
                {
                    patientENAux = new ChroniGenNHibernate.EN.Chroni.PatientEN();
                    patientENAux = (ChroniGenNHibernate.EN.Chroni.PatientEN)session.Load(typeof(ChroniGenNHibernate.EN.Chroni.PatientEN), item);
                    patientENAux.RelatedPerson.Add(relatedPersonEN);

                    relatedPersonEN.Patient.Add(patientENAux);
                }


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

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


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

            if (t == null)
            {
                return(false);
            }
            if (Identifier.Equals(t.Identifier))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public RelatedPersonEN(RelatedPersonEN relatedPerson)
 {
     this.init(Identifier, relatedPerson.Nif, relatedPerson.Name, relatedPerson.Surnames, relatedPerson.Gender, relatedPerson.BirthDate, relatedPerson.Address, relatedPerson.Email, relatedPerson.Phone, relatedPerson.Photo, relatedPerson.StartDate, relatedPerson.EndDate, relatedPerson.Patient, relatedPerson.Password, relatedPerson.Conversation, relatedPerson.Reclamation, relatedPerson.Active, relatedPerson.AssessmentPractitioner);
 }