/// <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);
        }
        /// <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 #3
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 #4
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);
        }
Example #6
0
 internal static string GetObdLabel(Guid obdGuid)
 {
     try
     {
         var pm  = ImpacPersistenceManagerFactory.CreatePersistenceManager();
         var obd = ObsDef.GetEntityByObdGuid(obdGuid, pm);
         return(obd.IsNullEntity ? String.Empty : obd.LabelInactiveIndicator);
     }
     catch (Exception)
     {
         return(String.Empty);
     }
 }
Example #7
0
        private bool IsAVSVolumeAvailable(string volumeSeriesUid)
        {
            var method = System.Reflection.MethodBase.GetCurrentMethod().Name;

            _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Enter: Is AVS File available", Thread.CurrentThread.ManagedThreadId));
            var pm = ImpacPersistenceManagerFactory.CreatePersistenceManager(
                ImpacPersistenceManagerFactory.Usage.HybridModel);

            try
            {
                var paramSql = new IdeaBlade.Rdb.ParameterizedSql(@"select ivc.NumSlices, im.Num_Images+1 from ImageVolumeCache ivc 
                                                                    inner join RelatedSeriesLink rsl on rsl.related_dcmseries_id = ivc.DCMSeries_id
                                                                    inner join DCMSeries ds on ds.DCMSeries_ID = ivc.DCMSeries_id
                                                                    inner join Image im on IM.DCMSeries_ID = ds.DCMSeries_ID
                                                                    and ds.SeriesInstanceUID = @seriesInstanceUID",
                                                                  new IDbDataParameter[]
                {
                    new SqlParameter("@seriesInstanceUID", volumeSeriesUid),
                }
                                                                  );

                // Pass through query was replaced with a dynamic query as pass-through query in this case was corrupting the ORM
                // without this changes the Purge will not function correctly in field.
                // The change was fixed in the field as it can't be easily reproduced in normal work-flow.
                //

                var entitities = pm.GetEntities <DynamicEntity>(new PassthruRdbQuery(GetImageVolumeCacheValues,
                                                                                     new IdeaBlade.Rdb.ParameterizedSql(paramSql)),
                                                                QueryStrategy.DataSourceOnly);

                _logger.Log(EventSeverity.Info, method, string.Format("[{0}] Exit: Is AVS File available, Series Instance UID: [{1}] Slices: {2} Num Images: {3}",
                                                                      Thread.CurrentThread.ManagedThreadId,
                                                                      volumeSeriesUid,
                                                                      entitities.Count != 0 ? ((int)(entitities[0][0])).ToString() : "query result empty",
                                                                      entitities.Count != 0 ? ((int)(entitities[0][1])).ToString() : "query result empty"));

                if (entitities.Count == 0)
                {
                    return(false);
                }
                return((int)(entitities[0][0]) == (int)(entitities[0][1]));
            }
            finally
            {
                ImpacPersistenceManagerFactory.DestroyPersistenceManager(pm);
            }
        }
        /// <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);
                }
            }
        }
        /// <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();
            }
        }
Example #10
0
        /// <summary> Opens the prompt browse for staff types. </summary>
        /// <returns></returns>
        protected override IQOpResult <int> OpenEditor(int currentValue, IQVarElementTarget target)
        {
            var pm         = ImpacPersistenceManagerFactory.CreatePersistenceManager();
            var query      = GetStaffTypesQuery();
            var staffTypes = pm.GetEntities <Prompt>(query);

            return(null);

            /*
             * var editor = new StaffTypeOrCategorySelector {Value = currentValue, Text = Strings.SelectStaffType};
             * // It seems that we cannot use the Prompt.Enum value for staff type because the database
             * // contains several entries that have Prompt.Enum = 0
             * foreach (var staffType in staffTypes)
             *      //editor.AddItem(staffType.Enum, staffType.Text);
             *      editor.AddItem(staffType.Pro_ID, staffType.Text);
             *
             * //If the user hit "close", don't update the primaryKeyValue)
             * return editor.ShowDialog() == DialogResult.OK
             *              ? new IQOpResult<int> { Result = OpResultEnum.Completed, Value = editor.Value }
             *              : new IQOpResult<int> { Result = OpResultEnum.Cancelled };
             */
        }
Example #11
0
        /// <summary> Default ctor </summary>
        public FlowsheetTabSelector()
        {
            InitializeComponent();

            _pm = ImpacPersistenceManagerFactory.CreatePersistenceManager();
        }
 /// <summary>
 /// Creates a new persistence manager and assigns it to the output argument.
 /// </summary>
 /// <param name="context"></param>
 protected override void DoWork(CodeActivityContext context)
 {
     //Set the output to a new persistence manager
     PersistenceManager.Set(context, ImpacPersistenceManagerFactory.CreatePersistenceManager());
 }
 /// <summary> Default ctor </summary>
 public StaffTypeOrCategorySelector()
 {
     InitializeComponent();
     _pm = ImpacPersistenceManagerFactory.CreatePersistenceManager();
 }
Example #14
0
 /// <summary> Default ctor </summary>
 public DrugSelector()
 {
     InitializeComponent();
     InitializeDrugControl();
     _pm = ImpacPersistenceManagerFactory.CreatePersistenceManager();
 }