Example #1
0
        private void FlowsheetItemSelector_Load(object sender, EventArgs e)
        {
            try
            {
                var query = new ImpacRdbQuery(typeof(ObsDef));
                query.AddClause(ObsDefDataRow.TypeEntityColumn, EntityQueryOp.EQ, (int)MedDefs.ObdType.ViewFilter);
                query.AddClause(ObsDefDataRow.ActiveEntityColumn, EntityQueryOp.EQ, true);
                query.AddOrderBy(ObsDefDataRow.LabelEntityColumn);
                _tabNames = _pm.GetEntities <ObsDef>(query);
                InitDropDown(lookUpEditFlowsheetTab, _tabNames, Value.TabGuid);

                LoadTabViews();
                InitDropDown(lookUpEditFlowsheetViews, _tabViews, Value.ItemGuids != null ? Value.ViewGuid : Guid.Empty);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("FlowsheetItemSelector: " + ex);
            }

            if (Value.ItemGuids == null)
            {
                return;
            }

            // disable the logic in treeTabViewItems_AfterCheck in this case, because
            // we will set the Checked flag on each node individually
            _initializingItemState = true;
            int pos = 0;

            SetCheckedItems(treeTabViewItems.Nodes, Value.ItemGuids, ref pos);
            _initializingItemState = false;
        }
Example #2
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));
        }
Example #3
0
        /// <summary> Populates a query object created by the base class. </summary>
        /// <param name="context">Activity context</param>
        /// <param name="pQuery">MOSAIQ BOM Query object</param>
        protected override void PopulateQuery(CodeActivityContext context, ImpacRdbQuery pQuery)
        {
            // Activity input
            int  patId1 = PatId1.Get(context);
            bool primaryDoseSitesOnly   = PrimaryDoseSitesOnly.Get(context);
            bool secondaryDoseSitesOnly = SecondaryDoseSitesOnly.Get(context);
            int  sitId = SitId.Get(context);

            // Build the query
            pQuery.AddClause(Region.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId1);

            // Primary Dose Sites Only
            if (primaryDoseSitesOnly)
            {
                pQuery.AddClause(Region.SIT_Set_IDEntityColumn, EntityQueryOp.IsNotNull);
            }

            // Secondary Dose Sites Only
            if (secondaryDoseSitesOnly)
            {
                pQuery.AddClause(Region.SIT_Set_IDEntityColumn, EntityQueryOp.IsNull);
            }

            // Specific Sit_ID
            if (sitId != 0)
            {
                pQuery.AddClause(Region.SIT_Set_IDEntityColumn, EntityQueryOp.EQ, sitId);
            }
        }
Example #4
0
        /// <summary> Populates a query object created by the base class. </summary>
        /// <param name="context"></param>
        /// <param name="pQuery"></param>
        protected override void PopulateQuery(CodeActivityContext context, ImpacRdbQuery pQuery)
        {
            // Activity inputs
            int    patId1   = PatId1.Get(context);
            string siteName = SiteName.Get(context);

            // Build the query
            pQuery.AddClause(PrescriptionSite.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId1);
            pQuery.AddClause(PrescriptionSite.VersionEntityColumn, EntityQueryOp.EQ, 0);
            if (siteName == null)
            {
                pQuery.AddClause(PrescriptionSite.SiteNameEntityColumn.ColumnName, EntityQueryOp.EQ,
                                 "Dummy string to force empty result!");
            }
            else
            {
                // Keep string.Empty in just for consistency since Site Name cannot be an empty string
                if (siteName == string.Empty)
                {
                    pQuery.AddClause(PrescriptionSite.SiteNameEntityColumn, EntityQueryOp.EQ, string.Empty);
                }
                else
                {
                    pQuery.AddClause(PrescriptionSite.SiteNameEntityColumn, EntityQueryOp.Contains, siteName);
                }
            }
            pQuery.AddOrderBy(PrescriptionSite.DisplaySequenceEntityColumn);
        }
        /// <summary> Populates a query object created by the base class. </summary>
        /// <param name="context"></param>
        /// <param name="pQuery"></param>
        protected override void PopulateQuery(CodeActivityContext context, ImpacRdbQuery pQuery)
        {
            // Activity input
            int patId = PatId.Get(context);
            int sitId = SitId.Get(context);

            var pm = ImpacPersistenceManagerFactory.CreatePersistenceManager();

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

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

            if (site.Count != 1)
            {
                sitSetId = -1;
            }
            else
            {
                sitSetId = (int)site[0].SIT_SET_ID;
            }

            // Build the query
            pQuery.AddClause(Field.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId);
            pQuery.AddClause(Field.SIT_Set_IDEntityColumn, EntityQueryOp.EQ, sitSetId);
            pQuery.AddClause(Field.VersionEntityColumn, EntityQueryOp.EQ, 0);
            pQuery.AddOrderBy(Field.DisplaySequenceEntityColumn);
        }
