//Case 47: 1.3.12_CreateAnalysis_Normal
        public void Run_Analysis_Acq_CreateAnalysis_Normal_Case47()
        {
            int runCount = 0;
            string analysisContent = "<trophy type=\"analysis\" version=\"1.0\">          <trophyheader>        <accesslog>            <creation date=\"2011-10-25\" time=\"10:54:17\" applicationname=\"kdis2dviewer\" applicationversion=\"7.0\" />            <modification date=\"2011/10/25\" time=\"10:54:18\" applicationname=\"kdis2dviewer\" applicationversion=\"7.0\" />        </accesslog>    </trophyheader>    <templateheader>        <object subtype=\"analysis\" instance=\"true\" name=\"Test Analysis\" uid=\"\" />        <comments />        <icon filepath=\"analysisicon.jpg\" />        <icon>            <ObjectData>base64imagedata</ObjectData>        </icon>        <icon id=\"thumbnailid\" />        <AnalysisProp name=\"1112222\" comments=\"\" date=\"2011-10-25\" time=\"10:54:17\" arrangementmode=\"0\" />    </templateheader>    <page index=\"0\" Dx=\"1280\" Dy=\"1024\" backgroundColour=\"RGB(0,0,0)\">        <Frame index=\"1\" type=\"floating panel\" x=\"938\" y=\"201\" w=\"200\" h=\"239\" Zorder=\"\">            <PanelProp paneltype=\"control panel xray\" id=\"control panel xray\" showstate=\"maximized\" />        </Frame>        <Frame index=\"2\" type=\"floating panel\" x=\"938\" y=\"201\" w=\"200\" h=\"240\" Zorder=\"\">            <PanelProp paneltype=\"control panel color\" id=\"control panel color\" showstate=\"maximized\" />        </Frame>        <Frame index=\"3\" type=\"image\" x=\"349\" y=\"299\" w=\"266\" h=\"355\" Zorder=\"\">            <PanelProp paneltype=\"image\" id=\"@@PSID0\" showstate=\"selected\" IdV0=\"76b3ec9d-1374-4a13-9950-6cf3f5ebc1e6\" />        </Frame>        <Frame index=\"4\" type=\"image\" x=\"818\" y=\"299\" w=\"266\" h=\"354\" Zorder=\"\">            <PanelProp paneltype=\"image\" id=\"@@PSID1\" showstate=\"deselected\" IdV0=\"eb87d761-accf-4531-b4fc-9ee9861f15fd\" />        </Frame>    </page></trophy>";

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                Round r = this.NewRound(runCount.ToString(), "Acquisition for Analysis");

                CheckPoint pAnalysis = new CheckPoint("Create Analysis", "Create Analysis");
                r.CheckPoints.Add(pAnalysis);

                XMLParameter acq = new XMLParameter("acq_info");
                string PatientID = string.Empty;
                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "acquire")
                    {
                        if (ids.InputParameters.GetParameter(i).Key == "patient_internal_id")
                            PatientID = ids.InputParameters.GetParameter(i).Value;
                        acq.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                }
                string retPsID = string.Empty;
                string repStr = "@@PSID";
                XMLParameterCollection anaUidsXML = new XMLParameterCollection();
                XMLParameter anaUids = new XMLParameter("presentationstate");

                for (int acqTime = 0; acqTime < 2; acqTime++)
                {
                    retPsID = AcquisitionService.AcquireImage(acq);
                    if (retPsID != string.Empty)
                    {
                        analysisContent = analysisContent.Replace(repStr + acqTime, retPsID);
                        anaUids.AddParameter("internal_id", retPsID);
                    }
                }
                anaUidsXML.Add(anaUids);
                AnalysisService ass = new AnalysisService();

                XMLResult rslCreateAnalysis = ass.createAnalysis(analysisContent, false, true, PatientID, @"D:\Test\DICOM_Imag_Lib\ImportImage\thumb.PNG", anaUidsXML);

                if (rslCreateAnalysis.IsErrorOccured)
                {
                    pAnalysis.Result = TestResult.Fail;
                    pAnalysis.Outputs.AddParameter("Create Analysis", "Analysis Service", rslCreateAnalysis.Message);
                }
                else
                {
                    pAnalysis.Result = TestResult.Pass;
                    pAnalysis.Outputs.AddParameter("Create Analysis ID:", "Analysis Service", rslCreateAnalysis.SingleResult);
                }
                ass.deleteAnalysis(rslCreateAnalysis.SingleResult);
                SaveRound(r);
            }
            Output();
        }
        //Case 980: 1.3.17_workflow_CSI select a patient, open an image and then close it
        public void Run_WorkFlow_CSIOpenImageAndClose_Case980()
        {
            // Test Case added for work flow: CSI select a patient to list all the image, click to open one of them and then save and close it.

            PatientService patientService = new PatientService();
            AcquisitionService acquisitionService = new AcquisitionService();
            PresentationStateService presentationStateService = new PresentationStateService();
            AnalysisService analysisService = new AnalysisService();

            string patientUID = null;
            XMLParameter setAsynAcqPatientInfoParam = new XMLParameter("acq_info");
            XMLParameter listObjectForPSParam = new XMLParameter("filter");
            XMLParameterCollection getPresentionStateInfoParam = new XMLParameterCollection();
            XMLParameter listObjectForVolumeParam = new XMLParameter("filter");
            XMLParameter listObjectForFMSParam = new XMLParameter("filter");
            XMLParameter listObjectForOtherParam = new XMLParameter("filter");

            XMLParameter setPresentationStateParam = new XMLParameter("presentationstate");
            XMLParameter setPresentationStateInfoParam = new XMLParameter("presentationstate");

            XMLParameter listObjectForAnalysisParam = new XMLParameter("filter");
            XMLParameter setAnalysisInfoParam = new XMLParameter("analysis");

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                Round r = new Round();

                try
                {
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "getPatient")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "patientInternalID")
                            {
                                patientUID = ids.InputParameters.GetParameter(i).Value;
                            }
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "setAsynAcqPatientInfo")
                        {
                            setAsynAcqPatientInfoParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "listObjectForPS")
                        {
                            listObjectForPSParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "listObjectForVolume")
                        {
                            listObjectForVolumeParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "listObjectForFMS")
                        {
                            listObjectForFMSParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "listObjectForOther")
                        {
                            listObjectForOtherParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "listObjectForAnalysis")
                        {
                            listObjectForAnalysisParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "setPresentationStateInfo")
                        {
                            setPresentationStateInfoParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "setAnalysisInfo")
                        {
                            setAnalysisInfoParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }
                    }

                    #region Step 1: Check the specific patient exists in Database
                    CheckPoint pGetPatient = new CheckPoint("getPatient", "Step 1: Get the specific patient info");
                    r.CheckPoints.Add(pGetPatient);

                    XMLResult getPatientResult = patientService.getPatient(patientUID);

                    if (getPatientResult.IsErrorOccured)
                    {
                        pGetPatient.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Get the specific patient info fail:");
                        pGetPatient.Outputs.AddParameter("getPatient", "get the specific patient info", getPatientResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pGetPatient.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Get the specific patient info succeed:");
                        pGetPatient.Outputs.AddParameter("getPatient", "get the specific patient info", getPatientResult.Message);
                    }
                    #endregion

                    // Step 2 - Step 7 are what to do after select a patient

                    #region Step 2: set asyn acq patient with the specific patient
                    CheckPoint pSetAsynAcqPatientInfo = new CheckPoint("setAsynAcqPatientInfo", "Step 2: call setAsynAcqPatientInfo to set asyn acq patient info");
                    r.CheckPoints.Add(pSetAsynAcqPatientInfo);

                    XMLResult setAsynAcqPatientInfoResult = acquisitionService.setAsynAcqPatientInfo(setAsynAcqPatientInfoParam);

                    if (setAsynAcqPatientInfoResult.IsErrorOccured)
                    {
                        pSetAsynAcqPatientInfo.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Set asyn acq PatientInfo fail:");
                        pSetAsynAcqPatientInfo.Outputs.AddParameter("setAsynAcqPatientInfo", "set asyn acq patient info", setAsynAcqPatientInfoResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pSetAsynAcqPatientInfo.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Set asyn acq PatientInfo succeed:");
                        pSetAsynAcqPatientInfo.Outputs.AddParameter("setAsynAcqPatientInfo", "set asyn acq patient info", setAsynAcqPatientInfoResult.Message);
                    }
                    #endregion

                    #region Step 3: Call listObject to get the presentation state list of the patient
                    CheckPoint pListObjectForPS = new CheckPoint("listObjectForPS", "Step 3: call listObject to get PS info");
                    r.CheckPoints.Add(pListObjectForPS);

                    XMLResult listObjectForPSResult = patientService.listObjects(listObjectForPSParam);

                    if (listObjectForPSResult.IsErrorOccured)
                    {
                        pListObjectForPS.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call listObject to get PS info fail:");
                        pListObjectForPS.Outputs.AddParameter("listObject", "listObject to get PS", listObjectForPSResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pListObjectForPS.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call listObject to get PS info succeed:");
                        pListObjectForPS.Outputs.AddParameter("listObject", "listObject to get PS", listObjectForPSResult.Message);

                    }
                    #endregion

                    #region Step 4: Call getPresentationStateInfo to get the presentationstate info according to the presentationstate internal_id

                    CheckPoint pGetPresentionStateInfo = new CheckPoint("getPresentionStateInfo", "Step 4: call getPresentationStateInfo to get presention state info");
                    r.CheckPoints.Add(pGetPresentionStateInfo);

                    foreach (XMLParameter param in listObjectForPSResult.MultiResults)
                    {
                        getPresentionStateInfoParam.Add(param);
                    }

                    XMLResult getPresentationStateInfoResult = presentationStateService.getPresentationStateInfo(getPresentionStateInfoParam);

                    if (getPresentationStateInfoResult.IsErrorOccured)
                    {
                        pGetPresentionStateInfo.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call getPresentationStateInfo to get PS info fail:");
                        pGetPresentionStateInfo.Outputs.AddParameter("getPresentationStateInfo", "getPresentationStateInfo to get PS info", getPresentationStateInfoResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pGetPresentionStateInfo.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call getPresentationStateInfo to get PS info succeed:");
                        pGetPresentionStateInfo.Outputs.AddParameter("getPresentationStateInfo", "getPresentationStateInfo to get PS info", getPresentationStateInfoResult.Message);

                    }
                    #endregion

                    #region Step 5: Call listObject to get the volume list of the patient
                    CheckPoint pListObjectForVolume = new CheckPoint("listObjectForVolume", "Step 5: call listObject to get volume info");
                    r.CheckPoints.Add(pListObjectForVolume);

                    XMLResult listObjectForVolumeResult = patientService.listObjects(listObjectForVolumeParam);

                    if (listObjectForVolumeResult.IsErrorOccured)
                    {
                        pListObjectForVolume.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call listObject to get volume info fail:");
                        pListObjectForVolume.Outputs.AddParameter("listObject", "listObject to get volume", listObjectForVolumeResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pListObjectForVolume.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call listObject to get volume info succeed:");
                        pListObjectForVolume.Outputs.AddParameter("listObject", "listObject to get volume", listObjectForVolumeResult.Message);

                    }
                    #endregion

                    #region Step 6: Call listObject to get the FMS list of the patient
                    CheckPoint pListObjectForFMS = new CheckPoint("listObjectForFMS", "Step 6: call listObject to get FMS info");
                    r.CheckPoints.Add(pListObjectForFMS);

                    XMLResult listObjectForFMSResult = patientService.listObjects(listObjectForFMSParam);

                    if (listObjectForFMSResult.IsErrorOccured)
                    {
                        pListObjectForFMS.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call listObject to get FMS info fail:");
                        pListObjectForFMS.Outputs.AddParameter("listObject", "listObject to get FMS", listObjectForFMSResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pListObjectForFMS.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call listObject to get FMS info succeed:");
                        pListObjectForFMS.Outputs.AddParameter("listObject", "listObject to get FMS", listObjectForFMSResult.Message);

                    }
                    #endregion

                    #region Step 7: Call listObject to get the other info of the patient
                    CheckPoint pListObjectForOther = new CheckPoint("listObjectForOther", "Step 7: call listObject to get other info");
                    r.CheckPoints.Add(pListObjectForOther);

                    XMLResult listObjectForOtherResult = patientService.listObjects(listObjectForOtherParam);

                    if (listObjectForOtherResult.IsErrorOccured)
                    {
                        pListObjectForOther.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call listObject to get other info fail:");
                        pListObjectForOther.Outputs.AddParameter("listObject", "listObject to get other", listObjectForOtherResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pListObjectForOther.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call listObject to get other info succeed:");
                        pListObjectForOther.Outputs.AddParameter("listObject", "listObject to get other", listObjectForOtherResult.Message);

                    }
                    #endregion

                    // After double click an image to open it, it will repeat step 3 to step 7
                    // When open image, it will call getPresentationState to get the presentation state, which can be used in setPresentationState step later
                    string presentationStateInternalID = null;
                    XMLParameterCollection setPresentationStateParamList = new XMLParameterCollection();

                    foreach (XMLParameterNode psNode in listObjectForPSResult.ArrayResult.Parameters)
                    {
                        presentationStateInternalID = psNode.ParameterValue;

                        XMLResult getPresentationStateResult = presentationStateService.getPresentationState(presentationStateInternalID);

                        setPresentationStateParam = getPresentationStateResult.ArrayResult;
                        setPresentationStateParamList.Add(setPresentationStateParam);
                    }

                    // Close the image, it will do step 8 to step 10
                    #region Step 8: Call setPresentationState to set presentation state, not change the presentation state value, just set it back
                    CheckPoint pSetPresentationState = new CheckPoint("setPresentationState", "Step 8: call setPresentationState to set the presentation state after close the image");
                    r.CheckPoints.Add(pSetPresentationState);

                    XMLResult setPresentationStateResult = new XMLResult();

                    foreach (XMLParameter presentationStateInfo in setPresentationStateParamList)
                    {
                        setPresentationStateResult = presentationStateService.setPresentationState(presentationStateInfo, presentationStateInternalID);

                        if (setPresentationStateResult.IsErrorOccured)
                        {
                            pSetPresentationState.Result = TestResult.Fail;
                            break;
                        }
                        else
                        {
                            pSetPresentationState.Result = TestResult.Pass;
                        }

                    }

                    if (pSetPresentationState.Result == TestResult.Fail)
                    {
                        System.Diagnostics.Debug.Print("Call setPresentationState to set presentation state fail:");
                        pSetPresentationState.Outputs.AddParameter("setPresentationState", "setPresentationState to set presentation state", setPresentationStateResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        System.Diagnostics.Debug.Print("Call setPresentationState to set presentation state succeed:");
                        pSetPresentationState.Outputs.AddParameter("setPresentationState", "setPresentationState to set presentation state", setPresentationStateResult.Message);
                    }
                    #endregion

                    #region Step 9: Call setPresentationStateInfo to set the presentation state info
                    CheckPoint pSetPresentationStateInfo = new CheckPoint("setPresentationStateInfo", "Step 9: call setPresentationStateInfo to set the presentation state info after close the image");
                    r.CheckPoints.Add(pSetPresentationStateInfo);

                    XMLResult setPresentationStateInfoResult = new XMLResult();

                    foreach (XMLParameter presentationStateInfoParam in getPresentationStateInfoResult.MultiResults)
                    {
                        presentationStateInternalID = presentationStateInfoParam.GetParameterValueByName("internal_id");

                        setPresentationStateInfoResult = presentationStateService.setPresentationStateInfo(setPresentationStateInfoParam, presentationStateInternalID);

                        if (setPresentationStateInfoResult.IsErrorOccured)
                        {
                            pSetPresentationStateInfo.Result = TestResult.Fail;
                            break;
                        }
                        else
                        {
                            pSetPresentationStateInfo.Result = TestResult.Pass;
                        }
                    }

                    if (pSetPresentationStateInfo.Result == TestResult.Fail)
                    {
                        System.Diagnostics.Debug.Print("Call setPresentationStateInfo to set presentation state info fail:");
                        pSetPresentationStateInfo.Outputs.AddParameter("setPresentationStateInfo", "setPresentationState to set presentation state info", setPresentationStateInfoResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        System.Diagnostics.Debug.Print("Call setPresentationStateInfo to set presentation state info succeed:");
                        pSetPresentationStateInfo.Outputs.AddParameter("setPresentationState", "setPresentationState to set presentation state info", setPresentationStateInfoResult.Message);
                    }
                    #endregion

                    #region Step 10: Call listObject to get the presentation state
                    CheckPoint pListObjectForPS2 = new CheckPoint("listObjectForPS", "Step 10: call listObject to get PS info after close image");
                    r.CheckPoints.Add(pListObjectForPS2);

                    XMLResult listObjectForPSResult2 = patientService.listObjects(listObjectForPSParam);

                    if (listObjectForPSResult2.IsErrorOccured)
                    {
                        pListObjectForPS.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call listObject to get PS info fail:");
                        pListObjectForPS2.Outputs.AddParameter("listObject", "listObject to get PS", listObjectForPSResult2.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pListObjectForPS2.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call listObject to get PS info succeed:");
                        pListObjectForPS2.Outputs.AddParameter("listObject", "listObject to get PS", listObjectForPSResult2.Message);

                    }
                    #endregion

                    #region Step 11: Call getPresentationStateInfo to get the presentation state info
                    CheckPoint pGetPresentionStateInfo2 = new CheckPoint("getPresentionStateInfo", "Step 11: call getPresentationStateInfo to get presention state info after close image");
                    r.CheckPoints.Add(pGetPresentionStateInfo2);

                    XMLResult getPresentationStateInfoResult2 = presentationStateService.getPresentationStateInfo(getPresentionStateInfoParam);

                    if (getPresentationStateInfoResult2.IsErrorOccured)
                    {
                        pGetPresentionStateInfo2.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call getPresentationStateInfo to get PS info fail:");
                        pGetPresentionStateInfo2.Outputs.AddParameter("getPresentationStateInfo", "getPresentationStateInfo to get PS info", getPresentationStateInfoResult2.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pGetPresentionStateInfo2.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call getPresentationStateInfo to get PS info succeed:");
                        pGetPresentionStateInfo2.Outputs.AddParameter("getPresentationStateInfo", "getPresentationStateInfo to get PS info", getPresentationStateInfoResult2.Message);

                    }
                    #endregion

                    // Close the viewer
                    #region Step 12: Call listObject to get the analysis
                    CheckPoint pListObjectForAnalysis = new CheckPoint("listObjectForAnalysis", "Step 12: call listObject to get analysis info");
                    r.CheckPoints.Add(pListObjectForAnalysis);

                    XMLResult listObjectForAnalysisResult = patientService.listObjects(listObjectForAnalysisParam);

                    if (listObjectForAnalysisResult.IsErrorOccured)
                    {
                        pListObjectForAnalysis.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call listObject to get analysis info fail:");
                        pListObjectForAnalysis.Outputs.AddParameter("listObject", "listObject to get analysis", listObjectForAnalysisResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pListObjectForAnalysis.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call listObject to get analysis info succeed:");
                        pListObjectForAnalysis.Outputs.AddParameter("listObject", "listObject to get analysis", listObjectForAnalysisResult.Message);
                    }
                    #endregion

                    string analysisId = null;
                    analysisId = listObjectForAnalysisResult.SingleResult;

                    if (analysisId == null || analysisId == string.Empty)
                    {
                        // Below Step are excuted when there is no analysis before

                        #region Step 13: createAnalysis
                        CheckPoint pCreateAnalysis = new CheckPoint("createAnalysis", "Step 13: call createAnalysis to create new analysis");
                        r.CheckPoints.Add(pCreateAnalysis);

                        XMLResult createAnalysisResult = new XMLResult();

                        XMLParameter analysisXml = new XMLParameter("analysis");
                        XMLParameterCollection uidsXml = new XMLParameterCollection();
                        XMLParameter presentationStateUids = new XMLParameter("presentationstate");
                        XMLParameter fmsUids = new XMLParameter("fms");
                        uidsXml.Add(presentationStateUids);
                        uidsXml.Add(fmsUids);

                        createAnalysisResult = analysisService.createAnalysis(analysisXml.GenerateXML().ToString(), true, true, patientUID, null, uidsXml);
                        // public XMLResult createAnalysis(string analysisXml, bool current, bool currentSpecified, string patientInternalID, string thumbnail, XMLParameterCollection uidsXml);
                        if (createAnalysisResult.IsErrorOccured)
                        {
                            System.Diagnostics.Debug.Print("Call createAnalysis to create analysis fail:");
                            pCreateAnalysis.Outputs.AddParameter("createAnalysis", "createAnalysis to create analysis", createAnalysisResult.Message);

                            SaveRound(r);
                            break;
                        }
                        else
                        {
                            System.Diagnostics.Debug.Print("Call createAnalysis to create analysis succeed:");
                            pCreateAnalysis.Outputs.AddParameter("createAnalysis", "createAnalysis to create analysis", createAnalysisResult.Message);
                        }
                        #endregion

                        #region Step 14: Call AnalysisService.setAnalysisInfo to set the analysis info
                        CheckPoint pSetAnalysisInfo = new CheckPoint("setAnalysisInfo", "Step 14: call setAnalysisInfo to set the analysis info");
                        r.CheckPoints.Add(pSetAnalysisInfo);

                        XMLResult setAnalysisInfoResult = new XMLResult();

                        analysisId = createAnalysisResult.MultiResults[0].GetParameterValueByName("internal_id");

                        setAnalysisInfoResult = analysisService.setAnalysisInfo(analysisId, setAnalysisInfoParam);

                        if (setAnalysisInfoResult.IsErrorOccured)
                        {
                            System.Diagnostics.Debug.Print("Call setAnalysisInfo to set analysis info fail:");
                            pSetAnalysisInfo.Outputs.AddParameter("setAnalysisInfo", "setAnalysisInfo to set analysis info", setAnalysisInfoResult.Message);

                            SaveRound(r);
                            break;
                        }
                        else
                        {
                            System.Diagnostics.Debug.Print("Call setAnalysisInfo to set analysis info succeed:");
                            pSetAnalysisInfo.Outputs.AddParameter("setAnalysisInfo", "setAnalysisInfo to set analysis info", setAnalysisInfoResult.Message);
                        }
                        #endregion
                    }

                    else
                    {
                        // Below Step 15 to Step 17 are excuted when there is analysis exist before...

                        #region Step 15: Call AnalysisService.getAnalysisInfo to get the analysis info
                        CheckPoint pGetAnalysisInfo = new CheckPoint("getAnalysisInfo", "Step 15: call getAnalysisInfo to get the analysis info");
                        r.CheckPoints.Add(pGetAnalysisInfo);

                        XMLResult getAnalysisInfoResult = new XMLResult();

                        getAnalysisInfoResult = analysisService.getAnalysisInfo(analysisId);

                        if (getAnalysisInfoResult.IsErrorOccured)
                        {
                            pGetAnalysisInfo.Result = TestResult.Fail;
                            System.Diagnostics.Debug.Print("Call getAnalysisInfo to get analysis info fail:");
                            pGetAnalysisInfo.Outputs.AddParameter("getAnalysisInfo", "getAnalysisInfo to get analysis info", getAnalysisInfoResult.Message);

                            SaveRound(r);
                            break;
                        }
                        else
                        {
                            pGetAnalysisInfo.Result = TestResult.Pass;
                            System.Diagnostics.Debug.Print("Call getAnalysisInfo to get analysis info succeed:");
                            pGetAnalysisInfo.Outputs.AddParameter("getAnalysisInfo", "getAnalysisInfo to get analysis info", getAnalysisInfoResult.Message);
                        }
                        #endregion

                        #region Step 16: Call AnalysisService.setAnalysisDescription to set analysis description
                        CheckPoint pSetAnalysisDescription = new CheckPoint("setAnalysisDescription", "Step 16: call setAnalysisDescription to set the analysis description");
                        r.CheckPoints.Add(pSetAnalysisDescription);

                        XMLResult setAnalysisDescriptionResult = new XMLResult();

                        XMLParameter analysisXml = new XMLParameter("analysis");
                        XMLParameterCollection uidsXml = new XMLParameterCollection();
                        XMLParameter presentationStateUids = new XMLParameter("presentationstate");
                        XMLParameter fmsUids = new XMLParameter("fms");
                        uidsXml.Add(presentationStateUids);
                        uidsXml.Add(fmsUids);

                        setAnalysisDescriptionResult = analysisService.setAnalysisDescription(analysisId, analysisXml.GenerateXML(), false, uidsXml);

                        if (setAnalysisDescriptionResult.IsErrorOccured)
                        {
                            pSetAnalysisDescription.Result = TestResult.Fail;
                            System.Diagnostics.Debug.Print("Call setAnalysisDescription to set the analysis description fail:");
                            pSetAnalysisDescription.Outputs.AddParameter("setAnalysisDescription", "call set the analysis description", setAnalysisDescriptionResult.Message);

                            SaveRound(r);
                            break;
                        }
                        else
                        {
                            pSetAnalysisDescription.Result = TestResult.Pass;
                            System.Diagnostics.Debug.Print("Call setAnalysisDescription to set the analysis description succeed:");
                            pSetAnalysisDescription.Outputs.AddParameter("setAnalysisDescription", "call set the analysis description", setAnalysisDescriptionResult.Message);
                        }
                        #endregion

                        #region Step 17: Call AnalysisService.setAnalysisInfo to set the analysis info
                        CheckPoint pSetAnalysisInfo = new CheckPoint("setAnalysisInfo", "Step 17: call setAnalysisInfo to set the analysis info");
                        r.CheckPoints.Add(pSetAnalysisInfo);

                        XMLResult setAnalysisInfoResult = new XMLResult();

                        setAnalysisInfoResult = analysisService.setAnalysisInfo(analysisId, setAnalysisInfoParam);

                        if (setAnalysisInfoResult.IsErrorOccured)
                        {
                            pSetAnalysisInfo.Result = TestResult.Fail;
                            System.Diagnostics.Debug.Print("Call setAnalysisInfo to set analysis info fail:");
                            pSetAnalysisInfo.Outputs.AddParameter("setAnalysisInfo", "setAnalysisInfo to set analysis info", setAnalysisInfoResult.Message);

                            SaveRound(r);
                            break;
                        }
                        else
                        {
                            pSetAnalysisInfo.Result = TestResult.Pass;
                            System.Diagnostics.Debug.Print("Call setAnalysisInfo to set analysis info succeed:");
                            pSetAnalysisInfo.Outputs.AddParameter("setAnalysisInfo", "setAnalysisInfo to set analysis info", setAnalysisInfoResult.Message);
                        }
                        #endregion
                    }

                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.Message);
                    cp.Result = TestResult.Fail;
                    SaveRound(r);
                }
            }

            Output();
        }
        //Case962: 1.3.12_DeleteAnalysis_N2_Delete Analysis with FMS
        public void Run_Analysis_Acq_DeleteAnalysiswithFMS_Case962()
        {
            int runCount = 0;
            string analysisContent = "<trophy type=\"analysis\" version=\"1.0\">    <trophyheader>        <accesslog>            <creation date=\"2011/10/26\" time=\"14:33:59\" applicationname=\"kdis2dviewer\" applicationversion=\"7.0\" />            <modification date=\"2011/10/26\" time=\"14:33:59\" applicationname=\"kdis2dviewer\" applicationversion=\"7.0\" />        </accesslog>    </trophyheader>    <templateheader>        <object subtype=\"analysis\" instance=\"true\" name=\"2011/10/26 14:33:59\" uid=\"a680942f-ae84-4a18-8dab-cd766bda64da\" />        <comments />        <icon filepath=\"analysisicon.jpg\" />        <icon>            <ObjectData>base64imagedata</ObjectData>        </icon>        <icon id=\"thumbnailid\" />        <AnalysisProp name=\"2011/10/26 14:33:59\" comments=\"\" date=\"2011/10/26\" time=\"14:33:59\" arrangementmode=\"0\" />    </templateheader>    <page index=\"0\" Dx=\"1280\" Dy=\"1024\" backgroundColour=\"RGB(0,0,0)\">        <Frame index=\"1\" type=\"floating panel\" x=\"914\" y=\"142\" w=\"200\" h=\"239\" Zorder=\"\">            <PanelProp paneltype=\"control panel xray\" id=\"control panel xray\" showstate=\"maximized\" />        </Frame>        <Frame index=\"2\" type=\"floating panel\" x=\"914\" y=\"142\" w=\"200\" h=\"240\" Zorder=\"\">            <PanelProp paneltype=\"control panel color\" id=\"control panel color\" showstate=\"maximized\" />        </Frame>        <Frame index=\"3\" type=\"fms\" x=\"697\" y=\"255\" w=\"457\" h=\"323\" Zorder=\"\">            <PanelProp paneltype=\"fms\" id=\"@@FMSID0\" showstate=\"selected\" IdV0=\"@@FMSID0\" />        </Frame>        <Frame index=\"4\" type=\"fms\" x=\"229\" y=\"255\" w=\"457\" h=\"323\" Zorder=\"\">            <PanelProp paneltype=\"fms\" id=\"@@FMSID1\" showstate=\"deselected\" IdV0=\"@@FMSID1\" />        </Frame>    </page></trophy>";
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                Round r = this.NewRound(runCount.ToString(), "Acquisition for Analysis");

                XMLParameter acq = new XMLParameter("acq_info");
                string PatientID = string.Empty;
                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "acquire")
                    {
                        if (ids.InputParameters.GetParameter(i).Key == "patient_internal_id")
                        {
                            PatientID = ids.InputParameters.GetParameter(i).Value;
                        }
                        acq.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                }
                string retFmsID = string.Empty;
                string repStr = "@@FMSID";
                XMLParameterCollection anaUidsXML = new XMLParameterCollection();
                XMLParameter anaUids = new XMLParameter("fms");

                for (int acqTime = 0; acqTime < 2; acqTime++)
                {
                    CheckPoint pAcquire = new CheckPoint("Acquire FMS", "Acquire FMS");
                    r.CheckPoints.Add(pAcquire);
                    System.Diagnostics.Debug.Print("Acquire start");

                    retFmsID = AcquisitionService.AcquireFMS(acq);

                    if (!string.IsNullOrEmpty(retFmsID))
                    {
                        pAcquire.Result = TestResult.Pass;
                        pAcquire.Outputs.AddParameter("Acquire FMS", "Acq return correct.", "FMS ID :" + retFmsID);
                        analysisContent = analysisContent.Replace(repStr + acqTime, retFmsID);
                        anaUids.AddParameter("internal_id", retFmsID);
                    }
                    else
                    {
                        pAcquire.Result = TestResult.Fail;
                        pAcquire.Outputs.AddParameter("Acquire FMS", "Acq return error.", "FMS ID :" + retFmsID);
                        goto CLEANUP;
                    }
                }

                CheckPoint pCreateAnalysis = new CheckPoint("Create Analysis", "Create Analysis");
                r.CheckPoints.Add(pCreateAnalysis);

                anaUidsXML.Add(anaUids);
                AnalysisService ass = new AnalysisService();

                XMLResult rslCreateAnalysis = ass.createAnalysis(analysisContent, false, true, PatientID, @"D:\Test\DICOM_Imag_Lib\ImportImage\thumb.PNG", anaUidsXML);

                if (rslCreateAnalysis.IsErrorOccured)
                {
                    pCreateAnalysis.Result = TestResult.Fail;
                    pCreateAnalysis.Outputs.AddParameter("Create Analysis Failed", "Analysis Service", rslCreateAnalysis.ResultContent);
                    break;
                }
                else
                {
                    pCreateAnalysis.Outputs.AddParameter("Create Analysis ID:", "Analysis Service", rslCreateAnalysis.ResultContent);
                }
                XMLResult rsldelAnalysis = ass.deleteAnalysis(rslCreateAnalysis.SingleResult);
                if (rsldelAnalysis.IsErrorOccured)
                {
                    pCreateAnalysis.Result = TestResult.Fail;
                    pCreateAnalysis.Outputs.AddParameter("Delete Analysis Failed", "Analysis Service", rslCreateAnalysis.ResultContent);
                }
                else
                {
                    pCreateAnalysis.Result = TestResult.Pass;
                    pCreateAnalysis.Outputs.AddParameter("Delete Analysis Success", "Analysis Service", rslCreateAnalysis.ResultContent);
                }

            CLEANUP:
                SaveRound(r);
            }
            Output();
        }
        //Case 1598: 1.1.06.21_ImportDir_MainDirectory_N01
        public void Run_Import_ImportDir_MainDirectory_Case1598()
        {
            int runCount = 0;
            NotificationSim.ReceiveNotification rn = new ReceiveNotification();
            System.Collections.Generic.List<string> topics = new System.Collections.Generic.List<string>();
            topics.Add("topic.postImportCompleted");
            string stopTopic = "teststop";
            string stopContent = "teststop";
            rn.startListon(topics, stopTopic, stopContent);

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "ImportMainDir");
                CheckPoint pimp = new CheckPoint("ImportDir", "Import Additional Dir");
                r.CheckPoints.Add(pimp);

                //create patient for import
                PatientService ps = new PatientService();
                XMLParameter cInputPatient = new XMLParameter("patient");
                cInputPatient.AddParameter("first_name", "test");
                cInputPatient.AddParameter("last_name", "importmaindir");
                XMLResult rslCreate = ps.createPatient(cInputPatient);

                if (rslCreate.IsErrorOccured)
                {
                    pimp.Result = TestResult.Fail;
                    pimp.Outputs.AddParameter("Import Main Dir", "Create Patient Fail", rslCreate.Message);
                    SaveRound(r);
                    continue;
                }
                string patientid = rslCreate.SingleResult;
                try
                {
                    string kdis6dir = ids.InputParameters.GetParameter("kdis6_dir").Value;

                    int retrynum = int.Parse(ids.InputParameters.GetParameter("retrynum").Value);
                    string flag = "import";
                    ImportService imps = new ImportService();
                    XMLResult rslimport = imps.importDir(patientid, kdis6dir, flag);

                    if (rslimport.Code != 800)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "Import Fail", rslimport.Message);
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    int n = 0;
                    while (rn.getRecievedNumber() == 0)
                    {
                        n++;
                        if (n < retrynum)
                        {
                            System.Threading.Thread.Sleep(5000);
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (n == retrynum)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "Notification Fail", "No notification recieved after retry " + n.ToString() + " times.");
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    ApplicationService app = new ApplicationService();
                    app.sendGenericNotification(stopTopic, stopContent);
                    System.Threading.Thread.Sleep(1000);
                    System.Collections.Generic.List<string> mmm = rn.getNotificationContent();
                    System.Collections.Generic.List<string> imageids = PAS.AutoTest.TestUtility.Utility.parsePostImportResult("Image", mmm[0]);
                    System.Collections.Generic.List<string> fmsids = PAS.AutoTest.TestUtility.Utility.parsePostImportResult("FMS", mmm[0]);
                    System.Collections.Generic.List<string> analysisids = PAS.AutoTest.TestUtility.Utility.parsePostImportResult("Analysis", mmm[0]);

                    int expectedimgcount = int.Parse(ids.ExpectedValues.GetParameter("imgnum").Value);
                    int expectedfmscount = int.Parse(ids.ExpectedValues.GetParameter("fmsnum").Value);
                    int expectedanalysiscount = int.Parse(ids.ExpectedValues.GetParameter("analysisnum").Value);

                    //check counts
                    if (imageids.Count != expectedimgcount)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "Image Count is not correct", "Actual:" + imageids.Count.ToString() + ",Expected:" + expectedimgcount.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    if (fmsids.Count != expectedfmscount)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "FMS Count is not correct", "Actual:" + fmsids.Count.ToString() + ",Expected:" + expectedfmscount.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    if (analysisids.Count != expectedanalysiscount)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "Analysis Count is not correct", "Actual:" + analysisids.Count.ToString() + ",Expected:" + expectedanalysiscount.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    //get image info
                    ImageService imgs = new ImageService();
                    foreach (string imgid in imageids)
                    {
                        XMLParameter cInputImage = new XMLParameter("image");
                        cInputImage.AddParameter("internal_id", imgid);
                        XMLResult rslget = imgs.getImageInfo(cInputImage);
                        if (rslget.IsErrorOccured)
                        {
                            pimp.Result = TestResult.Fail;
                            pimp.Outputs.AddParameter("Import Main Dir", "GetImage Fail", rslget.Message);
                            SaveRound(r);
                            ps.deletePatient(patientid);
                            goto error;
                        }
                    }
                    //get FMS info
                    FMSService fmss = new FMSService();
                    foreach (string fmsid in fmsids)
                    {
                        XMLResult rslget = fmss.getFMSInfo(fmsid);
                        if (rslget.IsErrorOccured)
                        {
                            pimp.Result = TestResult.Fail;
                            pimp.Outputs.AddParameter("Import Main Dir", "GetFMS Fail", rslget.Message);
                            SaveRound(r);
                            ps.deletePatient(patientid);
                            goto error;
                        }
                        rslget = fmss.getFMSDescription(fmsid);
                        if (rslget.IsErrorOccured)
                        {
                            pimp.Result = TestResult.Fail;
                            pimp.Outputs.AddParameter("Import Main Dir", "GetFMS Fail", rslget.Message);
                            SaveRound(r);
                            ps.deletePatient(patientid);
                            goto error;
                        }
                    }
                    //get Analysis info
                    AnalysisService anas = new AnalysisService();
                    foreach (string analysisid in analysisids)
                    {
                        XMLResult rslget = anas.getAnalysisInfo(analysisid);
                        if (rslget.IsErrorOccured)
                        {
                            pimp.Result = TestResult.Fail;
                            pimp.Outputs.AddParameter("Import Main Dir", "GetAnalysis Fail", rslget.Message);
                            SaveRound(r);
                            ps.deletePatient(patientid);
                            goto error;
                        }
                        rslget = anas.getAnalysisDescription(analysisid);
                        if (rslget.IsErrorOccured)
                        {
                            pimp.Result = TestResult.Fail;
                            pimp.Outputs.AddParameter("Import Main Dir", "GetAnalysis Fail", rslget.Message);
                            SaveRound(r);
                            ps.deletePatient(patientid);
                            goto error;
                        }
                    }

                    //check list object
                    NewPatientService nps = new NewPatientService();
                    PatientListObjectsRequestType request = new PatientListObjectsRequestType();
                    request.currentSpecified = true;
                    request.current = true;
                    request.patientInternalId = patientid;
                    request.type = PatientListObjectsType.all;
                    PatientListObjectsResponseType response = nps.listObjects(request);
                    //to refresh code 800 to 0
                    response = nps.listObjects(request);

                    if (!nps.LastReturnXMLValidateResult.isValid)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail", "Response is not complied with schema");
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    if (response.status.code != 0)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail,message: ", response.status.message);
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    int expectedcurrentps = int.Parse(ids.ExpectedValues.GetParameter("curpsnum").Value);
                    int expectedcurrentfms = int.Parse(ids.ExpectedValues.GetParameter("curfmsnum").Value);
                    int expectedcurrentanalysis = int.Parse(ids.ExpectedValues.GetParameter("curanalysisnum").Value);
                    if (response.presentationStates.Length != expectedcurrentps)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail,current image count not correct: ", "actural:" + response.presentationStates.Length.ToString() + " expect:" + expectedcurrentps.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }
                    //get PS
                    PresentationStateService pss = new PresentationStateService();
                    foreach (PresentationStateType pst in response.presentationStates)
                    {
                        XMLResult rslget = pss.getPresentationState(pst.uid);
                        if (rslget.IsErrorOccured)
                        {
                            pimp.Result = TestResult.Fail;
                            pimp.Outputs.AddParameter("Import Main Dir", "get PS fail: ", rslget.Message);
                            SaveRound(r);
                            ps.deletePatient(patientid);
                            goto error;
                        }

                    }

                    if (response.analysiss != null)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail,current analysis count not correct: ", "Expect no analysis will be returned");
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    if (response.fmss.Length != expectedcurrentfms)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail,current fms count not correct: ", "actural:" + response.fmss.Length.ToString() + " expect:" + expectedcurrentfms.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    //list noncurrent objects

                    request.currentSpecified = true;
                    request.current = false;
                    request.patientInternalId = patientid;
                    request.type = PatientListObjectsType.all;

                    response = nps.listObjects(request);

                    int expectednoncurrentps = int.Parse(ids.ExpectedValues.GetParameter("noncurpsnum").Value);
                    int expectednoncurrentfms = int.Parse(ids.ExpectedValues.GetParameter("noncurfmsnum").Value);
                    int expectednoncurrentanalysis = int.Parse(ids.ExpectedValues.GetParameter("noncuranalysisnum").Value);
                    if (response.presentationStates.Length != expectednoncurrentps)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail, non current ps count not correct: ", "actual:" + response.presentationStates.Length.ToString() + " expect:" + expectednoncurrentanalysis.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }
                    //get PS
                    foreach (PresentationStateType pst in response.presentationStates)
                    {
                        XMLResult rslget = pss.getPresentationState(pst.uid);
                        if (rslget.IsErrorOccured)
                        {
                            pimp.Result = TestResult.Fail;
                            pimp.Outputs.AddParameter("Import Main Dir", "get PS fail: ", rslget.Message);
                            SaveRound(r);
                            ps.deletePatient(patientid);
                            goto error;
                        }

                    }

                    //check 3d object

                    if (response.volumes.Length != int.Parse(ids.ExpectedValues.GetParameter("expect3dnum").Value))
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "Import 3d objects fail: ", "Count is " + response.volumes.Length.ToString() + ",expect:" + ids.ExpectedValues.GetParameter("expect3dnum").Value);
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    if (response.analysiss.Length != expectednoncurrentanalysis)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail,non current analysis count not correct: ", "actual:" + response.analysiss.Length.ToString() + " expect:" + expectednoncurrentanalysis.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    if (response.fmss.Length != expectednoncurrentfms)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail,non current fms count not correct: ", "actual:" + response.fmss.Length.ToString() + " expect:" + expectednoncurrentfms.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    //Finally the test success
                    pimp.Result = TestResult.Pass;
                    pimp.Outputs.AddParameter("Import Main Dir", "Success", "OK");
                    SaveRound(r);
                    ps.deletePatient(patientid);
                }
                catch (Exception e)
                {
                    ps.deletePatient(patientid);
                    pimp.Result = TestResult.Fail;
                    pimp.Outputs.AddParameter("Import Main Dir", "Fail", "Exception caught,message:" + e.Message);
                    SaveRound(r);
                }

            }
            error:
            Output();
        }