public void UnassignCarePlan(int p_Encounter_OID, System.Collections.Generic.IList <int> p_carePlan_OIDs)
        {
            try
            {
                SessionInitializeTransaction();
                ChroniGenNHibernate.EN.Chroni.EncounterEN encounterEN = null;
                encounterEN = (EncounterEN)session.Load(typeof(EncounterEN), p_Encounter_OID);

                ChroniGenNHibernate.EN.Chroni.CarePlanEN carePlanENAux = null;
                if (encounterEN.CarePlan != null)
                {
                    foreach (int item in p_carePlan_OIDs)
                    {
                        carePlanENAux = (ChroniGenNHibernate.EN.Chroni.CarePlanEN)session.Load(typeof(ChroniGenNHibernate.EN.Chroni.CarePlanEN), item);
                        if (encounterEN.CarePlan.Contains(carePlanENAux) == true)
                        {
                            encounterEN.CarePlan.Remove(carePlanENAux);
                            carePlanENAux.Encounter = null;
                        }
                        else
                        {
                            throw new ModelException("The identifier " + item + " in p_carePlan_OIDs you are trying to unrelationer, doesn't exist in EncounterEN");
                        }
                    }
                }

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

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


            finally
            {
                SessionClose();
            }
        }
        public void AssignCarePlan(int p_Encounter_OID, System.Collections.Generic.IList <int> p_carePlan_OIDs)
        {
            ChroniGenNHibernate.EN.Chroni.EncounterEN encounterEN = null;
            try
            {
                SessionInitializeTransaction();
                encounterEN = (EncounterEN)session.Load(typeof(EncounterEN), p_Encounter_OID);
                ChroniGenNHibernate.EN.Chroni.CarePlanEN carePlanENAux = null;
                if (encounterEN.CarePlan == null)
                {
                    encounterEN.CarePlan = new System.Collections.Generic.List <ChroniGenNHibernate.EN.Chroni.CarePlanEN>();
                }

                foreach (int item in p_carePlan_OIDs)
                {
                    carePlanENAux           = new ChroniGenNHibernate.EN.Chroni.CarePlanEN();
                    carePlanENAux           = (ChroniGenNHibernate.EN.Chroni.CarePlanEN)session.Load(typeof(ChroniGenNHibernate.EN.Chroni.CarePlanEN), item);
                    carePlanENAux.Encounter = encounterEN;

                    encounterEN.CarePlan.Add(carePlanENAux);
                }


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

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


            finally
            {
                SessionClose();
            }
        }
Esempio n. 3
0
        public void UnassignEncounter(int p_Slot_OID, int p_encounter_OID)
        {
            try
            {
                SessionInitializeTransaction();
                ChroniGenNHibernate.EN.Chroni.SlotEN slotEN = null;
                slotEN = (SlotEN)session.Load(typeof(SlotEN), p_Slot_OID);

                if (slotEN.Encounter.Identifier == p_encounter_OID)
                {
                    slotEN.Encounter = null;
                    ChroniGenNHibernate.EN.Chroni.EncounterEN encounterEN = (ChroniGenNHibernate.EN.Chroni.EncounterEN)session.Load(typeof(ChroniGenNHibernate.EN.Chroni.EncounterEN), p_encounter_OID);
                    encounterEN.Slot = null;
                }
                else
                {
                    throw new ModelException("The identifier " + p_encounter_OID + " in p_encounter_OID you are trying to unrelationer, doesn't exist in SlotEN");
                }

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

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


            finally
            {
                SessionClose();
            }
        }