Example #6
0
        /// <summary> Populates a query object created by the base class. </summary>
        /// <param name="context"></param>
        /// <param name="pQuery"></param>
        protected override void PopulateQuery(CodeActivityContext context, ImpacRdbQuery pQuery)
        {
            // Activity inputs
            int      patId1    = PatId1.Get(context);
            int      sitId     = (SitId.Expression != null) ? SitId.Get(context) : 0;
            DateTime startDate = CheckDateTime(StartDate.Get(context));
            DateTime endDate   = CheckDateTime(EndDate.Get(context));

            // Get the Dose_Hst entries for the given patient
            pQuery.AddClause(DoseHst.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId1);

            // Filter on SIT_ID if supplied
            if (sitId != 0)
            {
                pQuery.AddClause(DoseHst.SIT_IDEntityColumn, EntityQueryOp.EQ, sitId);
            }

            // Filter on StartDate if supplied
            if (startDate > SqlDateTime.MinValue.Value)
            {
                pQuery.AddClause(DoseHst.Tx_DtTmEntityColumn, EntityQueryOp.GE, startDate);
            }

            // Filter on EndDate if supplied
            if (endDate > SqlDateTime.MinValue.Value)
            {
                pQuery.AddClause(DoseHst.Tx_DtTmEntityColumn, EntityQueryOp.LE, endDate);
            }
        }
Example #7
0
        private void CdsReferenceSelector_Load(object sender, EventArgs e)
        {
            try
            {
                var query = new ImpacRdbQuery(typeof(CDSReference));
                query.AddClause(CDSReferenceDataRow.InactiveEntityColumn, EntityQueryOp.EQ, false);
                query.AddOrderBy(CDSReferenceDataRow.TitleEntityColumn);

                EntityList <CDSReference> list = _pm.GetEntities <CDSReference>(query);
                bsCdsReference.DataSource = list;

                gridCdsReference.ForceInitialize();
                for (int i = 0; i < gridViewCdsReference.RowCount; i++)
                {
                    int index  = gridViewCdsReference.GetDataSourceRowIndex(i);
                    var cdsRef = (CDSReference)bsCdsReference[index];
                    if (cdsRef != null && cdsRef.CDSR_ID == Value)
                    {
                        gridViewCdsReference.FocusedRowHandle = i;
                        break;
                    }
                }
            }
            catch (Exception)
            {
                bsCdsReference.Clear();
            }
        }
        /// <summary> Populates a query object created by the base class. </summary>
        /// <param name="context"></param>
        /// <param name="pQuery"></param>
        protected override void PopulateQuery(CodeActivityContext context, ImpacRdbQuery pQuery)
        {
            // Activity input
            int patId = PatId.Get(context);
            int pcpId = PcpId.Get(context);

            // In case startDate/endDate has input specified (Null/Nothing) it defaults to
            // DateTime.MinValue (0001-01-01 01:01:01).
            DateTime startDate = CheckDateTime(StartDate.Get(context));
            DateTime endDate   = CheckDateTime(EndDate.Get(context));

            // Build the query
            pQuery.AddClause(PatCItem.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId);
            pQuery.AddClause(PatCItem.PCP_IDEntityColumn, EntityQueryOp.EQ, pcpId);

            // Filter on StartDate if supplied
            if (startDate > SqlDateTime.MinValue.Value)
            {
                pQuery.AddClause(PatCItem.Due_DtTmEntityColumn, EntityQueryOp.GE, startDate);
            }

            // Filter on EndDate if supplied
            if (endDate > SqlDateTime.MinValue.Value)
            {
                pQuery.AddClause(PatCItem.Due_DtTmEntityColumn, EntityQueryOp.LE, endDate);
            }
        }
