/// <summary> /// Open the observation form and let the user enter data. /// Sets the observe form to the patient of the activity not the global patient. /// </summary> /// <param name="context"></param> protected override void DoWork(CodeActivityContext context) { //Get parameter values bool markReviewed = MarkReviewed.Expression != null?MarkReviewed.Get(context) : false; Guid obdGuid = ObdGuid.Get(context); var parms = new UddWidgetParams { MarkReviewed = markReviewed, UddDataParams = { PatId1 = PatientId.Get(context) }, TabViewObdGuid = obdGuid, Mode = UddWidgetMode.Insert, IsFlowsheetDisplay = true }; var view = ObsDef.GetEntityByObdGuid(obdGuid, PM); var securityEnum = SecurityUtility.ByteArrayToEnum(view.Security_Mask); bool returnResult = ReturnResult.Get(context); if (!returnResult) { // open an instance of the UDD with a distinct instanceid from the standard UDD indstance id var host = new UddWidgetModalHost(parms, securityEnum, null, Strings.FlowsheetFormActivity_UddInstanceId); // Defect 6398 - Clicking OK in error window cause Mosaiq crashed when trigger IQ script (create assessment by QCL task) // if user doesn't have modify rights in Assessment/Labs/Vital signs // Defect 7055: Replace IsHandleCreated with !IsDisposed because the window's handle is never created at this point if (!host.IsDisposed) { var modalDialog = ModalDialog.Get(context); if (modalDialog) { host.ShowDialog(); } else { host.Show(); host.ForceToFront(); } } return; } DialogResult res = UddWidgetModalHost.ShowModal(parms, securityEnum, Strings.FlowsheetFormActivity_UddInstanceId); if (res == System.Windows.Forms.DialogResult.OK) { ObrId.Set(context, parms.UddDataParams.ObrId); } //Record output parameters DialogResult.Set(context, res); }
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; } } }
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); } }
private void buttonEdit1_ButtonClick(object sender, ButtonPressedEventArgs e) { IQDataItemThresholdVarConfig.MinimizeIqEditor(this); int obdId = CallClarion.GetObsDefDataItem(0); IQDataItemThresholdVarConfig.RestoreIqEditor(this); if (obdId == 0) { return; } ObsDef obd = ObsDef.GetEntityById(obdId); PopulateChildControls(obd); }
/// <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); }
private string GetDisplayString() { if (Element.Value.ObdGuid == Guid.Empty) { return(String.Empty); } try { var obd = ObsDef.GetEntityByObdGuid(Element.Value.ObdGuid); if (obd.IsNullEntity) { return(String.Empty); } string str = String.Empty; var value = Element.Value; if (obd.Type == (short)MedDefs.ObdType.ItemTable) { if (value.TableItems != null) { var sb = new StringBuilder(); foreach (var item in value.TableItems) { var obdItem = ObsDef.GetEntityByObdGuid(item); sb.AppendFormat("{0}; ", obdItem.LabelDescriptionInactiveIndicator.Trim()); } str = sb.ToString().Trim().TrimEnd(';'); } } else { switch (obd.ObsDefDataFormat) { case ObsDefDataFormat.Numeric: str = FormatNumericThresholds(value); break; case ObsDefDataFormat.Date: if (value.DateRange.Type == InputDateRangeControlType.SpecificDates) { bool startDateValid = value.StartDate.HasValue && value.StartDate.Value > DateTime.MinValue; bool endDateValid = value.EndDate.HasValue && value.EndDate.Value < DateTime.MaxValue; if (startDateValid && endDateValid) { str = String.Format("{0} - {1}", value.StartDate.Value.ToShortDateString(), value.EndDate.Value.ToShortDateString()); } else if (startDateValid) { str = String.Format(">= {0}", value.StartDate.Value.ToShortDateString()); } else if (endDateValid) { str = String.Format("<= {0}", value.EndDate.Value.ToShortDateString()); } } else { str = Element.Value.DateRange.ToReadableString(); } break; case ObsDefDataFormat.String: case ObsDefDataFormat.Memo: if (DataItemThresholdsSelector.UseStringNumericLimits(Element.Value.StringAlgorithm)) { str = FormatNumericThresholds(value); } else { str = String.Format("{0} \"{1}\"", DataItemThresholdsSelector.StringAlgorithmIdToString(Element.Value.StringAlgorithm), Element.Value.StringInput); } break; } } if (String.IsNullOrEmpty(str)) { return(obd.LabelInactiveIndicator.Trim()); } return(String.Format("{0} ({1})", obd.LabelInactiveIndicator.Trim(), str)); } catch (Exception) { return(String.Empty); } }
/// <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)); } }
public static bool IsHeadingItemOrOtherLabs(ObsDef item) { return(IsHeadingItem(item.Type) || item.OBD_GUID == OtherLabsItemGuid); }
private void DataItemThresholdsSelector_Load(object sender, EventArgs e) { try { HideChildControls(); Height = 180; if (Value == null) { return; } ObsDef obd = ObsDef.GetEntityByObdGuid(Value.ObdGuid); PopulateChildControls(obd); if (obd.Type == (short)MedDefs.ObdType.ItemTable) { if (Value.TableItems != null) { foreach (CheckedListBoxItem item in comboTableItems.Properties.Items) { var obdGuid = (Guid)item.Value; if (Value.TableItems.Contains(obdGuid)) { item.CheckState = CheckState.Checked; } } } comboTableItems.RefreshEditValue(); } else if (obd.Type == (short)MedDefs.ObdType.ItemData) { switch (obd.ObsDefDataFormat) { case ObsDefDataFormat.Numeric: textLowerLimit.EditValue = Value.LowerLimit; textUpperLimit.EditValue = Value.UpperLimit; break; case ObsDefDataFormat.Date: inputDateRange.DateRange = new InputDateRangeValue(Value.DateRange.Type, Value.StartDate, Value.EndDate, Value.DateRange.SpinControlValue); break; case ObsDefDataFormat.String: case ObsDefDataFormat.Memo: int idx = 0; for (int i = 0; i < _stringAlgoriths.Length; i++) { if (_stringAlgoriths[i] == Value.StringAlgorithm) { idx = i; break; } } comboStringAlgorithm.SelectedIndex = idx; if (UseStringNumericLimits(Value.StringAlgorithm)) { textLowerLimit.EditValue = Value.LowerLimit; textUpperLimit.EditValue = Value.UpperLimit; } else { textStringInput.Text = Value.StringInput; } break; } } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("DataItemThresholdsSelector: " + ex); } }
private void CloseDialog() { ObsDef obd = null; if (buttonDataItem.Tag != null) { obd = buttonDataItem.Tag as ObsDef; } if (obd != null) { Value = new DataItemThresholds(); Value.ObdGuid = obd.OBD_GUID; if (obd.Type == (short)MedDefs.ObdType.ItemTable) { Value.TableItems = new List <Guid>(); foreach (CheckedListBoxItem item in comboTableItems.Properties.Items) { if (item.CheckState != CheckState.Checked) { continue; } var obdGuid = (Guid)item.Value; if (obdGuid != Guid.Empty) { Value.TableItems.Add(obdGuid); } } } else if (obd.Type == (short)MedDefs.ObdType.ItemData) { double d; switch (obd.ObsDefDataFormat) { case ObsDefDataFormat.Numeric: if (Double.TryParse(textLowerLimit.Text, out d)) { Value.LowerLimit = d; } if (Double.TryParse(textUpperLimit.Text, out d)) { Value.UpperLimit = d; } break; case ObsDefDataFormat.Date: Value.DateRange = inputDateRange.DateRange; Value.StartDate = inputDateRange.DateRange.StartDate; if (Value.StartDate == DateTime.MinValue) { Value.StartDate = null; } Value.EndDate = inputDateRange.DateRange.EndDate; if (Value.EndDate == DateTime.MaxValue) { Value.EndDate = null; } break; case ObsDefDataFormat.String: case ObsDefDataFormat.Memo: int algorithmId = comboStringAlgorithm.SelectedIndex >= 0 ? comboStringAlgorithm.SelectedIndex : 0; Value.StringAlgorithm = _stringAlgoriths[algorithmId]; if (UseStringNumericLimits(Value.StringAlgorithm)) { if (Double.TryParse(textLowerLimit.Text, out d)) { Value.LowerLimit = d; } if (Double.TryParse(textUpperLimit.Text, out d)) { Value.UpperLimit = d; } } else { Value.StringInput = textStringInput.Text; } break; } } } ValidateChildren(); DialogResult = DialogResult.OK; Close(); }
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(); } }