/// <summary>
        /// Opens the QCL Form.
        /// </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            //Get Values off the arguments
            ImpacPersistenceManager pm = ImpacPersistenceManagerFactory.CreatePersistenceManager();
            int    proId = ProId.Get(context);
            int    staffIdResponsible = StaffIdResponsible.Get(context);
            string comment            = Comment.Get(context);

            if (String.IsNullOrWhiteSpace(comment))
            {
                comment = String.Empty;
            }

            //Check if values exist in the database.
            var prompt = pm.GetEntity <Prompt>(new PrimaryKey(typeof(Prompt), proId));

            if (prompt.IsNullEntity)
            {
                throw new InvalidOperationException("Cannot find QCL Procedure (Prompt) record with Pro_Id: " + proId);
            }

            var staffResponsible = pm.GetEntity <Staff>(new PrimaryKey(typeof(Staff), staffIdResponsible));

            if (staffResponsible.IsNullEntity)
            {
                throw new InvalidOperationException("Cannot find Responsible (Staff) record with Staff_Id: " + staffIdResponsible);
            }

            int chkId = CallClarion.AddQclRecord(prompt.Text, comment, staffIdResponsible);

            ChkId.Set(context, chkId);
        }
Beispiel #2
0
        /// <summary>
        /// Assembles and returns the list of SiteWaveDetails that are not referenced by any SiteFractionDetails
        /// </summary>
        /// <param name="pm"></param>
        /// <param name="revisionedSite"></param>
        /// <returns></returns>
        private static IEnumerable <SiteWaveDetails> GetUnreferencedSiteWaveDetails(ImpacPersistenceManager pm, PrescriptionSite revisionedSite)
        {
            var swdEntitiesToRemove = new List <SiteWaveDetails>();

            List <SiteFractionDetails> sfdEntitiesSurviving =
                pm.GetAllEntitiesInCache().OfType <SiteFractionDetails>()
                .Where(e => e.SIT_ID == revisionedSite.SIT_ID && e.Seq <= revisionedSite.Fractions)
                .ToList();

            List <SiteWaveDetails> swdEntities =
                pm.GetAllEntitiesInCache().OfType <SiteWaveDetails>()
                .Where(e => e.SIT_ID == revisionedSite.SIT_ID)
                .ToList();

            // Assemble the list of SiteWaveDetails that are not referenced by any SiteFractionDetails records that will survive this update
            foreach (SiteWaveDetails swdEntity in swdEntities)
            {
                var swdId = swdEntity.SWD_ID;

                if (sfdEntitiesSurviving.Count(e => e.SWD_ID == swdId) == 0)
                {
                    swdEntitiesToRemove.Add(swdEntity);
                }
            }
            return(swdEntitiesToRemove);
        }
Beispiel #3
0
        /// <summary> </summary>
        public CdsReferenceSelector()
        {
            InitializeComponent();
            gridViewCdsReference.OptionsSelection.EnableAppearanceFocusedCell = false;

            _pm = Global.DefaultStaffImpacPM;
        }
        /// <summary> Performs the query requested. </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            //Get argument values.
            ImpacPersistenceManager pm = PersistenceManager.Expression != null
                                             ? PersistenceManager.Get(context)
                                             : PM;

            QueryStrategy strategy = Strategy.Get(context) ?? QueryStrategy.Normal;
            string        sqlQuery = Query.Get(context);

            //Defect-11131:Medication field in eScribe get error when the PC Regional Settings are changed to DD/MM/YY--Check the MAX date format, if exist possible issue format, change the format to standard format.
            if ((sqlQuery.IndexOf(DateTime.MaxValue.ToString("dd/MM/yyyy")) > 0) || (sqlQuery.IndexOf(DateTime.MaxValue.ToString("MM/dd/yyyy")) > 0))
            {
                if (sqlQuery.IndexOf(DateTime.MaxValue.ToString("dd/MM/yyyy")) > 0)
                {
                    sqlQuery = sqlQuery.Replace(DateTime.MaxValue.ToString("dd/MM/yyyy"), DateTime.MaxValue.ToString("yyyy/MM/dd"));
                }
                if (sqlQuery.IndexOf(DateTime.MaxValue.ToString("MM/dd/yyyy")) > 0)
                {
                    sqlQuery = sqlQuery.Replace(DateTime.MaxValue.ToString("MM/dd/yyyy"), DateTime.MaxValue.ToString("yyyy/MM/dd"));
                }
            }
            //Create and execute the query
            var            passthroughQuery = new PassthruRdbQuery(typeof(T), sqlQuery);
            EntityList <T> entities         = pm.GetEntities <T>(passthroughQuery, strategy);

            //Assign the result set.
            Result.Set(context, entities);
        }
