/// <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 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); } }
/// <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); } }
/// <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); } } }
/// <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> /// Create the QCL record. /// </summary> /// <param name="context"></param> protected override void DoWork(CodeActivityContext context) { var mgr = new NotesManager { PM = PM }; int noteId = mgr.CreateNote(PatId1.Get(context), NoteType.Get(context), Subject.Get(context), Note.Get(context)); NoteId.Set(context, noteId); }
/// <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); }
/// <summary> /// Get the current BSA for the patient passed in. /// </summary> /// <param name="context"></param> protected override void DoWork(CodeActivityContext context) { int obxId = 0; int patId1 = PatId1.Get(context); bool includeOrders = IncludeOrders != null?IncludeOrders.Get(context) : false; DoseCalcSourceTypeEnum bsaSourceType; int bsaSource; BSA.Set(context, includeOrders ? BSAUtils.FindExistingBSAForDoseCalc(patId1, MedDefs.OrderingDoseCalcFormulas.BsaFormulasAndManual, out bsaSourceType, out bsaSource) : BSAUtils.GetMostRecentBSA(patId1, MedDefs.OrderingDoseCalcFormulas.BsaFormulasAndManual, ref obxId)); }
/// <summary> /// Finds the next day with clinic hours for the current department. Searches 30 days into the future /// and then throws an InvalidOperationException. /// </summary> /// <param name="context"></param> protected override void DoWork(CodeActivityContext context) { var scheduleData = ScheduleData.Get(context); var pairs = scheduleData.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (var pair in pairs) { var tuple = pair.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (tuple.Length != 2) { continue; } var name = tuple[0].Trim().ToLower(); var value = tuple[1].Trim(); switch (name) { case "pat_id1": PatId1.Set(context, Int32.Parse(value)); break; case "appt_dttm": AppDtTm.Set(context, DateTime.Parse(value)); break; case "activity": Activity.Set(context, value); break; case "staff_id": StaffId.Set(context, Int32.Parse(value)); break; case "private": // TODO: should we call the IsAppointmentPrivate logic from the Schedule BOM entity? Private.Set(context, Int16.Parse(value) != 0); break; case "create_id": CreateId.Set(context, Int32.Parse(value)); break; case "create_dttm": CreateDtTm.Set(context, DateTime.Parse(value)); break; } } }
/// <summary> /// Create the QCL record. /// </summary> /// <param name="context"></param> protected override void DoWork(CodeActivityContext context) { var mgr = new QclManager { PM = PM }; int chkId = mgr.CreateQcl(PatId1.Get(context), TskId.Get(context), StaffIdResponsible.Get(context), StaffIdRequesting.Get(context), DueDate.Get(context), CGroup.Get(context), PrsId.Get(context), Instructions.Get(context), Comment.Get(context)); ChkId.Set(context, chkId); }
/// <summary> /// Checks for QCL's with attributes matching the parameters passed in. /// </summary> /// <param name="context"></param> protected override void DoWork(CodeActivityContext context) { var mgr = new QclManager { PM = PM }; bool qclExists = mgr.CheckQclExists(PatId1.Get(context), TskId.Get(context), StaffIdResponsible.Get(context), StaffIdRequesting.Get(context), DueDate.Get(context), CGroup.Get(context), PrsId.Get(context), Instructions.Get(context), Comment.Get(context), Completed.Get(context)); QclExists.Set(context, qclExists); }
/// <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)); } }