Example #9
0
        /// <summary> Populates a query object created by the base class. </summary>
        /// <param name="context"></param>
        /// <param name="pQuery"></param>
        protected override void PopulateQuery(CodeActivityContext context, ImpacRdbQuery pQuery)
        {
            // Activity input
            int instId = InstId.Get(context);

            // Build the query
            pQuery.AddClause(BOM.Entities.Config.Inst_IDEntityColumn, EntityQueryOp.EQ, instId);
        }
        /// <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));
        }
Example #11
0
        /*
         * /// <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 = GetStaffTypesQuery();
         *      query.AddClause(PromptDataRow.EnumEntityColumn, EntityQueryOp.In, ids.ToList());
         *      return pm.GetEntities<Prompt>(query, QueryStrategy.Normal).ToDictionary(e => (int) e.Enum, e => e);
         * }
         */

        private static ImpacRdbQuery GetStaffTypesQuery()
        {
            var query = new ImpacRdbQuery(typeof(Prompt));

            query.AddClause(PromptDataRow.PGroupEntityColumn, EntityQueryOp.EQ, "STF0");
            query.AddClause(PromptDataRow.TextEntityColumn, EntityQueryOp.NE, "Location");
            return(query);
        }
Example #12
0
        /// <summary> Populates a query object created by the base class. </summary>
        /// <param name="context"></param>
        /// <param name="pQuery"></param>
        protected override void PopulateQuery(CodeActivityContext context, ImpacRdbQuery pQuery)
        {
            // Activity inputs
            int             patId1              = PatId1.Get(context);
            string          commentFieldString  = CommentFieldString.Get(context);
            string          protocolFieldString = ProtocolFieldString.Get(context);
            EntityBooleanOp logicalOperator     = ((LogicalOperator.Expression != null)
                                                  ? LogicalOperator.Get(context)
                                                   : EntityBooleanOp.Or) ?? EntityBooleanOp.Or;

            // The logical NOT operator is not supported, because the meaning of the result is vague.
            if (logicalOperator == EntityBooleanOp.Not)
            {
                string message = String.Format("The Not value of the logical operator is not supported by the {0}",
                                               GetType().Name);

                throw new ArgumentException(message);
            }

            // Build the query
            pQuery.AddClause(Course.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId1);
            if ((commentFieldString == null) && (protocolFieldString == null))
            {
                // Don't want to change the base class to handle "empty" queries, so just perform a ridiculous query that will return
                // an empty result (in case none of the string identifiers have been supplied)
                pQuery.AddClause(Course.NotesEntityColumn.ColumnName, EntityQueryOp.EQ,
                                 "Dummy string to force empty result!");
            }
            else
            {
                if (commentFieldString != null)
                {
                    if (commentFieldString == string.Empty)
                    {
                        pQuery.AddClause(Course.NotesEntityColumn, EntityQueryOp.EQ, string.Empty);
                    }
                    else
                    {
                        pQuery.AddClause(Course.NotesEntityColumn, EntityQueryOp.Contains, commentFieldString);
                    }
                }
                if (protocolFieldString != null)
                {
                    if (protocolFieldString == string.Empty)
                    {
                        pQuery.AddClause(Course.ProtocolEntityColumn, EntityQueryOp.EQ, string.Empty);
                    }
                    else
                    {
                        pQuery.AddClause(Course.ProtocolEntityColumn, EntityQueryOp.Contains, protocolFieldString);
                    }
                }
                if ((commentFieldString != null) && (protocolFieldString != null))
                {
                    pQuery.AddOperator(logicalOperator);
                }
            }
        }