Beispiel #5
0
        /// <summary>
        /// Activity heavy lifting.
        /// </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            // Activity inputs
            int patId = PatId.Get(context);
            int pciId = PciId.Get(context);
            ImpacPersistenceManager pm = PersistenceManager.Expression != null
                                             ? PersistenceManager.Get(context)
                                             : PM;

            // Activity output
            FieldsDeleted.Set(context, 0); // Initialize the Activity output to 0

            // Get the available session fields for given PCI_ID
            var query = new ImpacRdbQuery(typeof(PatTxCal));

            query.AddClause(PatTxCal.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId);
            query.AddClause(PatTxCal.PCI_IDEntityColumn, EntityQueryOp.EQ, pciId);
            var sessionItems = pm.GetEntities <PatTxCal>(query);

            // Delete fields in the given session
            int fieldsDeleted = 0;

            try
            {
                // Store PatCItem record
                PatCItem patCItem       = null;
                byte     patCItemStatus = 0;

                if (sessionItems.Count > 0)
                {
                    // The Delete() member of PatTxField sets PatCItem.Status to "Pending" if the Status is "Approved"
                    // Save state of PatCItem record
                    patCItem       = sessionItems[0].PatCItemEntity;
                    patCItemStatus = patCItem.Status_Enum;
                }
                while (sessionItems.Count > 0)
                {
                    sessionItems[sessionItems.Count - 1].Delete();
                    pm.SaveChanges();
                    fieldsDeleted++;
                }
                if (patCItem != null)
                {
                    patCItem.Status_Enum = patCItemStatus;
                    pm.SaveChanges();
                }
            }
            catch
            {
                fieldsDeleted = -1;
            }
            finally
            {
                // Update Activity output
                FieldsDeleted.Set(context, fieldsDeleted);
            }
        }
