/// <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 = CalcFactor.Get(context); var order = PM.GetEntity <PharmOrd>(new PrimaryKey(typeof(PharmOrd), rxoId)); if (!order.IsNullEntity) { double calculatedDose; if (DoseCalcUtils.EstimateOrderingDose(order, bsa, out calculatedDose) == DoseCalcUtils.CalcStatus.CalcSucceed) { SuggestedDose.Set(context, calculatedDose); } } }
/// <summary> </summary> protected override void DoWork(CodeActivityContext context) { Success.Set(context, true); var obrId = ObrId.Get(context); var dataItemThresholds = DataItemThresholds.Get(context); if (dataItemThresholds == null) { return; } ObsDef obsDefEntity = ObsDef.GetEntityByObdGuid(dataItemThresholds.ObdGuid, PM); if (obsDefEntity.IsNullEntity) { return; } var query = new EntityQuery(typeof(ObsReq)); query.AddClause(ObsReqDataRow.OBR_IDEntityColumn, EntityQueryOp.EQ, obrId); var obsReqEntity = PM.GetEntity <ObsReq>(query); if (obsReqEntity.IsNullEntity) { return; } query = new EntityQuery(typeof(Observe)); query.AddClause(ObserveDataRow.OBD_IDEntityColumn, EntityQueryOp.EQ, obsDefEntity.OBD_ID); query.AddClause(ObserveDataRow.Pat_ID1EntityColumn, EntityQueryOp.EQ, obsReqEntity.Pat_ID1); query.AddClause(ObserveDataRow.OBR_SET_IDEntityColumn, EntityQueryOp.EQ, obsReqEntity.OBR_Set_ID); var observeEntity = PM.GetEntity <Observe>(query); if (observeEntity.IsNullEntity) { return; } var success = CommonCharting.CheckDataItemThresholds(observeEntity, dataItemThresholds); Success.Set(context, success); }
/// <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)); } }
/// <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); }