/// <summary> /// method /// saves a selection with the values from the data row passed in /// </summary> /// <param name="dr"></param> /// <param name="lItemComponentID"></param> /// <returns></returns> protected CStatus SaveSelection(DataRow dr, long lItemComponentID) { CICStateDataItem icsData = new CICStateDataItem(); icsData.ItemID = ItemID; icsData.ItemComponentID = lItemComponentID; icsData.ICStateID = Convert.ToInt64(dr["IC_STATE_ID"]); icsData.StateID = Convert.ToInt64(dr["STATE_ID"]); CItemComponentData icd = new CItemComponentData(BaseMstr.BaseData); CStatus status = null; if (icsData.ICStateID < 1) { long lICStateID = 0; status = icd.InsertICState(icsData, out lICStateID); if (!status.Status) { return(status); } dr["IC_STATE_ID"] = lICStateID; } else { status = icd.UpdateICState(icsData); if (!status.Status) { return(status); } } return(new CStatus()); }
/// <summary> /// override /// loads the control with the components of the item specified by /// the propery ItemID if the edit mode specified is update /// </summary> /// <param name="lEditMode"></param> /// <returns></returns> public override CStatus LoadControl(k_EDIT_MODE lEditMode) { EditMode = lEditMode; if (EditMode == k_EDIT_MODE.UPDATE) { CItemComponentData icd = new CItemComponentData(BaseMstr.BaseData); DataSet dsItemComponents = null; CStatus status = icd.GetItemComponentOJDS(ItemID, k_ACTIVE_ID.All, out dsItemComponents); if (!status.Status) { return(status); } ItemComponents = dsItemComponents.Tables[0]; SourceAndBind(); } else { ItemID = 0; InitializeDataTable(); SourceAndBind(); } return(new CStatus()); }
/// <summary> /// event /// US:902 /// loads the item PH and item component list boxes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void OnSelIndexChangedItem(object sender, EventArgs e) { ShowMPE(); lbItemPH.Items.Clear(); lbItemComponent.Items.Clear(); lbItemCompPH.Items.Clear(); lblItemCompPH.Visible = false; lbItemCompPH.Visible = false; CPlaceHolderData PHData = new CPlaceHolderData(BaseMstr.BaseData); DataSet dsItem = null; CStatus status = PHData.GetPlaceHolderChildDS(k_ITEM, out dsItem); if (!status.Status) { ShowStatusInfo(status); return; } if (dsItem.Tables[0].Rows.Count > 0) { lbItemPH.DataTextField = "PLACE_HOLDER_LABEL"; lbItemPH.DataValueField = "PLACE_HOLDER_ID"; lbItemPH.DataSource = dsItem; lbItemPH.DataBind(); lblItemPH.Visible = true; lbItemPH.Visible = true; } else { lblItemPH.Visible = false; lbItemPH.Visible = false; } CItemComponentData ICData = new CItemComponentData(BaseMstr.BaseData); DataSet dsItemComp = null; status = ICData.GetItemComponentDS(Convert.ToInt64(lbItem.SelectedValue), k_ACTIVE_ID.Active, out dsItemComp); if (!status.Status) { ShowStatusInfo(status); return; } if (dsItemComp.Tables[0].Rows.Count > 0) { lbItemComponent.DataTextField = "ITEM_COMPONENT_LABEL"; lbItemComponent.DataValueField = "ITEM_COMPONENT_ID"; lbItemComponent.DataSource = dsItemComp; lbItemComponent.DataBind(); lblItemComponent.Visible = true; lbItemComponent.Visible = true; } else { lblItemComponent.Visible = false; lbItemComponent.Visible = false; } }
/// <summary> /// US:1945 US:1883 /// method /// deletes all the component/collection records that are not supported by the item's type /// </summary> /// <param name="lItemID"></param> /// <param name="lItemTypeID"></param> /// <param name="strItemComponentIDs"></param> /// <param name="strItemIDs"></param> /// <returns></returns> public CStatus DeleteChildren(long lItemID, long lItemTypeID, string strItemComponentIDs, string strItemIDs) { CItemComponentData ic = new CItemComponentData(this); CItemCollectionData itemCollection = new CItemCollectionData(this); CStatus status = null; switch (lItemTypeID) { case (long)k_ITEM_TYPE_ID.Laboratory: status = ic.DeleteItemComponentStates(lItemID, string.Empty); if (!status.Status) { return(status); } break; case (long)k_ITEM_TYPE_ID.QuestionSelection: status = ic.DeleteItemComponentRanges(lItemID, string.Empty); if (!status.Status) { return(status); } break; case (long)k_ITEM_TYPE_ID.QuestionFreeText: case (long)k_ITEM_TYPE_ID.NoteTitle: case (long)k_ITEM_TYPE_ID.Collection: status = ic.DeleteItemComponentRanges(lItemID, string.Empty); if (!status.Status) { return(status); } status = ic.DeleteItemComponentStates(lItemID, string.Empty); if (!status.Status) { return(status); } break; default: return(new CStatus(false, k_STATUS_CODE.Failed, "TODO")); } status = itemCollection.DeleteItemCollection(lItemID, strItemIDs); if (!status.Status) { return(status); } status = ic.DeleteItemComponents(lItemID, strItemComponentIDs); if (!status.Status) { return(status); } return(new CStatus()); }
public override CStatus LoadControl(k_EDIT_MODE lEditMode) { Title = "Item History"; CItemData id = new CItemData(BaseMstr.BaseData); CItemDataItem diItem = null; CStatus status = id.GetItemDI(ItemID, out diItem); if (!status.Status) { return(status); } hItem.InnerText = diItem.ItemLabel; CPatientItemData pid = new CPatientItemData(BaseMstr.BaseData); DataSet dsPIC = null; status = pid.GetPatItemCompDS(PatientID, ItemID, out dsPIC); if (!status.Status) { return(status); } PatientItemComponents = dsPIC.Tables[0]; CItemComponentData icd = new CItemComponentData(BaseMstr.BaseData); DataSet dsIC = null; status = icd.GetItemComponentOJDS(ItemID, k_ACTIVE_ID.Active, out dsIC); if (!status.Status) { return(status); } ItemComponents = dsIC.Tables[0]; if (ItemComponents.Rows.Count > 1) { pnlComponents.Visible = true; rblComponents.DataSource = ItemComponents; rblComponents.DataBind(); DataRow rdItemComponent = ItemComponents.Rows[0]; rblComponents.SelectedValue = rdItemComponent["item_component_id"].ToString(); GraphItemComponent(rdItemComponent); } else { pnlComponents.Visible = false; GraphItemComponent(ItemComponents.Rows[0]); } return(new CStatus()); }
/// <summary> /// method /// US:902 /// parses a triple specified place holder /// </summary> /// <param name="lSpecifierOne"></param> /// <param name="strSpecifierTwo"></param> /// <param name="strSpecifierThree"></param> /// <returns></returns> private CStringStatus ParseTripleSpecified(long lSpecifierOne, string strSpecifierTwo, string strSpecifierThree) { switch (strSpecifierTwo) { case "temporalstate": case "outcomestate": case "decisionstate": return(ParsePatCLI(PatCLID, lSpecifierOne, strSpecifierTwo + CExpression.SpecifierTkn + strSpecifierThree)); case "summarystate": return(ParsePICSummaryState(PatientID, lSpecifierOne, strSpecifierTwo + CExpression.SpecifierTkn + strSpecifierThree)); } CItemComponentData ItemComponent = new CItemComponentData(BaseData); CItemComponentDataItem di = null; CStatus status = ItemComponent.GetItemComponentDI(lSpecifierOne, strSpecifierTwo, out di); if (!status.Status) { return(new CStringStatus(false, k_STATUS_CODE.Failed, LogicModuleMessages.ERROR_PARSE + lSpecifierOne.ToString() + CExpression.SpecifierTkn + strSpecifierTwo + CExpression.SpecifierTkn + strSpecifierThree, CExpression.NullTkn)); } switch (strSpecifierThree) { case "value": return(ParsePatItemComp(PatientID, lSpecifierOne, di.ItemComponentID, strSpecifierThree)); case "legalmin": case "criticallow": case "low": case "high": case "criticalhigh": case "legalmax": return(ParseItemCompRange(lSpecifierOne, di.ItemComponentID, strSpecifierThree)); case "state": return(ParseItemCompState(lSpecifierOne, di.ItemComponentID, strSpecifierThree)); default: return(new CStringStatus(false, k_STATUS_CODE.Failed, LogicModuleMessages.ERROR_PARSE + lSpecifierOne.ToString() + CExpression.SpecifierTkn + di.ItemComponentID.ToString() + CExpression.SpecifierTkn + strSpecifierThree, CExpression.NullTkn)); } }
/// <summary> /// method /// US:902 /// returns the attribute specified by the specifier for the item component range for /// the item component range specified by the item id and item component id /// </summary> /// <param name="lItemID"></param> /// <param name="lItemComponentID"></param> /// <param name="strSpecifier"></param> /// <returns></returns> private CStringStatus ParseItemCompRange(long lItemID, long lItemComponentID, string strSpecifier) { CItemComponentData ItemComp = new CItemComponentData(BaseData); CICRangeDataItem di = null; CStatus status = ItemComp.GetICRangeDI(lItemID, lItemComponentID, out di); if (!status.Status) { return(new CStringStatus(status, CExpression.NullTkn)); } string strValue = CExpression.NullTkn; switch (strSpecifier) { case "legalmin": strValue = (di.LegalMin < 0) ? CExpression.NullTkn : di.LegalMin.ToString(); break; case "criticallow": strValue = (di.CriticalLow < 0) ? CExpression.NullTkn : di.CriticalLow.ToString(); break; case "low": strValue = (di.Low < 0) ? CExpression.NullTkn : di.Low.ToString(); break; case "high": strValue = (di.High < 0) ? CExpression.NullTkn : di.High.ToString(); break; case "criticalhigh": strValue = (di.CriticalHigh < 0) ? CExpression.NullTkn : di.CriticalHigh.ToString(); break; case "legalmax": strValue = (di.LegalMax < 0) ? CExpression.NullTkn : di.LegalMax.ToString(); break; } return(new CStringStatus(status, strValue)); }
protected CStatus LoadComponents() { //get the item components DataSet dsComponents = null; CItemComponentData icd = new CItemComponentData(BaseMstr.BaseData); CStatus status = icd.GetItemComponentOJDS( ItemID, k_ACTIVE_ID.Active, out dsComponents); if (!status.Status) { return(status); } gvComponents.DataSource = dsComponents; gvComponents.DataBind(); return(new CStatus()); }
/// <summary> /// method /// saves a range with the values from the data row passed in /// </summary> /// <param name="gvr"></param> /// <param name="lItemComponentID"></param> /// <returns></returns> protected CStatus SaveRange(DataRow dr, long lItemComponentID) { CICRangeDataItem icrData = new CICRangeDataItem(); icrData.ItemID = ItemID; icrData.ItemComponentID = lItemComponentID; icrData.ICRangeID = Convert.ToInt64(dr["IC_RANGE_ID"]); icrData.Units = dr["UNITS"].ToString(); icrData.LegalMin = Convert.ToDouble(dr["LEGAL_MIN"]); icrData.CriticalLow = Convert.ToDouble(dr["CRITICAL_LOW"]); icrData.Low = Convert.ToDouble(dr["LOW"]); icrData.High = Convert.ToDouble(dr["HIGH"]); icrData.CriticalHigh = Convert.ToDouble(dr["CRITICAL_HIGH"]); icrData.LegalMax = Convert.ToDouble(dr["LEGAL_MAX"]); CItemComponentData icd = new CItemComponentData(BaseMstr.BaseData); CStatus status = null; if (icrData.ICRangeID < 1) { long lICRangeID = 0; status = icd.InsertICRange(icrData, out lICRangeID); if (!status.Status) { return(status); } dr["IC_RANGE_ID"] = lICRangeID; } else { status = icd.UpdateICRange(icrData); if (!status.Status) { return(status); } } return(new CStatus()); }
/// <summary> /// method /// US:902 /// returns the attribute specified by the specifier for the item component state /// for the item component state specified by the item id and item component id /// </summary> /// <param name="lItemID"></param> /// <param name="lItemComponentID"></param> /// <param name="strSpecifier"></param> /// <returns></returns> private CStringStatus ParseItemCompState(long lItemID, long lItemComponentID, string strSpecifier) { CItemComponentData ItemComp = new CItemComponentData(BaseData); CICStateDataItem di = null; CStatus status = ItemComp.GetICStateDI(lItemID, lItemComponentID, out di); if (!status.Status) { return(new CStringStatus(status, CExpression.NullTkn)); } string strValue = CExpression.NullTkn; switch (strSpecifier) { case "state": strValue = (di.StateID < 1) ? CExpression.NullTkn : di.StateID.ToString(); break; } return(new CStringStatus(status, strValue)); }
/// <summary> /// method /// saves a component with the values of the data row passed in /// </summary> /// <param name="dr"></param> /// <param name="lItemComponentID"></param> /// <returns></returns> protected CStatus SaveComponent(DataRow dr, out long lItemComponentID) { lItemComponentID = 0; CItemComponentDataItem icData = new CItemComponentDataItem(); icData.ItemID = ItemID; icData.ItemComponentID = Convert.ToInt64(dr["ITEM_COMPONENT_ID"]); icData.ItemComponentLabel = dr["ITEM_COMPONENT_LABEL"].ToString(); icData.SortOrder = Convert.ToInt64(dr["SORT_ORDER"]); icData.ActiveID = (k_ACTIVE_ID)Convert.ToInt64(dr["ACTIVE_ID"]); CItemComponentData icd = new CItemComponentData(BaseMstr.BaseData); CStatus status = new CStatus(); if (icData.ItemComponentID < 1) { status = icd.InsertItemComponent(icData, out lItemComponentID); if (!status.Status) { return(status); } dr["ITEM_COMPONENT_ID"] = lItemComponentID; } else { status = icd.UpdateItemComponent(icData); if (!status.Status) { return(status); } lItemComponentID = icData.ItemComponentID; } return(status); }
/// <summary> /// gets the item state id /// </summary> /// <param name="lCollItemID"></param> /// <param name="patItemDI"></param> /// <returns></returns> protected k_STATE_ID GetItemStateID(long lCollectionItemID, long lItemID, DataSet dsPatItemComps, CPatientItemDataItem patItemDI) { k_STATE_ID kStateID = k_STATE_ID.Unknown; k_STATE_ID kOverallTSStateID = k_STATE_ID.NotSelected; k_STATE_ID kOverallOSStateID = k_STATE_ID.NotSelected; //get the entry date DateTime dtEntryDate = patItemDI.EntryDate; //get the checklist collection item di CChecklistItemDataItem cidDI = null; CChecklistItemData cid = new CChecklistItemData(BaseMstr.BaseData); cid.GetCLItemDI(ChecklistID, lCollectionItemID, out cidDI); //calculate how far the TS can go back long lTS = cidDI.CLITSTimePeriod; DateTime dtNow = DateTime.Now; DateTime dtTSCompare = dtNow.AddDays(-1 * lTS); //check the TS and set overall TS state k_COMPARE kTS = CDataUtils.CompareDates(dtEntryDate, dtTSCompare); if (kTS == k_COMPARE.GREATERTHAN || kTS == k_COMPARE.EQUALTO) { kOverallTSStateID = k_STATE_ID.Good; } else { //bad kOverallTSStateID = k_STATE_ID.Bad; } //list to hold the created component items CPatientItemCompList PatItemCompList = new CPatientItemCompList(); //build a pat item component list loaded with the most recent //values foreach (DataTable tableComp in dsPatItemComps.Tables) { foreach (DataRow drComp in tableComp.Rows) { //values to load the component item long lCompItemID = CDataUtils.GetDSLongValue(drComp, "ITEM_ID"); long lComponentID = CDataUtils.GetDSLongValue(drComp, "ITEM_COMPONENT_ID"); string strComponentValue = CDataUtils.GetDSStringValue(drComp, "COMPONENT_VALUE"); long lPatItemID = CDataUtils.GetDSLongValue(drComp, "PAT_ITEM_ID"); //only this item if (lCompItemID == lItemID) { CPatientItemComponentDataItem diComp = new CPatientItemComponentDataItem(); diComp.PatientID = PatientID; diComp.ItemID = lCompItemID; diComp.ComponentID = lComponentID; diComp.ComponentValue = strComponentValue; diComp.PatItemID = lPatItemID; PatItemCompList.Add(diComp); } } } //we now have a list of item components for this item //loop and get status for this item and update the overall status bool bHasSelectedValue = false; foreach (CPatientItemComponentDataItem diPatItemComp in PatItemCompList) { //get the state id for this component CICStateDataItem sdi = null; CItemComponentData icd = new CItemComponentData(BaseMstr.BaseData); icd.GetICStateDI(lItemID, diPatItemComp.ComponentID, out sdi); //switch on the type and get the value switch ((k_ITEM_TYPE_ID)patItemDI.ItemTypeID) { case k_ITEM_TYPE_ID.Laboratory: { bHasSelectedValue = true; //get the ranges CICRangeDataItem rdi = null; icd.GetICRangeDI(lItemID, diPatItemComp.ComponentID, out rdi); if (String.IsNullOrEmpty(diPatItemComp.ComponentValue)) { //does not have a value? kOverallOSStateID = k_STATE_ID.Unknown; } else { try { double dblValue = Convert.ToDouble(diPatItemComp.ComponentValue); //max/high check if (dblValue >= rdi.LegalMax) { if (kOverallOSStateID != k_STATE_ID.Bad) { kOverallOSStateID = k_STATE_ID.Unknown; } } else { if (dblValue >= rdi.High) { kOverallOSStateID = k_STATE_ID.Bad; } else { if (kOverallOSStateID != k_STATE_ID.Bad) { kOverallOSStateID = k_STATE_ID.Good; } } } //min/low check if (dblValue <= rdi.LegalMin) { if (kOverallOSStateID != k_STATE_ID.Bad) { kOverallOSStateID = k_STATE_ID.Unknown; } } else { if (dblValue <= rdi.Low) { kOverallOSStateID = k_STATE_ID.Bad; } else { if (kOverallOSStateID != k_STATE_ID.Bad) { kOverallOSStateID = k_STATE_ID.Good; } } } } catch (Exception e) { if (kOverallOSStateID != k_STATE_ID.Bad) { kOverallOSStateID = k_STATE_ID.Unknown; } } } break; } case k_ITEM_TYPE_ID.NoteTitle: { //note titles are excluded from quick entry //and do not affect default logic. must use custom logic //for note titles bHasSelectedValue = true; kOverallOSStateID = k_STATE_ID.Unknown; break; } case k_ITEM_TYPE_ID.QuestionFreeText: { bHasSelectedValue = true; if (diPatItemComp.ComponentValue.Length < 1) { //if they did not enter a value //then the overall state is bad! kOverallOSStateID = k_STATE_ID.Bad; } else { kOverallOSStateID = k_STATE_ID.Good; } break; } case k_ITEM_TYPE_ID.QuestionSelection: if (!String.IsNullOrEmpty(diPatItemComp.ComponentValue)) { //only interested in the one they selected if ((k_TRUE_FALSE_ID)Convert.ToInt64(diPatItemComp.ComponentValue) != k_TRUE_FALSE_ID.False) { bHasSelectedValue = true; if (kOverallOSStateID != k_STATE_ID.Bad) { if ((k_STATE_ID)sdi.StateID == k_STATE_ID.Bad) { kOverallOSStateID = k_STATE_ID.Bad; } else { if ((k_STATE_ID)sdi.StateID == k_STATE_ID.Good) { if (kOverallOSStateID != k_STATE_ID.Unknown) { kOverallOSStateID = k_STATE_ID.Good; } } else { kOverallOSStateID = k_STATE_ID.Unknown; } } } } } break; } }//for each //if there is nothing selected then the overall os state is unk //and ts state is bad! if (!bHasSelectedValue) { kOverallOSStateID = k_STATE_ID.Unknown; kOverallTSStateID = k_STATE_ID.Bad; } if (kOverallTSStateID == k_STATE_ID.Bad || kOverallOSStateID == k_STATE_ID.Bad) { kStateID = k_STATE_ID.Bad; } else if (kOverallTSStateID == k_STATE_ID.Good && kOverallOSStateID == k_STATE_ID.Good) { kStateID = k_STATE_ID.Good; } else { kStateID = k_STATE_ID.Unknown; } return(kStateID); }
/// <summary> /// method to run logic over a colletion /// 1. all items in multi select must be have an option selected /// 2. all free text items must have data entered /// 3. labs and note titles are ignored /// 4. items that are not ACTIVE are ignored /// </summary> public CStatus RunCollectionLogic(string strPatientID, long lPatChecklistID, long lChecklistID, long lCollectionItemID) { //Get the patient checklist item data CPatChecklistItemData PatChecklistItem = new CPatChecklistItemData(this); CPatChecklistItemDataItem pdi = null; PatChecklistItem.GetPatCLItemDI(lPatChecklistID, lCollectionItemID, out pdi); //get all the items in the collection CItemCollectionData coll = new CItemCollectionData(this); DataSet dsColl = null; CStatus status = coll.GetItemCollectionDS(lCollectionItemID, out dsColl); //get all the patient item components in the collection DataSet dsPatItemComps = null; status = coll.GetItemColMostRecentPatICDS(lCollectionItemID, strPatientID, out dsPatItemComps); //if this collection item is overridden just return and don't update the state if (pdi.IsOverridden == k_TRUE_FALSE_ID.True) { bool bReturn = true; //check to see if there is a new result and override if there is... foreach (DataTable tableI in dsColl.Tables) { foreach (DataRow drI in tableI.Rows) { //get values from the the item in the collection (not the patient items, the collection items) long lItemID = CDataUtils.GetDSLongValue(drI, "ITEM_ID"); long lItemTypeID = CDataUtils.GetDSLongValue(drI, "ITEM_TYPE_ID"); long lActiveID = CDataUtils.GetDSLongValue(drI, "ACTIVE_ID"); //get the item so we can check entry date against TS etc... CPatientItemDataItem patItemDI = null; CPatientItemData patData = new CPatientItemData(this); patData.GetMostRecentPatientItemDI(strPatientID, lItemID, out patItemDI); DateTime dtEntryDate = patItemDI.EntryDate; if (dtEntryDate > pdi.OverrideDate) { pdi.OverrideDate = CDataUtils.GetNullDate(); pdi.IsOverridden = k_TRUE_FALSE_ID.False; PatChecklistItem.UpdatePatChecklistItem(pdi); bReturn = false; break; } } } if (bReturn) { //return if this item is overridden and there are no new results return(new CStatus()); } } //get the checklist item di CChecklistItemDataItem cidDI = null; CChecklistItemData cid = new CChecklistItemData(this); cid.GetCLItemDI(lChecklistID, lCollectionItemID, out cidDI); //calculate how far the TS can go back long lTS = cidDI.CLITSTimePeriod; DateTime dtNow = DateTime.Now; DateTime dtTSCompare = dtNow.AddDays(-1 * lTS); //keeps the overall OS state of the items k_STATE_ID kOverallOSStateID = k_STATE_ID.NotSelected; //keeps the overall TS state of the items k_STATE_ID kOverallTSStateID = k_STATE_ID.NotSelected; //loop over the collection items foreach (DataTable table in dsColl.Tables) { foreach (DataRow dr in table.Rows) { //get values from the the item in the collection (not the patient items, the collection items) long lItemID = CDataUtils.GetDSLongValue(dr, "ITEM_ID"); long lItemTypeID = CDataUtils.GetDSLongValue(dr, "ITEM_TYPE_ID"); long lActiveID = CDataUtils.GetDSLongValue(dr, "ACTIVE_ID"); //get the item so we can check entry date against TS etc... CPatientItemDataItem patItemDI = null; CPatientItemData patData = new CPatientItemData(this); patData.GetMostRecentPatientItemDI(strPatientID, lItemID, out patItemDI); DateTime dtEntryDate = patItemDI.EntryDate; //only interested in ACTIVE items if ((k_ACTIVE)lActiveID == k_ACTIVE.ACTIVE) { //check the TS and set overall TS state k_COMPARE kTS = CDataUtils.CompareDates(dtEntryDate, dtTSCompare); if (kTS == k_COMPARE.GREATERTHAN || kTS == k_COMPARE.EQUALTO) { //good if (kOverallTSStateID != k_STATE_ID.Bad) { kOverallTSStateID = k_STATE_ID.Good; } } else { //bad kOverallTSStateID = k_STATE_ID.Bad; } //list to hold the created component items CPatientItemCompList PatItemCompList = new CPatientItemCompList(); //build a pat item component list loaded with the most recent //values foreach (DataTable tableComp in dsPatItemComps.Tables) { foreach (DataRow drComp in tableComp.Rows) { //values to load the component item long lCompItemID = CDataUtils.GetDSLongValue(drComp, "ITEM_ID"); long lComponentID = CDataUtils.GetDSLongValue(drComp, "ITEM_COMPONENT_ID"); string strComponentValue = CDataUtils.GetDSStringValue(drComp, "COMPONENT_VALUE"); long lPatItemID = CDataUtils.GetDSLongValue(drComp, "PAT_ITEM_ID"); //only this item if (lCompItemID == lItemID) { CPatientItemComponentDataItem diComp = new CPatientItemComponentDataItem(); diComp.PatientID = strPatientID; diComp.ItemID = lCompItemID; diComp.ComponentID = lComponentID; diComp.ComponentValue = strComponentValue; diComp.PatItemID = lPatItemID; PatItemCompList.Add(diComp); } } //we now have a list of item components for this item //loop and get status for this item and update the overall status bool bHasSelectedValue = false; foreach (CPatientItemComponentDataItem diPatItemComp in PatItemCompList) { //get the state id for this component CICStateDataItem sdi = null; CItemComponentData icd = new CItemComponentData(this); icd.GetICStateDI(lItemID, diPatItemComp.ComponentID, out sdi); //switch on the type and get the value switch ((k_ITEM_TYPE_ID)lItemTypeID) { case k_ITEM_TYPE_ID.Laboratory: { bHasSelectedValue = true; //get the ranges CICRangeDataItem rdi = null; icd.GetICRangeDI(lItemID, diPatItemComp.ComponentID, out rdi); if (String.IsNullOrEmpty(diPatItemComp.ComponentValue)) { //does not have a value? kOverallOSStateID = k_STATE_ID.Unknown; } else { try { double dblValue = Convert.ToDouble(diPatItemComp.ComponentValue); //max/high check if (dblValue >= rdi.LegalMax) { if (kOverallOSStateID != k_STATE_ID.Bad) { kOverallOSStateID = k_STATE_ID.Unknown; } } else { if (dblValue >= rdi.High) { kOverallOSStateID = k_STATE_ID.Bad; } else { if (kOverallOSStateID != k_STATE_ID.Bad) { kOverallOSStateID = k_STATE_ID.Good; } } } //min/low check if (dblValue <= rdi.LegalMin) { if (kOverallOSStateID != k_STATE_ID.Bad) { kOverallOSStateID = k_STATE_ID.Unknown; } } else { if (dblValue <= rdi.Low) { kOverallOSStateID = k_STATE_ID.Bad; } else { if (kOverallOSStateID != k_STATE_ID.Bad) { kOverallOSStateID = k_STATE_ID.Good; } } } } catch (Exception e) { if (kOverallOSStateID != k_STATE_ID.Bad) { kOverallOSStateID = k_STATE_ID.Unknown; } } } break; } case k_ITEM_TYPE_ID.NoteTitle: { //note titles are excluded from quick entry //so if we have one our os state is unknown bHasSelectedValue = true; kOverallOSStateID = k_STATE_ID.Unknown; break; } case k_ITEM_TYPE_ID.QuestionFreeText: { bHasSelectedValue = true; if (diPatItemComp.ComponentValue.Length < 1) { //if they did not enter a value //then the overall state is bad! kOverallOSStateID = k_STATE_ID.Bad; } break; } case k_ITEM_TYPE_ID.QuestionSelection: if (!String.IsNullOrEmpty(diPatItemComp.ComponentValue)) { //only interested in the one they selected if ((k_TRUE_FALSE_ID)Convert.ToInt64(diPatItemComp.ComponentValue) != k_TRUE_FALSE_ID.False) { bHasSelectedValue = true; if (kOverallOSStateID != k_STATE_ID.Bad) { if ((k_STATE_ID)sdi.StateID == k_STATE_ID.Bad) { kOverallOSStateID = k_STATE_ID.Bad; } else { if ((k_STATE_ID)sdi.StateID == k_STATE_ID.Good) { if (kOverallOSStateID != k_STATE_ID.Unknown) { kOverallOSStateID = k_STATE_ID.Good; } } else { kOverallOSStateID = k_STATE_ID.Unknown; } } } } } break; } }//for each //if there is nothing selected then the //overall TS state is bad and the OS state is unknown if (!bHasSelectedValue) { kOverallOSStateID = k_STATE_ID.Unknown; kOverallTSStateID = k_STATE_ID.Bad; } } } } } // //now update the collection item states. // //get the ts,os and ds possible values CChecklistItemData dCL = new CChecklistItemData(this); DataSet dsTS = null; dCL.GetTemporalStateDS(lChecklistID, lCollectionItemID, out dsTS); long lGoodTSID = dCL.GetTSDefaultStateID(dsTS, k_STATE_ID.Good); long lBadTSID = dCL.GetTSDefaultStateID(dsTS, k_STATE_ID.Bad); long lUnknownTSID = dCL.GetTSDefaultStateID(dsTS, k_STATE_ID.Unknown); DataSet dsOS = null; dCL.GetOutcomeStateDS(lChecklistID, lCollectionItemID, out dsOS); long lGoodOSID = dCL.GetOSDefaultStateID(dsOS, k_STATE_ID.Good); long lBadOSID = dCL.GetOSDefaultStateID(dsOS, k_STATE_ID.Bad); long lUnknownOSID = dCL.GetOSDefaultStateID(dsOS, k_STATE_ID.Unknown); DataSet dsDS = null; dCL.GetDecisionStateDS(lChecklistID, lCollectionItemID, out dsDS); long lGoodDSID = dCL.GetDSDefaultStateID(dsDS, k_STATE_ID.Good); long lBadDSID = dCL.GetDSDefaultStateID(dsDS, k_STATE_ID.Bad); long lUnknownDSID = dCL.GetDSDefaultStateID(dsDS, k_STATE_ID.Unknown); //update the TS state on the data item if (kOverallTSStateID == k_STATE_ID.Bad) { pdi.TSID = lBadTSID; } else if (kOverallTSStateID == k_STATE_ID.Good) { pdi.TSID = lGoodTSID; } else { pdi.TSID = lUnknownTSID; } //update the OS state on the data item if (kOverallOSStateID == k_STATE_ID.Bad) { pdi.OSID = lBadOSID; } else if (kOverallOSStateID == k_STATE_ID.Good) { pdi.OSID = lGoodOSID; } else { pdi.OSID = lUnknownOSID; } //update the ds state on the item data if (kOverallTSStateID == k_STATE_ID.Good && kOverallOSStateID == k_STATE_ID.Good) { pdi.DSID = lGoodDSID; } else { pdi.DSID = lBadDSID; } //update the checklist item state status = PatChecklistItem.UpdatePatChecklistItem(pdi); return(status); }