Beispiel #6
0
        private void NoteTypeSelector_Load(object sender, EventArgs e)
        {
            try
            {
                ImpacPersistenceManager pm = ImpacPersistenceManagerFactory.CreatePersistenceManager();
                var query = new ImpacRdbQuery(typeof(Prompt));
                query.AddClause(PromptDataRow.PGroupEntityColumn, EntityQueryOp.EQ, "#NT1");
                var noteTypes =
                    pm.GetEntities <Prompt>(query).Select(ent => new NoteType {
                    Text = ent.Text, Enum = ent.Enum
                }).ToList();

                foreach (var noteType in noteTypes)
                {
                    noteType.Text = IQNoteTypeVarConfig.FixNoteTypeName(noteType.Enum, noteType.Text);
                }

                // sort the notes types by name
                noteTypes.Sort((n1, n2) => n1.Text.CompareTo(n2.Text));

                listNoteTypes.DisplayMember = "Text";
                listNoteTypes.ValueMember   = "Enum";
                listNoteTypes.DataSource    = noteTypes;

                listNoteTypes.SelectionMode = IsMultiSelect ? SelectionMode.MultiSimple : SelectionMode.One;
                if (!IsMultiSelect)
                {
                    checkAll.Enabled = false;
                }
                listNoteTypes.SelectedIndex = -1;
                // Select the current value if there is one and if the mode is single-select
                if (!IsMultiSelect && Value != null && Value.Count > 0)
                {
                    for (int i = 0; i < listNoteTypes.ItemCount; i++)
                    {
                        var item = (NoteType)listNoteTypes.GetItem(i);
                        if (item == null)
                        {
                            continue;
                        }
                        if (item.Enum != Value[0])
                        {
                            continue;
                        }

                        listNoteTypes.SelectedIndex = i;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("NoteTypeSelector: " + ex);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Remove fraction-specific notes that will be orphaned when the excess fractions are removed
        /// (The same Notes record can be referenced from the same fraction# SiteFractionDetails
        ///  record in more than one version of a Site.)
        /// </summary>
        /// <param name="pm"></param>
        /// <param name="sfdsToRemove"></param>
        /// <param name="revisionedSite"></param>
        private static void RemoveFxNotesThatWillBeOrphaned(ImpacPersistenceManager pm, IEnumerable <SiteFractionDetails> sfdsToRemove, PrescriptionSite revisionedSite)
        {
            // Normal usage is for Plan-of-the-Day i.e., a single Site_FractionDetails record will be removed
            // and if there is a fraction-specific note for that Site_FractionDetails recore then it will be removed.
            // Usage of fraction-specific notes in general is probably uncommon.
            // Usage with Plan-of-the-Day should be even less common given that the feature removes fractions.
            // Considering the above, performance tuning of the functionality below offers little if any benefit.

            List <int?> fxNoteIdsInsfdsToRemove = sfdsToRemove.Where(d => d.FxNote_ID != null).Select(d => d.FxNote_ID).ToList();

            // Notes records are not in the cache (yet)

            if (fxNoteIdsInsfdsToRemove.Count > 0)
            {
                // Determine whether any of the fx Notes records will be orphaned when the fraction details record is removed

                // Get the SIT_IDs for the historic versions of the Site
                var historicSitesInSetQuery = new ImpacRdbQuery(typeof(PrescriptionSite));
                historicSitesInSetQuery.AddClause(PrescriptionSite.SIT_SET_IDEntityColumn, EntityQueryOp.EQ, revisionedSite.SIT_SET_ID);
                historicSitesInSetQuery.AddClause(PrescriptionSite.VersionEntityColumn, EntityQueryOp.GT, 0);
                var historicSites   = pm.GetEntities <PrescriptionSite>(historicSitesInSetQuery);
                var historicSIT_IDs = historicSites.Select(s => s.SIT_ID).ToList();

                // Get the FxNote_IDs in the fraction details for the historic versions of the Site
                var historicSFDsQuery = new ImpacRdbQuery(typeof(SiteFractionDetails));
                historicSFDsQuery.AddClause(SiteFractionDetails.SIT_IDEntityColumn, EntityQueryOp.In, historicSIT_IDs);
                var         historicSFDs          = pm.GetEntities <SiteFractionDetails>(historicSFDsQuery);
                List <int?> historicSFDFx_NoteIDs = historicSFDs.Where(n => n.FxNote_ID != null).Select(n => n.FxNote_ID).ToList();

                for (int i = 0; i < fxNoteIdsInsfdsToRemove.Count; i++)
                {
                    int fxNoteId = fxNoteIdsInsfdsToRemove[i].GetValueOrDefault();

                    // Until we find evidence otherwise this fxNoteId will be orphaned
                    bool isGoingToBeOrphaned = true;

                    if (historicSFDFx_NoteIDs.Count > 0)
                    {
                        // If this fxNoteId is an fx note for an historic version of the Site then it will NOT be orphaned
                        if (historicSFDFx_NoteIDs.Exists(h => h == fxNoteId))
                        {
                            isGoingToBeOrphaned = false;
                        }
                    }

                    if (isGoingToBeOrphaned)
                    {
                        // Either there are no fx notes for historic versions of the Site
                        // or there are but this fxNoteId isn't an fx note for any of them
                        Notes note = Notes.GetEntityByID(fxNoteId, pm);
                        note.Delete();
                    }
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Excess SiteFractionDetails record (if any) must have already been removed from the persistence manager or marked for delete.
        /// If the SiteFractionDetails record to be removed/deleted was the only one that referenced a particular SiteWaveDetails
        /// then remove/delete that now unreferenced SiteWaveDetails record.
        /// </summary>
        /// <param name="pm"></param>
        /// <param name="revisionedSite"></param>
        private static void RemoveUnreferencedSiteWaveDetails(ImpacPersistenceManager pm, PrescriptionSite revisionedSite)
        {
            // Assemble the list of SiteWaveDetails that are not referenced by any SiteFractionDetails that isn't marked for deletion
            var swdsToRemove = new List <SiteWaveDetails>(GetUnreferencedSiteWaveDetails(pm, revisionedSite));

            if (swdsToRemove.Count > 0)
            {
                // Mark for deletion the excess wave detail records
                swdsToRemove.Delete();
            }
        }
Beispiel #9
0
        /// <summary>
        /// Opens the intent prompt browse and allows the user to select a prompt value.
        /// </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            ImpacPersistenceManager pm = ImpacPersistenceManagerFactory.CreatePersistenceManager();
            var form = new IntentPromptSelectorForm(pm);

            if (form.ShowDialog() == DialogResult.OK)
            {
                PromptProId.Set(context, form.SelectedItem.Pro_ID);
                SelectedText.Set(context, form.SelectedItem.Text);
            }
        }
        /// <summary>
        /// Checks the database to see if the PharmCalcAccept table contains a record indicating that the
        /// calculation factor passed has been accepted..
        /// </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            ImpacPersistenceManager pm = ImpacPersistenceManagerFactory.CreatePersistenceManager();
            int    rxoSetId            = RxoSetId.Get(context);
            double calcFactor          = CalcFactor.Get(context);

            //Lookup all of the PharmCalcAccept records to get the minimum and maximum accepted values.
            EntityList <PharmCalcAccept> acceptRecords = PharmCalcAccept.FindByRxoSetId(pm, QueryStrategy.Normal, rxoSetId);
            double maxAccepted = acceptRecords.Where(e => e.Accepted_High.HasValue).Max(e => e.Accepted_High.Value);
            double minAccepted = acceptRecords.Where(e => e.Accepted_Low.HasValue).Min(e => e.Accepted_Low.Value);

            Result.Set(context, calcFactor >= minAccepted && calcFactor <= maxAccepted);
        }
Beispiel #11
0
        /// <summary> Performs the query requested. </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            //Get argument values
            //Get argument values.
            ImpacPersistenceManager pm = PersistenceManager.Expression != null
                                             ? PersistenceManager.Get(context)
                                             : PM;

            QueryStrategy strategy = Strategy.Get(context) ?? QueryStrategy.Normal;
            object        key      = PrimaryKey.Get(context);

            //Execute the query and return the result.
            Entity entity = pm.GetEntity <T>(new PrimaryKey(typeof(T), key), strategy);

            Result.Set(context, entity);
        }
        /// <summary>
        /// Estimates the dose based on the pharmacy order and calculation factor passed in.
        /// </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            int    rxoId = RxoId.Get(context);
            double bsa   = BSA.Get(context);

            ImpacPersistenceManager pm = ImpacPersistenceManagerFactory.CreatePersistenceManager();
            var order = pm.GetEntity <BOM.Entities.PharmOrd>(new PrimaryKey(typeof(BOM.Entities.PharmOrd), rxoId));

            if (!order.IsNullEntity)
            {
                double calculatedDose;
                if (DoseCalcUtils.EstimateOrderingDose(order, bsa, out calculatedDose) == DoseCalcUtils.CalcStatus.CalcSucceed)
                {
                    SuggestedDose.Set(context, calculatedDose);
                }
            }
        }
Beispiel #13
0
        /// <summary>
        /// Performs the query.
        /// </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            //Get arguments
            //Get argument values.
            ImpacPersistenceManager pm = PersistenceManager.Expression != null
                                             ? PersistenceManager.Get(context)
                                             : PM;

            QueryStrategy strategy = Strategy.Get(context) ?? QueryStrategy.Normal;
            string        sqlQuery = Query.Get(context);

            //Run query and set results.
            var passthroughQuery = new PassthruRdbQuery(typeof(T), sqlQuery);
            var entity           = pm.GetEntity <T>(passthroughQuery, strategy);

            Result.Set(context, entity);
        }
        /// <summary>
        /// Writes to the PharmCalcAccept table indicating that the calculation factor passed in has
        /// been accepted.
        /// </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            ImpacPersistenceManager pm = ImpacPersistenceManagerFactory.CreatePersistenceManager();
            int    rxoSetId            = RxoSetId.Get(context);
            double calcFactor          = AcceptedCalcFactor.Get(context);

            //Get PharmOrd Object
            BOM.Entities.PharmOrd pharmOrd = BOM.Entities.PharmOrd.GetEntityByRxoSetIdAndVersion0(rxoSetId);

            if (pharmOrd.IsNullEntity)
            {
                throw new InvalidOperationException("Cannot find PharmOrd record with Version = 0 and Rxo_Set_Id = " + rxoSetId);
            }

            //Only write to the table if a BSA is found.
            if (pharmOrd.BSA != 0)
            {
                PharmCalcAccept obj = PharmCalcAccept.Create(pm);
                obj.RXO_Set_ID = rxoSetId;

                //If the BSA on the order is equal to the value passed in, reject the change since there's no reason to save the record.
                if (calcFactor == pharmOrd.BSA)
                {
                    pm.RejectChanges();
                    return;
                }

                //Otherwise, if the acepted calc factor is greater than the order BSA, set the high value.  If it's less than the order
                //BSA, set the low value.
                if (calcFactor > pharmOrd.BSA)
                {
                    obj.Accepted_High = calcFactor;
                }
                else
                {
                    obj.Accepted_Low = calcFactor;
                }

                pm.SaveChanges();
            }
        }
Beispiel #15
0
        /// <summary>
        /// Remove from the persistence manager or mark for deletion the excess SiteFractionDetails records, if there are any.
        /// (There aren't necessarily any SiteFractionDetails records for the Site.)
        /// If a SiteFractionDetails record is to be removed/deleted and it contains a link to a Notes record
        /// which is referenced by no other SiteFractionDetails record then mark it for deletion.
        /// </summary>
        /// <param name="pm"></param>
        /// <param name="revisionedSite"></param>
        private static void RemoveExcessSiteFractionDetailsAndNotes(ImpacPersistenceManager pm, PrescriptionSite revisionedSite)
        {
            List <SiteFractionDetails> sfdsToRemove =
                pm.GetAllEntitiesInCache().OfType <SiteFractionDetails>()
                .Where(e => e.SIT_ID == revisionedSite.SIT_ID && e.Seq > revisionedSite.Fractions)
                .ToList();

            if (sfdsToRemove.Count > 0)
            {
                if (revisionedSite.SIT_ID > 0)
                {
                    // A version roll will NOT occur
                    // Remove fraction-specific notes that will be orphaned (if any) when the excess fractions are removed
                    // (No fraction-specific notes will be orphaned when there is a version roll
                    // - they'll still be referenced from the about-to-be historic rx fx detail recs)
                    RemoveFxNotesThatWillBeOrphaned(pm, sfdsToRemove, revisionedSite);
                }

                // Mark for deletion the excess fraction detail records
                sfdsToRemove.Delete();
            }
        }
        /// <summary>
        /// Overriden method for looking up details by ID (since we're not using the primary key of Prompt)
        /// </summary>
        protected override IDictionary <int, Prompt> GetEntitiesDictFromIds(IEnumerable <int> ids, ImpacPersistenceManager pm)
        {
            var query = new ImpacRdbQuery(typeof(Prompt));

            query.AddClause(PromptDataRow.PGroupEntityColumn, EntityQueryOp.EQ, "ESC7");
            query.AddClause(PromptDataRow.EnumEntityColumn, EntityQueryOp.In, ids.ToList());
            return(pm.GetEntities <Prompt>(query, QueryStrategy.Normal).ToDictionary(e => (int)e.Enum, e => e));
        }
Beispiel #17
0
 /// <summary> Default ctor </summary>
 public DrugSelector()
 {
     InitializeComponent();
     InitializeDrugControl();
     _pm = ImpacPersistenceManagerFactory.CreatePersistenceManager();
 }
Beispiel #18
0
        /// <summary>
        /// Activity heavy lifting.
        /// </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            // This processing is intended for the Plan-of-the-Day feature and does not necessarily support any other usage
            // The passed Site.SIT_ID must be for a version zero prescription record (aka the 'tip' or 'current' version)
            // Prescribed fraction dose must not be zero and must be uniform
            // If fractionation details records exist for the prescription (Site_FractionDetails) then the passed deltaFraction must be negative
            // For Plan-of-the-Day the deltaFraction value is -1
            // The valid range of prescribed fractions after the adjustment is 0 to 100 inclusive

            // Activity inputs
            int patId                  = PatId.Get(context);
            int sitId                  = Sitid.Get(context);
            int deltaFraction          = DeltaFraction.Get(context);
            ImpacPersistenceManager pm = PersistenceManager.Expression != null
                                             ? PersistenceManager.Get(context)
                                             : PM;

            // Activity output
            FractionsChanged.Set(context, false); // Initialize the Activity output to False

            // Don't do anything if deltaFraction is zero i.e., no adjustment requested
            if (deltaFraction == 0)
            {
                return;
            }

            // Get the Rad Rx to be updated
            PrescriptionSite site = PrescriptionSite.GetEntityByID(sitId, pm);

            // Determine whether the request is valid for this prescription

            // If the Site record no longer exists or the record's version is no longer zero (because a version roll has occurred)
            // then do not proceed with updates to this prescription
            if (site.IsNullEntity || site.Version != 0)
            {
                return;
            }

            // If the prescribed fraction dose is zero or non-uniform then do not proceed with updates to this prescription
            // (Dose_Tx is zero when fraction dose is non-uniform; check for negative dose is excessive but doesn't hurt)
            if (site.Dose_Tx <= 0)
            {
                return;
            }

            // If the adjusted number of fractions won't be valid (must be between 0 and 100 inclusive)
            // then do not proceed with updates to this prescription
            int newFractions = site.Fractions + deltaFraction;

            if ((newFractions < 0) || (newFractions > 100))
            {
                return;
            }

            // Get the fraction and wave detail records (if any) for this prescription
            if (site.FxType == 2)
            {
                // When there are fraction detail records, FxType is 2
                EntityList <SiteFractionDetails> siteFractionDetails = SiteFractionDetails.GetSiteFractionDetailsEntitiesBySitId(sitId, pm, QueryStrategy.DataSourceOnly);

                // There can be wave detail records only when there are fraction detail records
                if (siteFractionDetails.Count > 0)
                {
                    EntityList <SiteWaveDetails> siteWaveDetails = SiteWaveDetails.GetSiteWaveDetailsEntitiesBySitId(sitId, pm, QueryStrategy.DataSourceOnly);
                }

                // If there are fraction and/or wave detail records and deltaFraction > 0
                // then do NOT proceed because inserting fraction and/or wave detail records is NOT supported here
                if (deltaFraction > 0 && siteFractionDetails.Count > 0)
                {
                    return;
                }
            }

            // The request is valid for this prescription so make the adjustments

            // Prepare for edit, including version roll if necessary
            var revisionedSite = (PrescriptionSite)site.PrepareEntityForEdit("PlanOfTheDay", true);

            // Adjust prescribed total dose and prescribed number of fractions
            revisionedSite.Dose_Ttl  = revisionedSite.Dose_Tx * newFractions;
            revisionedSite.Fractions = (short)newFractions;

            // If the prescription is approved, maintain the approval status and approving staff
            // but set the approval date/time stamp to now
            if (revisionedSite.Sanct_Id.HasValue)
            {
                revisionedSite.Sanct_DtTm = DateTime.Now;
            }

            if (revisionedSite.FxType == 2)
            {
                // Manage the fraction details, fraction specific Notes and wave details records (if any)
                RemoveExcessSiteFractionDetailsAndNotes(pm, revisionedSite);
                RemoveUnreferencedSiteWaveDetails(pm, revisionedSite);

                // If fractions were reduced to zero
                // then there will be no details records when the update is complete so change FxType to 0 (no details records)
                if (revisionedSite.Fractions == 0)
                {
                    revisionedSite.FxType = 0;
                }
            }

            try
            {
                pm.SaveChanges();
            }
            catch
            {
                return;
            }

            FractionsChanged.Set(context, true);
        }
