コード例 #1
0
        /// <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);
        }
コード例 #2
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);
        }
コード例 #3
0
        /// <summary>
        /// Execute the activity and look up the flowsheet value.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        protected override void DoWork(CodeActivityContext context)
        {
            //Get Variables
            Guid obdGuid = ObdGuid.Get(context);
            int? patId1  = PatId1.Expression != null?PatId1.Get(context) : (int?)null;

            int?obrId = ObrId.Expression != null?ObrId.Get(context) : (int?)null;

            FlowsheetLookupMethod lookupMethod = LookupMethod.Expression != null
                                               ? LookupMethod.Get(context)
                                               : FlowsheetLookupMethod.Earliest;

            //Lookup entities
            ObsDef obsDefEntity = ObsDef.GetEntityByObdGuid(obdGuid, PM);

            ObsDataValueFormat.Set(context, obsDefEntity.ObsDefDataFormat);

            string queryString;

            switch (lookupMethod)
            {
            case FlowsheetLookupMethod.Earliest:
                queryString = String.Format(EARLIEST_QUERY, patId1.GetValueOrDefault(0),
                                            obsDefEntity.OBD_ID);
                break;

            case FlowsheetLookupMethod.Latest:
                queryString = String.Format(LATEST_QUERY, patId1.GetValueOrDefault(0),
                                            obsDefEntity.OBD_ID);
                break;


            case FlowsheetLookupMethod.ByObrId:
                queryString = String.Format(OBR_ID_QUERY, patId1.GetValueOrDefault(0),
                                            obsDefEntity.OBD_ID, obrId.GetValueOrDefault(0));
                break;

            default:
                throw new InvalidOperationException("Invalid Lookup Operation");
            }

            var pQuery = new PassthruRdbQuery(typeof(Observe), queryString);
            var result = PM.GetEntity <Observe>(pQuery, QueryStrategy.DataSourceOnly);

            //If we didn't find any observations
            if (result == result.NullEntity)
            {
                ObsResultFound.Set(context, false);
                return;
            }

            //Assign output information.
            ObsResultFound.Set(context, true);
            ObsDtTm.Set(context, result.ObsReqTip.Obs_DtTm);
            ObrIdValue.Set(context, result.OBR_SET_ID);

            if (result.ObsReqTip.Obs_DtTm != null)
            {
                // Recalculating for hours since don't want to mess with day calculation
                TimeSpan span = DateTime.Now - result.ObsReqTip.Obs_DtTm.Value;
                AgeInDays.Set(context, span.TotalDays);
                AgeInHours.Set(context, span.TotalHours);
            }

            //Always populate ObsString.  Lab interface may populate this even if the ObsDef type is something
            //different.
            ObsStringValue.Set(context, result.Obs_String);
            if (result.ObsDefEntityOnObsChoice != null && !result.ObsDefEntityOnObsChoice.IsNullEntity)
            {
                ObsChoiceValue.Set(context, result.ObsDefEntityOnObsChoice.OBD_GUID);
            }
            else
            {
                ObsChoiceValue.Set(context, null);
            }

            //Set the appropriate output value.
            switch (result.ObsDefEntity.ObsDefDataFormat)
            {
            case ObsDefDataFormat.CheckBox:
                ObsCheckboxValue.Set(context, (result.Obs_Float == 0) ? false : true);
                break;

            case ObsDefDataFormat.Date:
                ObsDateTimeValue.Set(context, ClarionConversions.DateToDateTime(result.Obs_Float));
                break;

            case ObsDefDataFormat.Time:
                ObsDateTimeValue.Set(context, ClarionConversions.TimeToDateTime(result.Obs_Float));
                break;

            case ObsDefDataFormat.Numeric:
                ObsNumericValue.Set(context, result.Obs_Float);
                break;

            case ObsDefDataFormat.Choice:
            case ObsDefDataFormat.String:
            case ObsDefDataFormat.Memo:
                //Do nothing.  Already string and choice already set set above the switch statement
                break;

            default:
                throw new InvalidOperationException(
                          String.Format(Strings.Error_InvalidObsDefDataFormat,
                                        result.ObsDefEntity.ObsDefDataFormat));
            }
        }