Exemple #1
0
    /// <summary>
    /// method
    /// US:902
    /// returns the parsed expression if no errors were found
    /// </summary>
    /// <param name="strExp"></param>
    /// <returns></returns>
    public CStringStatus Parse(string strExp)
    {
        string strPlaceHolder = CExpression.GetNextPlaceHolder(strExp);

        while (!string.IsNullOrEmpty(strPlaceHolder))
        {
            strPlaceHolder = strPlaceHolder.TrimStart(CExpression.BeginPHTkn).TrimEnd(CExpression.EndPHTkn);
            CStringStatus status = ParsePlaceHolder(strPlaceHolder);
            if (!status.Status)
            {
                return(status);
            }

            strExp         = strExp.Replace(CExpression.BeginPHTkn + strPlaceHolder + CExpression.EndPHTkn, status.Value);
            strPlaceHolder = CExpression.GetNextPlaceHolder(strExp);
        }

        return(new CStringStatus(true, k_STATUS_CODE.Success, string.Empty, strExp));
    }
    /// <summary>
    /// method
    /// US:902
    /// executes the actions in the expression passed in
    /// </summary>
    /// <param name="strExp"></param>
    /// <returns></returns>
    public CStatus Execute(string strExp)
    {
        CParseExpression ParseExp = new CParseExpression(BaseData, PatientID, PatCLID, ChecklistID, ItemID);
        CStringStatus    ss       = ParseExp.ParseAction(strExp);

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

        switch (ss.Value)
        {
        case "checklist.cancel()":
            return(CancelChecklist(PatCLID));

        case "item.disable()":
            return(DisableChecklistItem(PatCLID, ItemID));

        default:
            return(ParseSpecifiedAction(ss.Value));
        }
    }
