// Case 1643: 1.1.03.12_List Objects - N10 - tag for image with logicon report
        public void Run_Patient_ListObjects_LogiconTagForImage_Case1643()
        {
            int runCount = 0;

            PatientService oldPatientSvc = new PatientService();
            ImportService ims = new ImportService();
            NewPatientService patientSvc = new NewPatientService();
            PatientListObjectsRequestType pListObjects = new PatientListObjectsRequestType();
            PatientListObjectsResponseType rtListObjects = new PatientListObjectsResponseType();
            PatientListObjectsResponseType rtListObjectsAfterProcess = new PatientListObjectsResponseType();

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), ids.Description);

                try
                {
                    #region Initialize test data
                    XMLParameter pCreatePatient = new XMLParameter("patient");
                    string patientID = string.Empty;
                    string filePath = string.Empty;
                    string archivePath = string.Empty;
                    string imageID = string.Empty;
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "createPatient")
                        {
                            pCreatePatient.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "import")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "filePath")
                            {
                                filePath = ids.InputParameters.GetParameter(i).Value;
                            }
                            else if (ids.InputParameters.GetParameter(i).Key == "archivePath")
                            {
                                archivePath = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                    }

                    string tagBeforeProcess = null;
                    string tagAfterProcess = null;
                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Step == "listObjectsBeforeProcess")
                        {
                            tagBeforeProcess = ids.ExpectedValues.GetParameter(i).Value;
                        }
                        else if (ids.ExpectedValues.GetParameter(i).Step == "listObjectsAfterProcess")
                        {
                            tagAfterProcess = ids.ExpectedValues.GetParameter(i).Value;
                        }
                    }
                    #endregion

                    #region Step: Create a patient
                    CheckPoint cpCreate = new CheckPoint("Create Patient", "Create Patient");
                    r.CheckPoints.Add(cpCreate);

                    XMLResult rtCreatePatient = oldPatientSvc.createPatient(pCreatePatient);
                    if (rtCreatePatient.IsErrorOccured)
                    {
                        cpCreate.Result = TestResult.Fail;
                        cpCreate.Outputs.AddParameter("Create returns error:", "Create Patient", rtCreatePatient.Message);
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        patientID = rtCreatePatient.SingleResult;
                        pListObjects.patientInternalId = patientID;
                        pListObjects.current = true;
                        pListObjects.currentSpecified = true;
                        cpCreate.Outputs.AddParameter("Patient ID:", "Create Patient", rtCreatePatient.SingleResult);
                        cpCreate.Result = TestResult.Pass;
                    }
                    #endregion

                    #region Step: Prepare a RVG image
                    CheckPoint cpImport = new CheckPoint("Import Image", "Test import");
                    r.CheckPoints.Add(cpImport);

                    XMLResult rtlImport = ims.importObject(patientID, "", filePath, archivePath, false, "false");
                    if (rtlImport.IsErrorOccured)
                    {
                        cpImport.Result = TestResult.Fail;
                        cpImport.Outputs.AddParameter("import", "Import image fail", rtlImport.ResultContent);
                    }
                    else
                    {
                        cpImport.Result = TestResult.Pass;
                        cpImport.Outputs.AddParameter("import", "Import image OK", rtlImport.ResultContent);
                        imageID = rtlImport.SingleResult;
                    }
                    #endregion

                    #region Step: Check the tag before do logicon processing
                    CheckPoint cpListObjects = new CheckPoint("List Object", "List Object before process");
                    r.CheckPoints.Add(cpListObjects);
                    rtListObjects = patientSvc.listObjects(pListObjects);
                    if (patientSvc.LastReturnXMLValidateResult.isValid && rtListObjects.status.code == 0)
                    {
                        cpListObjects.Result = TestResult.Pass;
                        cpListObjects.Outputs.AddParameter("List Object Return Pass", "List Object", "The web service return is OK!: " + patientSvc.LastReturnXML);
                    }
                    else
                    {
                        cpListObjects.Result = TestResult.Fail;
                        cpListObjects.Outputs.AddParameter("List Object Return Fail", "List Object", "The web service return is ERROR! : " + patientSvc.LastReturnXML);
                        goto CLEANUP;
                    }

                    CheckPoint cpLogiconTag = new CheckPoint("Tag", "Check the logicon tag before processing");
                    if (tagBeforeProcess == rtListObjects.presentationStates[0].image.tags)
                    {
                        cpLogiconTag.Outputs.AddParameter("Check Tag", "List Object", "List Object return tag as expect: " + patientSvc.LastReturnXML);
                        cpLogiconTag.Result = TestResult.Pass;
                    }
                    else
                    {
                        cpLogiconTag.Outputs.AddParameter("List Object Return Result unexpect", "List Object", "List Object return unexpected tag!" + patientSvc.LastReturnXML);
                        cpLogiconTag.Result = TestResult.Fail;
                    }
                    #endregion

                    #region Step: Do logicon processing
                    GenericInstanceService genericInstanceSvc = new GenericInstanceService();
                    genericInstanceSvc.DoLogiconProcess(r, imageID);
                    #endregion

                    #region Step: Check the tag after do logicon processing
                    CheckPoint cpListObjectsAfterProcess = new CheckPoint("List Object", "List Object after process");
                    r.CheckPoints.Add(cpListObjectsAfterProcess);
                    rtListObjectsAfterProcess = patientSvc.listObjects(pListObjects);
                    if (patientSvc.LastReturnXMLValidateResult.isValid && rtListObjectsAfterProcess.status.code == 0)
                    {
                        cpListObjectsAfterProcess.Result = TestResult.Pass;
                        cpListObjectsAfterProcess.Outputs.AddParameter("List Object Return Pass", "List Object", "The web service return is OK!");
                    }
                    else
                    {
                        cpListObjectsAfterProcess.Result = TestResult.Fail;
                        cpListObjectsAfterProcess.Outputs.AddParameter("List Object Return Fail", "List Object", "The web service return is ERROR! : " + patientSvc.LastReturnXML);
                        goto CLEANUP;
                    }

                    CheckPoint cpLogiconTagAfterProcess = new CheckPoint("Tag", "Check the logicon tag before processing");
                    if (tagAfterProcess == rtListObjectsAfterProcess.presentationStates[0].image.tags)
                    {
                        cpListObjectsAfterProcess.Outputs.AddParameter("Check Tag", "List Object", "List Object return tag as expect: " + patientSvc.LastReturnXML);
                        cpListObjectsAfterProcess.Result = TestResult.Pass;
                    }
                    else
                    {
                        cpListObjectsAfterProcess.Outputs.AddParameter("List Object Return Result unexpect", "List Object", "List Object return unexpected tag!" + patientSvc.LastReturnXML);
                        cpListObjectsAfterProcess.Result = TestResult.Fail;
                    }
                    #endregion

                    #region Delete patient
                CLEANUP:
                    CheckPoint cpDelete = new CheckPoint("Delete Patient", "Delete Patient");
                    r.CheckPoints.Add(cpDelete);

                    XMLResult rtDeletePatient = oldPatientSvc.deletePatient(patientID);
                    if (rtDeletePatient.IsErrorOccured)
                    {
                        cpDelete.Result = TestResult.Fail;
                        cpDelete.Outputs.AddParameter("Delete returns error:", "Delete Patient", rtDeletePatient.Message);
                    }
                    else
                    {
                        cpDelete.Outputs.AddParameter("Delete return success:", "Delete Patient", rtDeletePatient.Message);
                        cpDelete.Result = TestResult.Pass;
                    }
                    #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();
        }
        // Case 1527: 1.1.03.03_List Objects - N1 - ALL
        public void Run_Patient_ListObjects_Case1527()
        {
            int runCount = 0;

            NewPatientService nps = new NewPatientService();
            PatientListObjectsRequestType ploReq = new PatientListObjectsRequestType();
            //ploReq.type = PatientListObjectsType.all
            PatientListObjectsResponseType ploRes = new PatientListObjectsResponseType();

            //ploReq.filter = ploFilter;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "ListObject");
                CheckPoint pLo = new CheckPoint("List Object", "Test create");
                r.CheckPoints.Add(pLo);

                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "filter")
                    {
                        if (ids.InputParameters.GetParameter(i).Key == "patientUid")
                        { ploReq.patientInternalId = ids.InputParameters.GetParameter(i).Value; }

                        if (ids.InputParameters.GetParameter(i).Key == "type")
                        {
                            switch (ids.InputParameters.GetParameter(i).Value)
                            {
                                case "all":
                                    ploReq.type = PatientListObjectsType.all;
                                    break;
                                case "fms":
                                    ploReq.type = PatientListObjectsType.fms;
                                    break;
                                case "presentationstate":
                                    ploReq.type = PatientListObjectsType.presentationState;
                                    break;
                                case "analysis":
                                    ploReq.type = PatientListObjectsType.analysis;
                                    break;
                                case "other":
                                    ploReq.type = PatientListObjectsType.other;
                                    break;
                                case "video":
                                    ploReq.type = PatientListObjectsType.video;
                                    break;
                                case "colorimage":
                                    ploReq.type = PatientListObjectsType.colorImage;
                                    break;
                                case "gallery":
                                    ploReq.type = PatientListObjectsType.gallery;
                                    break;
                                case "volume":
                                    ploReq.type = PatientListObjectsType.volume;
                                    break;
                                case "analysis3d":
                                    ploReq.type = PatientListObjectsType.analysis3D;
                                    break;
                            }
                        }

                        if (ids.InputParameters.GetParameter(i).Key == "current" && ids.InputParameters.GetParameter(i).Value == "true")
                            ploReq.current = true;
                        if (ids.InputParameters.GetParameter(i).Key == "current" && ids.InputParameters.GetParameter(i).Value == "false")
                            ploReq.current = false;
                        ploReq.currentSpecified = true;
                    }
                }
                ploRes = nps.listObjects(ploReq);
                //nps.listObjects(ploReq);
                if (ploRes.status.code == 0)
                {
                    pLo.Result = TestResult.Pass;
                    pLo.Outputs.AddParameter("List Object Return Pass", "List Object", "The web service return is OK!");

                }
                else
                {
                    pLo.Result = TestResult.Fail;
                    pLo.Outputs.AddParameter("List Object Return Fail", "List Object", "The web service return is ERROR!");
                }
                string expectString = string.Empty;
                int matchItem = 0;
                for (int j = 0; j < ids.ExpectedValues.Count; j++)
                {
                    if (ids.ExpectedValues.GetParameter(j).Step == "presentationstate")
                    {
                        expectString = ids.ExpectedValues.GetParameter(j).Value;
                        if (ploRes.presentationStates != null && ploRes.presentationStates.Length > 0)
                        {
                            foreach (PresentationStateType ps in ploRes.presentationStates)
                            {
                                if (ps.uid != expectString)
                                    continue;
                                else
                                {
                                    matchItem++;
                                    break;
                                }
                            }
                        }

                    }
                    if (ids.ExpectedValues.GetParameter(j).Step == "fms")
                    {
                        expectString = ids.ExpectedValues.GetParameter(j).Value;
                        if (ploRes.fmss != null && ploRes.fmss.Length > 0)
                        {
                            foreach (FmsType fms in ploRes.fmss)
                            {
                                if (fms.uid != expectString)
                                    continue;
                                else
                                {
                                    matchItem++;
                                    break;
                                }
                            }
                        }
                    }
                    if (ids.ExpectedValues.GetParameter(j).Step == "analysis")
                    {
                        expectString = ids.ExpectedValues.GetParameter(j).Value;
                        if (ploRes.analysiss != null && ploRes.analysiss.Length > 0)
                        {
                            foreach (AnalysisType als in ploRes.analysiss)
                            {
                                if (als.uid != expectString)
                                    continue;
                                else
                                {
                                    matchItem++;
                                    break;
                                }
                            }
                        }
                    }
                    if (ids.ExpectedValues.GetParameter(j).Step == "analysis3d")
                    {
                        expectString = ids.ExpectedValues.GetParameter(j).Value;
                        if (ploRes.analysis3Ds != null && ploRes.analysis3Ds.Length > 0)
                        {
                            foreach (Analysis3DType als in ploRes.analysis3Ds)
                            {
                                if (als.uid != expectString)
                                    continue;
                                else
                                {
                                    matchItem++;
                                    break;
                                }
                            }
                        }
                    }
                    if (ids.ExpectedValues.GetParameter(j).Step == "volume")
                    {
                        expectString = ids.ExpectedValues.GetParameter(j).Value;
                        if (ploRes.volumes != null && ploRes.volumes.Length > 0)
                        {
                            foreach (VolumeType vls in ploRes.volumes)
                            {
                                if (vls.uid != expectString)
                                    continue;
                                else
                                {
                                    matchItem++;
                                    break;
                                }
                            }
                        }
                    }
                    if (ids.ExpectedValues.GetParameter(j).Step == "simpleinstance")
                    {
                        expectString = ids.ExpectedValues.GetParameter(j).Value;
                        if (ploRes.simpleInstances != null && ploRes.simpleInstances.Length > 0)
                        {
                            foreach (SimpleInstanceType sis in ploRes.simpleInstances)
                            {
                                if (sis.uid != expectString)
                                    continue;
                                else
                                {
                                    matchItem++;
                                    break;
                                }
                            }
                        }
                    }
                    if (ids.ExpectedValues.GetParameter(j).Step == "colorimage")
                    {
                        expectString = ids.ExpectedValues.GetParameter(j).Value;
                        if (ploRes.images != null && ploRes.images.Length > 0)
                        {
                            foreach (ImageType img in ploRes.images)
                            {
                                if (img.uid != expectString)
                                    continue;
                                else
                                {
                                    matchItem++;
                                    break;
                                }
                            }
                        }
                    }
                }
                if (ids.ExpectedValues.Count == matchItem)
                {
                    pLo.Outputs.AddParameter("List Object Return as expect", "List Object", "All return is matched!");
                }
                else
                {
                    pLo.Result = TestResult.Fail;
                    pLo.Outputs.AddParameter("List Object Return Result unexpect", "List Object", "The web service return is NOT MATCH EXPECT!");
                }

                SaveRound(r);

            }
            Output();
        }