/// <summary>
    /// method
    /// US:874 US:902
    /// gets the syntax for the static place holder
    /// </summary>
    /// <returns></returns>
    protected string GetStaticSyntax()
    {
        if (lbStaticSpecifier.SelectedIndex < 0)
        {
            return(string.Empty);
        }

        string               strSyntax = string.Empty;
        CPlaceHolderData     PHData    = new CPlaceHolderData(BaseMstr.BaseData);
        CPlaceHolderDataItem di        = null;
        CStatus              status    = PHData.GetPlaceHolderDI(Convert.ToInt64(lbStatic.SelectedValue), out di);

        if (di == null)
        {
            return(string.Empty);
        }
        strSyntax = di.PlaceHolderSyntax;

        status = PHData.GetPlaceHolderDI(Convert.ToInt64(lbStaticSpecifier.SelectedValue), out di);
        if (di == null)
        {
            return(string.Empty);
        }
        strSyntax += CExpression.SpecifierTkn + di.PlaceHolderSyntax;
        return(CExpression.BeginPHTkn + strSyntax + CExpression.EndPHTkn);
    }
    /// <summary>
    /// method
    /// US:874 US:902
    /// gets the syntax for the item place holder
    /// </summary>
    /// <returns></returns>
    protected string GetItemSyntax()
    {
        CPlaceHolderData     PHData = new CPlaceHolderData(BaseMstr.BaseData);
        CPlaceHolderDataItem di     = null;
        CStatus status    = new CStatus();
        string  strSyntax = string.Empty;

        if (lbItemPH.SelectedIndex >= 0 && lbItem.SelectedIndex >= 0)
        {
            status = PHData.GetPlaceHolderDI(Convert.ToInt64(lbItemPH.SelectedValue), out di);
            if (di == null)
            {
                return(string.Empty);
            }
            strSyntax = lbItem.SelectedItem.Text + CExpression.SpecifierTkn + di.PlaceHolderSyntax;
            strSyntax = CExpression.BeginPHTkn + strSyntax + CExpression.EndPHTkn;
        }
        else if (lbItemCompPH.SelectedIndex >= 0 &&
                 lbItemComponent.SelectedIndex >= 0 &&
                 lbItem.SelectedIndex >= 0)
        {
            status = PHData.GetPlaceHolderDI(Convert.ToInt64(lbItemCompPH.SelectedValue), out di);
            if (di == null)
            {
                return(string.Empty);
            }
            strSyntax = lbItem.SelectedItem.Text + CExpression.SpecifierTkn + lbItemComponent.SelectedItem.Text + CExpression.SpecifierTkn + di.PlaceHolderSyntax;
            strSyntax = CExpression.BeginPHTkn + strSyntax + CExpression.EndPHTkn;
        }
        return(strSyntax);
    }
    /// <summary>
    /// event
    /// US:902
    /// Loads the operator sub groups
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void OnSelIndexChangedOperator(object sender, EventArgs e)
    {
        ShowMPE();
        lbOperatorSubGroup.Items.Clear();

        CPlaceHolderData PHData = new CPlaceHolderData(BaseMstr.BaseData);
        DataSet          ds     = null;
        CStatus          status = PHData.GetPlaceHolderChildDS(Convert.ToInt64(lbOperator.SelectedValue), out ds);

        if (!status.Status)
        {
            ShowStatusInfo(status);
            return;
        }

        if (ds.Tables[0].Rows.Count > 0)
        {
            lbOperatorSubGroup.DataTextField  = "PLACE_HOLDER_LABEL";
            lbOperatorSubGroup.DataValueField = "PLACE_HOLDER_ID";
            lbOperatorSubGroup.DataSource     = ds;
            lbOperatorSubGroup.DataBind();
            lblOperatorSubGroup.Visible = true;
            lbOperatorSubGroup.Visible  = true;
        }
        else
        {
            lblOperatorSubGroup.Visible = false;
            lbOperatorSubGroup.Visible  = false;
        }
    }
    /// <summary>
    /// method
    /// US:874 US:902
    /// gets the syntax for the operator place holder
    /// </summary>
    /// <returns></returns>
    protected string GetOperatorSyntax()
    {
        CPlaceHolderData     PHData = new CPlaceHolderData(BaseMstr.BaseData);
        CPlaceHolderDataItem di     = null;
        string strSyntax            = string.Empty;

        if (lbOperatorSubGroup.SelectedIndex >= 0)
        {
            PHData.GetPlaceHolderDI(Convert.ToInt64(lbOperatorSubGroup.SelectedValue), out di);
            if (di == null)
            {
                return(string.Empty);
            }
            strSyntax = di.PlaceHolderSyntax;
        }
        else if (lbOperator.SelectedIndex >= 0 &&
                 Convert.ToInt32(lbOperator.SelectedValue) != k_BOOLEAN &&
                 Convert.ToInt32(lbOperator.SelectedValue) != k_ARITHMETIC)
        {
            PHData.GetPlaceHolderDI(Convert.ToInt64(lbOperator.SelectedValue), out di);
            if (di == null)
            {
                return(string.Empty);
            }
            strSyntax = di.PlaceHolderSyntax;
        }

        return(strSyntax);
    }
    /// <summary>
    /// method
    /// US:902
    /// loads the action view
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected CStatus LoadActionView()
    {
        lbAction.Items.Clear();
        lbActionSpecifier.Items.Clear();
        lbActionValue.Items.Clear();
        lblActionSpecifier.Visible = false;
        lbActionSpecifier.Visible  = false;
        lblActionValue.Visible     = false;
        lbActionValue.Visible      = false;

        CPlaceHolderData PHData = new CPlaceHolderData(BaseMstr.BaseData);
        DataSet          ds     = null;
        CStatus          status = PHData.GetPlaceHolderChildDS(Convert.ToInt64(rblLogic.SelectedValue), out ds);

        if (!status.Status)
        {
            return(status);
        }

        lbAction.DataTextField  = "PLACE_HOLDER_LABEL";
        lbAction.DataValueField = "PLACE_HOLDER_ID";
        lbAction.DataSource     = ds;
        lbAction.DataBind();
        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>
    /// method
    /// US:874 US:902
    /// gets the syntax for the action place holder
    /// </summary>
    /// <returns></returns>
    protected string GetActionSyntax()
    {
        CPlaceHolderData     PHData = new CPlaceHolderData(BaseMstr.BaseData);
        CPlaceHolderDataItem di     = null;
        string strSyntax            = string.Empty;

        if (lbActionValue.SelectedIndex >= 0 &&
            lbActionSpecifier.SelectedIndex >= 0 &&
            lbAction.SelectedIndex >= 0)
        {
            PHData.GetPlaceHolderDI(Convert.ToInt64(lbActionSpecifier.SelectedValue), out di);
            if (di == null)
            {
                return(string.Empty);
            }
            strSyntax = di.PlaceHolderSyntax;

            PHData.GetPlaceHolderDI(Convert.ToInt64(lbAction.SelectedValue), out di);
            if (di == null)
            {
                return(string.Empty);
            }
            strSyntax += CExpression.SpecifierTkn + di.PlaceHolderSyntax;
            strSyntax += CExpression.ParamStartTkn + lbActionValue.SelectedItem.Text + CExpression.ParamEndTkn;
        }
        else if (lbActionSpecifier.SelectedIndex >= 0 &&
                 Convert.ToInt32(lbActionSpecifier.SelectedValue) != k_TEMPORAL_STATE &&
                 Convert.ToInt32(lbActionSpecifier.SelectedValue) != k_OUTCOME_STATE &&
                 Convert.ToInt32(lbActionSpecifier.SelectedValue) != k_DECISION_STATE &&
                 lbAction.SelectedIndex >= 0)
        {
            PHData.GetPlaceHolderDI(Convert.ToInt64(lbActionSpecifier.SelectedValue), out di);
            if (di == null)
            {
                return(string.Empty);
            }
            strSyntax = di.PlaceHolderSyntax;

            PHData.GetPlaceHolderDI(Convert.ToInt64(lbAction.SelectedValue), out di);
            if (di == null)
            {
                return(string.Empty);
            }
            strSyntax += CExpression.SpecifierTkn + di.PlaceHolderSyntax + CExpression.ParamStartTkn + CExpression.ParamEndTkn;
        }
        return(strSyntax);
    }
    /// <summary>
    /// event
    /// US:902
    /// loads the action set list box
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void OnSelIndexChangedAction(object sender, EventArgs e)
    {
        ShowMPE();
        lbActionSpecifier.Items.Clear();
        lbActionValue.Items.Clear();
        lblActionValue.Visible = false;
        lbActionValue.Visible  = false;

        CPlaceHolderData PHData             = new CPlaceHolderData(BaseMstr.BaseData);
        DataSet          ds                 = null;
        long             lStatPlaceHolderID = Convert.ToInt64(lbAction.SelectedValue);
        CStatus          status             = PHData.GetPlaceHolderChildDS(lStatPlaceHolderID, out ds);

        if (!status.Status)
        {
            ShowStatusInfo(status);
            return;
        }

        if (ds.Tables[0].Rows.Count > 0)
        {
            lbActionSpecifier.DataTextField  = "PLACE_HOLDER_LABEL";
            lbActionSpecifier.DataValueField = "PLACE_HOLDER_ID";
            lbActionSpecifier.DataSource     = ds;
            lbActionSpecifier.DataBind();

            if (lStatPlaceHolderID == k_SET)
            {
                lblActionSpecifier.AccessKey = "S";
                lblActionSpecifier.Text      = "<span class=access_key>S</span>pecifier(s)";
            }
            else
            {
                lblActionSpecifier.AccessKey = "P";
                lblActionSpecifier.Text      = "Action <span class=access_key>P</span>lace Holder(s)";
            }

            lblActionSpecifier.Visible = true;
            lbActionSpecifier.Visible  = true;
        }
        else
        {
            lblActionSpecifier.Visible = false;
            lbActionSpecifier.Visible  = false;
        }
    }
    /// <summary>
    /// method
    /// US:902
    /// loads the logic categories into the radio button list
    /// </summary>
    /// <returns></returns>
    protected CStatus LoadLogicCategories()
    {
        CPlaceHolderData PHData = new CPlaceHolderData(BaseMstr.BaseData);
        DataSet          ds     = null;
        CStatus          status = PHData.GetPlaceHolderParentDS(out ds);

        if (!status.Status)
        {
            ShowStatusInfo(status);
            return(status);
        }

        rblLogic.DataTextField  = "PLACE_HOLDER_LABEL";
        rblLogic.DataValueField = "PLACE_HOLDER_ID";
        rblLogic.DataSource     = ds;
        rblLogic.DataBind();
        return(status);
    }
    /// <summary>
    /// method
    /// US:902
    /// loads the patient view
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected CStatus LoadPatientView()
    {
        lbPatient.Items.Clear();

        CPlaceHolderData PHData = new CPlaceHolderData(BaseMstr.BaseData);
        DataSet          ds     = null;
        CStatus          status = PHData.GetPlaceHolderChildDS(Convert.ToInt64(rblLogic.SelectedValue), out ds);

        if (!status.Status)
        {
            return(status);
        }

        lbPatient.DataTextField  = "PLACE_HOLDER_LABEL";
        lbPatient.DataValueField = "PLACE_HOLDER_ID";
        lbPatient.DataSource     = ds;
        lbPatient.DataBind();
        return(new CStatus());
    }
    /// <summary>
    /// event
    /// US:902
    /// loads the item component PH list box
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void OnSelIndexChangedItemComp(object sender, EventArgs e)
    {
        ShowMPE();
        lbItemPH.ClearSelection();
        lbItemCompPH.Items.Clear();

        // bind standard options
        CPlaceHolderData PHData = new CPlaceHolderData(BaseMstr.BaseData);
        DataSet          ds     = null;

        CStatus status = PHData.GetPlaceHolderChildDS(k_ITEM_COMPONENT, out ds);

        if (!status.Status)
        {
            ShowStatusInfo(status);
            return;
        }

        if (ds.Tables[0].Rows.Count > 0)
        {
            lbItemCompPH.DataTextField  = "PLACE_HOLDER_LABEL";
            lbItemCompPH.DataValueField = "PLACE_HOLDER_ID";
            lbItemCompPH.DataSource     = ds;
            lbItemCompPH.DataBind();
            lblItemCompPH.Visible = true;
            lbItemCompPH.Visible  = true;
        }
        else
        {
            lblItemCompPH.Visible = false;
            lbItemCompPH.Visible  = false;
        }

        // bind selection specific options
        CItemData     IData   = new CItemData(BaseMstr.BaseData);
        CItemDataItem di      = null;
        long          lItemID = Convert.ToInt64(lbItem.SelectedValue);

        status = IData.GetItemDI(lItemID, out di);
        if (!status.Status)
        {
            ShowStatusInfo(status);
            return;
        }

        if (di.ItemID != lItemID)
        {
            status.Status        = false;
            status.StatusCode    = k_STATUS_CODE.Failed;
            status.StatusComment = "TODO";
            ShowStatusInfo(status);
            return;
        }

        long lPlaceHolderID = -1;

        switch (di.ItemTypeID)
        {
        case (long)k_ITEM_TYPE_ID.Laboratory:
            lPlaceHolderID = k_IC_RANGE;
            break;

        case (long)k_ITEM_TYPE_ID.QuestionSelection:
            lPlaceHolderID = k_IC_STATE;
            break;

        case (long)k_ITEM_TYPE_ID.QuestionFreeText:
            // there are not any options specific to question free text
            return;
        }

        status = PHData.GetPlaceHolderChildDS(lPlaceHolderID, out ds);
        if (!status.Status)
        {
            ShowStatusInfo(status);
            return;
        }

        lbItemCompPH.DataSource = ds;
        lbItemCompPH.DataBind();
    }