Exemple #3
0
    /// <summary>
    /// method
    /// US:902
    /// returns the parsed action if no errors were found
    /// </summary>
    /// <param name="strExp"></param>
    /// <returns></returns>
    public CStringStatus ParseAction(string strExp)
    {
        if (string.IsNullOrEmpty(strExp))
        {
            return(new CStringStatus(false, k_STATUS_CODE.Failed, "TODO", string.Empty));
        }

        int nParamStartIndex = strExp.IndexOf(CExpression.ParamStartTkn);
        int nParamEndIndex   = strExp.IndexOf(CExpression.ParamEndTkn);

        if (nParamStartIndex < 0 ||
            nParamEndIndex < 0 ||
            nParamEndIndex < nParamStartIndex)
        {
            return(new CStringStatus(true, k_STATUS_CODE.Success, string.Empty, strExp));
        }

        string        strParam = strExp.Substring(nParamStartIndex + 1, nParamEndIndex - nParamStartIndex - 1);
        CStringStatus status   = null;

        switch (strParam)
        {
        case "defaultunknownstate":
        case "defaultgoodstate":
        case "defaultbadstate":
            status = ParseStatic(strParam);
            break;

        default:
            status = ParseDynamicParam(strExp);
            break;
        }

        strExp = strExp.Replace(CExpression.ParamStartTkn + strParam + CExpression.ParamEndTkn,
                                CExpression.ParamStartTkn + status.Value + CExpression.ParamEndTkn);

        return(new CStringStatus(true, k_STATUS_CODE.Success, string.Empty, strExp));
    }
    /// <summary>
    /// method
    /// US:902
    /// evaluates all the expressions in the list
    /// </summary>
    /// <returns></returns>
    public CStatus Evaluate()
    {
        CParseExpression ParseExp = new CParseExpression(BaseData, PatientID, PatCLID, ChecklistID, ItemID);
        CStatus          status   = new CStatus();

        foreach (CExpression exp in this)
        {
            CStringStatus ss = ParseExp.Parse(exp.GetIf());
            if (!ss.Status)
            {
                status = ss;
                break;
            }

            if (ss.Value.IndexOf(CExpression.NullTkn) >= 0)
            {
                CPatChecklistItemData     PatChecklistItem = new CPatChecklistItemData(BaseData);
                CPatChecklistItemDataItem di = null;
                status = PatChecklistItem.GetPatCLItemDI(PatCLID, ItemID, out di);
                if (!status.Status)
                {
                    return(status);
                }

                di.TSID         = Convert.ToInt64(k_DEFAULT_STATE_ID.Bad);
                di.OSID         = Convert.ToInt64(k_DEFAULT_STATE_ID.Unknown);
                di.IsOverridden = k_TRUE_FALSE_ID.False;
                di.OverrideDate = CDataUtils.GetNullDate();
                di.DSID         = Convert.ToInt64(k_DEFAULT_STATE_ID.Bad);

                status = PatChecklistItem.UpdatePatChecklistItem(di);
                if (!status.Status)
                {
                    return(status);
                }

                continue;
            }

            int nResult = CLogic.Evaluate(ss.Value);
            CExecuteExpression ExecuteExp = new CExecuteExpression(
                BaseData,
                PatientID,
                PatCLID,
                ChecklistID,
                ItemID);
            switch (nResult)
            {
            // false
            case 0:
                string strElse = exp.GetElse();
                if (!string.IsNullOrEmpty(strElse))
                {
                    status = ExecuteExp.Execute(strElse);
                }
                break;

            // true
            case 1:
                status = ExecuteExp.Execute(exp.GetThen());
                break;

            // error
            case 2:
                status.Status        = false;
                status.StatusCode    = k_STATUS_CODE.Failed;
                status.StatusComment = LogicModuleMessages.ERROR_LOGIC + exp.Expression;
                break;
            }

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

        return(status);
    }
Exemple #5
0
    /// <summary>
    /// method
    /// US:902
    /// parses a static place holder
    /// </summary>
    /// <param name="strPlaceHolder"></param>
    /// <returns></returns>
    private CStringStatus ParseStatic(string strPlaceHolder)
    {
        CStringStatus status = new CStringStatus();

        switch (strPlaceHolder)
        {
        case "state.good":
            status.Value = Convert.ToInt64(k_STATE_ID.Good).ToString();
            break;

        case "state.unknown":
            status.Value = Convert.ToInt64(k_STATE_ID.Unknown).ToString();
            break;

        case "state.bad":
            status.Value = Convert.ToInt64(k_STATE_ID.Bad).ToString();
            break;

        case "sex.male":
            status.Value = Convert.ToInt64(k_SEX.MALE).ToString();
            break;

        case "sex.female":
            status.Value = Convert.ToInt64(k_SEX.FEMALE).ToString();
            break;

        case "source.vista":
            status.Value = Convert.ToInt64(k_SOURCE_TYPE_ID.VistA).ToString();
            break;

        case "source.vappct":
            status.Value = Convert.ToInt64(k_SOURCE_TYPE_ID.VAPPCT).ToString();
            break;

        case "defaultunknownstate":
            status.Value = Convert.ToInt64(k_DEFAULT_STATE_ID.Unknown).ToString();
            break;

        case "defaultgoodstate":
            status.Value = Convert.ToInt64(k_DEFAULT_STATE_ID.Good).ToString();
            break;

        case "defaultbadstate":
            status.Value = Convert.ToInt64(k_DEFAULT_STATE_ID.Bad).ToString();
            break;

        case "value.selected":
            status.Value = Convert.ToInt64(k_TRUE_FALSE_ID.True).ToString();
            break;

        case "value.notselected":
            status.Value = Convert.ToInt64(k_TRUE_FALSE_ID.False).ToString();
            break;

        default:
            return(new CStringStatus(
                       false,
                       k_STATUS_CODE.Failed,
                       LogicModuleMessages.ERROR_PARSE + strPlaceHolder,
                       CExpression.NullTkn));
        }

        return(status);
    }