Example #13
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));
        }
Example #14
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);
            }
        }
Example #15
0
        /// <summary> Populates a query object created by the base class. </summary>
        /// <param name="context"></param>
        /// <param name="pQuery"></param>
        protected override void PopulateQuery(CodeActivityContext context, ImpacRdbQuery pQuery)
        {
            // Activity input
            int patId1 = PatId1.Get(context);
            int regId  = RegId.Get(context);

            // Build the query
            pQuery.AddClause(Coeff.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId1);
            pQuery.AddClause(Coeff.REG_IDEntityColumn, EntityQueryOp.EQ, regId);
        }
        /// <summary> Populates a query object created by the base class. </summary>
        /// <param name="context"></param>
        /// <param name="pQuery"></param>
        protected override void PopulateQuery(CodeActivityContext context, ImpacRdbQuery pQuery)
        {
            // Activity input
            int patId = PatId.Get(context);
            int pciId = PciId.Get(context);

            // Build the query
            pQuery.AddClause(PatTxCal.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId);
            pQuery.AddClause(PatTxCal.PCI_IDEntityColumn, EntityQueryOp.EQ, pciId);
        }
Example #17
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);
            }
        }
Example #18
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();
                    }
                }
            }
        }
        /// <summary> Populates a query object created by the base class. </summary>
        /// <param name="context"></param>
        /// <param name="pQuery"></param>
        protected override void PopulateQuery(CodeActivityContext context, ImpacRdbQuery pQuery)
        {
            // Activity inputs
            int patId = PatId.Get(context);
            int pcpId = PcpId.Get(context);

            pQuery.AddClause(PrescriptionSite.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId);
            pQuery.AddClause(PrescriptionSite.PCP_IDEntityColumn, EntityQueryOp.EQ, pcpId);
            pQuery.AddClause(PrescriptionSite.VersionEntityColumn, EntityQueryOp.EQ, 0);
            pQuery.AddOrderBy(PrescriptionSite.DisplaySequenceEntityColumn);
        }
        private void PopulateChildControls(ObsDef obd)
        {
            buttonDataItem.EditValue = obd.LabelInactiveIndicator;
            buttonDataItem.Tag       = obd;

            HideChildControls();

            if (obd.Type == (short)MedDefs.ObdType.ItemTable)
            {
                layoutItemTableItems.RestoreFromCustomization();
                var query = new ImpacRdbQuery(typeof(ObsDef));
                query.AddClause(ObsDefDataRow.TypeEntityColumn, EntityQueryOp.EQ, (int)MedDefs.ObdType.Choice);
                query.AddClause(ObsDefDataRow.TblEntityColumn, EntityQueryOp.EQ, obd.Tbl);
                query.AddClause(ObsDefDataRow.ActiveEntityColumn, EntityQueryOp.EQ, true);
                var tblItems = Global.DefaultStaffImpacPM.GetEntities <ObsDef>(query);

                comboTableItems.Properties.Items.Clear();
                foreach (var tblItem in tblItems)
                {
                    comboTableItems.Properties.Items.Add(tblItem.OBD_GUID, tblItem.FullDescription);
                }

                //comboTableItems.Properties.DataSource = tblItems;
                //comboTableItems.Properties.DisplayMember = "FullDescription";
                //comboTableItems.Properties.ValueMember = "OBD_GUID";
                //comboTableItems.Properties.DropDownRows = tblItems.Count + 2;
            }
            else if (obd.Type == (short)MedDefs.ObdType.ItemData)
            {
                switch (obd.ObsDefDataFormat)
                {
                case ObsDefDataFormat.Numeric:
                    layoutItemLowerLimit.RestoreFromCustomization();
                    layoutItemUpperLimit.RestoreFromCustomization();
                    break;

                case ObsDefDataFormat.Date:
                    layoutItemDateRange.RestoreFromCustomization();
                    inputDateRange.DateRange = new InputDateRangeValue(InputDateRangeControlType.Today,
                                                                       DateTime.Today, DateTime.Today, 1);
                    break;

                case ObsDefDataFormat.String:
                case ObsDefDataFormat.Memo:
                    layoutItemStringAlgorithm.RestoreFromCustomization();
                    if (comboStringAlgorithm.SelectedIndex == -1)
                    {
                        comboStringAlgorithm.SelectedIndex = 0;
                    }
                    EnableStringControls();
                    break;
                }
            }
        }