Beispiel #19
0
        /// <summary>
        ///  Overriden method for looking up details by ID (since we're not using the primary key of obsdef)
        ///  </summary>
        /// <param name="ids"></param>
        /// <param name="pm"></param>
        /// <returns></returns>
        protected override IDictionary <int, CPlan> GetEntitiesDictFromIds(IEnumerable <int> ids, ImpacPersistenceManager pm)
        {
            var query = new ImpacRdbQuery(typeof(CPlan));

            //Defect 12161, Change logic to use CPL_SET_ID rather than CPL_ID to trigger IQ
            query.AddClause(CPlanDataRow.CPL_Set_IDEntityColumn, EntityQueryOp.In, ids.ToList());
            query.AddClause(CPlanDataRow.VersionEntityColumn, EntityQueryOp.EQ, 0);
            return(pm.GetEntities <CPlan>(query, QueryStrategy.Normal).ToDictionary(e => (int)e.CPL_Set_ID, e => e));
        }
Beispiel #20
0
        /// <summary>
        ///  Overriden method for looking up details by ID (since we're not using the primary key of obsdef)
        ///  </summary>
        /// <param name="ids"></param>
        /// <param name="pm"></param>
        /// <returns></returns>
        protected override IDictionary <Guid, ObsDef> GetEntitiesDictFromIds(IEnumerable <Guid> ids, ImpacPersistenceManager pm)
        {
            var query = new ImpacRdbQuery(typeof(ObsDef));

            query.AddClause(ObsDefDataRow.OBD_GUIDEntityColumn, EntityQueryOp.In, ids.ToList());
            return(pm.GetEntities <ObsDef>(query, QueryStrategy.Normal).ToDictionary(e => e.OBD_GUID, e => e));
        }
 /// <summary>
 /// ctor with persistence manager.
 /// </summary>
 public IntentPromptSelectorForm(ImpacPersistenceManager pManager)
 {
     InitializeComponent();
     _pm = pManager;
 }