Example #21
0
        /// <summary>
        /// Handles form Loading
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void IntentPromptSelectorForm_Load(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                //pm = ImpacPersistenceManagerFactory.CreatePersistenceManager();

                var query = new ImpacRdbQuery(typeof(Prompt));
                query.AddClause(PromptDataRow.PGroupEntityColumn, EntityQueryOp.EQ, "MEDA");
                query.AddOrderBy(PromptDataRow.TextEntityColumn, ListSortDirection.Ascending);
                _promptValues       = _pm.GetEntities <Prompt>(query);
                bsPropmt.DataSource = _promptValues;
            }
        }
Example #22
0
        /// <summary> Populates a query object created by the base class. </summary>
        /// <param name="context"></param>
        /// <param name="pQuery"></param>
        protected override void PopulateQuery(CodeActivityContext context, ImpacRdbQuery pQuery)
        {
            // Activity inputs
            int             patId1             = PatId1.Get(context);
            string          commentFieldString = CommentFieldString.Get(context);
            string          patternFieldString = PatternFieldString.Get(context);
            EntityBooleanOp logicalOperator    = ((LogicalOperator.Expression != null)
                                                  ? LogicalOperator.Get(context)
                                                   : EntityBooleanOp.Or) ?? EntityBooleanOp.Or;

            // Build the query
            pQuery.AddClause(PrescriptionSite.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId1);
            pQuery.AddClause(PrescriptionSite.VersionEntityColumn, EntityQueryOp.EQ, 0);
            if ((commentFieldString == null) && (patternFieldString == null))
            {
                // Don't want to change the base class to handle "empty" queries, so just perform a ridiculous query that will return
                // an empty result (in case none of the string identifiers have been supplied)
                pQuery.AddClause(PrescriptionSite.PrescriptionDescriptionEntityColumn.ColumnName,
                                 EntityQueryOp.EQ, "Dummy string to force empty result!");
            }
            else
            {
                if (commentFieldString != null)
                {
                    if (commentFieldString == string.Empty)
                    {
                        pQuery.AddClause(PrescriptionSite.PrescriptionDescriptionEntityColumn, EntityQueryOp.EQ, string.Empty);
                    }
                    else
                    {
                        pQuery.AddClause(PrescriptionSite.PrescriptionDescriptionEntityColumn, EntityQueryOp.Contains, commentFieldString);
                    }
                }
                if (patternFieldString != null)
                {
                    if (patternFieldString == string.Empty)
                    {
                        pQuery.AddClause(PrescriptionSite.Frac_PatternEntityColumn, EntityQueryOp.EQ, string.Empty);
                    }
                    else
                    {
                        pQuery.AddClause(PrescriptionSite.Frac_PatternEntityColumn, EntityQueryOp.Contains, patternFieldString);
                    }
                }
                if ((commentFieldString != null) && (patternFieldString != null))
                {
                    pQuery.AddOperator(logicalOperator);
                }
            }
            pQuery.AddOrderBy(PrescriptionSite.DisplaySequenceEntityColumn);
        }
Example #23
0
        private void LoadTabViews()
        {
            var query = new ImpacRdbQuery(typeof(ObsDef));

            query.AddClause(ObsDefDataRow.OBD_GUIDEntityColumn, EntityQueryOp.EQ, Value.TabGuid);
            var tab = _pm.GetEntity <ObsDef>(query);

            query = new ImpacRdbQuery(typeof(ObsDef));
            query.AddClause(ObsDefDataRow.TypeEntityColumn, EntityQueryOp.EQ, 1);
            query.AddClause(ObsDefDataRow.TblEntityColumn, EntityQueryOp.EQ, tab.Tbl);
            query.AddClause(ObsDefDataRow.ActiveEntityColumn, EntityQueryOp.EQ, true);
            query.AddOrderBy(ObsDefDataRow.LabelEntityColumn);
            _tabViews = _pm.GetEntities <ObsDef>(query);
        }
        private void GetStaffTypes()
        {
            var query = new ImpacRdbQuery(typeof(Prompt));

            query.AddClause(PromptDataRow.PGroupEntityColumn, EntityQueryOp.EQ, "STF0");
            query.AddClause(PromptDataRow.TextEntityColumn, EntityQueryOp.NE, "Location");
            var staffTypes = _pm.GetEntities <Prompt>(query);

            foreach (var staffType in staffTypes)
            {
                var item = new KeyLabelInfo {
                    Key = staffType.Pro_ID, Label = staffType.Text
                };
                _items.Add(item);
            }
        }
Example #25
0
        private IEnumerable <ObsDef> LoadTabViewItems(int viewId)
        {
            var subQuery = new ImpacRdbQuery(typeof(ObsDef));

            subQuery.AddClause(ObsDefDataRow.TypeEntityColumn, EntityQueryOp.EQ, 12);
            subQuery.AddClause(ObsDefDataRow.View_IDEntityColumn, EntityQueryOp.EQ, viewId);
            subQuery.AddOrderBy(ObsDefDataRow.SeqEntityColumn);     // chart items (obsdef.type=12) are internal only and don't need Active filter.

            var defs  = _pm.GetEntities <ObsDef>(subQuery);
            var ids   = defs.Select(o => o.Item_ID).ToList();
            var query = new ImpacRdbQuery(typeof(ObsDef));

            query.AddClause(ObsDefDataRow.OBD_IDEntityColumn, EntityQueryOp.In, ids);
            query.AddClause(ObsDefDataRow.ActiveEntityColumn, EntityQueryOp.EQ, true);
            var obsDefs = _pm.GetEntities <ObsDef>(query);

            // sort the result in the same order of IDs as in the 'ids' list
            var result = ids.Select(id => obsDefs.Find(o => o.OBD_ID == id)).ToList();

            return(result.ToArray());
        }
Example #26
0
        private void FlowsheetTabSelector_Load(object sender, EventArgs e)
        {
            try
            {
                var query = new ImpacRdbQuery(typeof(ObsDef));
                query.AddClause(ObsDefDataRow.TypeEntityColumn, EntityQueryOp.EQ, (int)MedDefs.ObdType.ViewFilter);
                _tabNames = _pm.GetEntities <ObsDef>(query);

                listTabNames.DisplayMember = "Label";
                listTabNames.ValueMember   = "OBD_GUID";
                listTabNames.DataSource    = _tabNames;

                // Select the current value if there is one and if the mode is sinlge-select
                if (TabGuid == Guid.Empty)
                {
                    return;
                }

                for (int i = 0; i < listTabNames.ItemCount; i++)
                {
                    var item = (ObsDef)listTabNames.GetItem(i);
                    if (item == null)
                    {
                        continue;
                    }
                    if (item.OBD_GUID != TabGuid)
                    {
                        continue;
                    }

                    listTabNames.SelectedIndex = i;
                    break;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("FlowsheetTabSelector: " + ex);
            }
        }
Example #27
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);
            }
        }