Beispiel #22
0
        /// <summary> Default ctor </summary>
        public FlowsheetTabSelector()
        {
            InitializeComponent();

            _pm = ImpacPersistenceManagerFactory.CreatePersistenceManager();
        }
Beispiel #23
0
        /// <summary>
        /// Activity heavy lifting.
        /// </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            // Activity inputs
            int patId      = PatId.Get(context);
            int sitId      = SitId.Get(context);
            int pciId      = PciId.Get(context);
            int statusEnum = StatusEnum.Expression != null?StatusEnum.Get(context) : 5;

            if ((statusEnum != 5) && (statusEnum != 7))
            {
                statusEnum = 7;
            }
            bool useAfs = UseAfs.Expression != null?UseAfs.Get(context) : false;

            bool useMfs = UseMfs.Expression != null?UseMfs.Get(context) : false;

            ImpacPersistenceManager pm = PersistenceManager.Expression != null
                                             ? PersistenceManager.Get(context)
                                             : PM;

            // Activity output
            FieldsInserted.Set(context, -1); // Initialize the Activity output to -1 (indication of error)

            // Do not continue if both AFS and MFS are set to true (there is no way to resolve this at run time)
            if (useAfs && useMfs)
            {
                return;
            }

            // Get the Sit_Set_Id of the Site (Sit_Id) given
            var query = new ImpacRdbQuery(typeof(PrescriptionSite));

            query.AddClause(PrescriptionSiteDataRow.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId);
            query.AddClause(PrescriptionSiteDataRow.SIT_IDEntityColumn, EntityQueryOp.EQ, sitId);
            var site = pm.GetEntities <PrescriptionSite>(query);

            if (site.Count != 1)
            {
                return;
            }

            int sitSetId = (int)site[0].SIT_SET_ID.GetValueOrDefault(0);

            // Get the list of treatment fields from the given Rad Rx to insert
            query = new ImpacRdbQuery(typeof(Field));
            query.AddClause(FieldDataRow.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId);
            query.AddClause(FieldDataRow.SIT_Set_IDEntityColumn, EntityQueryOp.EQ, sitSetId);
            query.AddClause(FieldDataRow.VersionEntityColumn, EntityQueryOp.EQ, 0);
            query.AddOrderBy(FieldDataRow.DisplaySequenceEntityColumn);
            var txField = pm.GetEntities <Field>(query);

            if (txField.Count == 0)
            {
                return;
            }

            // Make sure we have a (1) session to insert the fields in to
            query = new ImpacRdbQuery(typeof(PatCItem));
            query.AddClause(PatCItemDataRow.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId);
            query.AddClause(PatCItemDataRow.PCI_IDEntityColumn, EntityQueryOp.EQ, pciId);
            var calendarSession = pm.GetEntities <PatCItem>(query);

            if (calendarSession.Count != 1)
            {
                return;
            }

            // Add new entry to PatTxCal for each treatment field
            int fieldsInserted = 0;

            try
            {
                for (int f = 0; f < txField.Count; f++)
                {
                    PatTxCal sessionItem = PatTxCal.Create(pm);
                    sessionItem.PCI_ID      = calendarSession[0].PCI_ID;
                    sessionItem.Status_enum = (byte)statusEnum;
                    sessionItem.Pat_ID1     = patId;
                    sessionItem.FLD_Set_ID  = txField[f].FLD_SET_ID;
                    sessionItem.TxSequence  = (short)(f + 1);
                    sessionItem.ProFormaPF  = 0;
                    if (useAfs)
                    {
                        if (f == 0)
                        {
                            sessionItem.AFS_Begin = true;
                        }
                        else
                        {
                            sessionItem.AFS = true;
                        }
                    }
                    if (useMfs)
                    {
                        if (f == 0)
                        {
                            sessionItem.MFS_Begin = true;
                        }
                        else
                        {
                            sessionItem.MFS = true;
                        }
                    }
                    sessionItem.PF_Only = txField[f].Type_Enum == 3 || txField[f].Type_Enum == 4 ||
                                          txField[f].Type_Enum == 5 || txField[f].Type_Enum == 9; //FLD.Type_Enum: 3=Setup, 4=kV Setup, 5=CT, 9=MVCT

                    pm.SaveChanges();
                    fieldsInserted++;
                }
            }
            catch
            {
                fieldsInserted = -1;
            }
            finally
            {
                FieldsInserted.Set(context, fieldsInserted);
            }
        }
 /// <summary> Default ctor </summary>
 public StaffTypeOrCategorySelector()
 {
     InitializeComponent();
     _pm = ImpacPersistenceManagerFactory.CreatePersistenceManager();
 }
        /// <summary>
        /// Activity heavy lifting.
        /// </summary>
        /// <param name="context"></param>
        protected override void DoWork(CodeActivityContext context)
        {
            // Activity inputs
            int patId1 = PatId.Get(context);
            EntityList <PrescriptionSite> rxSite = RxSite.Get(context);
            string regionName = RegionName.Get(context);
            double doseCoeff  = DoseCoeff.Expression != null?DoseCoeff.Get(context) : 1.000;

            ImpacPersistenceManager pm = PersistenceManager.Expression != null
                                             ? PersistenceManager.Get(context)
                                             : PM;


            // Activity output
            DoseSiteCreated.Set(context, false); // Initialize the Activity output to False

            // Make sure rxSite is not supplied as a null (e.g. Nothing)
            if (rxSite == null)
            {
                return;
            }

            // Make sure none of the given Sites is Null
            if (rxSite.Count == 0)
            {
                return;
            }

            for (int i = 0; i < rxSite.Count; i++)
            {
                if (rxSite[i] == null)
                {
                    return;
                }
            }

            // Only continue if doseCoeff given is within valid range
            if ((doseCoeff < 0.0) || (doseCoeff > 9.9990))
            {
                return;
            }

            // Name for the Region cannot be empty or null
            if (string.IsNullOrEmpty(regionName))
            {
                return;
            }

            // Trim regionName to max allowed chars
            const int maxSiteNameLength = 20;

            if (regionName.Length > maxSiteNameLength)
            {
                regionName = regionName.Substring(0, maxSiteNameLength);
            }

            // First check if supplied siteName exists already in the database
            var query = new ImpacRdbQuery(typeof(Region));

            query.AddClause(Region.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId1);
            query.AddClause(Region.Region_NameEntityColumn, EntityQueryOp.EQ, regionName);
            EntityList <Region> queryRegion = pm.GetEntities <Region>(query);

            if (queryRegion.Count > 0)
            {
                return;
            }

            // Check if any of the tip revision or historic Rx sites are already using the name
            var rxSitesQuery = new ImpacRdbQuery(typeof(PrescriptionSite));

            rxSitesQuery.AddClause(PrescriptionSiteDataRow.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId1);
            rxSitesQuery.AddClause(PrescriptionSiteDataRow.SiteNameEntityColumn, EntityQueryOp.EQ, regionName);
            if (pm.GetEntities <PrescriptionSite>(rxSitesQuery).Count > 0)
            {
                return;
            }

            // Create an entry in the Region table (new REG_ID will be used later)
            Region region = Region.Create(pm);

            region.Pat_ID1     = patId1;
            region.Region_Name = regionName;
            try
            {
                pm.SaveChanges();
            }
            catch
            {
                return;
            }

            // Go through each Rx Site given and collect the treatment field properties
            var txField = new EntityList <Field>();

            foreach (var t in rxSite)
            {
                query = new ImpacRdbQuery(typeof(PrescriptionSite));
                query.AddClause(PrescriptionSite.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId1);
                query.AddClause(PrescriptionSite.SIT_IDEntityColumn, EntityQueryOp.EQ, t.SIT_ID);
                query.AddClause(PrescriptionSite.VersionEntityColumn, EntityQueryOp.EQ, 0);
                EntityList <PrescriptionSite> site = pm.GetEntities <PrescriptionSite>(query);

                if (site.Count == 1)
                {
                    query = new ImpacRdbQuery(typeof(Field));
                    query.AddClause(Field.SIT_Set_IDEntityColumn, EntityQueryOp.EQ, site[0].SIT_SET_ID);
                    query.AddClause(Field.VersionEntityColumn, EntityQueryOp.EQ, 0);
                    txField.AddRange(pm.GetEntities <Field>(query));
                }
            }

            // Now add for each field an entry in the Coeff table with a link to the Region entry earlier
            int fieldsInserted = 0;

            try
            {
                foreach (var t in txField)
                {
                    Coeff coeff = Coeff.Create(pm);
                    coeff.Pat_ID1                   = patId1;
                    coeff.FLD_SET_ID                = t.FLD_SET_ID;
                    coeff.REG_ID                    = region.REG_ID;
                    coeff.Reg_Coeff                 = doseCoeff;
                    coeff.IsFromDataImport          = false;
                    coeff.IsModifiedAfterDataImport = false;
                    pm.SaveChanges();
                    fieldsInserted++;
                }
            }
            finally
            {
                DoseSiteCreated.Set(context, fieldsInserted == txField.Count);
            }
        }