Example #28
0
        private void PopulateTree(int viewId)
        {
            // load the items belonging to the selected tab view
            treeTabViewItems.Nodes.Clear();
            IEnumerable <ObsDef> items = LoadTabViewItems(viewId);

            // populate the tree with the view items so that it looks similar to the flowsheet
            TreeNode   currentFolder     = null;
            FolderType currentFolderType = FolderType.Root;
            ObsDef     otherLabsEntity   = null;

            foreach (var obsDef in items)
            {
                if (obsDef == null)
                {
                    continue;
                }

                // skip the 'Other Labs' function item
                if (obsDef.OBD_GUID == _otherLabsItemGuid)
                {
                    otherLabsEntity = obsDef;
                    continue;
                }
                var newNode = new TreeNode(obsDef.Label)
                {
                    Tag = obsDef.OBD_GUID
                };
                var itemType = (MedDefs.ObdType)obsDef.Type;
                if (itemType == MedDefs.ObdType.MajorHeading || itemType == MedDefs.ObdType.MinorHeading)
                {
                    newNode.BackColor = Color.DarkGray;
                    newNode.ForeColor = Color.White;
                }

                TreeNode insertInNode = null;                 // an exisitng tree node in which the new node is to be inserted
                if (itemType == MedDefs.ObdType.MajorHeading)
                {
                    // major headings are inserted at root level (i.e. insertInNode is null)
                    currentFolder     = newNode;
                    currentFolderType = FolderType.MajorHeading;
                }
                else if (itemType == MedDefs.ObdType.MinorHeading)
                {
                    // minor headings are inserted either as children of major headings or at root level
                    if (currentFolderType == FolderType.MajorHeading)
                    {
                        // insert inside the current major heading
                        insertInNode = currentFolder;
                    }
                    else if (currentFolderType == FolderType.MinorHeading && currentFolder != null)
                    {
                        // insert at the same level as the previous minor heading
                        insertInNode = currentFolder.Parent;
                    }

                    currentFolder     = newNode;
                    currentFolderType = FolderType.MinorHeading;
                }
                else
                {
                    // all other items are inserted in the current folder
                    insertInNode = currentFolder;
                }

                if (insertInNode != null)
                {
                    insertInNode.Nodes.Add(newNode);
                }
                else
                {
                    treeTabViewItems.Nodes.Add(newNode);
                }


                /*
                 * if (itemType == MedDefs.ObdType.MajorHeading)
                 * {
                 *      treeTabViewItems.Nodes.Add(newNode);
                 *      currentFolder = newNode;
                 *      currentFolderType = FolderType.MajorHeading;
                 * }
                 * else if (itemType == MedDefs.ObdType.MinorHeading)
                 * {
                 *      if (currentFolderType == FolderType.MajorHeading && currentFolder != null)
                 *              currentFolder.Nodes.Add(newNode);
                 *      else if (currentFolderType == FolderType.MinorHeading && currentFolder != null)
                 *              currentFolder.Parent.Nodes.Add(newNode);
                 *      else
                 *              treeTabViewItems.Nodes.Add(newNode);
                 *
                 *      currentFolder = newNode;
                 *      currentFolderType = FolderType.MinorHeading;
                 * }
                 * else
                 * {
                 *      if (currentFolder != null)
                 *              currentFolder.Nodes.Add(newNode);
                 *      else
                 *              treeTabViewItems.Nodes.Add(newNode);
                 * }
                 */
            }

            if (IncudeOtherLabs)
            {
                if (otherLabsEntity == null)
                {
                    var query = new ImpacRdbQuery(typeof(ObsDef));
                    query.AddClause(ObsDefDataRow.OBD_GUIDEntityColumn, EntityQueryOp.EQ, _otherLabsItemGuid);
                    otherLabsEntity = _pm.GetEntity <ObsDef>(query);
                }

                var node = new TreeNode(otherLabsEntity.Label)
                {
                    Tag = otherLabsEntity.OBD_GUID
                };
                node.BackColor = Color.DarkGray;
                node.ForeColor = Color.White;
                treeTabViewItems.Nodes.Add(node);
            }

            foreach (TreeNode nd in treeTabViewItems.Nodes)
            {
                nd.Checked = true;
            }

            treeTabViewItems.ExpandAll();
            if (treeTabViewItems.Nodes.Count > 0)
            {
                treeTabViewItems.Nodes[0].EnsureVisible();
            }
        }
        /// <summary> Populates a query object created by the base class. </summary>
        /// <param name="context"></param>
        /// <param name="pQuery"></param>
        protected override void PopulateQuery(CodeActivityContext context, ImpacRdbQuery pQuery)
        {
            int patId1 = PatId1.Get(context);

            pQuery.AddClause(Patient.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId1);
        }
Example #30
0
        /// <summary>
        ///
        /// </summary>
        protected override void DoWork(CodeActivityContext context)
        {
            var patId1  = PatId.Get(context);
            var patient = Patient.GetEntityByID(patId1, PM);

            if (patient.IsNullEntity)
            {
                return;
            }

            short?docType     = null;
            var   docTypeTemp = DocType.Get(context);

            if (docTypeTemp.HasValue)
            {
                docType = (short)docTypeTemp.Value;
            }

            var dictId = DictatedBy.Get(context);

            if (dictId == 0)
            {
                return;
            }

            int?reviewId = null;
            int temp     = ReviewRequiredBy.Get(context);

            if (temp > 0)
            {
                reviewId = temp;
            }

            int?cosignId = null;

            temp = CoSignRequiredBy.Get(context);
            if (temp > 0)
            {
                cosignId = temp;
            }

            int?transId = null;

            temp = TranscribedBy.Get(context);
            if (temp > 0)
            {
                transId = temp;
            }

            var encounterTemp = EncounterDate.Get(context);

            if (!encounterTemp.HasValue)
            {
                return;
            }
            var encounterDate = encounterTemp.Value;

            var transcribedDate = TranscribedDate.Get(context);

            var instId    = Department.Get(context);
            var accountId = Account.Get(context);

            var template = Template.Get(context);

            var openAfterCreation = OpenAfterCreation.Get(context).Key == (int)OpenAfterCreationOptions.Yes;
            var status            = (byte)Status.Get(context);

            if (CreateIfDuplicateExists.Get(context).Key == (int)CreateIfDuplicateExistsOptions.No)
            {
                // Check for a duplicate encounter
                var query = new ImpacRdbQuery(typeof(ObjectTable));
                query.AddClause(ObjectTableDataRow.Pat_ID1EntityColumn, EntityQueryOp.EQ, patId1);
                query.AddClause(ObjectTableDataRow.DocTypeEntityColumn, EntityQueryOp.EQ, docType);

                query.AddClause(ObjectTableDataRow.Dict_IDEntityColumn, EntityQueryOp.EQ, dictId);
                query.AddClause(ObjectTableDataRow.Review_IDEntityColumn, EntityQueryOp.EQ, reviewId);
                query.AddClause(ObjectTableDataRow.CoSig_IDEntityColumn, EntityQueryOp.EQ, cosignId);
                query.AddClause(ObjectTableDataRow.Trans_IDEntityColumn, EntityQueryOp.EQ, transId);

                // Defect 11605, the Encounter_DtTm and Trans_DtTm store date time rather than the previous date part
                // so we should check items if it exists within the day of datetime
                query.AddClause(ObjectTableDataRow.Encounter_DtTmEntityColumn, EntityQueryOp.Between, encounterDate.Date, encounterDate.Date.AddDays(1));

                if (transcribedDate.HasValue)
                {
                    query.AddClause(ObjectTableDataRow.Trans_DtTmEntityColumn, EntityQueryOp.Between, transcribedDate.Value.Date, transcribedDate.Value.Date.AddDays(1));
                }

                query.AddClause(ObjectTableDataRow.Inst_IDEntityColumn, EntityQueryOp.EQ, instId);
                query.AddClause(ObjectTableDataRow.Account_IDEntityColumn, EntityQueryOp.EQ, accountId);
                query.AddClause(ObjectTableDataRow.DocumentTemplateEntityColumn, EntityQueryOp.EQ, template);

                var objectEntity = PM.GetEntity(query);
                if (objectEntity != null && !objectEntity.IsNullEntity)
                {
                    return;
                }
            }

            EscribeOperations.CreateDocument(patId1, docType,
                                             dictId, reviewId, cosignId, transId,
                                             encounterDate, transcribedDate,
                                             instId, accountId, template,
                                             status, openAfterCreation);
        }