コード例 #1
0
        public override void Run()
        {
            //create a new patient.
            string newPatientId = CommonLib.CreatePatient();

            ImportService importService = new ImportService();

            for (int i = 1; i <= this.mRepeat; i++)
            {
                LogRecordType lr = new LogRecordType();
                lr.FunctionName = this.mFunctionName;
                lr.Lable = this.mLabel;

                try
                {
                    XMLResult result = importService.importObject(newPatientId, string.Empty, @"C:\PASPerformance\001.png", null,true, string.Empty);
                    lr.ResponseTime = importService.ResponseTime;
                    lr.Passed = !(result.IsErrorOccured);

                    if (!lr.Passed)
                    {
                        this.mFailed++;
                        lr.Message = result.Message;
                    }
                    else
                    {
                        this.mExectuedTime += importService.ResponseTime;
                        lr.Message = result.Message;
                    }
                }
                catch (Exception ex)
                {
                    string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                    lr.Message = ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";
                    lr.Passed = false;
                    this.mFailed ++;
                }

                this.mExecuted = i;
                Log.AddRecord(lr);

                this.RiseSingleCallCompleteEvent(lr.ResponseTime, lr.Passed);
            }

            this.RiseTestCaseCompleteEvent();
        }
コード例 #2
0
        // Case 1562: 1.1.04.05 SetImage_WorkFlow_02_Call setImage when archive path is NOT accessible and then call again when its  accessible
        public void Run_Image_SetInfo_WorkFlow_Case1562()
        {
            int runCount = 0;

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

                try
                {
                    #region Parameter initialize
                    string patientInternalId = string.Empty;
                    string objectFileFullPath = string.Empty;
                    string archivedPath = string.Empty;

                    XMLParameter pSetImageInfo = new XMLParameter("image");
                    XMLParameter pSetImageInfoWithError = new XMLParameter("image");
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "importImage")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "patient_internal_id")
                            {
                                patientInternalId = ids.InputParameters.GetParameter(i).Value;
                            }
                            else if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath")
                            {
                                objectFileFullPath = ids.InputParameters.GetParameter(i).Value;
                            }
                            else if (ids.InputParameters.GetParameter(i).Key == "archivePath")
                            {
                                archivedPath = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "setImageInfo_error")
                        {
                            pSetImageInfoWithError.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "setImageInfo_correct")
                        {
                            pSetImageInfo.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }
                    }
                    #endregion

                    #region Step 1: Call ImportService.importObject to import a image
                    string imageInternalID = string.Empty;
                    string currentPSID = string.Empty;
                    ImportService importService = new ImportService();

                    CheckPoint cpImportImage = new CheckPoint("Import Image", "Call ImportService.importObject to import an archived  image");
                    r.CheckPoints.Add(cpImportImage);

                    XMLResult rtImportImage = importService.importObject(patientInternalId, null, objectFileFullPath, archivedPath, true, "false");
                    if (rtImportImage.IsErrorOccured)
                    {
                        cpImportImage.Result = TestResult.Fail;
                        cpImportImage.Outputs.AddParameter("Import image returns error", "Import image", rtImportImage.Message);

                        SaveRound(r);
                        continue; // There is error when create image, end current run
                    }
                    else
                    {
                        cpImportImage.Result = TestResult.Pass;
                        cpImportImage.Outputs.AddParameter("Import image returns success", "Import image", rtImportImage.Message);

                        imageInternalID = rtImportImage.MultiResults[0].Parameters[0].ParameterValue;
                        currentPSID = rtImportImage.MultiResults[1].Parameters[0].ParameterValue;
                    }
                    #endregion

                    ImageService imageService = new ImageService();

                    #region Step 2-1: Check the getImageDescription return is correct after import image
                    CheckPoint cpGetImageDescriptionAfterImport = new CheckPoint("Check getImageDescription return", "Check getImageDescription return is corerct or not after import image");
                    r.CheckPoints.Add(cpGetImageDescriptionAfterImport);

                    XMLResult rtGetImageDescriptionAfterImport = imageService.getImageDescription(imageInternalID);
                    string imagePathAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("path");
                    string archivedPathAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("archive_path");
                    string archiveTagAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("tags");

                    if (imagePathAfterImport == string.Empty && archivedPathAfterImport == archivedPath && string.IsNullOrEmpty(archiveTagAfterImport))
                    {
                        cpGetImageDescriptionAfterImport.Result = TestResult.Pass;
                        cpGetImageDescriptionAfterImport.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is correct after import image");
                    }
                    else
                    {
                        cpGetImageDescriptionAfterImport.Result = TestResult.Fail;
                        cpGetImageDescriptionAfterImport.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is not correct after import image. Actually get: " + rtGetImageDescriptionAfterImport.ResultContent);
                    }
                    #endregion

                    #region Step 2-2: Check the info is correct in getImageInfo return after import image
                    CheckPoint cpGetImageInfoAfterImport = new CheckPoint("Check getImageInfo return", "Check getImageInfo return is corerct or not import the image");
                    r.CheckPoints.Add(cpGetImageInfoAfterImport);

                    XMLParameter pGetImageInfoAfterImport = new XMLParameter("image");
                    pGetImageInfoAfterImport.AddParameter("internal_id", imageInternalID);
                    XMLResult rtGetImageInfo = imageService.getImageInfo(pGetImageInfoAfterImport);

                    imagePathAfterImport = rtGetImageInfo.DicomArrayResult.GetParameterValueByName("path");
                    archivedPathAfterImport = rtGetImageInfo.DicomArrayResult.GetParameterValueByName("archive_path");
                    archiveTagAfterImport = rtGetImageInfo.DicomArrayResult.GetParameterValueByName("tags");

                    if (string.IsNullOrEmpty(imagePathAfterImport) && string.IsNullOrEmpty(archivedPathAfterImport) && string.IsNullOrEmpty(archiveTagAfterImport))  // archivedPathAfterImport == archivedPath, will be supported in new service
                    {
                        cpGetImageInfoAfterImport.Result = TestResult.Pass;
                        cpGetImageInfoAfterImport.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is correct after import image");
                    }
                    else
                    {
                        cpGetImageInfoAfterImport.Result = TestResult.Fail;
                        cpGetImageInfoAfterImport.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is not correct after import image. Actually get: " + rtGetImageInfo.ResultContent);
                    }
                    #endregion

                    #region Step 3-1: Call imageService.SetImageInfo to save the archived image but the archive path is wrong
                    CheckPoint cpSetImageInfowithError = new CheckPoint("Set Image Info", "Call ImageService.SetImageInfo to save the archived image as normal image, with wrong path");
                    r.CheckPoints.Add(cpSetImageInfowithError);

                    XMLResult rtSetImageInfowithError = imageService.setImageInfo(pSetImageInfoWithError, imageInternalID);

                    if (rtSetImageInfowithError.IsErrorOccured)
                    {
                        cpSetImageInfowithError.Result = TestResult.Pass;
                        cpSetImageInfowithError.Outputs.AddParameter("SetImageInfo returns error as expected", "SetImageInfo", rtSetImageInfowithError.Message);
                    }
                    else
                    {
                        cpSetImageInfowithError.Result = TestResult.Fail;
                        cpSetImageInfowithError.Outputs.AddParameter("SetImageInfo returns success unexpectly", "SetImageInfo", rtSetImageInfowithError.Message);
                    }
                    #endregion

                    System.Threading.Thread.Sleep(1000);

                    #region Step 3-2: Call ImageService.SetImageInfo to save the archived image as normal image again
                    CheckPoint cpSetImageInfo = new CheckPoint("Set Image Info", "Call ImageService.SetImageInfo to save the archived image as normal image again, with correct path");
                    r.CheckPoints.Add(cpSetImageInfo);

                    XMLResult rtSetImageInfo = imageService.setImageInfo(pSetImageInfo, imageInternalID);

                    if (rtSetImageInfo.IsErrorOccured)
                    {
                        cpSetImageInfo.Result = TestResult.Fail;
                        cpSetImageInfo.Outputs.AddParameter("SetImageInfo returns error", "SetImageInfo", rtSetImageInfo.Message);
                    }
                    else
                    {
                        cpSetImageInfo.Result = TestResult.Pass;
                        cpSetImageInfo.Outputs.AddParameter("SetImageInfo returns success", "SetImageInfo", rtSetImageInfo.Message);

                        // Wait the file is transferred to server DB
                        System.Threading.Thread.Sleep(3000);

                        // Below to check the info is correct after setImageInfo. Check points includes:
                        //1. The Image ID and PS ID are not changed
                        //2. GetImageDescription return correct image path and archive path, correct archive flag
                        //3. GetImageInfo return correct image path, correct archive flag
                        //4. Use the image path to check the image file is in server DB
                        //5. The original archived image is not deleted

                        #region Step 4: Check the ps is set, not newly created after set image
                        CheckPoint cpPSID = new CheckPoint("Check PS ID", "Check the PS ID is not changed after call setImageInfo");
                        r.CheckPoints.Add(cpPSID);

                        XMLParameter pListPS = new XMLParameter("filter");
                        pListPS.AddParameter("current", "true");
                        string currentPSIDAfterSet = imageService.listPresentationState(pListPS, imageInternalID).SingleResult; // may need change

                        if (currentPSIDAfterSet == currentPSID)
                        {
                            cpPSID.Result = TestResult.Pass;
                            cpPSID.Outputs.AddParameter("listPresentationState", "Check PS ID", "The PS ID is not changed");
                        }
                        else
                        {
                            cpPSID.Result = TestResult.Fail;
                            cpPSID.Outputs.AddParameter("listPresentationState", "Check PS ID", "The PS ID is changed. Expect: " + currentPSID + "; Actually new PS ID: " + currentPSIDAfterSet);
                        }
                        #endregion

                        string imagePathAfterSet = string.Empty;
                        string archivePathAfterSet = string.Empty;
                        string archiveTagAfterSet = string.Empty;

                        #region Step 5: Check the getImageDescription return is correct after set image
                        CheckPoint cpGetImageDescriptionAfterSet = new CheckPoint("Check getImageDescription return", "Check getImageDescription return is corerct or not after call setImageInfo");
                        r.CheckPoints.Add(cpGetImageDescriptionAfterSet);

                        XMLResult rtGetImageDescriptionAfterSet = imageService.getImageDescription(imageInternalID);
                        imagePathAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("path");
                        archivePathAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("archive_path");
                        archiveTagAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("tags");

                        if (imagePathAfterSet.Contains(imageInternalID) && string.IsNullOrEmpty(archivePathAfterSet) && string.IsNullOrEmpty(archiveTagAfterSet)) // imagePathAfterSet sample: C:/Documents and Settings/All Users/Application Data/TW/PAS/pas_data/patient/03/8af0a7e63310cc65013310d46d0e0003/1956bc28-ca5e-4720-a857-d4de18fc1479/02962f27-e4be-4d59-b112-9663a2f2572b.dcm"
                        {
                            cpGetImageDescriptionAfterSet.Result = TestResult.Pass;
                            cpGetImageDescriptionAfterSet.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is correct after set image");
                        }
                        else
                        {
                            cpGetImageDescriptionAfterSet.Result = TestResult.Fail;
                            cpGetImageDescriptionAfterSet.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is not correct after set image. Actually get: " + rtGetImageDescriptionAfterSet.ResultContent);
                        }
                        #endregion

                        #region Step 6: Check the getImageinfo return is correct after set image
                        CheckPoint cpGetImageInfoAfterSet = new CheckPoint("Check getImageInfo return", "Check getImageInfo return is corerct or not after call setImageInfo");
                        r.CheckPoints.Add(cpGetImageInfoAfterSet);

                        XMLParameter pGetImageInfoAfterSet = new XMLParameter("image");
                        pGetImageInfoAfterSet.AddParameter("internal_id", imageInternalID);
                        XMLResult rtGetImageInfoAfterSet = imageService.getImageInfo(pGetImageInfoAfterSet);

                        imagePathAfterSet = rtGetImageInfoAfterSet.DicomArrayResult.GetParameterValueByName("path");
                        archivePathAfterSet = rtGetImageInfoAfterSet.DicomArrayResult.GetParameterValueByName("archive_path");
                        archiveTagAfterSet = rtGetImageInfoAfterSet.DicomArrayResult.GetParameterValueByName("tags");

                        if (imagePathAfterSet.Contains(imageInternalID) && string.IsNullOrEmpty(archivePathAfterSet) && string.IsNullOrEmpty(archiveTagAfterSet))
                        {
                            cpGetImageInfoAfterSet.Result = TestResult.Pass;
                            cpGetImageInfoAfterSet.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is correct after set image");
                        }
                        else
                        {
                            cpGetImageInfoAfterSet.Result = TestResult.Fail;
                            cpGetImageInfoAfterSet.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is not correct after set image. Actually get: " + rtGetImageInfoAfterSet.ResultContent);
                        }
                        #endregion

                        #region Step 7: Check the file exist in server DB
                        CheckPoint cpImageInDB = new CheckPoint("Check file in DB", "Check the file exist in server DB after call setImageInfo");
                        r.CheckPoints.Add(cpImageInDB);

                        if (Utility.IsImageExistInServerDB(imagePathAfterSet))
                        {
                            cpImageInDB.Result = TestResult.Pass;
                            cpImageInDB.Outputs.AddParameter("Check the file exist in server DB after call setImageInfo", "Check file in DB", "File exist");
                        }
                        else
                        {
                            cpImageInDB.Result = TestResult.Fail;
                            cpImageInDB.Outputs.AddParameter("Check the file exist in server DB after call setImageInfo", "Check file in DB", "File NOT exist");
                        }
                        #endregion

                        #region Step 8: Check the original archived image is not deleted
                        CheckPoint cpOriginalArchivedImage = new CheckPoint("Check original archived file", "Check the original archived image is not deleted after call setImageInfo");
                        r.CheckPoints.Add(cpOriginalArchivedImage);

                        if (System.IO.File.Exists(archivedPath))
                        {
                            cpOriginalArchivedImage.Result = TestResult.Pass;
                            cpOriginalArchivedImage.Outputs.AddParameter("Check the original archived image is not deleted after call setImageInfo", "Check original archived file", "File exist");
                        }
                        else
                        {
                            cpOriginalArchivedImage.Result = TestResult.Fail;
                            cpOriginalArchivedImage.Outputs.AddParameter("Check the original archived image is not deleted after call setImageInfo", "Check original archived file", "File NOT exist");
                        }
                        #endregion
                    }
                    #endregion

                    #region Step 9: Call ImageService.deleteImage to delete the created image
                    CheckPoint cp_DeleteImage = new CheckPoint("Delete Image", "Call imageService.deleteImage to delete the image");
                    r.CheckPoints.Add(cp_DeleteImage);

                    XMLResult rt_DeleteImage = imageService.deleteImage(imageInternalID, new XMLParameter("preferences"));
                    if (rt_DeleteImage.IsErrorOccured)
                    {
                        cp_DeleteImage.Result = TestResult.Fail;
                        cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns error", rt_DeleteImage.Message);
                    }
                    else
                    {
                        cp_DeleteImage.Result = TestResult.Pass;
                        cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns success", rt_DeleteImage.Message);
                    }
                    #endregion

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

            Output();
        }
コード例 #3
0
        // Case 1203: 1.3.10_ImportImage_N07_Import single 8100 dicom thin layer slice
        public void Run_Import_8100Slice_Case1203()
        {
            int runCount = 0;
            string patientUID = string.Empty;
            bool isCreatePatient = false;
            bool isDeletePatient = true;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                isCreatePatient = false;
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Import image");

                ImportService ims = new ImportService();
                XMLParameter pa = new XMLParameter("patient");
                XMLParameter ia = new XMLParameter("import");
                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "create")
                    {
                        pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        isCreatePatient = true;
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "import")
                    {
                        ia.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                }

                string epGetImageInfoImageType = null;
                string epGetImageInfoAnatomicRegion = null;
                string epGetImageInfoAnatomicRegionModifiers = null;
                string epGetPSInfoImageType = null;
                string epGetPSInfoAnatomicRegion = null;
                string epGetPSInfoAnatomicRegionModifiers = null;

                for (int i = 0; i < ids.ExpectedValues.Count; i++)
                {
                    if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo")
                    {
                        switch (ids.ExpectedValues.GetParameter(i).Key)
                        {
                            case "image_type":
                                epGetImageInfoImageType = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_anatomic_region":
                                epGetImageInfoAnatomicRegion = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_anatomic_region_modifiers":
                                epGetImageInfoAnatomicRegionModifiers = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            default:
                                break;
                        }
                    }
                    else if (ids.ExpectedValues.GetParameter(i).Step == "getPresentationStateInfo")
                    {
                        switch (ids.ExpectedValues.GetParameter(i).Key)
                        {
                            case "image_type":
                                epGetPSInfoImageType = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_anatomic_region":
                                epGetPSInfoAnatomicRegion = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_anatomic_region_modifiers":
                                epGetPSInfoAnatomicRegionModifiers = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            default:
                                break;
                        }
                    }
                }

                try
                {
                    PatientService patientSvc = new PatientService();
                    if (isCreatePatient)
                    {
                        CheckPoint pCreate = new CheckPoint("Create Patient", "Test create");
                        r.CheckPoints.Add(pCreate);

                        XMLResult result = patientSvc.createPatient(pa);
                        if (!result.IsErrorOccured)
                        {
                            patientUID = result.SingleResult;
                            pCreate.Result = TestResult.Pass;
                            pCreate.Outputs.AddParameter("Create patient UID", "Create Patient", patientUID);
                        }
                        else
                        {
                            pCreate.Result = TestResult.Fail;
                            pCreate.Outputs.AddParameter("Create patient returns error", "Create Patient", result.ResultContent);
                        }
                    }

                    CheckPoint pImport = new CheckPoint("Import Image", "Test import");
                    r.CheckPoints.Add(pImport);

                    string filePath = string.Empty;
                    string archivePath = string.Empty;
                    bool move = false;
                    for (int c = 0; c < ia.Length; c++)
                    {
                        if (ia.GetParameterName(c) == "path")
                            filePath = ia.GetParameterValue(c);
                        if (ia.GetParameterName(c) == "archivePath")
                            archivePath = ia.GetParameterValue(c);
                        if (ia.GetParameterName(c) == "move")
                        {
                            if (ia.GetParameterValue(c) == "true")
                                move = true;
                        }
                    }

                    XMLResult rslImport = ims.importObject(patientUID, "", filePath, archivePath, move, "false");

                    //import return sample:
                    //   <trophy type="result" version="1.0">
                    //           <status code="0" message="ok" />
                    //           <image><parameter key="internal_id" value="2bfb416b-037e-41e7-aaef-8d2bd08b1ae7" /></image>
                    //           <presentationstate><parameter key="internal_id" value="75675345-a164-4088-b6d3-1b2ae86b703b" /></presentationstate>
                    // </trophy>

                    if (rslImport.IsErrorOccured)
                    {
                        pImport.Result = TestResult.Fail;
                        pImport.Outputs.AddParameter("Import image fail", "Import", rslImport.Message);
                        pImport.Outputs.AddParameter("Import image returns error code", "Import", rslImport.Code.ToString());
                    }
                    else
                    {
                        // Check the return contiains image id and ps id
                        string imageID = null;
                        imageID = rslImport.MultiResults[0].GetParameterValueByName("internal_id"); // image internal_id
                        if (imageID == null || imageID == string.Empty)
                        {
                            pImport.Result = TestResult.Fail;
                            pImport.Outputs.AddParameter("Import image returns wrong image internal id", "Import", rslImport.ResultContent);
                        }

                        string psID = null;
                        psID = rslImport.MultiResults[1].GetParameterValueByName("internal_id"); // ps internal_id
                        if (psID == null || psID == string.Empty)
                        {
                            pImport.Result = TestResult.Fail;
                            pImport.Outputs.AddParameter("import image returns wrong ps internal id", "Import", rslImport.ResultContent);
                        }
                        else
                        {
                            pImport.Result = TestResult.Pass;
                            pImport.Outputs.AddParameter("import image returns OK", "Import", rslImport.ResultContent);
                        }

                        #region Call getImageInfo to check image_type and anatomic_region
                        ImageService imageSvc = new ImageService();
                        PresentationStateService psSvc = new PresentationStateService();

                        XMLParameter pGetImageInfo = new XMLParameter("image");
                        pGetImageInfo.AddParameter("internal_id", imageID);

                        CheckPoint cpGetImageInfo = new CheckPoint("GetImageInfo", "Call GetImageInfo to check the dcm_anatomic_region value");
                        r.CheckPoints.Add(cpGetImageInfo);

                        XMLResult rtGetImageInfo = imageSvc.getImageInfo(pGetImageInfo);
                        if (rtGetImageInfo.IsErrorOccured)
                        {
                            cpGetImageInfo.Result = TestResult.Fail;
                            cpGetImageInfo.Outputs.AddParameter("Get Image Info return error", "getImageInfo", rtGetImageInfo.ResultContent);
                        }
                        else
                        {
                            cpGetImageInfo.Outputs.AddParameter("Get Image Info return success", "getImageInfo", rtGetImageInfo.Message);

                            // Check the image_type, anatomic_region values in return are correct
                            if (!rtGetImageInfo.ResultContent.Contains("parameter key=\"image_type\" value=\"" + epGetImageInfoImageType + "\""))  //parameter key="image_type" value="PANOV6"
                            {
                                cpGetImageInfo.Result = TestResult.Fail;
                                cpGetImageInfo.Outputs.AddParameter("Get Image Info return wrong image_type info", "getImageInfo", rtGetImageInfo.ResultContent);
                            }
                            else if (!rtGetImageInfo.ResultContent.Contains("parameter key=\"dcm_anatomic_region\" value=\"" + epGetImageInfoAnatomicRegion + "\""))  // parameter key="dcm_anatomic_region" value="Jaw region"
                            {
                                cpGetImageInfo.Result = TestResult.Fail;
                                cpGetImageInfo.Outputs.AddParameter("Get Image Info return wrong dcm_anatomic_region info", "getImageInfo", rtGetImageInfo.ResultContent);
                            }
                            else if (!rtGetImageInfo.ResultContent.Contains("parameter key=\"dcm_anatomic_region_modifiers\" value=\"" + epGetImageInfoAnatomicRegionModifiers + "\""))  // parameter key="dcm_anatomic_region_modifiers" value="Molar 1"
                            {
                                cpGetImageInfo.Result = TestResult.Fail;
                                cpGetImageInfo.Outputs.AddParameter("Get Image Info return wrong dcm_anatomic_region_modifiers info", "getImageInfo", rtGetImageInfo.ResultContent);
                            }
                            else
                            {
                                cpGetImageInfo.Result = TestResult.Pass;
                                cpGetImageInfo.Outputs.AddParameter("Get Image Info return correct info", "getImageInfo", rtGetImageInfo.ResultContent);
                            }
                        }

                        XMLParameterCollection pGetPSInfo = new XMLParameterCollection();
                        XMLParameter psList = new XMLParameter("presentationstate");
                        psList.AddParameter("internal_id", psID);
                        pGetPSInfo.Add(psList);

                        CheckPoint cpGetPSInfo = new CheckPoint("GetPSInfo", "Call GetPSInfo to check the dcm_anatomic_region value");
                        r.CheckPoints.Add(cpGetPSInfo);

                        XMLResult rtGetPSInfo = psSvc.getPresentationStateInfo(pGetPSInfo);
                        if (rtGetPSInfo.IsErrorOccured)
                        {
                            cpGetPSInfo.Result = TestResult.Fail;
                            cpGetPSInfo.Outputs.AddParameter("Get PS Info return error", "GetPSInfo", rtGetPSInfo.ResultContent);
                        }
                        else
                        {
                            cpGetPSInfo.Outputs.AddParameter("Get PS Info return success", "GetPSInfo", rtGetPSInfo.Message);

                            // Check the image_type, anatomic_region values in return are correct
                            if (!rtGetPSInfo.ResultContent.Contains("parameter key=\"image_type\" value=\"" + epGetPSInfoImageType + "\"")) //parameter key="image_type" value="PANOV6"
                            {
                                cpGetPSInfo.Result = TestResult.Fail;
                                cpGetPSInfo.Outputs.AddParameter("Get PS Info return wrong image_type info", "GetPSInfo", rtGetPSInfo.ResultContent);
                            }
                            else if (!rtGetPSInfo.ResultContent.Contains("parameter key=\"dcm_anatomic_region\" value=\"" + epGetPSInfoAnatomicRegion + "\""))  // parameter key="dcm_anatomic_region" value="Jaw region"
                            {
                                cpGetPSInfo.Result = TestResult.Fail;
                                cpGetPSInfo.Outputs.AddParameter("Get PS Info return wrong dcm_anatomic_region info", "GetPSInfo", rtGetPSInfo.ResultContent);
                            }
                            else if (!rtGetPSInfo.ResultContent.Contains("parameter key=\"dcm_anatomic_region_modifiers\" value=\"" + epGetPSInfoAnatomicRegionModifiers + "\""))  // parameter key="dcm_anatomic_region_modifiers" value="Molar 1"
                            {
                                cpGetPSInfo.Result = TestResult.Fail;
                                cpGetPSInfo.Outputs.AddParameter("Get PS Info return wrong dcm_anatomic_region_modifiers info", "GetPSInfo", rtGetPSInfo.ResultContent);
                            }
                            else
                            {
                                cpGetPSInfo.Result = TestResult.Pass;
                                cpGetPSInfo.Outputs.AddParameter("Get PS Info return correct info", "GetPSInfo", rtGetPSInfo.ResultContent);
                            }
                        }

                        CheckPoint cpGetPS = new CheckPoint("GetPS", "Call GetPS to check the ps xml info");
                        r.CheckPoints.Add(cpGetPS);

                        XMLResult rtGetPS = psSvc.getPresentationState(psID);
                        if (rtGetPS.IsErrorOccured)
                        {
                            cpGetPS.Result = TestResult.Fail;
                            cpGetPS.Outputs.AddParameter("Get PS return error", "GetPS", rtGetPS.ResultContent);
                        }
                        else
                        {
                            cpGetPS.Outputs.AddParameter("Get PS return success", "GetPS", rtGetPS.Message);

                            if (rtGetPS.ResultContent.Contains("parameter key=\"general.xml\"") && rtGetPS.ResultContent.Contains("parameter key=\"processing.xml\"") && rtGetPS.ResultContent.Contains("parameter key=\"annotation.xml\"")) // Should return empty ps info for this case as there is not
                            {
                                cpGetPS.Result = TestResult.Pass;
                                cpGetPS.Outputs.AddParameter("Get PS return correct info", "GetPS", rtGetPS.ResultContent);
                            }
                            else
                            {
                                cpGetPS.Result = TestResult.Fail;
                                cpGetPS.Outputs.AddParameter("Get PS return wrong content", "GetPS", rtGetPS.ResultContent);
                            }
                        }
                        #endregion
                    }

                    if (isDeletePatient)
                    {
                        CheckPoint cpDelete = new CheckPoint("Delete Patient", "Test delete patient");
                        r.CheckPoints.Add(cpDelete);
                        XMLResult rltDelete = patientSvc.deletePatient(patientUID);
                        if (rltDelete.IsErrorOccured)
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns error", "Delete Patient", rltDelete.Message);
                            cpDelete.Result = TestResult.Fail;
                        }
                        else
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns OK", "Delete Patient", rltDelete.Message);
                            cpDelete.Result = TestResult.Pass;
                        }
                    }

                    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 1566: EK_HI00159159_Create Presentation State
        public void Run_PS_CreatePS_Case1566()
        {
            int runCount = 0;

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Test PresentationState Service: createPresentationState");

                try
                {
                    #region Parameter initialize
                    string imageInternalID = string.Empty;
                    string currentPSID = string.Empty;
                    string patientInternalId = string.Empty;
                    string objectFileFullPath = string.Empty;

                    XMLParameter p_CreatePresentationState = new XMLParameter("presentationstate");

                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "importImage")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "patient_internal_id")
                            {
                                patientInternalId = ids.InputParameters.GetParameter(i).Value;
                            }
                            else if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath")
                            {
                                objectFileFullPath = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "createPresentationState")
                        {
                            p_CreatePresentationState.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }
                    }

                    bool ep_isCurrent = false;
                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Key == "isCurrent")
                        {
                            ep_isCurrent = ids.ExpectedValues.GetParameter(i).Value.Equals("true");
                        }
                    }
                    #endregion

                    ImageService imageService = new ImageService();
                    ImportService importService = new ImportService();
                    PresentationStateService psService = new PresentationStateService();

                    #region Step 1: Call ImportService.importObject to import a image
                    CheckPoint cp_ImportImage = new CheckPoint("Import Image", "Call ImportService.importObject to import a image");
                    r.CheckPoints.Add(cp_ImportImage);

                    XMLResult rt_ImportImage = importService.importObject(patientInternalId, null, objectFileFullPath, null, true, "false");
                    if (rt_ImportImage.IsErrorOccured)
                    {
                        cp_ImportImage.Result = TestResult.Fail;
                        cp_ImportImage.Outputs.AddParameter("Import", "Import image returns error", rt_ImportImage.Message);

                        SaveRound(r);
                        continue; // There is error when create image, end current run
                    }
                    else
                    {
                        cp_ImportImage.Result = TestResult.Pass;
                        cp_ImportImage.Outputs.AddParameter("Import", "Import image returns success", rt_ImportImage.Message);
                        imageInternalID = rt_ImportImage.MultiResults[0].Parameters[0].ParameterValue;
                        currentPSID = rt_ImportImage.MultiResults[1].Parameters[0].ParameterValue;
                    }
                    #endregion

                    #region Step 2: Call PresentationStateService.CreatePresentationState to create a PS for the image
                    string returnPSID = string.Empty;
                    CheckPoint cp_CreatePresentationState = new CheckPoint("Create PS", "Call PresentationStateService.CreatePresentationState to create a new ps");
                    r.CheckPoints.Add(cp_CreatePresentationState);

                    XMLResult rt_CreatePresentationState = psService.createPresentationState(imageInternalID, p_CreatePresentationState);
                    returnPSID = rt_CreatePresentationState.SingleResult;

                    if (rt_CreatePresentationState.IsErrorOccured)
                    {
                        cp_CreatePresentationState.Result = TestResult.Fail;
                        cp_CreatePresentationState.Outputs.AddParameter("create", "Create PS returns error", rt_CreatePresentationState.Message);
                    }
                    else
                    {
                        cp_CreatePresentationState.Result = TestResult.Pass;
                        cp_CreatePresentationState.Outputs.AddParameter("create", "Create PS returns success", rt_CreatePresentationState.Message);

                        CheckPoint cp_PresentationStateID = new CheckPoint("Check PS ID", "Check the retrun PS ID in create PS return");
                        r.CheckPoints.Add(cp_PresentationStateID);

                        if (currentPSID == returnPSID) // Return the old current PS ID, defect EK_HI00159159
                        {
                            cp_PresentationStateID.Result = TestResult.Fail;
                            cp_PresentationStateID.Outputs.AddParameter("Check PS ID", "Create PS returns error", "The return ID is not new as expected after call createPS");
                        }
                        else  //Actually return a new PS ID
                        {
                            //Get new current PS ID
                            XMLParameter pListPS = new XMLParameter("filter");
                            pListPS.AddParameter("current", "true");
                            currentPSID = imageService.listPresentationState(pListPS, imageInternalID).SingleResult;

                            if (ep_isCurrent == (currentPSID == returnPSID))
                            {
                                cp_PresentationStateID.Result = TestResult.Pass;
                                cp_PresentationStateID.Outputs.AddParameter("Check PS ID", "Create PS returns error", "The PS ID is correct after call createPS");
                            }
                            else
                            {
                                cp_PresentationStateID.Result = TestResult.Fail;
                                cp_PresentationStateID.Outputs.AddParameter("Check PS ID", "Create PS returns error", "The PS ID is not correct after call createPS");
                            }
                        }
                    }
                    #endregion

                    #region Step 3: Call ImageService.deleteImage to delete the created image
                    CheckPoint cp_DeleteImage = new CheckPoint("Delete Image", "Call imageService.deleteImage to delete the image");
                    r.CheckPoints.Add(cp_DeleteImage);

                    XMLResult rt_DeleteImage = imageService.deleteImage(imageInternalID, new XMLParameter("preferences"));
                    if (rt_DeleteImage.IsErrorOccured)
                    {
                        cp_DeleteImage.Result = TestResult.Fail;
                        cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns error", rt_DeleteImage.Message);
                    }
                    else
                    {
                        cp_DeleteImage.Result = TestResult.Pass;
                        cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns success", rt_DeleteImage.Message);
                    }
                    #endregion

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

            Output();
        }
        //Case 1073: 1.3.7_GetPresentationStateInfo_N06_Import image and check the DICOM info value is correct in GetPSInfo return
        public void Run_PS_Import_GetPSInfo_Case1073()
        {
            int runCount = 0;

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;

                Round r = this.NewRound(runCount.ToString(), ids.Description);

                try
                {
                    string patientID = null;
                    string objectFileFullPath = null;
                    XMLParameter getPSInfoReturnParam = new XMLParameter("DICOM INFO in getPSInfo return");

                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "import")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "patientInternalID")
                            {
                                patientID = ids.InputParameters.GetParameter(i).Value;
                            }
                            if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath")
                            {
                                objectFileFullPath = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                    }

                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Step == "getPSInfo")
                        {
                            // Add the key to check and the expected value
                            getPSInfoReturnParam.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                        }
                    }

                    #region Step 1: import the image
                    CheckPoint pImport = new CheckPoint("Import", "Import the prepared DICOM image file");
                    r.CheckPoints.Add(pImport);

                    ImportService import = new ImportService();
                    XMLResult importResult = import.importObject(patientID, null, objectFileFullPath, null, true, null);

                    if (importResult.IsErrorOccured)
                    {
                        pImport.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call import service to import DICOM image file returns error.");
                        pImport.Outputs.AddParameter("import", "Import DICOM image file", importResult.Message);

                        SaveRound(r);
                        break; // There is error, end test case
                    }
                    else
                    {
                        pImport.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call import service to import DICOM image file succeeds.");
                        pImport.Outputs.AddParameter("import", "Import DICOM image file", importResult.Message);
                    }
                    #endregion

                    #region Step 2: call getPSInfo
                    CheckPoint pGetPSInfo = new CheckPoint("GetPSInfo", "Get the presentionstate info");
                    r.CheckPoints.Add(pGetPSInfo);

                    PresentationStateService psService = new PresentationStateService();

                    XMLParameterCollection getPSInfoParam = new XMLParameterCollection();

                    for (int i = 0; i < importResult.MultiResults.Count; i++)
                    {
                        if (importResult.MultiResults[i].Name.ToLower() == "presentationstate")
                        {
                            getPSInfoParam.Add(importResult.MultiResults[i]);
                            break; // get the PS ID, end for loop
                        }
                    }

                    XMLResult getPSResult = psService.getPresentationStateInfo(getPSInfoParam);

                    if (getPSResult.IsErrorOccured)
                    {
                        pGetPSInfo.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call getPSInfo returns error.");
                        pGetPSInfo.Outputs.AddParameter("getPSInfo", "Get the presentionstate info", importResult.Message);

                        SaveRound(r);
                        break; // There is error, end test case
                    }
                    else
                    {
                        pGetPSInfo.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call getPSInfo succeeds.");
                        pGetPSInfo.Outputs.AddParameter("import", "Get the presentionstate info", importResult.Message);
                    }
                    #endregion

                    #region Step 3: check the dicom info in getPSInfo return
                    CheckPoint pDICOMInfo = new CheckPoint("DICOMInfo", "Check the DICOM info in the returned presentionstate info");
                    r.CheckPoints.Add(pDICOMInfo);

                    bool isValueEqual = false;
                    bool isKeyShow = false;

                    foreach (XMLParameterNode psNode in getPSInfoReturnParam.Parameters)
                    {
                        isValueEqual = false;
                        isKeyShow = false;

                        int i = 0;
                        for (i = 0; i < getPSResult.DicomArrayResult.Parameters.Count; i++)
                        {
                            if (getPSResult.DicomArrayResult.Parameters[i].ParameterName.ToLower() == "dicom_info")
                            {
                                if (getPSResult.DicomArrayResult.Parameters[i].ParameterValue.Contains("<parameter key=\"" + psNode.ParameterName + "\" value=\"" + psNode.ParameterValue + "\" />"))   // <parameter key="dcm_modality" value="PX" />
                                {
                                    isKeyShow = true;
                                    isValueEqual = true;
                                    break;
                                }
                            }
                            //if (psNode.ParameterName == getPSResult.DicomArrayResult.Parameters[i].ParameterName)  // need change here to check the dicom info
                            //{
                            //    isKeyShow = true;
                            //    isValueEqual = string.Equals(psNode.ParameterValue, getPSResult.DicomArrayResult.Parameters[i].ParameterValue);
                            //    break; // End current for loop to search node
                            //}
                        }

                        if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress
                        {
                            pDICOMInfo.Result = TestResult.Fail;

                            if (isKeyShow)
                            {
                                System.Diagnostics.Debug.Print("The return value in getPSInfo does not match the expected.");
                                pDICOMInfo.Outputs.AddParameter("DICOMInfo", "Check the DICOM info in the returned presentionstate info", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + getPSResult.MultiResults[0].Parameters[i].ParameterValue);
                            }
                            else
                            {
                                System.Diagnostics.Debug.Print("The return value in getPSInfo does not contain the node: " + psNode.ParameterName);
                                pDICOMInfo.Outputs.AddParameter("DICOMInfo", "Check the DICOM info in the returned presentionstate info", "The return value in getPSInfo does not contain the node: " + psNode.ParameterName);
                            }

                            break; // End current foreach loop, not compare the follwing nodes
                        }
                    }

                    if (isValueEqual)
                    {
                        pDICOMInfo.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("The return values in getPSInfo all match the expected.");
                        pDICOMInfo.Outputs.AddParameter("DICOMInfo", "Check the DICOM info in the returned presentionstate info", "The return values in getPSInfo all match the expected");
                    }
                    #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 992: 1.3.7_GetPresentationStateDescription_N02_WhenPSNotExist
        public void Run_PS_GetPresentationStateDescription_PSNotExist_Case992()
        {
            int runCount = 0;
            string patientUID = string.Empty;
            bool isCreatePatient = false;
            bool isDeletePatient = false;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                isCreatePatient = false;
                isDeletePatient = false;
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Import image");
                CheckPoint pCreate = new CheckPoint("Create Patient", "Test create");
                r.CheckPoints.Add(pCreate);
                PatientService ps = new PatientService();
                ImportService ims = new ImportService();
                PresentationStateService pss = new PresentationStateService();

                XMLParameter pa = new XMLParameter("patient");
                XMLParameter ia = new XMLParameter("import");
                //XMLParameter psa = new XMLParameter("presentationstate");

                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "create")
                    {
                        pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        isCreatePatient = true;
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "import")
                    {
                        ia.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "delete")
                    {
                        isDeletePatient = true;
                    }
                }
                if (isCreatePatient)
                {
                    XMLResult result = ps.createPatient(pa);
                    if (!result.IsErrorOccured)
                    {
                        patientUID = result.SingleResult;
                        pCreate.Result = TestResult.Pass;
                        pCreate.Outputs.AddParameter("create", "Create patient UID", patientUID);
                    }
                }

                CheckPoint pImport = new CheckPoint("Import Image", "Test import");
                r.CheckPoints.Add(pImport);

                string filePath = string.Empty;
                string archivePath = string.Empty;
                bool move = false;
                for (int c = 0; c < ia.Length; c++)
                {
                    if (ia.GetParameterName(c) == "path")
                        filePath = ia.GetParameterValue(c);
                    if (ia.GetParameterName(c) == "archivePath")
                        archivePath = ia.GetParameterValue(c);
                    if (ia.GetParameterName(c) == "move")
                    {
                        if (ia.GetParameterValue(c) == "true")
                            move = true;
                    }
                }

                XMLResult rslImport = ims.importObject(patientUID, "", filePath, archivePath, move, "false");

                if (rslImport.IsErrorOccured)
                {
                    pImport.Result = TestResult.Fail;
                    pImport.Outputs.AddParameter("import", "Import image fail", rslImport.Message);
                    pImport.Outputs.AddParameter("import", "Import image error code", rslImport.Code.ToString());
                }
                else
                {
                    pImport.Result = TestResult.Pass;
                    pImport.Outputs.AddParameter("import", "Import image OK", rslImport.Message);

                    for (int findPs = 0; findPs < rslImport.MultiResults.Count; findPs++)
                    {
                        if (rslImport.MultiResults[findPs].Name == "presentationstate")
                        {
                            string psUID = rslImport.MultiResults[findPs].Parameters[0].ParameterValue;
                            XMLResult psreturn = pss.getPresentationState(psUID);

                            CheckPoint pGetPS = new CheckPoint("Get Presentation State", "PS Desc");
                            r.CheckPoints.Add(pGetPS);
                            if (psreturn.MultiResults.Count == 1 && !string.IsNullOrEmpty(psreturn.MultiResults[0].GetParameterValueByName("image_internal_id")) && string.IsNullOrEmpty(psreturn.MultiResults[0].GetParameterValueByName("general.xml")) && string.IsNullOrEmpty(psreturn.MultiResults[0].GetParameterValueByName("processing.xml")) && string.IsNullOrEmpty(psreturn.MultiResults[0].GetParameterValueByName("annotation.xml")))
                            {
                                pGetPS.Result = TestResult.Pass;
                                pGetPS.Outputs.AddParameter("get presentation state", "get presentation state as expect", psreturn.ResultContent);
                            }
                            else
                            {
                                pGetPS.Result = TestResult.Fail;
                                pGetPS.Outputs.AddParameter("get presentation state", "get presentation state not as expect", psreturn.ResultContent);
                            }
                        }
                    }
                }
                if (isDeletePatient)
                {
                    XMLResult rltDelete = ps.deletePatient(patientUID);
                    if (!rltDelete.IsErrorOccured)
                    {
                        pCreate.Outputs.AddParameter("Delete created patient", "Delete Patient", rltDelete.Message);
                    }
                }
                SaveRound(r);
            }
            Output();
        }
コード例 #7
0
        // 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();
        }
コード例 #8
0
        public override void Run()
        {
            string newPSId = string.Empty;
            string setPSInfoString = string.Empty;
            string getPSInfoString = string.Empty;
            PresentationStateService psService = new PresentationStateService();

            try
            {
                //create a new patient and import a new image to get a new ps id.
                string newPatientId = CommonLib.CreatePatient();
                ImportService import = new ImportService();
                XMLResult r = import.importObject(newPatientId, string.Empty, @"c:\PASPerformance\001.png", null, true, string.Empty);
                newPSId = r.MultiResults[1].GetParameterValueByIndex(0);
                XMLParameter psId = new XMLParameter("presentationstate");
                psId.AddParameter("internal_id", newPSId);
                getPSInfoString = psId.GenerateXML();
                XMLParameterCollection c = new XMLParameterCollection();
                c.Add(psId);
                setPSInfoString = psService.getPresentationStateInfo(c).ArrayResult.GenerateXML();
            }
            catch (Exception ex)
            {
                LogRecordType lr = new LogRecordType();
                lr.FunctionName = this.mFunctionName;
                lr.Lable = this.mLabel;
                string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                lr.Message = ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";
                lr.Passed = false;

                Log.AddRecord(lr);

                this.RiseSingleCallCompleteEvent(lr.ResponseTime, lr.Passed, true);
                this.RiseTestCaseCompleteEvent();

                this.mExecuted = this.mRepeat;
                this.mFailed = this.mRepeat;
                return;
            }

            double userCaseResponse=0;

            for (int i = 1; i <= this.mRepeat; i++)
            {
                LogRecordType lr = new LogRecordType();
                lr.Lable = this.mLabel;
                lr.FunctionName = this.mFunctionName;

                try
                {
                    //get ps info
                    XMLResult getResult=new XMLResult (psService.InvokeMethod ("getPresentationStateInfo", new object []{getPSInfoString }));

                    //if get presentation infor failed.
                    if (getResult.IsErrorOccured)
                    {
                        lr.Message = "Get PS info faild. Message: " + getResult.Message;
                        lr.ResponseTime = psService.ResponseTime;
                        lr.Passed = false;
                        Log.AddRecord(lr);
                        this.mFailed++;
                        continue;
                    }
                    else  //if get ps info successed
                    {
                        userCaseResponse = psService.ResponseTime;
                    }

                    //set ps info
                    XMLResult setResult = new XMLResult(psService.InvokeMethod("setPresentationStateInfo", new object[] { setPSInfoString, newPSId}));

                    //if set ps info failed
                    if (setResult.IsErrorOccured)
                    {
                        lr.Message = "Set PS info failed. Message: " + setResult.Message;
                        lr.ResponseTime = psService.ResponseTime;
                        lr.Passed = false;
                        Log.AddRecord(lr);
                        this.mFailed++;
                        continue;
                    }
                    else  //if set ps info successed.
                    {
                        userCaseResponse += psService.ResponseTime;
                    }

                    lr.ResponseTime = userCaseResponse;
                    this.ExecutedTime += userCaseResponse;
                }
                catch (Exception ex)
                {
                    this.mFailed++;
                    lr.Passed = false;
                    string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                    lr.Message = ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";
                }

                this.mExecuted = i;
                Log.AddRecord(lr);

                this.RiseSingleCallCompleteEvent(lr.ResponseTime, lr.Passed);
            }

            this.RiseTestCaseCompleteEvent();
        }
コード例 #9
0
        //Case 512: 1.2.3_ImportZip_Normal
        public void Run_Import_Zip_Case512()
        {
            int runCount = 0;
            string patientUID = string.Empty;
            bool isCreatePatient = false;
            bool isDeletePatient = false;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                isCreatePatient = false;
                isDeletePatient = false;
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Import image");
                CheckPoint pCreate = new CheckPoint("Create Patient", "Test create");
                r.CheckPoints.Add(pCreate);
                PatientService ps = new PatientService();
                ImportService ims = new ImportService();
                PresentationStateService pss = new PresentationStateService();

                XMLParameter pa = new XMLParameter("patient");
                XMLParameter ia = new XMLParameter("import");
                XMLParameter ObjFilter = new XMLParameter("filter");
                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "create")
                    {
                        pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        isCreatePatient = true;
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "import")
                    {
                        ia.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "delete")
                    {
                        isDeletePatient = true;
                    }
                }
                if (isCreatePatient)
                {
                    XMLResult result = ps.createPatient(pa);
                    if (!result.IsErrorOccured)
                    {
                        patientUID = result.SingleResult;
                        pCreate.Outputs.AddParameter("create", "Create patient UID", patientUID);
                        pCreate.Result = TestResult.Pass;
                    }
                }

                CheckPoint pImport = new CheckPoint("Import Image", "Test import");
                r.CheckPoints.Add(pImport);

                string filePath = string.Empty;
                string archivePath = string.Empty;
                bool move = false;
                for (int c = 0; c < ia.Length; c++)
                {
                    if (ia.GetParameterName(c) == "path")
                        filePath = ia.GetParameterValue(c);
                    if (ia.GetParameterName(c) == "archivePath")
                        archivePath = ia.GetParameterValue(c);
                    if (ia.GetParameterName(c) == "move")
                    {
                        if (ia.GetParameterValue(c) == "true")
                            move = true;
                    }
                }

                XMLResult rslImport = ims.importObject(patientUID, "", filePath, archivePath, move, "false");
                if (rslImport.IsErrorOccured)
                {
                    pImport.Result = TestResult.Fail;
                    pImport.Outputs.AddParameter("import", "Import image fail", rslImport.Message);
                    pImport.Outputs.AddParameter("import", "Import image error code", rslImport.Code.ToString());
                }
                else
                {
                    pImport.Result = TestResult.Pass;
                    pImport.Outputs.AddParameter("import", "Import image OK", rslImport.Message);

                    ObjFilter.AddParameter("patient_internal_id", patientUID);
                    ObjFilter.AddParameter("type", "presentationstate");
                    ObjFilter.AddParameter("current", "true");
                    XMLResult listObjcetRsl = ps.listObjects(ObjFilter);

                    CheckPoint pListObject = new CheckPoint("List Image", "Test list object");
                    r.CheckPoints.Add(pListObject);

                    if (listObjcetRsl.IsErrorOccured)
                    {
                        pListObject.Result = TestResult.Fail;
                        pListObject.Outputs.AddParameter("Erron in List Object", "List Object", "List Patient Presentation State Error");
                    }
                    else
                    {
                        pListObject.Outputs.AddParameter("List Object return content", "List Object", listObjcetRsl.ResultContent);
                        if (listObjcetRsl.ArrayResult.Length == 3)
                        {
                            bool isMatchXML = true;
                            for (int index = 0; index < listObjcetRsl.ArrayResult.Parameters.Count; index++)
                            {
                                XMLResult getPSRsl = pss.getPresentationState(listObjcetRsl.ArrayResult.Parameters[index].ParameterValue);
                                if (getPSRsl.ArrayResult.Parameters.Count != 4)
                                {
                                    isMatchXML = false;
                                    pListObject.Outputs.AddParameter("Get PS return content", "Get PS Description", getPSRsl.ResultContent);
                                    break;
                                }
                            }
                            if (isMatchXML)
                            {
                                pListObject.Result = TestResult.Pass;
                            }
                            else
                            {
                                pListObject.Result = TestResult.Fail;
                                pListObject.Outputs.AddParameter("Get PS description error", "Get PS Description", "Not return all xml and image id");
                            }
                        }
                        else
                        {
                            pListObject.Result = TestResult.Fail;
                            pListObject.Outputs.AddParameter("The PS count not match", "Get All PS Description", "Not three PS be retrieve.");
                        }
                    }
                }
                if (isDeletePatient)
                {
                    XMLResult rslDelete = ps.deletePatient(patientUID);
                    if (!rslDelete.IsErrorOccured)
                    {
                        pImport.Outputs.AddParameter("Delete created patient", "Delete Patient", rslDelete.ResultContent);
                    }
                }
                SaveRound(r);
            }
            Output();
        }
コード例 #10
0
        // Case 1048: 1.3.10_ImportImage_N05_TW5Tiff_FMS
        public void Run_Import_TW5Tiff_Case1048()
        {
            int runCount = 0;
            string patientUID = string.Empty;
            bool isCreatePatient = false;
            bool isDeletePatient = true;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                isCreatePatient = false;
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Import image");

                ImportService ims = new ImportService();
                XMLParameter pa = new XMLParameter("patient");
                XMLParameter ia = new XMLParameter("import");
                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "create")
                    {
                        pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        isCreatePatient = true;
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "import")
                    {
                        ia.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                }

                XMLParameter epImport = new XMLParameter();

                for (int i = 0; i < ids.ExpectedValues.Count; i++)
                {
                    if (ids.ExpectedValues.GetParameter(i).Step == "import")
                    {
                        epImport.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                    }
                }

                try
                {
                    PatientService patientSvc = new PatientService();
                    if (isCreatePatient)
                    {
                        CheckPoint pCreate = new CheckPoint("Create Patient", "Test create");
                        r.CheckPoints.Add(pCreate);

                        XMLResult result = patientSvc.createPatient(pa);
                        if (!result.IsErrorOccured)
                        {
                            patientUID = result.SingleResult;
                            pCreate.Result = TestResult.Pass;
                            pCreate.Outputs.AddParameter("Create patient UID", "Create Patient", patientUID);
                        }
                        else
                        {
                            pCreate.Result = TestResult.Fail;
                            pCreate.Outputs.AddParameter("Create patient returns error", "Create Patient", result.ResultContent);
                        }
                    }

                    CheckPoint pImport = new CheckPoint("Import Image", "Test import");
                    r.CheckPoints.Add(pImport);

                    string filePath = string.Empty;
                    string archivePath = string.Empty;
                    bool move = false;
                    for (int c = 0; c < ia.Length; c++)
                    {
                        if (ia.GetParameterName(c) == "path")
                            filePath = ia.GetParameterValue(c);
                        if (ia.GetParameterName(c) == "archivePath")
                            archivePath = ia.GetParameterValue(c);
                        if (ia.GetParameterName(c) == "move")
                        {
                            if (ia.GetParameterValue(c) == "true")
                                move = true;
                        }
                    }

                    XMLResult rslImport = ims.importObject(patientUID, "", filePath, archivePath, move, "false");
                    /************************************************
                    import return sample:
                        - <trophy type="result" version="1.0">
                          <status code="0" message="ok" />
                        - <fms>
                          <parameter key="internal_id" value="79d96c5c-1ec5-4408-8709-622c0bd4a951" />
                          </fms>
                        - <image>
                          <parameter key="internal_id" value="1547aca3-7d98-4282-bd4c-e4e9547e126b" />
                          </image>
                        - <presentationstate>
                          <parameter key="internal_id" value="f0c4ed26-e41f-45dc-9f03-41e982d70b23" />
                          </presentationstate>
                        - <image>
                          <parameter key="internal_id" value="14831be6-ca69-417c-957f-c7f3a493cc70" />
                          </image>
                        - <presentationstate>
                          <parameter key="internal_id" value="a640fe70-7ad9-45c4-b68c-1f0ba2c503f1" />
                          </presentationstate>
                        - <image>
                          <parameter key="internal_id" value="d8b65e88-a9c7-4e7b-baac-05da4982f6be" />
                          </image>
                        - <presentationstate>
                          <parameter key="internal_id" value="18834173-1ce8-4d6e-9ce7-daf1745761e0" />
                          </presentationstate>
                        - <image>
                          <parameter key="internal_id" value="6608a41f-de96-4d0b-8391-6f16cf9fb812" />
                          </image>
                        - <presentationstate>
                          <parameter key="internal_id" value="c1b10673-a4ba-4ee9-824c-0431926b3f27" />
                          </presentationstate>
                        - <other>
                          <parameter key="total" value="4" />
                          <parameter key="success" value="4" />
                          </other>
                          </trophy>
                     * **********************************************/

                    if (rslImport.IsErrorOccured)
                    {
                        pImport.Result = TestResult.Fail;
                        pImport.Outputs.AddParameter("Import image fail", "Import", rslImport.Message);
                        pImport.Outputs.AddParameter("Import image returns error code", "Import", rslImport.Code.ToString());
                    }
                    else
                    {
                        // Check the return contiains image id and ps id
                        string fmsID = null;
                        fmsID = rslImport.MultiResults[0].GetParameterValueByName("internal_id"); // image internal_id
                        if (fmsID == null || fmsID == string.Empty)
                        {
                            pImport.Result = TestResult.Fail;
                            pImport.Outputs.AddParameter("Import image returns wrong FMS internal id", "Import", rslImport.ResultContent);
                        }

                        #region Call getImageInfo to check expected key and value

                        //Check the return info contain the expected key and value: parameter key="XXX" value="XXX"
                        foreach (XMLParameterNode node in epImport.Parameters)
                        {
                            if (!rslImport.ResultContent.Contains("parameter key=\"" + node.ParameterName + "\" value=\"" + node.ParameterValue + "\""))
                            {
                                pImport.Result = TestResult.Fail;
                                pImport.Outputs.AddParameter("Import image returns wrong key-value info for: " + node.ParameterName, "Import", rslImport.ResultContent);
                                continue;
                            }
                            else
                            {
                                pImport.Outputs.AddParameter("Import image returns correct key-value info for: " + node.ParameterName, "Import", "ok");
                            }
                        }

                        if (pImport.Result != TestResult.Fail)
                        {
                            pImport.Result = TestResult.Pass;
                            pImport.Outputs.AddParameter("Import image Info returns all correct info", "Import", rslImport.ResultContent);
                        }

                        #endregion
                    }

                    if (isDeletePatient)
                    {
                        CheckPoint cpDelete = new CheckPoint("Delete Patient", "Test delete patient");
                        r.CheckPoints.Add(cpDelete);
                        XMLResult rltDelete = patientSvc.deletePatient(patientUID);
                        if (rltDelete.IsErrorOccured)
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns error", "Delete Patient", rltDelete.Message);
                            cpDelete.Result = TestResult.Fail;
                        }
                        else
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns OK", "Delete Patient", rltDelete.Message);
                            cpDelete.Result = TestResult.Pass;
                        }
                    }

                    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();
        }
コード例 #11
0
        //Case 981: 1.3.10_ImportImage_N01_WithNotification
        public void Run_Import_TestNotification_Case981()
        {
            int runCount = 0;
            string patientUID = string.Empty;
            bool isCreatePatient = false;
            bool isDeletePatient = false;
            string stopMessageType = "teststop";
            string stopMessageContent = "teststop";
            //LaunchNotification();

            NotificationSim.ReceiveNotification rn = new NotificationSim.ReceiveNotification();
            //NotificationSim.ReceiveNotification rn = new NotificationSim.ReceiveNotification("10.112.39.167");
            System.Collections.Generic.List<string> rms = new System.Collections.Generic.List<string>();
            rms.Add("topic.patientCreated");
            rms.Add("topic.acquisitionCompleted");
            rms.Add("topic.imageCreated");
            rms.Add("topic.presentationStateModified");
            rn.startListon(rms, stopMessageType, stopMessageContent);

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                isCreatePatient = false;
                isDeletePatient = false;
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Import image");
                CheckPoint pCreate = new CheckPoint("Create Patient", "Test create");
                r.CheckPoints.Add(pCreate);
                PatientService ps = new PatientService();
                ImportService ims = new ImportService();
                ApplicationService ass = new ApplicationService();
                XMLParameter pa = new XMLParameter("patient");
                XMLParameter ia = new XMLParameter("import");
                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "create")
                    {
                        pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        isCreatePatient = true;
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "import")
                    {
                        ia.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "delete")
                    {
                        isDeletePatient = true;
                    }
                }
                if (isCreatePatient)
                {
                    XMLResult result = ps.createPatient(pa);
                    if (!result.IsErrorOccured)
                    {
                        patientUID = result.SingleResult;
                        pCreate.Result = TestResult.Pass;
                        pCreate.Outputs.AddParameter("create", "Create patient UID", patientUID);
                    }
                }
                System.Threading.Thread.Sleep(500);

                CheckPoint pImport = new CheckPoint("Import Image", "Test import");
                r.CheckPoints.Add(pImport);

                string filePath = string.Empty;
                string archivePath = string.Empty;
                for (int c = 0; c < ia.Length; c++)
                {
                    if (ia.GetParameterName(c) == "path")
                        filePath = ia.GetParameterValue(c);
                    if (ia.GetParameterName(c) == "archivepath")
                        archivePath = ia.GetParameterValue(c);
                }

                XMLResult rslImport = ims.importObject(patientUID, "", filePath, archivePath, true, "false");
                if (rslImport.IsErrorOccured)
                {
                    pImport.Result = TestResult.Fail;
                    pImport.Outputs.AddParameter("import", "Import image fail", rslImport.Message);
                    pImport.Outputs.AddParameter("import", "Import image error code", rslImport.Code.ToString());
                }
                else
                {
                    pImport.Result = TestResult.Pass;
                    pImport.Outputs.AddParameter("import", "Import image OK", rslImport.Message);
                }

                System.Threading.Thread.Sleep(500);
                ass.sendGenericNotification(stopMessageType, stopMessageContent);
                System.Threading.Thread.Sleep(500);

                int getn = rn.getNotificationNumber();

                CheckPoint pNotification = new CheckPoint("Receive Notification", "import message");
                r.CheckPoints.Add(pNotification);

                if (getn == 3)
                {
                    pNotification.Result = TestResult.Pass;
                    foreach (string mmm in rn.getNotificationContent())
                        pNotification.Outputs.AddParameter("Notification message", "Content:", mmm);
                }
                else
                {
                    pNotification.Result = TestResult.Fail;
                    pNotification.Outputs.AddParameter("Message", "Content:", "miss message on receive");
                }
                if (isDeletePatient)
                {
                    XMLResult rslDelete = ps.deletePatient(patientUID);
                    if (!rslDelete.IsErrorOccured)
                    {
                        pNotification.Outputs.AddParameter("Delete created patient", "Delete Patient", rslDelete.ResultContent);
                    }
                }
                SaveRound(r);
            }
            Output();
        }
コード例 #12
0
        // Case 1658: 1.2.3_ImportImage_SimpleInstance_large file
        public void Run_Import_SimpleInstance_LargeFile_Case1658()
        {
            int runCount = 0;
            string patientUID = string.Empty;
            bool isCreatePatient = false;
            bool isDeletePatient = true;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                isCreatePatient = false;
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Import image");

                string instanceID = null;

                PatientService ps = new PatientService();
                ImportService ims = new ImportService();
                XMLParameter pa = new XMLParameter("patient");
                XMLParameter ia = new XMLParameter("import");
                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "create")
                    {
                        pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        isCreatePatient = true;
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "import")
                    {
                        ia.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                }

                XMLParameter epGetInstanceInfo = new XMLParameter();
                for (int i = 0; i < ids.ExpectedValues.Count; i++)
                {
                    if (ids.ExpectedValues.GetParameter(i).Step == "getInstanceInfo")
                    {
                        epGetInstanceInfo.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                    }
                }

                try
                {
                    if (isCreatePatient)
                    {
                        CheckPoint pCreate = new CheckPoint("Create Patient", "Test create");
                        r.CheckPoints.Add(pCreate);

                        XMLResult result = ps.createPatient(pa);
                        if (!result.IsErrorOccured)
                        {
                            patientUID = result.SingleResult;
                            pCreate.Result = TestResult.Pass;
                            pCreate.Outputs.AddParameter("Create patient UID", "Create Patient", patientUID);
                        }
                    }

                    CheckPoint pImport = new CheckPoint("Import Image", "Test import");
                    r.CheckPoints.Add(pImport);

                    string filePath = string.Empty;
                    string archivePath = string.Empty;
                    bool move = false;
                    for (int c = 0; c < ia.Length; c++)
                    {
                        if (ia.GetParameterName(c) == "path")
                            filePath = ia.GetParameterValue(c);
                        if (ia.GetParameterName(c) == "archivePath")
                            archivePath = ia.GetParameterValue(c);
                        if (ia.GetParameterName(c) == "move")
                        {
                            if (ia.GetParameterValue(c) == "true")
                                move = true;
                        }
                    }

                    XMLResult rslImport = ims.importObject(patientUID, "", filePath, archivePath, move, "false");

                    /*****************************************
                     *  import simple instance return sample:
                     * <trophy type="result" version="1.0">
                     * <status code="0" message="ok" />
                     * <instance><parameter key="internal_id" value="1f678090-2c54-4128-8d13-833645ac7483" /></instance>
                     * </trophy>
                     * ****************************************/

                    if (rslImport.IsErrorOccured)
                    {
                        pImport.Result = TestResult.Fail;
                        pImport.Outputs.AddParameter("Import simple instance fail", "Import", rslImport.Message);
                        pImport.Outputs.AddParameter("Import simple instance returns error code", "Import", rslImport.Code.ToString());
                    }
                    else
                    {
                        // Check the return contiains instance id
                        instanceID = rslImport.MultiResults[0].GetParameterValueByName("internal_id"); // image internal_id
                        if (instanceID == null || instanceID == string.Empty)
                        {
                            pImport.Result = TestResult.Fail;
                            pImport.Outputs.AddParameter("Import simple instance returns wrong instance internal id", "Import", rslImport.ResultContent);
                        }
                        else
                        {
                            pImport.Result = TestResult.Pass;
                            pImport.Outputs.AddParameter("import simple instance returns OK", "Import", rslImport.ResultContent);
                        }
                    }

                    #region Call getInstanceInfo to check expected key and value
                    SimpleInstanceService simpleInstanceSvc = new SimpleInstanceService();

                    CheckPoint cpGetInstanceInfo = new CheckPoint("GetInstanceInfo", "Call GetInstanceInfo to check the return value");
                    r.CheckPoints.Add(cpGetInstanceInfo);

                    XMLResult rtGetInstanceInfo = simpleInstanceSvc.getInstanceInfo(instanceID);
                    if (rtGetInstanceInfo.IsErrorOccured)
                    {
                        cpGetInstanceInfo.Result = TestResult.Fail;
                        cpGetInstanceInfo.Outputs.AddParameter("Get Instance Info return error", "getInstanceInfo", rtGetInstanceInfo.ResultContent);
                    }
                    else
                    {
                        cpGetInstanceInfo.Outputs.AddParameter("Get Instance Info return success", "getInstanceInfo", rtGetInstanceInfo.Message);

                        //Check the return info contain the expected key and value: parameter key="XXX" value="XXX"
                        foreach (XMLParameterNode node in epGetInstanceInfo.Parameters)
                        {
                            if (!rtGetInstanceInfo.ResultContent.Contains("parameter key=\"" + node.ParameterName + "\" value=\"" + node.ParameterValue + "\""))
                            {
                                cpGetInstanceInfo.Result = TestResult.Fail;
                                cpGetInstanceInfo.Outputs.AddParameter("Get Instance Info returns wrong key-value info for: " + node.ParameterName, "GetInstanceInfo", rtGetInstanceInfo.ResultContent);
                                continue;
                            }
                            else
                            {
                                cpGetInstanceInfo.Outputs.AddParameter("Get Instance Info returns correct key-value info for: " + node.ParameterName, "GetInstanceInfo", "ok");
                            }
                        }

                        if (cpGetInstanceInfo.Result != TestResult.Fail)
                        {
                            cpGetInstanceInfo.Result = TestResult.Pass;
                            cpGetInstanceInfo.Outputs.AddParameter("Get Instance Info return all correct info", "GetInstanceInfo", rtGetInstanceInfo.ResultContent);
                        }
                    }
                    #endregion

                    System.Threading.Thread.Sleep(10000);

                    if (isDeletePatient)
                    {
                        CheckPoint cpDelete = new CheckPoint("Delete Patient", "Test delete patient");
                        r.CheckPoints.Add(cpDelete);
                        XMLResult rltDelete = ps.deletePatient(patientUID);
                        if (rltDelete.IsErrorOccured)
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns error", "Delete Patient", rltDelete.Message);
                            cpDelete.Result = TestResult.Fail;
                        }
                        else
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns OK", "Delete Patient", rltDelete.Message);
                            cpDelete.Result = TestResult.Pass;
                        }
                    }

                    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();
        }
コード例 #13
0
        //Case 1599: 1.1.06.22_ImportDir_MoveCopyOption_N02
        public void Run_Import_ImportDir_MoveCopyOption_Case1599()
        {
            int runCount = 0;
            foreach (InputDataSet ids in this.Input.DataSets)
            {

                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Move Copy Check for importdir");
                CheckPoint pimp = new CheckPoint("ImportDirMoveCopy", "Move Copy Check for importdir");
                r.CheckPoints.Add(pimp);

                string moveflag = ids.InputParameters.GetParameter("move" + runCount.ToString()).Value;
                string flag = ids.InputParameters.GetParameter("flag" + runCount.ToString()).Value;

                string kdis6_path = ids.InputParameters.GetParameter("kdis6_path" + runCount.ToString()).Value;

                PatientService ps = new PatientService();
                XMLParameter cInputPatient = new XMLParameter("patient");
                cInputPatient.AddParameter("first_name", "test");
                cInputPatient.AddParameter("last_name", "importdir_move");
                XMLResult rslcreate = ps.createPatient(cInputPatient);

                if (rslcreate.IsErrorOccured)
                {
                    pimp.Result = TestResult.Fail;
                    pimp.Outputs.AddParameter("create patient", "fail", rslcreate.Message);
                    SaveRound(r);
                    continue;
                }

                string patientid = rslcreate.SingleResult;

                try
                {

                    ImportService imps = new ImportService();

                    Utility.SetCSDMConfig(CSDMConfigSection.remote, "moveWhenPostImport", moveflag);
                    Utility.RestartCSDM(20000);

                    XMLResult rslimp = imps.importDir(patientid, kdis6_path, flag);

                    if (rslimp.Code != 800)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("import dir", "fail", rslimp.Message);
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    System.Threading.Thread.Sleep(2000);

                    int expectfilenum = int.Parse(ids.ExpectedValues.GetParameter("expectfilenum" + runCount.ToString()).Value);
                    int filenum = Utility.getFileNumOfDirectory(kdis6_path);

                    if (filenum != expectfilenum)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("import dir", "fail", "File Number not correct");
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    pimp.Result = TestResult.Pass;
                    pimp.Outputs.AddParameter("import dir_move", "success", "OK");
                    SaveRound(r);
                    ps.deletePatient(patientid);
                }
                catch (Exception e)
                {
                    pimp.Result = TestResult.Fail;
                    pimp.Outputs.AddParameter("import dir_move", "exception caught", e.Message);
                    SaveRound(r);
                    ps.deletePatient(patientid);
                    continue;
                }

            }

            Output();
        }
コード例 #14
0
        //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();
        }
コード例 #15
0
        //Case 925: 1.3.3_WorkFlow_N01_CreateGet
        public void Run_RadioLogicalLog_WorkFlow_N01_CreateGet_Case925()
        {
            //int runCount = this.Input.Repetition;

            int runCount = 0; // this is the initial run count. Use this count to repeat different test data set.

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

                //Mark the check point here to indicate what's the check point here
                CheckPoint p1 = new CheckPoint("createPatient", "Setup environment of createPatient");
                CheckPoint p2 = new CheckPoint("importObject", "Setup environment of importObject");
                CheckPoint p3 = new CheckPoint("createRadioLogEntry", "Test createRadioLogEntry");
                CheckPoint p4 = new CheckPoint("getRadioLogEntry", "Test getRadioLogEntry");

                r.CheckPoints.Add(p1);
                r.CheckPoints.Add(p2);
                r.CheckPoints.Add(p3);
                r.CheckPoints.Add(p4);

                //create required PAS service instaces here
                PatientService pats = new PatientService();
                ImportService ims = new ImportService();
                RadiologService radios = new RadiologService();

                //create input parameters here, it may include XML path type and string type value
                XMLParameter pa1 = new XMLParameter("createPatient");
                XMLParameter pa2 = new XMLParameter("importObject");
                XMLParameter pa3 = new XMLParameter("createRadioLogEntry");
                XMLParameter pa4 = new XMLParameter("getRadioLogEntry");

                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    switch (ids.InputParameters.GetParameter(i).Step)
                    {
                        case "createPatient":
                            pa1.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                            break;
                        case "importObject":
                            pa2.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                            break;
                        case "createRadioLogEntry":
                            pa3.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                            break;
                        case "getRadioLogEntry":
                            pa4.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                            break;
                        default:
                            Console.WriteLine("There is no valid selection when parse input parameters.");
                            break;
                    }
                }

                //If we need change parameter by specific logic, please put code here

                //Get service result
                //Step1 result

                XMLResult step1_result = pats.createPatient(pa1);

                //Log step1 service output
                if (step1_result.IsErrorOccured)
                {
                    p1.Result = TestResult.Fail;
                    p1.Outputs.AddParameter("createPatient", "Error", step1_result.ResultContent);
                    SaveRound(r);
                    continue;
                }

                p1.Result = TestResult.Pass;
                p1.Outputs.AddParameter("createPatient", "Success", step1_result.ResultContent);

                //Change input parameter according the output of Step1
                pa2.AddParameter("patientInternalId", step1_result.SingleResult);
                pa3.AddParameter("patient_internal_id", step1_result.SingleResult);

                //Step2 result

                //if objectFileFullPath is empty string, skip step2
                if (pa2.GetParameterValueByName("objectFileFullPath") != null && pa2.GetParameterValueByName("objectFileFullPath") != "")
                {
                    XMLResult step2_result = ims.importObject(pa2.GetParameterValueByName("patientInternalId"), "", pa2.GetParameterValueByName("objectFileFullPath"), "", false, "");

                    //Log step2 service output
                    if (step2_result.IsErrorOccured)
                    {
                        p2.Result = TestResult.Fail;
                        p2.Outputs.AddParameter("importObject", "Error", step2_result.ResultContent);
                        SaveRound(r);
                        continue;
                    }

                    p2.Result = TestResult.Pass;
                    p2.Outputs.AddParameter("importObject", "Success", step2_result.ResultContent);

                    //Change input parameter according the output of Step2
                    // if step2 is skipped, step3 input has no need parameter of instance_internal_id
                    pa3.AddParameter("instance_internal_id", step2_result.ArrayResult.GetParameterValueByName("internal_id"));
                }
                else
                {
                    p2.Outputs.AddParameter("importObject", "Success", "This step is ignored by case, no run");
                    p2.Result = TestResult.Pass;
                }

                //Step3 result

                XMLResult step3_result = radios.createRadioLogEntry(pa3);

                //Log step3 service output
                if (step3_result.IsErrorOccured)
                {
                    p3.Result = TestResult.Fail;
                    p3.Outputs.AddParameter("createRadioLogEntry", "Error", step3_result.ResultContent);
                    SaveRound(r);
                    continue;
                }

                p3.Result = TestResult.Pass;
                p3.Outputs.AddParameter("createRadioLogEntry", "Success", step3_result.ResultContent);

                //Change input parameter according the output of Step3
                pa4.AddParameter("radioLogEntryInternalId", step3_result.SingleResult);
                //Step4 result

                XMLResult step4_result = radios.getRadioLogEntry(pa4.GetParameterValueByName("radioLogEntryInternalId"));

                //Log step4 service output
                //Compare the input parameters of createRadioLogEntry and output result of getRadioLogEntry
                int compCount = 0;

                for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++)
                {
                    if (ids.ExpectedValues.Parameters[index].Value == step4_result.ArrayResult.GetParameterValueByName(ids.ExpectedValues.Parameters[index].Key))
                    { compCount++; }
                }

                if (step4_result.IsErrorOccured || compCount != ids.ExpectedValues.Parameters.Count)
                {
                    p4.Result = TestResult.Fail;
                    p4.Outputs.AddParameter("getRadioLogEntry", "Error", step4_result.ResultContent);
                }
                else
                {
                    p4.Result = TestResult.Pass;
                    p4.Outputs.AddParameter("getRadioLogEntry", "Success", step4_result.ResultContent);
                }

                //Save data for each round
                SaveRound(r);
            }

            //Save service log as xml file
            Output();
        }
コード例 #16
0
        //Case 1043: 1.3.17_workflow_ImportCeph_GetImageInfo_RadilogIsNotSaved
        public void Run_WorkFlow_ImportCeph_RadioLog_Case1043()
        {
            int runCount = 0;
            string patientUID = string.Empty;
            bool isCreatePatient = false;
            bool isDeletePatient = true;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                isCreatePatient = false;
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Import image");

                PatientService patientSvc = new PatientService();
                ImportService importSvc = new ImportService();
                ImageService imageSvc = new ImageService();

                string radioLogBeforeImport = string.Empty;
                string radioLogAfterImport = string.Empty;
                string imageID = null;

                XMLParameter pa = new XMLParameter("patient");
                XMLParameter ia = new XMLParameter("import");
                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "create")
                    {
                        pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        isCreatePatient = true;
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "import")
                    {
                        ia.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                }

                XMLParameter epGetImagInfo = new XMLParameter();
                for (int i = 0; i < ids.ExpectedValues.Count; i++)
                {
                    if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo")
                    {
                        epGetImagInfo.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                    }
                }

                try
                {
                    #region Step1: Create Image
                    if (isCreatePatient)
                    {
                        CheckPoint pCreate = new CheckPoint("Create Patient", "Test create");
                        r.CheckPoints.Add(pCreate);

                        XMLResult rtCreatePatient = patientSvc.createPatient(pa);
                        if (!rtCreatePatient.IsErrorOccured)
                        {
                            patientUID = rtCreatePatient.SingleResult;
                            pCreate.Outputs.AddParameter("Create patient UID", "Create Patient", patientUID);
                            pCreate.Result = TestResult.Pass;
                        }
                    }
                    #endregion

                    #region Step2: Get patient radio log info before import
                    CheckPoint cpGetPatientBeforeImport = new CheckPoint("GetPatient", "Get Patient Info before import image");
                    r.CheckPoints.Add(cpGetPatientBeforeImport);

                    XMLResult rtGetPatientBeforeImport = patientSvc.getPatient(patientUID);
                    if (rtGetPatientBeforeImport.IsErrorOccured)
                    {
                        cpGetPatientBeforeImport.Result = TestResult.Fail;
                        cpGetPatientBeforeImport.Outputs.AddParameter("Get Patient Info before import image returns error", "GetPatient", rtGetPatientBeforeImport.ResultContent);
                    }
                    else
                    {
                        cpGetPatientBeforeImport.Result = TestResult.Pass;
                        cpGetPatientBeforeImport.Outputs.AddParameter("Get Patient Info before import image returns ok", "GetPatient", rtGetPatientBeforeImport.ResultContent);

                        radioLogBeforeImport = rtGetPatientBeforeImport.MultiResults[0].GetParameterValueByName("cumulative_dose");  //get the cumulative_dose info
                    }
                    #endregion

                    #region Step3: Import Image
                    CheckPoint pImport = new CheckPoint("Import Image", "Test import");
                    r.CheckPoints.Add(pImport);

                    string filePath = string.Empty;
                    string archivePath = string.Empty;
                    bool move = false;
                    for (int c = 0; c < ia.Length; c++)
                    {
                        if (ia.GetParameterName(c) == "path")
                        {
                            filePath = ia.GetParameterValue(c);
                        }
                        else if (ia.GetParameterName(c) == "archivePath")
                        {
                            archivePath = ia.GetParameterValue(c);
                        }
                        else if (ia.GetParameterName(c) == "move")
                        {
                            if (ia.GetParameterValue(c) == "true")
                            {
                                move = true;
                            }
                        }
                    }

                    XMLResult rtlImport = importSvc.importObject(patientUID, "", filePath, archivePath, move, "false");

                    //import return sample:
                    //   <trophy type="result" version="1.0">
                    //           <status code="0" message="ok" />
                    //           <image><parameter key="internal_id" value="2bfb416b-037e-41e7-aaef-8d2bd08b1ae7" /></image>
                    //           <presentationstate><parameter key="internal_id" value="75675345-a164-4088-b6d3-1b2ae86b703b" /></presentationstate>
                    // </trophy>

                    if (rtlImport.IsErrorOccured)
                    {
                        pImport.Result = TestResult.Fail;
                        pImport.Outputs.AddParameter("Import image fail", "Import", rtlImport.Message);
                        pImport.Outputs.AddParameter("Import image returns error code", "Import", rtlImport.Code.ToString());
                    }
                    else
                    {
                        // Check the return contiains image id and ps id
                        imageID = rtlImport.MultiResults[0].GetParameterValueByName("internal_id"); // image internal_id
                        if (imageID == null || imageID == string.Empty)
                        {
                            pImport.Result = TestResult.Fail;
                            pImport.Outputs.AddParameter("Import image returns wrong image internal id", "Import", rtlImport.ResultContent);
                        }

                        string psID = null;
                        psID = rtlImport.MultiResults[1].GetParameterValueByName("internal_id"); // ps internal_id
                        if (psID == null || psID == string.Empty)
                        {
                            pImport.Result = TestResult.Fail;
                            pImport.Outputs.AddParameter("import image returns wrong ps internal id", "Import", rtlImport.ResultContent);
                        }
                        else
                        {
                            pImport.Result = TestResult.Pass;
                            pImport.Outputs.AddParameter("import image returns OK", "Import", rtlImport.ResultContent);
                        }
                    }
                    #endregion

                    #region Step4: Call GetImageInfo to check the radio log info
                    CheckPoint cpGetImageInfo = new CheckPoint("GetImageInfo", "Get the image info of the imported image");
                    r.CheckPoints.Add(cpGetImageInfo);

                    XMLParameter pGetImageInfo = new XMLParameter("image");
                    pGetImageInfo.AddParameter("internal_id", imageID);
                    XMLResult rtGetImageInfo = imageSvc.getImageInfo(pGetImageInfo);

                    if (rtGetImageInfo.IsErrorOccured)
                    {
                        cpGetImageInfo.Result = TestResult.Fail;
                        cpGetImageInfo.Outputs.AddParameter("Get the image info of the imported image return error", "GetImageInfo", rtGetImageInfo.ResultContent);
                    }
                    else
                    {
                        cpGetImageInfo.Outputs.AddParameter("Get Image Info return success", "getImageInfo", rtGetImageInfo.Message);

                        //Check the return info contain the expected key and value: <parameter key="XXX" value="XXX" />
                        foreach (XMLParameterNode node in epGetImagInfo.Parameters)
                        {
                            if (!rtGetImageInfo.ResultContent.Contains("parameter key=\"" + node.ParameterName + "\" value=\"" + node.ParameterValue + "\""))
                            {
                                cpGetImageInfo.Result = TestResult.Fail;
                                cpGetImageInfo.Outputs.AddParameter("Get Image Info returns wrong key-value info for: " + node.ParameterName, "GetImageInfo", rtGetImageInfo.ResultContent);
                                continue;
                            }
                            else
                            {
                                cpGetImageInfo.Outputs.AddParameter("Get Image Info returns correct key-value info for: " + node.ParameterName, "GetImageInfo", "ok");
                            }
                        }

                        if (cpGetImageInfo.Result != TestResult.Fail)
                        {
                            cpGetImageInfo.Result = TestResult.Pass;
                            cpGetImageInfo.Outputs.AddParameter("Get Image Info return all correct info", "GetImageInfo", rtGetImageInfo.ResultContent);
                        }
                    }
                    #endregion

                    #region Step5: Get patient radio log info after import
                    CheckPoint cpGetPatientAfterImport = new CheckPoint("GetPatient", "Get Patient Info after import image");
                    r.CheckPoints.Add(cpGetPatientAfterImport);

                    XMLResult rtGetPatientAfterImport = patientSvc.getPatient(patientUID);
                    if (rtGetPatientAfterImport.IsErrorOccured)
                    {
                        cpGetPatientAfterImport.Result = TestResult.Fail;
                        cpGetPatientAfterImport.Outputs.AddParameter("Get Patient Info after import image returns error", "GetPatient", rtGetPatientAfterImport.ResultContent);
                    }
                    else
                    {
                        cpGetPatientAfterImport.Result = TestResult.Pass;
                        cpGetPatientAfterImport.Outputs.AddParameter("Get Patient Info after import image returns ok", "GetPatient", rtGetPatientAfterImport.ResultContent);

                        radioLogAfterImport = rtGetPatientAfterImport.MultiResults[0].GetParameterValueByName("cumulative_dose");  //get the cumulative_dose info
                    }
                    #endregion

                    #region Step6: Check the patient radio log info not changes after import image
                    CheckPoint cpPatientRadioLogInfo = new CheckPoint("Patient Radiolog Info", "Check patient radio log info not changes aftert import image");
                    r.CheckPoints.Add(cpPatientRadioLogInfo);

                    if (radioLogAfterImport == radioLogBeforeImport)
                    {
                        cpPatientRadioLogInfo.Result = TestResult.Pass;
                        cpPatientRadioLogInfo.Outputs.AddParameter("Patient radio log info not changes aftert import image", "Patient Radiolog Info", "Before import value is: " + radioLogBeforeImport + ". After import value is: " + radioLogAfterImport);
                    }
                    else
                    {
                        cpPatientRadioLogInfo.Result = TestResult.Fail;
                        cpPatientRadioLogInfo.Outputs.AddParameter("Patient radio log info  changes aftert import image", "Patient Radiolog Info", "Before import value is: " + radioLogBeforeImport + ". After import value is: " + radioLogAfterImport);
                    }
                    #endregion

                    #region Step7: Delete Patient
                    if (isDeletePatient)
                    {
                        CheckPoint cpDelete = new CheckPoint("Delete Patient", "Test delete patient");
                        r.CheckPoints.Add(cpDelete);
                        XMLResult rltDelete = patientSvc.deletePatient(patientUID);
                        if (rltDelete.IsErrorOccured)
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns error", "Delete Patient", rltDelete.Message);
                            cpDelete.Result = TestResult.Fail;
                        }
                        else
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns OK", "Delete Patient", rltDelete.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();
        }
コード例 #17
0
        // Case 721: 1.3.10_ImportImage_N02_Archived image
        public void Run_Import_ArchivedImage_Case721()
        {
            int runCount = 0;
            string patientUID = string.Empty;
            bool isCreatePatient = false;
            bool isDeletePatient = true;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                isCreatePatient = false;
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Import image");

                ImportService ims = new ImportService();
                XMLParameter pa = new XMLParameter("patient");
                XMLParameter ia = new XMLParameter("import");
                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "create")
                    {
                        pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        isCreatePatient = true;
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "import")
                    {
                        ia.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                }

                XMLParameter epGetImagInfo = new XMLParameter();
                XMLParameter epGetImageDescription = new XMLParameter();

                for (int i = 0; i < ids.ExpectedValues.Count; i++)
                {
                    if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo")
                    {
                        epGetImagInfo.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                    }
                    else if (ids.ExpectedValues.GetParameter(i).Step == "getImageDescription")
                    {
                        epGetImageDescription.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                    }
                }

                try
                {
                    PatientService patientSvc = new PatientService();
                    if (isCreatePatient)
                    {
                        CheckPoint pCreate = new CheckPoint("Create Patient", "Test create");
                        r.CheckPoints.Add(pCreate);

                        XMLResult result = patientSvc.createPatient(pa);
                        if (!result.IsErrorOccured)
                        {
                            patientUID = result.SingleResult;
                            pCreate.Result = TestResult.Pass;
                            pCreate.Outputs.AddParameter("Create patient UID", "Create Patient", patientUID);
                        }
                        else
                        {
                            pCreate.Result = TestResult.Fail;
                            pCreate.Outputs.AddParameter("Create patient returns error", "Create Patient", result.ResultContent);
                        }
                    }

                    CheckPoint pImport = new CheckPoint("Import Image", "Test import");
                    r.CheckPoints.Add(pImport);

                    string filePath = string.Empty;
                    string archivePath = string.Empty;
                    bool move = false;
                    for (int c = 0; c < ia.Length; c++)
                    {
                        if (ia.GetParameterName(c) == "path")
                            filePath = ia.GetParameterValue(c);
                        if (ia.GetParameterName(c) == "archivePath")
                            archivePath = ia.GetParameterValue(c);
                        if (ia.GetParameterName(c) == "move")
                        {
                            if (ia.GetParameterValue(c) == "true")
                                move = true;
                        }
                    }

                    XMLResult rslImport = ims.importObject(patientUID, "", filePath, archivePath, move, "false");

                    //import return sample:
                    //   <trophy type="result" version="1.0">
                    //           <status code="0" message="ok" />
                    //           <image><parameter key="internal_id" value="2bfb416b-037e-41e7-aaef-8d2bd08b1ae7" /></image>
                    //           <presentationstate><parameter key="internal_id" value="75675345-a164-4088-b6d3-1b2ae86b703b" /></presentationstate>
                    // </trophy>

                    if (rslImport.IsErrorOccured)
                    {
                        pImport.Result = TestResult.Fail;
                        pImport.Outputs.AddParameter("Import image fail", "Import", rslImport.Message);
                        pImport.Outputs.AddParameter("Import image returns error code", "Import", rslImport.Code.ToString());
                    }
                    else
                    {
                        // Check the return contiains image id and ps id
                        string imageID = null;
                        imageID = rslImport.MultiResults[0].GetParameterValueByName("internal_id"); // image internal_id
                        if (imageID == null || imageID == string.Empty)
                        {
                            pImport.Result = TestResult.Fail;
                            pImport.Outputs.AddParameter("Import image returns wrong image internal id", "Import", rslImport.ResultContent);
                        }

                        string psID = null;
                        psID = rslImport.MultiResults[1].GetParameterValueByName("internal_id"); // ps internal_id
                        if (psID == null || psID == string.Empty)
                        {
                            pImport.Result = TestResult.Fail;
                            pImport.Outputs.AddParameter("import image returns wrong ps internal id", "Import", rslImport.ResultContent);
                        }
                        else
                        {
                            pImport.Result = TestResult.Pass;
                            pImport.Outputs.AddParameter("import image returns OK", "Import", rslImport.ResultContent);
                        }

                        #region Call getImageInfo to check expected key and value
                        ImageService imageSvc = new ImageService();

                        XMLParameter pGetImageInfo = new XMLParameter("image");
                        pGetImageInfo.AddParameter("internal_id", imageID);

                        CheckPoint cpGetImageInfo = new CheckPoint("GetImageInfo", "Call GetImageInfo to check the dcm_anatomic_region value");
                        r.CheckPoints.Add(cpGetImageInfo);

                        XMLResult rtGetImageInfo = imageSvc.getImageInfo(pGetImageInfo);
                        if (rtGetImageInfo.IsErrorOccured)
                        {
                            cpGetImageInfo.Result = TestResult.Fail;
                            cpGetImageInfo.Outputs.AddParameter("Get Image Info return error", "getImageInfo", rtGetImageInfo.ResultContent);
                        }
                        else
                        {
                            cpGetImageInfo.Outputs.AddParameter("Get Image Info return success", "getImageInfo", rtGetImageInfo.Message);

                            //Check the return info contain the expected key and value: parameter key="XXX" value="XXX"
                            foreach (XMLParameterNode node in epGetImagInfo.Parameters)
                            {
                                if (!rtGetImageInfo.ResultContent.Contains("parameter key=\"" + node.ParameterName + "\" value=\"" + node.ParameterValue + "\""))
                                {
                                    cpGetImageInfo.Result = TestResult.Fail;
                                    cpGetImageInfo.Outputs.AddParameter("Get Image Info returns wrong key-value info for: " + node.ParameterName, "GetImageInfo", rtGetImageInfo.ResultContent);
                                    continue;
                                }
                                else
                                {
                                    cpGetImageInfo.Outputs.AddParameter("Get Image Info returns correct key-value info for: " + node.ParameterName, "GetImageInfo", "ok");
                                }
                            }

                            if (cpGetImageInfo.Result != TestResult.Fail)
                            {
                                cpGetImageInfo.Result = TestResult.Pass;
                                cpGetImageInfo.Outputs.AddParameter("Get Image Info return all correct info", "GetImageInfo", rtGetImageInfo.ResultContent);
                            }
                        }
                        #endregion

                        #region Call getImageDescription to check expected key and value
                        CheckPoint cpGetImageDescription = new CheckPoint("GetImageDescription", "Call GetImageDescription to check the info in return value");
                        r.CheckPoints.Add(cpGetImageDescription);

                        XMLResult rtGetImageDescription = imageSvc.getImageDescription(imageID);
                        if (rtGetImageDescription.IsErrorOccured)
                        {
                            cpGetImageDescription.Result = TestResult.Fail;
                            cpGetImageDescription.Outputs.AddParameter("Get Image Description returns error", "getImageDescription", rtGetImageDescription.ResultContent);
                        }
                        else
                        {
                            cpGetImageDescription.Outputs.AddParameter("Get Image Description return success", "getImageDescription", rtGetImageDescription.Message);

                            //Check the return info contain the expected key and value: parameter key="XXX" value="XXX"
                            foreach (XMLParameterNode node in epGetImageDescription.Parameters)
                            {
                                if (!rtGetImageDescription.ResultContent.Contains("parameter key=\"" + node.ParameterName + "\" value=\"" + node.ParameterValue + "\""))
                                {
                                    cpGetImageDescription.Result = TestResult.Fail;
                                    cpGetImageDescription.Outputs.AddParameter("Get Image Description returns wrong key-value info for: " + node.ParameterName, "GetImageDescription", rtGetImageDescription.ResultContent);
                                    continue;
                                }
                                else
                                {
                                    cpGetImageDescription.Outputs.AddParameter("Get Image Description returns correct key-value info for: " + node.ParameterName, "GetImageDescription", "ok");
                                }
                            }

                            if (cpGetImageDescription.Result != TestResult.Fail)
                            {
                                cpGetImageDescription.Result = TestResult.Pass;
                                cpGetImageDescription.Outputs.AddParameter("Get Image Description returns all correct info", "GetImageDescription", rtGetImageDescription.ResultContent);
                            }
                        }
                        #endregion
                    }

                    if (isDeletePatient)
                    {
                        CheckPoint cpDelete = new CheckPoint("Delete Patient", "Test delete patient");
                        r.CheckPoints.Add(cpDelete);
                        XMLResult rltDelete = patientSvc.deletePatient(patientUID);
                        if (rltDelete.IsErrorOccured)
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns error", "Delete Patient", rltDelete.Message);
                            cpDelete.Result = TestResult.Fail;
                        }
                        else
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns OK", "Delete Patient", rltDelete.Message);
                            cpDelete.Result = TestResult.Pass;
                        }
                    }

                    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();
        }
コード例 #18
0
        //Case 1220: 1.9.1_WorkFlow_N2_Import CS Model_GetVolumeInfo
        public void Run_3D_ImportCSModel_GetVolumeInfo_Case1220()
        {
            int runCount = 0;
            string patientUID = string.Empty;
            bool isCreatePatient = false;
            bool isDeletePatient = true;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                isCreatePatient = false;
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Import image");

                ImportService importSvc = new ImportService();
                XMLParameter pCreatePatient = new XMLParameter("patient");
                XMLParameter pImportImage = new XMLParameter("import");
                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "create")
                    {
                        pCreatePatient.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        isCreatePatient = true;
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "import")
                    {
                        pImportImage.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                }

                XMLParameter epGetVolumeInfo = new XMLParameter();

                for (int i = 0; i < ids.ExpectedValues.Count; i++)
                {
                    if (ids.ExpectedValues.GetParameter(i).Step == "getVolumeInfo")
                    {
                        epGetVolumeInfo.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                    }
                }

                try
                {
                    PatientService patientSvc = new PatientService();
                    if (isCreatePatient)
                    {
                        CheckPoint pCreate = new CheckPoint("Create Patient", "Test create");
                        r.CheckPoints.Add(pCreate);

                        XMLResult result = patientSvc.createPatient(pCreatePatient);
                        if (!result.IsErrorOccured)
                        {
                            patientUID = result.SingleResult;
                            pCreate.Result = TestResult.Pass;
                            pCreate.Outputs.AddParameter("Create patient UID", "Create Patient", patientUID);
                        }
                        else
                        {
                            pCreate.Result = TestResult.Fail;
                            pCreate.Outputs.AddParameter("Create patient returns error", "Create Patient", result.ResultContent);
                        }
                    }

                    CheckPoint cpImport = new CheckPoint("Import Image", "Test import");
                    r.CheckPoints.Add(cpImport);

                    string filePath = string.Empty;
                    string archivePath = string.Empty;
                    bool overrideExisted = false;
                    for (int c = 0; c < pImportImage.Length; c++)
                    {
                        if (pImportImage.GetParameterName(c) == "path")
                            filePath = pImportImage.GetParameterValue(c);
                        if (pImportImage.GetParameterName(c) == "archivePath")
                            archivePath = pImportImage.GetParameterValue(c);
                        if (pImportImage.GetParameterName(c) == "move")
                        {
                            if (pImportImage.GetParameterValue(c) == "true")
                                overrideExisted = true;
                        }
                    }

                    XMLResult rtlImport = importSvc.importObject(patientUID, "", filePath, archivePath, overrideExisted, "false");

                    /**********************************************
                        import return sample:
                        - <trophy type="result" version="1.0">
                          <status code="0" message="ok" />
                        - <volume>
                          <parameter key="internal_id" value="5412d81a-c096-4b0d-ab93-524266af21b6" />
                          </volume>
                          </trophy>
                     * **********************************************/

                    if (rtlImport.IsErrorOccured)
                    {
                        cpImport.Result = TestResult.Fail;
                        cpImport.Outputs.AddParameter("Import volume fail", "Import", rtlImport.Message);
                        cpImport.Outputs.AddParameter("Import volume returns error code", "Import", rtlImport.Code.ToString());
                    }
                    else
                    {
                        // Check the return contiains image id and ps id
                        string volumeID = null;
                        volumeID = rtlImport.MultiResults[0].GetParameterValueByName("internal_id"); // image internal_id
                        if (volumeID == null || volumeID == string.Empty)
                        {
                            cpImport.Result = TestResult.Fail;
                            cpImport.Outputs.AddParameter("Import volume returns wrong volume internal id", "Import", rtlImport.ResultContent);
                        }
                        else
                        {
                            cpImport.Result = TestResult.Pass;
                            cpImport.Outputs.AddParameter("import volume returns OK", "Import", rtlImport.ResultContent);
                        }

                        #region Call getVolumeInfo to check expected key and value
                        VolumeService volumeSvc = new VolumeService();

                        XMLParameter pGetVolumeInfo = new XMLParameter("volume");
                        pGetVolumeInfo.AddParameter("internal_id", volumeID);

                        CheckPoint cpGetVolumeInfo = new CheckPoint("GetVolumeInfo", "Call GetVolumeInfo to check the return value");
                        r.CheckPoints.Add(cpGetVolumeInfo);

                        XMLResult rtGetVolumeInfo = volumeSvc.getVolumeInfo(pGetVolumeInfo);
                        if (rtGetVolumeInfo.IsErrorOccured)
                        {
                            cpGetVolumeInfo.Result = TestResult.Fail;
                            cpGetVolumeInfo.Outputs.AddParameter("Get Volume Info return error", "GetVolumeInfo", rtGetVolumeInfo.ResultContent);
                        }
                        else
                        {
                            cpGetVolumeInfo.Outputs.AddParameter("Get Volume Info return success", "GetVolumeInfo", rtGetVolumeInfo.Message);

                            //Check the return info contain the expected key and value: parameter key="XXX" value="XXX"
                            foreach (XMLParameterNode node in epGetVolumeInfo.Parameters)
                            {
                                if (!rtGetVolumeInfo.ResultContent.Contains("parameter key=\"" + node.ParameterName + "\" value=\"" + node.ParameterValue + "\""))
                                {
                                    cpGetVolumeInfo.Result = TestResult.Fail;
                                    cpGetVolumeInfo.Outputs.AddParameter("Get Volume Info returns wrong key-value info for: " + node.ParameterName, "GetVolumeInfo", rtGetVolumeInfo.ResultContent);
                                    continue;
                                }
                                else
                                {
                                    cpGetVolumeInfo.Outputs.AddParameter("Get Volume Info returns correct key-value info for: " + node.ParameterName, "GetVolumeInfo", "ok");
                                }
                            }

                            if (cpGetVolumeInfo.Result != TestResult.Fail)
                            {
                                cpGetVolumeInfo.Result = TestResult.Pass;
                                cpGetVolumeInfo.Outputs.AddParameter("Get Volume Info returns all correct info", "GetVolumeInfo", rtGetVolumeInfo.ResultContent);
                            }
                        }
                        #endregion
                    }

                    if (isDeletePatient)
                    {
                        CheckPoint cpDelete = new CheckPoint("Delete Patient", "Test delete patient");
                        r.CheckPoints.Add(cpDelete);
                        XMLResult rltDelete = patientSvc.deletePatient(patientUID);
                        if (rltDelete.IsErrorOccured)
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns error", "Delete Patient", rltDelete.Message);
                            cpDelete.Result = TestResult.Fail;
                        }
                        else
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns OK", "Delete Patient", rltDelete.Message);
                            cpDelete.Result = TestResult.Pass;
                        }
                    }

                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.ToString());
                    cp.Result = TestResult.Fail;
                    SaveRound(r);
                }
            }
            Output();
        }
コード例 #19
0
        //Import archive
        public void Run_SimpleInstance_WorkFlow_Case1585()
        {
            int runCount = 0;

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

                try
                {
                    string instanceUID = null;
                    ImportService importSvc = new ImportService();
                    SimpleInstanceServiceV2 simpleInstanceSvc = new SimpleInstanceServiceV2();

                    #region Input param
                    string patientInternalId = null;
                    string objectFileFullPath = null;
                    string archivePath = null;
                    SimpleSetSimpleInstanceInfoRequestType pSet = new SimpleSetSimpleInstanceInfoRequestType();
                    pSet.simpleInstance = new SimpleInstanceType();

                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "import")  // Import parameter
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "patientInternalId")
                            {
                                patientInternalId = ids.InputParameters.GetParameter(i).Value;
                            }
                            else if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath")
                            {
                                objectFileFullPath = ids.InputParameters.GetParameter(i).Value;
                            }
                            else if (ids.InputParameters.GetParameter(i).Key == "archivePath")
                            {
                                archivePath = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "set")
                        {
                            switch (ids.InputParameters.GetParameter(i).Key) // setSimpleInstance parameter
                            {
                                case "filePath":
                                    pSet.simpleInstance.filePath = ids.InputParameters.GetParameter(i).Value;
                                    break;
                                case "originalPath":
                                    pSet.simpleInstance.originalPath = ids.InputParameters.GetParameter(i).Value;
                                    break;
                                case "instanceType":
                                    pSet.simpleInstance.instanceType = ids.InputParameters.GetParameter(i).Value;
                                    break;
                                case "comments":
                                    pSet.simpleInstance.comments = ids.InputParameters.GetParameter(i).Value;
                                    break;
                                case "sopInstanceUid":
                                    pSet.simpleInstance.sopInstanceUid = ids.InputParameters.GetParameter(i).Value;
                                    break;
                                default:
                                    break;
                            }
                        }
                    }
                    #endregion

                    #region Expected Values
                    SimpleGetSimpleInstanceResponseType epGetAfterImport = new SimpleGetSimpleInstanceResponseType();
                    epGetAfterImport.simpleInstance = new SimpleInstanceType();

                    SimpleGetSimpleInstanceInfoResponseType epGetInfoAfterImport = new SimpleGetSimpleInstanceInfoResponseType();
                    epGetInfoAfterImport.simpleInstance = new SimpleInstanceType();
                    epGetInfoAfterImport.simpleInstance.filePath = null;

                    SimpleGetSimpleInstanceResponseType epGetAfterSet = new SimpleGetSimpleInstanceResponseType();
                    epGetAfterSet.simpleInstance = new SimpleInstanceType();

                    SimpleGetSimpleInstanceInfoResponseType epGetInfoAfterSet = new SimpleGetSimpleInstanceInfoResponseType();
                    epGetInfoAfterSet.simpleInstance = new SimpleInstanceType();
                    epGetInfoAfterSet.simpleInstance.filePath = null;

                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Step == "getAfterImport")
                        {
                            switch (ids.ExpectedValues.GetParameter(i).Key)
                            {
                                case "patientUid":
                                    epGetAfterImport.simpleInstance.patientUid = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "filePath":
                                    epGetAfterImport.simpleInstance.filePath = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "archivePath":
                                    epGetAfterImport.simpleInstance.archivePath = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "originalPath":
                                    epGetAfterImport.simpleInstance.originalPath = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "instanceType":
                                    epGetAfterImport.simpleInstance.instanceType = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "comments":
                                    epGetAfterImport.simpleInstance.comments = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "sopInstanceUid":
                                    epGetAfterImport.simpleInstance.sopInstanceUid = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "fileCreatedTime":
                                    epGetAfterImport.simpleInstance.fileCreatedTime = Utility.GetFileCreationTime(objectFileFullPath);
                                    break;
                                case "fileModifiedTime":
                                    epGetAfterImport.simpleInstance.fileModifiedTime = Utility.GetFileModifiedTime(objectFileFullPath);
                                    break;
                                case "tags":
                                    epGetAfterImport.simpleInstance.tags = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                default:
                                    break;
                            }
                        }
                        else if (ids.ExpectedValues.GetParameter(i).Step == "getInfoAfterImport")
                        {
                            switch (ids.ExpectedValues.GetParameter(i).Key)
                            {
                                case "patientUid":
                                    epGetInfoAfterImport.simpleInstance.patientUid = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "originalPath":
                                    epGetInfoAfterImport.simpleInstance.originalPath = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "archivePath":
                                    epGetInfoAfterImport.simpleInstance.archivePath = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "instanceType":
                                    epGetInfoAfterImport.simpleInstance.instanceType = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "objectType":
                                    epGetInfoAfterImport.simpleInstance.objectType = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "comments":
                                    epGetInfoAfterImport.simpleInstance.comments = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "sopInstanceUid":
                                    epGetInfoAfterImport.simpleInstance.sopInstanceUid = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "fileCreatedTime":
                                    epGetInfoAfterImport.simpleInstance.fileCreatedTime = Utility.GetFileCreationTime(objectFileFullPath); ;
                                    break;
                                case "fileModifiedTime":
                                    epGetInfoAfterImport.simpleInstance.fileModifiedTime = Utility.GetFileModifiedTime(objectFileFullPath);
                                    break;
                                case "fileName":
                                    epGetInfoAfterImport.simpleInstance.fileName = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "tags":
                                    epGetInfoAfterImport.simpleInstance.tags = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                default:
                                    break;
                            }
                        }
                        else if (ids.ExpectedValues.GetParameter(i).Step == "getAfterSet")
                        {
                            switch (ids.ExpectedValues.GetParameter(i).Key)
                            {
                                case "patientUid":
                                    epGetAfterSet.simpleInstance.patientUid = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "filePath":
                                    epGetAfterSet.simpleInstance.filePath = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "archivePath":
                                    epGetAfterSet.simpleInstance.archivePath = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "originalPath":
                                    epGetAfterSet.simpleInstance.originalPath = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "instanceType":
                                    epGetAfterSet.simpleInstance.instanceType = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "comments":
                                    epGetAfterSet.simpleInstance.comments = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "sopInstanceUid":
                                    epGetAfterSet.simpleInstance.sopInstanceUid = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "fileCreatedTime":
                                    if (pSet.simpleInstance.filePath != null)
                                    {
                                        epGetAfterSet.simpleInstance.fileCreatedTime = Utility.GetFileCreationTime(pSet.simpleInstance.filePath);
                                    }
                                    else
                                    {
                                        epGetAfterSet.simpleInstance.fileCreatedTime = epGetInfoAfterImport.simpleInstance.fileCreatedTime;
                                    }
                                    break;
                                case "fileModifiedTime":
                                    if (pSet.simpleInstance.filePath != null)
                                    {
                                        epGetAfterSet.simpleInstance.fileModifiedTime = Utility.GetFileModifiedTime(pSet.simpleInstance.filePath);
                                    }
                                    else
                                    {
                                        epGetAfterSet.simpleInstance.fileModifiedTime = epGetInfoAfterImport.simpleInstance.fileModifiedTime;
                                    }
                                    break;
                                case "tags":
                                    epGetAfterSet.simpleInstance.tags = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                default:
                                    break;
                            }
                        }
                        else if (ids.ExpectedValues.GetParameter(i).Step == "getInfoAfterSet")
                        {
                            switch (ids.ExpectedValues.GetParameter(i).Key)
                            {
                                case "patientUid":
                                    epGetInfoAfterSet.simpleInstance.patientUid = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "archivePath":
                                    epGetInfoAfterSet.simpleInstance.archivePath = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "originalPath":
                                    epGetInfoAfterSet.simpleInstance.originalPath = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "instanceType":
                                    epGetInfoAfterSet.simpleInstance.instanceType = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "objectType":
                                    epGetInfoAfterSet.simpleInstance.objectType = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "comments":
                                    epGetInfoAfterSet.simpleInstance.comments = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "sopInstanceUid":
                                    epGetInfoAfterSet.simpleInstance.sopInstanceUid = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "fileCreatedTime":
                                    if (pSet.simpleInstance.filePath != null)
                                    {
                                        epGetInfoAfterSet.simpleInstance.fileCreatedTime = Utility.GetFileCreationTime(pSet.simpleInstance.filePath);
                                    }
                                    else
                                    {
                                        epGetInfoAfterSet.simpleInstance.fileCreatedTime = epGetInfoAfterImport.simpleInstance.fileCreatedTime;
                                    }
                                    break;
                                case "fileModifiedTime":
                                    if (pSet.simpleInstance.filePath != null)
                                    {
                                        epGetInfoAfterSet.simpleInstance.fileModifiedTime = Utility.GetFileModifiedTime(pSet.simpleInstance.filePath);
                                    }
                                    else
                                    {
                                        epGetInfoAfterSet.simpleInstance.fileModifiedTime = epGetInfoAfterImport.simpleInstance.fileModifiedTime;
                                    }
                                    break;
                                case "fileName":
                                    epGetInfoAfterSet.simpleInstance.fileName = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "tags":
                                    epGetInfoAfterSet.simpleInstance.tags = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                default:
                                    break;
                            }
                        }
                    }
                    #endregion

                    #region Step: Call import to import a normal simple instance
                    XMLResult rtImport = importSvc.CallImportAndCheck(r, patientInternalId, objectFileFullPath, archivePath);
                    instanceUID = rtImport.SingleResult;
                    #endregion

                    #region Step: Call get to a normal simple instance after create
                    simpleInstanceSvc.CallGetAndCheck(r, instanceUID, epGetAfterImport);
                    #endregion

                    #region Step: Call getInfo to a normal simple isntance after create
                    simpleInstanceSvc.CallGetInfoAndCheck(r, instanceUID, epGetInfoAfterImport);
                    #endregion

                    #region Step: Call set to change the simple instance property
                    pSet.simpleInstance.uid = instanceUID;
                    simpleInstanceSvc.CallSetAndCheck(r, pSet);
                    #endregion

                    //System.Threading.Thread.Sleep(3000); //Sleep to make sure the call finished

                    #region Step: Call get to check after set
                    simpleInstanceSvc.CallGetAndCheck(r, instanceUID, epGetAfterSet);
                    #endregion

                    #region Step: Call getInfo to check after set
                    simpleInstanceSvc.CallGetInfoAndCheck(r, instanceUID, epGetInfoAfterSet);
                    #endregion

                    #region Step: Call delete and check
                    //simpleInstanceSvc.CallDeleteAndCheck(r, instanceUID);
                    #endregion

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

            Output();
        }
コード例 #20
0
        public override void Run()
        {
            string openObjInfo = string.Empty;
            string psId = string.Empty;
            KDIS7ImageWindow iw = new KDIS7ImageWindow();
            KDIS7ATAssistant ka = new KDIS7ATAssistant();

            ApplicationService appService = new ApplicationService();

            try
            {
                string PatientId = CommonLib.CreatePatient();
                ImportService import = new ImportService();
                XMLResult importResult = import.importObject(PatientId, string.Empty, @"c:\PASPerformance\001.png",null, true, string.Empty);
                psId = importResult.MultiResults[1].GetParameterValueByIndex(0);

                XMLParameter pa = new XMLParameter("two_dimension_viewer");
                pa.AddParameter("internal_id", psId);

                openObjInfo = pa.GenerateXML();

                appService.openObjects(pa);
                iw.ItemByID(psId).WaitProperty("ShownOnScreen", true, 60);
            }
            catch (Exception ex)
            {
                LogRecordType lr = new LogRecordType();
                lr.FunctionName = this.mFunctionName;
                lr.Lable = this.mLabel;
                string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                lr.Message = ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";
                lr.Passed = false;

                Log.AddRecord(lr);

                this.RiseSingleCallCompleteEvent(lr.ResponseTime, lr.Passed, true);
                this.RiseTestCaseCompleteEvent();

                this.mExecuted = this.mRepeat;
                this.mFailed = this.mRepeat;

                return;
            }

            for (int i = 1; i <= this.mRepeat; i++)
            {
                LogRecordType lr = new LogRecordType();
                lr.Lable = this.mLabel;
                lr.FunctionName = this.mFunctionName;

                try
                {
                    XMLResult result = new XMLResult(appService.InvokeMethod("openObjects", new object[] { openObjInfo }));

                    lr.ResponseTime = appService.ResponseTime;
                    lr.Passed = !(result.IsErrorOccured);

                    if (!lr.Passed)
                    {
                        lr.Message = result.Message;
                        this.mFailed++;
                    }
                    else
                    {
                        lr.Message = result.SingleResult;
                        this.mExectuedTime += lr.ResponseTime;
                    }
                }
                catch (Exception ex)
                {
                    this.mFailed++;
                    lr.Passed = false;
                    string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                    lr.Message = ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";
                }

                this.mExecuted = i;
                Log.AddRecord(lr);

                this.RiseSingleCallCompleteEvent(lr.ResponseTime, lr.Passed);
            }

            this.RiseTestCaseCompleteEvent();
        }
コード例 #21
0
        // Try to set normal to archive
        public void Run_SimpleInstance_Set_Error_Case1597()
        {
            int runCount = 0;

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

                try
                {
                    ImportService importSvc = new ImportService();
                    SimpleInstanceServiceV2 simpleInstanceSvc = new SimpleInstanceServiceV2();

                    string patientID = null;
                    string objectFileFullPath = null;

                    SimpleSetSimpleInstanceInfoRequestType pSetSimpleInstanceInfo = new SimpleSetSimpleInstanceInfoRequestType();
                    pSetSimpleInstanceInfo.simpleInstance = new SimpleInstanceType();

                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "import")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "patientID")
                            {
                                patientID = ids.InputParameters.GetParameter(i).Value;
                            }
                            else if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath")
                            {
                                objectFileFullPath = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "setSimpleInstance")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "archivePath")
                            {
                                pSetSimpleInstanceInfo.simpleInstance.archivePath = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                    }

                    string epCode = string.Empty;
                    string epMessage = string.Empty;
                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Key == "code")
                        {
                            epCode = ids.ExpectedValues.GetParameter(i).Value;
                        }
                        else if (ids.ExpectedValues.GetParameter(i).Key == "message")
                        {
                            epMessage = ids.ExpectedValues.GetParameter(i).Value;
                        }
                    }

                    #region Step: Import a normal simple instance
                    CheckPoint cpImport = new CheckPoint("Import Simple Instance", "Import to create a normal simple instance");
                    r.CheckPoints.Add(cpImport);

                    XMLResult rtImport = importSvc.importObject(patientID, null, objectFileFullPath, null, true, "false");

                    if (rtImport.IsErrorOccured)
                    {
                        cpImport.Result = TestResult.Fail;
                        cpImport.Outputs.AddParameter("Import", "Call import to create a normal simple instance returns error", rtImport.Message);
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        cpImport.Result = TestResult.Pass;
                        cpImport.Outputs.AddParameter("Import", "Call import to create a normal simple instance returns ok", rtImport.Message);
                    }
                    #endregion

                    #region Step: Call setSimpleInstanceInfo to change info
                    // To do: debug this if the id is correct
                    pSetSimpleInstanceInfo.simpleInstance.uid = rtImport.SingleResult;

                    CheckPoint cpSetSimpleInstanceInfo = new CheckPoint("Set Simple Instance Info", "Set Simple Instance Info");
                    r.CheckPoints.Add(cpSetSimpleInstanceInfo);

                    SimpleSetSimpleInstanceInfoResponseType rtSetSimpleInstanceInfo = simpleInstanceSvc.setSimpleInstanceInfo(pSetSimpleInstanceInfo);
                    if (!simpleInstanceSvc.LastReturnXMLValidateResult.isValid)
                    {
                        cpSetSimpleInstanceInfo.Result = TestResult.Fail;
                        cpSetSimpleInstanceInfo.Outputs.AddParameter("Set Simple Instance", "Invalid XML", "setSimpleInstance response is not complied with schema.");
                        SaveRound(r);
                        continue;
                    }

                    if (rtSetSimpleInstanceInfo.status.code.ToString() != epCode || !rtSetSimpleInstanceInfo.status.message.Contains(epMessage))
                    {
                        cpSetSimpleInstanceInfo.Result = TestResult.Fail;
                        cpSetSimpleInstanceInfo.Outputs.AddParameter("Set Simple Instance", "Check the setSimpleInstance response", "setSimpleInstance doesn't return expected result.  Code: " + rtSetSimpleInstanceInfo.status.code.ToString() + "; Message: " + rtSetSimpleInstanceInfo.status.message);
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        cpSetSimpleInstanceInfo.Result = TestResult.Pass;
                        cpSetSimpleInstanceInfo.Outputs.AddParameter("Set Simple Instance Info", "Check the setSimpleInstance response", "setSimpleInstance returns expected result. Code: " + rtSetSimpleInstanceInfo.status.code.ToString() + "; Message: " + rtSetSimpleInstanceInfo.status.message);
                    }
                    #endregion

                    #region Step: Check the instance is still normal
                    SimpleGetSimpleInstanceInfoResponseType rtGetInfo = simpleInstanceSvc.getSimpleInstanceInfo(pSetSimpleInstanceInfo.simpleInstance.uid);

                    CheckPoint cpPatientID = new CheckPoint("Check instance", "Check instance after set");
                    r.CheckPoints.Add(cpPatientID);
                    if (rtGetInfo.simpleInstance.tags != "archived" && string.IsNullOrEmpty(rtGetInfo.simpleInstance.archivePath))
                    {
                        cpPatientID.Result = TestResult.Pass;
                        cpPatientID.Outputs.AddParameter("Check instance", "Check instance after set", "The instance is still normal as expected.");
                    }
                    else
                    {
                        cpPatientID.Result = TestResult.Fail;
                        cpPatientID.Outputs.AddParameter("Check instance", "Check instance after set", "The instance info is not correct. getSimpleInstanceInfo returns: " + simpleInstanceSvc.LastReturnXML);
                        SaveRound(r);
                        continue;
                    }
                    #endregion

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

            Output();
        }
コード例 #22
0
        //Case 1094: 1.3.7_WorkFlow_ImportDICOMImage+GetPresentationStateInfo_RadioLogInformation
        public void Run_PS_ImportDicom_RadioLog_Case1094()
        {
            //int runCount = this.Input.Repetition;

            int runCount = 0; // this is the initial run count. Use this count to repeat different test data set.

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

                //Mark the check point here to indicate what's the check point here
                CheckPoint p1 = new CheckPoint("createPatient", "Setup environment of createPatient");
                CheckPoint p2 = new CheckPoint("importObject", "Setup environment of importObject");
                CheckPoint p3 = new CheckPoint("getImageInfo", "Test getImageInfo");
                CheckPoint p4 = new CheckPoint("getPresentationStateInfo", "Test getPresentationStateInfo");

                r.CheckPoints.Add(p1);
                r.CheckPoints.Add(p2);
                r.CheckPoints.Add(p3);
                r.CheckPoints.Add(p4);

                //create required PAS service instaces here
                PatientService pats = new PatientService();
                ImportService ims = new ImportService();
                ImageService img = new ImageService();
                PresentationStateService ps = new PresentationStateService();

                //create input parameters here, it may include XML path type and string type value
                XMLParameter pa1 = new XMLParameter("patient");
                XMLParameter pa2 = new XMLParameter("importObject");
                XMLParameter pa3 = new XMLParameter("image");
                XMLParameter ps4 = new XMLParameter("presentationstate");
                XMLParameterCollection pa4 = new XMLParameterCollection();

                try
                {
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        switch (ids.InputParameters.GetParameter(i).Step)
                        {
                            case "createPatient":
                                pa1.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "importObject":
                                pa2.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            default:
                                Console.WriteLine("There is no valid selection when parse input parameters.");
                                break;
                        }
                    }

                    //If we need change parameter by specific logic, please put code here

                    //Get service result
                    //Step1 result

                    XMLResult step1_result = pats.createPatient(pa1);

                    //Log step1 service output
                    if (step1_result.IsErrorOccured)
                    {
                        p1.Result = TestResult.Fail;
                        p1.Outputs.AddParameter("Step 1: createPatient", "Error", step1_result.ResultContent);
                        SaveRound(r);
                        continue;
                    }

                    p1.Result = TestResult.Pass;
                    p1.Outputs.AddParameter("Step 1: createPatient", "Success", step1_result.ResultContent);

                    //Change input parameter according the output of Step1
                    pa2.AddParameter("patientInternalId", step1_result.SingleResult);

                    //Step2 result

                    //if objectFileFullPath is empty string, skip step2
                    if (pa2.GetParameterValueByName("objectFileFullPath") != null && pa2.GetParameterValueByName("objectFileFullPath") != "")
                    {
                        XMLResult step2_result = ims.importObject(pa2.GetParameterValueByName("patientInternalId"), "", pa2.GetParameterValueByName("objectFileFullPath"), "", false, "");

                        //Log step2 service output
                        if (step2_result.IsErrorOccured)
                        {
                            p2.Result = TestResult.Fail;
                            p2.Outputs.AddParameter("Step 2: importObject", "Error", step2_result.ResultContent);
                            SaveRound(r);
                            continue;
                        }

                        p2.Result = TestResult.Pass;
                        p2.Outputs.AddParameter("Step 2: importObject", "Success", step2_result.ResultContent);

                        //Change input parameter according the output of Step2
                        // if step2 is skipped, step3 input has no need parameter of internal_id

                        for (int i = 0; i < step2_result.MultiResults.Count; i++)
                        {
                            if (step2_result.MultiResults[i].Name == "image")
                            {
                                pa3.AddParameter("internal_id", step2_result.MultiResults[i].GetParameterValueByIndex(i));
                            }
                            if (step2_result.MultiResults[i].Name == "presentationstate")
                            {
                                pa4.Add(step2_result.MultiResults[i]);
                            }
                        }
                    }

                    //Step3 result
                    XMLResult step3_result = img.getImageInfo(pa3);

                    if (step3_result.IsErrorOccured)
                    {
                        p3.Result = TestResult.Fail;
                        p3.Outputs.AddParameter("Step 3: getImageInfo", "The call 'getImageInfo' returns error: ", step3_result.Message);
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        p3.Result = TestResult.Pass; // Assume test pass at first, check the details later to update this
                    }

                    //Log step3 service output
                    int expectedParameterCount = 0;
                    for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++)
                    {
                        if (ids.ExpectedValues.Parameters[index].Step == "getImageInfo")
                        {
                            expectedParameterCount++;
                        }
                    }

                    string dicom_info_getImageInfo = step3_result.DicomArrayResult.GetParameterValueByName("dicom_info");

                    for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++)
                    {
                        if (ids.ExpectedValues.Parameters[index].Step == "getImageInfo")
                        {
                            // The dicom_info in return does not match the expected key and value
                            if (false == dicom_info_getImageInfo.Contains("<parameter key=\"" + ids.ExpectedValues.Parameters[index].Key + "\" value=\"" + ids.ExpectedValues.Parameters[index].Value + "\" />"))
                            {
                                p3.Result = TestResult.Fail;
                                p3.Outputs.AddParameter("Step 3: getImageInfo", "Error: the expect value does not match: " + ids.ExpectedValues.Parameters[index].Key + ". Actually get dicom_Info: ", dicom_info_getImageInfo);
                                break;
                            }
                        }
                    }
                    if (p3.Result == TestResult.Pass)
                    {
                        p3.Outputs.AddParameter("Step 3: getImageInfo", "The dicom info all match the expected value", dicom_info_getImageInfo);
                    }

                    //Step4 result
                    XMLResult step4_result = ps.getPresentationStateInfo(pa4);

                    if (step4_result.IsErrorOccured)
                    {
                        p4.Result = TestResult.Fail;
                        p4.Outputs.AddParameter("Step 4: getPresentationStateInfo", "The call 'getPresentationStateInfo' returns error: ", step4_result.Message);
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        p4.Result = TestResult.Pass;
                    }

                    expectedParameterCount = 0;  //count of expected parameters on getPresentationStateInfo
                    for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++)
                    {
                        if (ids.ExpectedValues.Parameters[index].Step == "getPresentationStateInfo")
                        {
                            expectedParameterCount++;
                        }
                    }

                    string dicom_info_getPSInfo = step4_result.DicomArrayResult.GetParameterValueByName("dicom_info");

                    for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++)
                    {
                        if (ids.ExpectedValues.Parameters[index].Step == "getPresentationStateInfo")
                        {
                            if (false == dicom_info_getPSInfo.Contains("<parameter key=\"" + ids.ExpectedValues.Parameters[index].Key + "\" value=\"" + ids.ExpectedValues.Parameters[index].Value + "\" />"))
                            {
                                p4.Result = TestResult.Fail;
                                p4.Outputs.AddParameter("Step 4: getPresentationStateInfo", "Error: the expect dicom value does not match: " + ids.ExpectedValues.Parameters[index].Key + ". Actually get dicom_Info: ", dicom_info_getPSInfo);
                                break;
                            }
                        }
                    }

                    if (p4.Result == TestResult.Pass)
                    {
                        p4.Outputs.AddParameter("Step 4: getPresentationStateInfo", "Success: the expect dicom value all match the expected", dicom_info_getPSInfo);
                    }

                    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);
                }
            }

            //Save service log as xml file
            Output();
        }
コード例 #23
0
        public override void Run()
        {
            string newPatientId = string.Empty;
            string psId = string.Empty;
            string PsInfoString = string.Empty;

            PresentationStateService ps = new PresentationStateService();

            try
            {
                //create a new patient and import a new image to get a new ps id.
                newPatientId = CommonLib.CreatePatient();
                ImportService import = new ImportService();
                XMLResult importResult = import.importObject(newPatientId, string.Empty, @"c:\PASPerformance\001.png", null,  true, string.Empty);
                psId = importResult.MultiResults[1].GetParameterValueByIndex(0);

                //Get PS info string.
                PsInfoString = ps.getPresentationState(psId).ArrayResult.GenerateXML();
            }
            catch (Exception ex)
            {
                LogRecordType lr = new LogRecordType();
                lr.FunctionName = this.mFunctionName;
                lr.Lable = this.mLabel;
                string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                lr.Message = ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";
                lr.Passed = false;

                Log.AddRecord(lr);

                this.RiseSingleCallCompleteEvent(lr.ResponseTime, lr.Passed, true);
                this.RiseTestCaseCompleteEvent();

                this.mExecuted = this.mRepeat;
                this.mFailed = this.mRepeat;

                return;
            }

            for (int i = 1; i <= this.mRepeat; i++)
            {
                LogRecordType lr = new LogRecordType();
                lr.Lable = this.mLabel;
                lr.FunctionName = this.mFunctionName;

                double userCaseResponse = 0;

                try
                {
                    //get ps
                    XMLResult getPsResult = ps.getPresentationState(psId);

                    if (getPsResult.IsErrorOccured)
                    {
                        lr.Passed = false;
                        lr.Message = getPsResult.Message;
                        lr.ResponseTime = ps.ResponseTime;
                        Log.AddRecord(lr);

                        this.mFailed++;
                        continue;
                    }
                    else
                        userCaseResponse = ps.ResponseTime;

                    //set ps
                    XMLResult setPsResult = new XMLResult(ps.InvokeMethod("setPresentationState", new object[] { PsInfoString, psId }));

                    if (setPsResult.IsErrorOccured)
                    {
                        lr.Passed = false;
                        lr.Message = setPsResult.Message;
                        lr.ResponseTime = ps.ResponseTime;
                        Log.AddRecord(lr);

                        this.mFailed++;
                        continue;
                    }
                    else
                        userCaseResponse += ps.ResponseTime;

                    //if no exception.
                    lr.Passed = true;
                    lr.ResponseTime = userCaseResponse;

                    this.mExectuedTime += userCaseResponse;
                }
                catch (Exception ex)
                {
                    lr.Passed = false;
                    string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                    lr.Message = ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";

                    this.mFailed++;
                }

                Log.AddRecord(lr);
                this.mExecuted = i;

                this.RiseSingleCallCompleteEvent(lr.ResponseTime, lr.Passed);
            }

            this.RiseTestCaseCompleteEvent();
        }
コード例 #24
0
        //Case 10: 1.3.7_SetPresentationStateInfo_Normal
        public void Run_PS_SetPresentationStateInfo_Normal_Case10()
        {
            int runCount = 0;

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

                try
                {
                    #region Parameter initialize
                    bool isImportImage = false;
                    string psID = null;
                    string imageID = null;

                    //Input parameters
                    string p_Import_patientId = null;
                    string p_Import_objectFileFullPath = null;
                    XMLParameter p_setPresentationStateInfo = new XMLParameter("presentationstate");
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "import")
                        {
                            isImportImage = true;
                            if (ids.InputParameters.GetParameter(i).Key == "patientInternalId")
                            {
                                p_Import_patientId = ids.InputParameters.GetParameter(i).Value;
                            }
                            else if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath")
                            {
                                p_Import_objectFileFullPath = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "setPresentationStateInfo")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "presentationStateInternalID")
                            {
                                psID = ids.InputParameters.GetParameter(i).Value;
                            }
                            else
                            {
                                p_setPresentationStateInfo.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                            }
                        }
                    }

                    // Output value
                    bool ep_isSetPSInfoReturnOK = true;
                    string ep_SetPSInfoReturnMessage = string.Empty;
                    XMLParameter ep_getPresentationStateInfo = new XMLParameter();
                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Step == "setPresentationStateInfo")
                        {
                            switch (ids.ExpectedValues.GetParameter(i).Key)
                            {
                                case "returnState":
                                    {
                                        if (ids.ExpectedValues.GetParameter(i).Value.ToLower().Equals("pass"))
                                        {
                                            ep_isSetPSInfoReturnOK = true;
                                        }
                                        else if (ids.ExpectedValues.GetParameter(i).Value.ToLower().Equals("fail"))
                                        {
                                            ep_isSetPSInfoReturnOK = false;
                                        }
                                        break;
                                    }
                                case "returnMessage":
                                    {
                                        ep_SetPSInfoReturnMessage = ids.ExpectedValues.GetParameter(i).Value;
                                        break;
                                    }
                                default:
                                    break;
                            }
                        }
                        else if (ids.ExpectedValues.GetParameter(i).Step == "getPresentationStateInfo")
                        {
                            ep_getPresentationStateInfo.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                        }
                    }
                    #endregion

                    ImportService importService = new ImportService();
                    PresentationStateService psService = new PresentationStateService();

                    if (isImportImage)
                    {
                        #region Step 1: Call ImportService.ImportObject to import an image and create a PS
                        CheckPoint cp_Import = new CheckPoint("Import Image", "Call ImportService.ImportObject to import an image");
                        r.CheckPoints.Add(cp_Import);

                        XMLResult rt_Import = importService.importObject(p_Import_patientId, null, p_Import_objectFileFullPath, null, true, "FALSE");
                        if (rt_Import.IsErrorOccured)
                        {
                            cp_Import.Result = TestResult.Fail;
                            cp_Import.Outputs.AddParameter("import", "Import image returns error", rt_Import.Message);

                            SaveRound(r);
                            continue; // Error happens, end current Test Set
                        }
                        else
                        {
                            cp_Import.Result = TestResult.Pass;
                            cp_Import.Outputs.AddParameter("import", "Import image returns success as expected", rt_Import.Message);

                            imageID = rt_Import.MultiResults[0].Parameters[0].ParameterValue; // This one is the ImageID
                            psID = rt_Import.MultiResults[1].Parameters[0].ParameterValue; // This one is the PS ID
                        }
                        #endregion
                    }

                    #region Step 2: Call PresentationStateService.SetPresentationStateInfo to set the PSInfo for the image
                    CheckPoint cp_SetPresentationStateInfo = new CheckPoint("Set PSInfo", "Call PresentationStateService.SetPresentationStateInfo to set ps info");
                    r.CheckPoints.Add(cp_SetPresentationStateInfo);

                    XMLResult rt_SetPresentationStateInfo = psService.setPresentationStateInfo(p_setPresentationStateInfo, psID);
                    if (ep_isSetPSInfoReturnOK) // Expect the call return OK
                    {
                        if (rt_SetPresentationStateInfo.IsErrorOccured)
                        {
                            cp_SetPresentationStateInfo.Result = TestResult.Fail;
                            cp_SetPresentationStateInfo.Outputs.AddParameter("state", "Set PresentationStateInfo returns error", rt_SetPresentationStateInfo.Message);

                            SaveRound(r);
                            continue; // Error happens, end current Test Set
                        }
                        else
                        {
                            cp_SetPresentationStateInfo.Result = TestResult.Pass;
                            cp_SetPresentationStateInfo.Outputs.AddParameter("state", "Set PresentationStateInfo returns success as expected", rt_SetPresentationStateInfo.Message);

                            #region Step 3: Call PresentationStateService.GetPresentationStateInfo to get the PSInfo for the image
                            CheckPoint cp_GetPresentationStateInfo = new CheckPoint("Get PSInfo", "Call PresentationStateService.GetPresentationStateInfo and check the return state");
                            r.CheckPoints.Add(cp_GetPresentationStateInfo);

                            XMLParameterCollection p_GetPresentationStateInfo = new XMLParameterCollection();
                            XMLParameter p_GetPSInfo_ID = new XMLParameter("presentationstate");
                            p_GetPSInfo_ID.AddParameter("internal_id", psID); // Add current psID as the input param
                            XMLParameter p_GetPSInfo_Preferences = new XMLParameter("preferences");
                            p_GetPresentationStateInfo.Add(p_GetPSInfo_ID);
                            p_GetPresentationStateInfo.Add(p_GetPSInfo_Preferences);

                            XMLResult rt_GetPresentationStateInfo = psService.getPresentationStateInfo(p_GetPresentationStateInfo);

                            if (rt_GetPresentationStateInfo.IsErrorOccured)
                            {
                                cp_GetPresentationStateInfo.Result = TestResult.Fail;
                                cp_GetPresentationStateInfo.Outputs.AddParameter("state", "Get PSInfo returns error", rt_GetPresentationStateInfo.Message);

                                SaveRound(r);
                                continue; // Error happens, end current Test Get
                            }
                            else
                            {
                                cp_GetPresentationStateInfo.Result = TestResult.Pass;
                                cp_GetPresentationStateInfo.Outputs.AddParameter("state", "Get PSInfo returns succeed", rt_GetPresentationStateInfo.Message);

                                // Check the return value is correct
                                #region Step 4: Check the values in PresentationStateService.getPresentationStateInfo return are correct
                                CheckPoint cp_getPSInfoReturnValues = new CheckPoint("Get PSInfo", "Check the values in PresentationStateService.GetPresentationStateInfo return");
                                r.CheckPoints.Add(cp_getPSInfoReturnValues);

                                // Add two check values dynamically
                                ep_getPresentationStateInfo.AddParameter("internal_id", psID);
                                ep_getPresentationStateInfo.AddParameter("image_internal_id", imageID);

                                bool isValueEqual = false;
                                bool isKeyShow = false;
                                foreach (XMLParameterNode psNode in ep_getPresentationStateInfo.Parameters)
                                {
                                    isValueEqual = false;
                                    isKeyShow = false;

                                    int i = 0;
                                    for (i = 0; i < rt_GetPresentationStateInfo.DicomArrayResult.Parameters.Count; i++)
                                    {
                                        if (psNode.ParameterName == rt_GetPresentationStateInfo.DicomArrayResult.Parameters[i].ParameterName)
                                        {
                                            isKeyShow = true;
                                            isValueEqual = string.Equals(psNode.ParameterValue, rt_GetPresentationStateInfo.DicomArrayResult.Parameters[i].ParameterValue.Replace("\r", "").Replace("\n", ""));
                                            break; // Find the node, end current for loop to search node
                                        }
                                    }

                                    if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress
                                    {
                                        cp_getPSInfoReturnValues.Result = TestResult.Fail;

                                        if (isKeyShow)
                                        {
                                            System.Diagnostics.Debug.Print("The return value in getPresentationStateInfo does not match the expected.");
                                            cp_getPSInfoReturnValues.Outputs.AddParameter("PSInfo Info", "Check the values in PresentationStateService.getPresentationStateInfo return", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + rt_GetPresentationStateInfo.MultiResults[0].Parameters[i].ParameterValue);
                                        }
                                        else
                                        {
                                            System.Diagnostics.Debug.Print("The return value in getPresentationStateInfo does not contain the node: " + psNode.ParameterName);
                                            cp_getPSInfoReturnValues.Outputs.AddParameter("PSInfo Info", "Check the values in PresentationStateService.getPresentationStateInfo return", "The return value does not contain the node: " + psNode.ParameterName);
                                        }

                                        break; // End current foreach loop, not compare the follwing nodes
                                    }
                                }

                                if (isValueEqual)
                                {
                                    cp_getPSInfoReturnValues.Result = TestResult.Pass;

                                    System.Diagnostics.Debug.Print("The return values in getPresentationStateInfoInfo all match the expected.");
                                    cp_getPSInfoReturnValues.Outputs.AddParameter("PSInfo Info", "Check the values in PresentationStateService.getPresentationStateInfoInfo return", "The return values all match the expected");
                                }
                                #endregion
                            }
                            #endregion
                        }
                    }
                    else // Expect the call return error
                    {
                        if (rt_SetPresentationStateInfo.IsErrorOccured) // There is error
                        {
                            if (rt_SetPresentationStateInfo.Message.ToLower().Contains(ep_SetPSInfoReturnMessage.ToLower()))
                            {
                                cp_SetPresentationStateInfo.Result = TestResult.Pass;
                                cp_SetPresentationStateInfo.Outputs.AddParameter("state", "Set PresentationStateInfo returns error as expected", rt_SetPresentationStateInfo.Message);
                            }
                            else
                            {
                                cp_SetPresentationStateInfo.Result = TestResult.Fail;
                                cp_SetPresentationStateInfo.Outputs.AddParameter("state", "Set PresentationStateInfo returns error message not match the expected. ", "Expect: " + ep_SetPSInfoReturnMessage + "; Actually returns: " + rt_SetPresentationStateInfo.Message);

                                SaveRound(r);
                                continue; // Error happens, end current Test Get
                            }
                        }
                        else // There is no error
                        {
                            cp_SetPresentationStateInfo.Result = TestResult.Fail;
                            cp_SetPresentationStateInfo.Outputs.AddParameter("state", "Set PS not returns error as expected. ", "Actually returns: " + rt_SetPresentationStateInfo.Message);

                            SaveRound(r);
                            continue; // Error happens, end current Test Get
                        }
                    }
                    #endregion

                    if (isImportImage)
                    {
                        #region Step 5: Call ImageService.deleteImage to delete the created image
                        ImageService imageService = new ImageService();
                        CheckPoint cp_DeleteImage = new CheckPoint("Delete Image", "Call imageService.deleteImage to delete the image");
                        r.CheckPoints.Add(cp_DeleteImage);

                        XMLResult rt_DeleteImage = imageService.deleteImage(imageID, new XMLParameter("preferences"));
                        if (rt_DeleteImage.IsErrorOccured)
                        {
                            cp_DeleteImage.Result = TestResult.Fail;
                            cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns error", rt_DeleteImage.Message);

                            SaveRound(r);
                            continue; // End current test set
                        }
                        else
                        {
                            cp_DeleteImage.Result = TestResult.Pass;
                            cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns success", rt_DeleteImage.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();
        }
コード例 #25
0
        //Case 1624: 1.3.6_WorkFlow_N05_Import DICOM Image_Check DICOM Info
        public void Run_Image_Import_GetInfo_Case1624()
        {
            int runCount = 0;

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;

                Round r = this.NewRound(runCount.ToString(), ids.Description);

                try
                {
                    // Input parameter
                    string patientID = null;
                    string objectFileFullPath = null;
                    string imageID = null;
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "import")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "patientID")
                            {
                                patientID = ids.InputParameters.GetParameter(i).Value;
                            }
                            else if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath")
                            {
                                objectFileFullPath = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                    }

                    // Output value
                    XMLParameter getImageInfoReturnValue = new XMLParameter("image");
                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo")
                        {
                            if (ids.ExpectedValues.GetParameter(i).Key == "path") // to handle different path, such as in different OS or user changes the install dr
                            {
                                string path = Utility.GetCSDMConfig(CSDMConfigSection.local, "patientDirectory") + ids.ExpectedValues.GetParameter(i).Value;
                                getImageInfoReturnValue.AddParameter(ids.ExpectedValues.GetParameter(i).Key, path);
                            }
                            else
                            {
                                getImageInfoReturnValue.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                            }
                        }
                    }

                    #region Step: mport the image
                    ImportService importSvc = new ImportService();
                    XMLResult rtImport = importSvc.CallImportAndCheck(r, patientID, objectFileFullPath, null);
                    if (rtImport.IsErrorOccured)
                    {
                        continue;
                    }
                    else
                    {
                        imageID = rtImport.SingleResult;
                    }
                    #endregion

                    #region Step 1: Call ImageService.getImageInfo to get the image info
                    CheckPoint pGetImageInfo = new CheckPoint("getImageInfo", "Call ImageService.getImageInfo to get the image info");
                    r.CheckPoints.Add(pGetImageInfo);

                    ImageService imageService = new ImageService();
                    XMLParameter getImageInfoParam = new XMLParameter("image");
                    getImageInfoParam.AddParameter("internal_id", imageID);
                    XMLResult getImageInfoResult = imageService.getImageInfo(getImageInfoParam);

                    if (getImageInfoResult.IsErrorOccured)
                    {
                        pGetImageInfo.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call ImageService.getImageInfo to get the image info returns error.");
                        pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo to get the image info", getImageInfoResult.Message);

                        SaveRound(r);
                        break; // There is error, end test case
                    }
                    else
                    {
                        pGetImageInfo.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call ImageService.getImageInfo to get the image info succeeds.");
                        pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo to get the image info", getImageInfoResult.Message);
                    }
                    #endregion

                    #region Step 2: Check the values in ImageService.getImageInfo return are correct
                    CheckPoint pImageInfo = new CheckPoint("ImageInfo", "Check the values in ImageService.getImageInfo return");
                    r.CheckPoints.Add(pImageInfo);

                    string dicom_info = null;
                    for (int i = 0; i < getImageInfoResult.DicomArrayResult.Parameters.Count; i++)
                    {
                        if (getImageInfoResult.DicomArrayResult.Parameters[i].ParameterName == "dicom_info")
                        {
                            dicom_info = getImageInfoResult.DicomArrayResult.Parameters[i].ParameterValue;
                            break; // End current for loop to search node
                        }
                    }

                    foreach (XMLParameterNode psNode in getImageInfoReturnValue.Parameters)
                    {
                        if (!dicom_info.Contains("<parameter key=\"" + psNode.ParameterName + "\" value=\"" + psNode.ParameterValue + "\" />"))   //example: <parameter key="dcm_modality" value="IO" />
                        {
                            pImageInfo.Result = TestResult.Fail;
                            pImageInfo.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + dicom_info);
                        }
                    }

                    if (pImageInfo.Result != TestResult.Fail)
                    {
                        pImageInfo.Result = TestResult.Pass;
                        pImageInfo.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return", "The return values in getImageInfo all match the expected. Get:" + getImageInfoResult.ResultContent);
                    }
                    #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();
        }
コード例 #26
0
        // Case 1558:  1.1.04.01 SetImage_N01_Call setImage when the original archived image file is accessible
        public void Run_Image_SetInfo_Normal_Case1558()
        {
            int runCount = 0;

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

                try
                {
                    #region Parameter initialize
                    string patientInternalId = string.Empty;
                    string objectFileFullPath = string.Empty;
                    string archivePath = string.Empty;

                    XMLParameter pSetImageInfo = new XMLParameter("image");
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "importImage")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath")
                            {
                                objectFileFullPath = ids.InputParameters.GetParameter(i).Value;
                            }
                            else if (ids.InputParameters.GetParameter(i).Key == "archivePath")
                            {
                                archivePath = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "setImageInfo")
                        {
                            pSetImageInfo.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }
                    }
                    #endregion

                    #region Step 0: Create a patient for import
                    patientInternalId = PatientService.Utility_CreatePatientForSpecificCase("case1558");

                    if (string.IsNullOrEmpty(patientInternalId))
                    {
                        goto CLEANUP;
                    }
                    #endregion

                    string imageInternalID = string.Empty;
                    string currentPSID = string.Empty;
                    ImportService importService = new ImportService();

                    #region Step 1: Call ImportService.importObject to import a image
                    CheckPoint cpImportImage = new CheckPoint("Import Image", "Call ImportService.importObject to import an archived  image");
                    r.CheckPoints.Add(cpImportImage);

                    XMLResult rtImportImage = importService.importObject(patientInternalId, null, objectFileFullPath, archivePath, true, "false");
                    if (rtImportImage.IsErrorOccured)
                    {
                        cpImportImage.Result = TestResult.Fail;
                        cpImportImage.Outputs.AddParameter("Import image returns error", "Import image", rtImportImage.Message);

                        SaveRound(r);
                        continue; // There is error when create image, end current run
                    }
                    else
                    {
                        cpImportImage.Result = TestResult.Pass;
                        cpImportImage.Outputs.AddParameter("Import image returns success", "Import image", rtImportImage.Message);

                        imageInternalID = rtImportImage.MultiResults[0].Parameters[0].ParameterValue;
                        currentPSID = rtImportImage.MultiResults[1].Parameters[0].ParameterValue;
                    }
                    #endregion

                    string imagePathAfterImport = string.Empty;
                    string archivedPathAfterImport = string.Empty;
                    string archiveTagAfterImport = string.Empty;
                    ImageService imageSvc = new ImageService();

                    #region Step 2-1: Check the getImageDescription return is correct after import image
                    CheckPoint cpGetImageDescriptionAfterImport = new CheckPoint("Check getImageDescription return", "Check getImageDescription return is corerct or not after import image");
                    r.CheckPoints.Add(cpGetImageDescriptionAfterImport);

                    XMLResult rtGetImageDescriptionAfterImport = imageSvc.getImageDescription(imageInternalID);
                    imagePathAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("path");
                    archivedPathAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("archive_path");
                    archiveTagAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("tags");

                    if (string.IsNullOrEmpty(imagePathAfterImport) && archivedPathAfterImport.Equals(archivePath) && string.IsNullOrEmpty(archiveTagAfterImport)) //getImageDescription should return not tags info
                    {
                        cpGetImageDescriptionAfterImport.Result = TestResult.Pass;
                        cpGetImageDescriptionAfterImport.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is correct after import image" + rtGetImageDescriptionAfterImport.ResultContent);
                    }
                    else
                    {
                        cpGetImageDescriptionAfterImport.Result = TestResult.Fail;
                        cpGetImageDescriptionAfterImport.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is not correct after import image. Actually get: " + rtGetImageDescriptionAfterImport.ResultContent);
                    }
                    #endregion

                    #region Step 2-2: Check the info is correct in getImageInfo return after import image
                    CheckPoint cpGetImageInfoAfterImport = new CheckPoint("Check getImageInfo return", "Check getImageInfo return is corerct or not import the image");
                    r.CheckPoints.Add(cpGetImageInfoAfterImport);

                    XMLParameter pGetImageInfoAfterImport = new XMLParameter("image");
                    pGetImageInfoAfterImport.AddParameter("internal_id", imageInternalID);
                    XMLResult rtGetImageInfo = imageSvc.getImageInfo(pGetImageInfoAfterImport);

                    imagePathAfterImport = rtGetImageInfo.DicomArrayResult.GetParameterValueByName("path");
                    archivedPathAfterImport = rtGetImageInfo.DicomArrayResult.GetParameterValueByName("archive_path");
                    archiveTagAfterImport = rtGetImageInfo.DicomArrayResult.GetParameterValueByName("tags");

                    if (string.IsNullOrEmpty(imagePathAfterImport) && string.IsNullOrEmpty(archivedPathAfterImport) && string.IsNullOrEmpty(archiveTagAfterImport)) //&& archivePath.Equals(archivedPathAfterImport) && archiveTagAfterImport == "archived", will be supported in new service
                    {
                        cpGetImageInfoAfterImport.Result = TestResult.Pass;
                        cpGetImageInfoAfterImport.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is correct after import image." + rtGetImageInfo.ResultContent);
                    }
                    else
                    {
                        cpGetImageInfoAfterImport.Result = TestResult.Fail;
                        cpGetImageInfoAfterImport.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is not correct after import image. Actually get: " + rtGetImageInfo.ResultContent);
                    }
                    #endregion

                    #region Step 2-3: Check the image info in listObject retrun after import, such as path, archivePath and tags
                    CheckPoint cpListObject = new CheckPoint("listObjects", "Call PatientService.listObjects to check the archive tag");
                    r.CheckPoints.Add(cpListObject);

                    NewPatientService patientSvcV2 = new NewPatientService();
                    PatientListObjectsRequestType pListObjects = new PatientListObjectsRequestType();
                    pListObjects.current = true;
                    pListObjects.currentSpecified = true;
                    pListObjects.patientInternalId = patientInternalId;
                    pListObjects.type = PatientListObjectsType.presentationState;
                    PatientListObjectsResponseType rtListObjectAfterImport = patientSvcV2.listObjects(pListObjects);

                    if (!patientSvcV2.LastReturnXMLValidateResult.isValid)
                    {
                        cpListObject.Result = TestResult.Fail;
                        cpListObject.Outputs.AddParameter("listObjects", "Check listObjects after import", "The listObjects return XML is not valid per XSD. Returned:" + patientSvcV2.LastReturnXML);
                    }
                    else
                    {
                        bool isArchivePathCorrect = string.Equals(rtListObjectAfterImport.presentationStates[0].image.archivePath, archivePath);
                        bool isPathCorrect = string.IsNullOrEmpty(rtListObjectAfterImport.presentationStates[0].image.path);
                        bool isTagCorrect = string.Equals(rtListObjectAfterImport.presentationStates[0].image.tags, "archived");

                        if (!isArchivePathCorrect || !isTagCorrect || !isPathCorrect)
                        {
                            cpListObject.Result = TestResult.Fail;
                            cpListObject.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The tag or archivedPath info is wrong in the return. Actually get: " + patientSvcV2.LastReturnXML);
                        }
                        else
                        {
                            cpListObject.Result = TestResult.Pass;
                            cpListObject.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The tag and archivedPath info is correct in the return.");
                        }
                    }
                    #endregion

                    #region Step 3: Call ImageService.SetImageInfo to save the archived image as normal image
                    CheckPoint cpSetImageInfo = new CheckPoint("Set Image Info", "Call ImageService.SetImageInfo to save the archived image as normal image");
                    r.CheckPoints.Add(cpSetImageInfo);

                    XMLResult rtSetImageInfo = imageSvc.setImageInfo(pSetImageInfo, imageInternalID);

                    if (rtSetImageInfo.IsErrorOccured)
                    {
                        cpSetImageInfo.Result = TestResult.Fail;
                        cpSetImageInfo.Outputs.AddParameter("SetImageInfo returns error", "SetImageInfo", rtSetImageInfo.Message);
                    }
                    else
                    {
                        cpSetImageInfo.Result = TestResult.Pass;
                        cpSetImageInfo.Outputs.AddParameter("SetImageInfo returns success", "SetImageInfo", rtSetImageInfo.Message);
                    #endregion

                        // Wait the file is transferred to server DB
                        System.Threading.Thread.Sleep(3000);

                        // Below to check the info is correct after setImageInfo. Check points includes:
                        //1. The Image ID and PS ID are not changed
                        //2. GetImageDescription return correct image path and archive path, correct archive flag
                        //3. GetImageInfo return correct image path, correct archive flag
                        //4. Use the image path to check the image file is in server DB
                        //5. The original archived image is not deleted
                        //6. The listObject return contains correct archive tag

                        #region Step 4: Check the ps is set, not newly created after set image
                        CheckPoint cpPSID = new CheckPoint("Check PS ID", "Check the PS ID is not changed after call setImageInfo");
                        r.CheckPoints.Add(cpPSID);

                        XMLParameter pListPS = new XMLParameter("filter");
                        pListPS.AddParameter("current", "true");
                        string currentPSIDAfterSet = imageSvc.listPresentationState(pListPS, imageInternalID).SingleResult;

                        if (currentPSIDAfterSet == currentPSID)
                        {
                            cpPSID.Result = TestResult.Pass;
                            cpPSID.Outputs.AddParameter("listPresentationState", "Check PS ID", "The PS ID is not changed");
                        }
                        else
                        {
                            cpPSID.Result = TestResult.Fail;
                            cpPSID.Outputs.AddParameter("listPresentationState", "Check PS ID", "The PS ID is changed. Expect: " + currentPSID + "; Actually new PS ID: " + currentPSIDAfterSet);
                        }
                        #endregion

                        string imagePathAfterSet = string.Empty;
                        string archivePathAfterSet = string.Empty;
                        string archivedTagAfterSet = string.Empty;

                        #region Step 5: Check the getImageDescription return is correct after set image
                        CheckPoint cpGetImageDescriptionAfterSet = new CheckPoint("Check getImageDescription return", "Check getImageDescription return is corerct or not after call setImageInfo");
                        r.CheckPoints.Add(cpGetImageDescriptionAfterSet);

                        XMLResult rtGetImageDescriptionAfterSet = imageSvc.getImageDescription(imageInternalID);
                        imagePathAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("path");
                        archivePathAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("archive_path");
                        archivedTagAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("tags");

                        if (imagePathAfterSet.Contains(imageInternalID) && string.IsNullOrEmpty(archivePathAfterSet) && string.IsNullOrEmpty(archivedTagAfterSet)) // imagePathAfterSet sampe: C:/Documents and Settings/All Users/Application Data/TW/PAS/pas_data/patient/03/8af0a7e63310cc65013310d46d0e0003/1956bc28-ca5e-4720-a857-d4de18fc1479/02962f27-e4be-4d59-b112-9663a2f2572b.dcm"
                        {
                            cpGetImageDescriptionAfterSet.Result = TestResult.Pass;
                            cpGetImageDescriptionAfterSet.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is correct after set image");
                        }
                        else
                        {
                            cpGetImageDescriptionAfterSet.Result = TestResult.Fail;
                            cpGetImageDescriptionAfterSet.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is not correct after set image. Actually get: " + rtGetImageDescriptionAfterSet.ResultContent);
                        }
                        #endregion

                        #region Step 6: Check the getImageinfo return is correct after set image
                        CheckPoint cpGetImageInfoAfterSet = new CheckPoint("Check getImageInfo return", "Check getImageInfo return is corerct or not after call setImageInfo");
                        r.CheckPoints.Add(cpGetImageInfoAfterSet);

                        XMLParameter pGetImageInfoAfterSet = new XMLParameter("image");
                        pGetImageInfoAfterSet.AddParameter("internal_id", imageInternalID);
                        XMLResult rtGetImageInfoAfterSet = imageSvc.getImageInfo(pGetImageInfoAfterSet);

                        imagePathAfterSet = rtGetImageInfoAfterSet.DicomArrayResult.GetParameterValueByName("path");
                        archivePathAfterSet = rtGetImageInfoAfterSet.DicomArrayResult.GetParameterValueByName("archive_path");
                        archivedTagAfterSet = rtGetImageInfoAfterSet.DicomArrayResult.GetParameterValueByName("tags");

                        if (imagePathAfterSet.Contains(Utility.GetCSDMConfig(CSDMConfigSection.local, "patientDirectory")) && imagePathAfterSet.Contains(imageInternalID) && string.IsNullOrEmpty(archivePathAfterSet) && string.IsNullOrEmpty(archivedTagAfterSet))
                        {
                            cpGetImageInfoAfterSet.Result = TestResult.Pass;
                            cpGetImageInfoAfterSet.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is correct after set image");
                        }
                        else
                        {
                            cpGetImageInfoAfterSet.Result = TestResult.Fail;
                            cpGetImageInfoAfterSet.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is not correct after set image. Actually get: " + rtGetImageInfoAfterSet.ResultContent);
                        }
                        #endregion

                        #region Step 7: Check the file exist in server DB
                        CheckPoint cpImageInDB = new CheckPoint("Check file in DB", "Check the file exist in server DB after call setImageInfo");
                        r.CheckPoints.Add(cpImageInDB);

                        if (Utility.IsImageExistInServerDB(imagePathAfterSet))
                        {
                            cpImageInDB.Result = TestResult.Pass;
                            cpImageInDB.Outputs.AddParameter("Check the file exist in server DB after call setImageInfo", "Check file in DB", "File exist");
                        }
                        else
                        {
                            cpImageInDB.Result = TestResult.Fail;
                            cpImageInDB.Outputs.AddParameter("Check the file exist in server DB after call setImageInfo", "Check file in DB", "File NOT exist");
                        }
                        #endregion

                        #region Step 8: Check the original archived image is not deleted
                        CheckPoint cpOriginalArchivedImage = new CheckPoint("Check original archived file", "Check the original archived image is not deleted after call setImageInfo");
                        r.CheckPoints.Add(cpOriginalArchivedImage);

                        if (System.IO.File.Exists(archivePath))
                        {
                            cpOriginalArchivedImage.Result = TestResult.Pass;
                            cpOriginalArchivedImage.Outputs.AddParameter("Check the original archived image is not deleted after call setImageInfo", "Check original archived file", "File exist");
                        }
                        else
                        {
                            cpOriginalArchivedImage.Result = TestResult.Fail;
                            cpOriginalArchivedImage.Outputs.AddParameter("Check the original archived image is not deleted after call setImageInfo", "Check original archived file", "File NOT exist");
                        }
                        #endregion

                        #region Step 9: Check the image info in listObject retrun after set, such as path, archivePath and tags
                        CheckPoint cpListObjectAfterSet = new CheckPoint("listObjects", "Call PatientService.listObjects to check the archive tag after set");
                        r.CheckPoints.Add(cpListObjectAfterSet);

                        PatientListObjectsResponseType rtListObjectAfterSet = patientSvcV2.listObjects(pListObjects);
                        if (!patientSvcV2.LastReturnXMLValidateResult.isValid)
                        {
                            cpListObjectAfterSet.Result = TestResult.Fail;
                            cpListObjectAfterSet.Outputs.AddParameter("listObjects", "Check listObjects after set", "The listObjects return XML is not valid per XSD. Returned:" + patientSvcV2.LastReturnXML);
                        }
                        else
                        {
                            //bool isPathCorrect = rtListObjectAfterSet.presentationStates[0].image.path.Contains(Utility.GetCSDMConfig(CSDMConfigSection.remote, "patientDirectory")) && rtListObjectAfterSet.presentationStates[0].image.path.Contains(imageInternalID);
                            bool isArchivePathCorrect = string.IsNullOrEmpty(rtListObjectAfterSet.presentationStates[0].image.archivePath);
                            bool isTagCorrect = string.IsNullOrEmpty(rtListObjectAfterSet.presentationStates[0].image.tags);

                            if (!isArchivePathCorrect)
                            {
                                cpListObjectAfterSet.Result = TestResult.Fail;
                                cpListObjectAfterSet.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The archivedPath info is wrong in the return. Actually get: " + patientSvcV2.LastReturnXML);
                            }
                            else if (!isTagCorrect)
                            {
                                cpListObjectAfterSet.Result = TestResult.Fail;
                                cpListObjectAfterSet.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The tag info is wrong in the return. Actually get: " + patientSvcV2.LastReturnXML);
                            }
                            //else if (!isPathCorrect)
                            //{
                            //    cpListObjectAfterSet.Result = TestResult.Fail;
                            //    cpListObjectAfterSet.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The path info is wrong in the return. Actually get: " + patientSvc.LastReturnXML);
                            //}
                            else
                            {
                                cpListObjectAfterSet.Result = TestResult.Pass;
                                cpListObjectAfterSet.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The tag and archivedPath info is correct in the return.");
                            }
                        }
                        #endregion
                    }

                    #region Step 10: Call ImageService.deleteImage to delete the created image
                    if (!string.IsNullOrEmpty(imageInternalID))
                    {
                        CheckPoint cp_DeleteImage = new CheckPoint("Delete Image", "Call imageService.deleteImage to delete the image");
                        r.CheckPoints.Add(cp_DeleteImage);

                        XMLResult rt_DeleteImage = imageSvc.deleteImage(imageInternalID, new XMLParameter("preferences"));
                        if (rt_DeleteImage.IsErrorOccured)
                        {
                            cp_DeleteImage.Result = TestResult.Fail;
                            cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns error", rt_DeleteImage.Message);
                        }
                        else
                        {
                            cp_DeleteImage.Result = TestResult.Pass;
                            cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns success", rt_DeleteImage.Message);
                        }
                    }
                    #endregion

                CLEANUP:
                    #region Step 11: Delete the patient used in this case
                    if (!string.IsNullOrEmpty(patientInternalId))
                    {
                        CheckPoint cp_DeletePatient = new CheckPoint("Step 11: Delete Patient", "Call patientService.deletePatient to delete the patient");
                        r.CheckPoints.Add(cp_DeletePatient);

                        XMLResult rt_DeletePatient = PatientService.Utility_DeletePatientForSpecificCase(patientInternalId);
                        if (rt_DeletePatient.IsErrorOccured)
                        {
                            cp_DeletePatient.Result = TestResult.Fail;
                            cp_DeletePatient.Outputs.AddParameter("delete patient", "Delete patient returns error", rt_DeletePatient.Message);
                        }
                        else
                        {
                            cp_DeletePatient.Result = TestResult.Pass;
                            cp_DeletePatient.Outputs.AddParameter("delete patient", "Delete patient returns success", rt_DeletePatient.Message);
                        }
                    }
                    #endregion

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

            Output();
        }
コード例 #27
0
        // Case 1496: 1.2.3_ImportImage_FMS
        public void Run_Import_FMS_Case1496()
        {
            int runCount = 0;
            string patientUID = string.Empty;
            bool isCreatePatient = false;
            bool isDeletePatient = true;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                isCreatePatient = false;
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Import image");
                CheckPoint pCreate = new CheckPoint("Create Patient", "Test create");
                r.CheckPoints.Add(pCreate);

                PatientService ps = new PatientService();
                ImportService ims = new ImportService();
                XMLParameter pa = new XMLParameter("patient");
                XMLParameter ia = new XMLParameter("import");

                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "create")
                    {
                        pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        isCreatePatient = true;
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "import")
                    {
                        ia.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                }

                string ep_nodeNum = string.Empty;
                string ep_totalSubImageNum = string.Empty;
                string ep_successImageNum = string.Empty;
                for (int i = 0; i < ids.ExpectedValues.Count; i++)
                {
                    if (ids.ExpectedValues.GetParameter(i).Step == "import")
                    {
                        if (ids.ExpectedValues.GetParameter(i).Key == "node")
                        {
                            ep_nodeNum = ids.ExpectedValues.GetParameter(i).Value;
                        }
                        else if (ids.ExpectedValues.GetParameter(i).Key == "total")
                        {
                            ep_totalSubImageNum = ids.ExpectedValues.GetParameter(i).Value;
                        }
                        else if (ids.ExpectedValues.GetParameter(i).Key == "success")
                        {
                            ep_successImageNum = ids.ExpectedValues.GetParameter(i).Value;
                        }
                    }
                }

                XMLParameter epGetFMSInfo = new XMLParameter();
                //XMLParameter epGetFMSDescription = new XMLParameter();

                for (int i = 0; i < ids.ExpectedValues.Count; i++)
                {
                    if (ids.ExpectedValues.GetParameter(i).Step == "getFMSInfo")
                    {
                        epGetFMSInfo.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                    }
                    //else if (ids.ExpectedValues.GetParameter(i).Step == "getFMSDescription")
                    //{
                    //    epGetFMSDescription.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                    //}
                }

                try
                {
                    if (isCreatePatient)
                    {
                        XMLResult result = ps.createPatient(pa);
                        if (!result.IsErrorOccured)
                        {
                            patientUID = result.SingleResult;
                            pCreate.Outputs.AddParameter("Create patient UID", "Create Patient", patientUID);
                            pCreate.Result = TestResult.Pass;
                        }
                        else
                        {
                            pCreate.Outputs.AddParameter("Create patient UID", "Create Patient Fail", result.ResultContent);
                            pCreate.Result = TestResult.Fail;
                        }
                    }

                    CheckPoint pImport = new CheckPoint("Import Image", "Test import");
                    r.CheckPoints.Add(pImport);

                    string filePath = string.Empty;
                    string archivePath = string.Empty;
                    bool move = false;
                    for (int c = 0; c < ia.Length; c++)
                    {
                        if (ia.GetParameterName(c) == "path")
                            filePath = ia.GetParameterValue(c);
                        if (ia.GetParameterName(c) == "archivePath")
                            archivePath = ia.GetParameterValue(c);
                        if (ia.GetParameterName(c) == "move")
                        {
                            if (ia.GetParameterValue(c) == "true")
                                move = true;
                        }
                    }

                    XMLResult rslImport = ims.importObject(patientUID, "", filePath, archivePath, move, "false");

                    /*********************** import FMS return sample:
                       <trophy type="result" version="1.0">
                          <status code="0" message="ok" />
                        - <fms>
                          <parameter key="internal_id" value="637e9a0d-73dc-447e-bf7d-607b6a088468" />
                          </fms>
                        - <image>
                          <parameter key="internal_id" value="c8e90079-1f6f-4d6c-92d2-4cd91e63c3bc" />
                          </image>
                        - <presentationstate>
                          <parameter key="internal_id" value="2ff59bd5-d1c3-4a3b-a514-9871abded236" />
                          </presentationstate>
                        - <image>
                          <parameter key="internal_id" value="9057d7c5-8e1a-4aee-95ce-a4a9e98dc42e" />
                          </image>
                        - <presentationstate>
                          <parameter key="internal_id" value="99179d8d-9855-4bb4-b1c0-c47c7e364d95" />
                          </presentationstate>
                          </trophy>
                     * **********************/

                    if (rslImport.IsErrorOccured)
                    {
                        pImport.Result = TestResult.Fail;
                        pImport.Outputs.AddParameter("Import FMS fail", "Import", rslImport.Message);
                        pImport.Outputs.AddParameter("Import FMS returns error code", "Import", rslImport.Code.ToString());
                    }
                    else
                    {
                        if (rslImport.MultiResults.Count.ToString() != ep_nodeNum)
                        {
                            pImport.Result = TestResult.Fail;
                            pImport.Outputs.AddParameter("Import FMS returns wrong node", "Import", rslImport.ResultContent);
                        }
                        else
                        {
                            pImport.Result = TestResult.Pass;

                            for (int i = 0; i < rslImport.MultiResults.Count - 1; i++)
                            {
                                string internalID = rslImport.MultiResults[i].GetParameterValueByName("internal_id");
                                if (internalID == null || internalID == string.Empty)
                                {
                                    pImport.Result = TestResult.Fail;
                                    pImport.Outputs.AddParameter("Import image returns wrong FMS, image or PS info", "Import", rslImport.ResultContent);
                                    break;
                                }
                            }

                            if (pImport.Result == TestResult.Pass)
                            {
                                string totalSubImages = rslImport.MultiResults[rslImport.MultiResults.Count - 1].GetParameterValueByName("total");
                                string successSubImages = rslImport.MultiResults[rslImport.MultiResults.Count - 1].GetParameterValueByName("success");

                                if (totalSubImages != ep_totalSubImageNum || successSubImages != ep_successImageNum)
                                {
                                    pImport.Result = TestResult.Fail;
                                    pImport.Outputs.AddParameter("Import FMS returns wrong info for [other] when import sub images", "Import", rslImport.ResultContent);
                                }
                                else
                                {
                                    pImport.Result = TestResult.Pass;
                                    pImport.Outputs.AddParameter("import FMS returns OK", "Import", rslImport.ResultContent);
                                }
                            }
                        }
                    }

                    #region Call GetFMSInfo to check the return value
                    FMSService fmsSvc = new FMSService();

                    string fmsID = string.Empty; // Try to get from the import return
                    fmsID = rslImport.MultiResults[0].GetParameterValueByName("internal_id");

                    CheckPoint cpGetFMSInfo = new CheckPoint("GetFMSInfo", "Call GetFMSInfo to check the return value");
                    r.CheckPoints.Add(cpGetFMSInfo);

                    XMLResult rtGetFMSInfo = fmsSvc.getFMSInfo(fmsID);
                    if (rtGetFMSInfo.IsErrorOccured)
                    {
                        cpGetFMSInfo.Result = TestResult.Fail;
                        cpGetFMSInfo.Outputs.AddParameter("Get FMS Info returns error", "getFMSInfo", rtGetFMSInfo.ResultContent);
                    }
                    else
                    {
                        cpGetFMSInfo.Outputs.AddParameter("Get FMS Info returns success", "getFMSInfo", rtGetFMSInfo.Message);

                        //Check the return info contain the expected key and value: parameter key="XXX" value="XXX"
                        foreach (XMLParameterNode node in epGetFMSInfo.Parameters)
                        {
                            if (!rtGetFMSInfo.ResultContent.Contains("parameter key=\"" + node.ParameterName + "\" value=\"" + node.ParameterValue + "\""))
                            {
                                cpGetFMSInfo.Result = TestResult.Fail;
                                cpGetFMSInfo.Outputs.AddParameter("Get FMS Info returns wrong key-value info for: " + node.ParameterName, "GetFMSInfo", rtGetFMSInfo.ResultContent);
                                continue;
                            }
                            else
                            {
                                cpGetFMSInfo.Outputs.AddParameter("Get FMS Info returns correct key-value info for: " + node.ParameterName, "GetFMSInfo", "ok");
                            }
                        }

                        if (cpGetFMSInfo.Result != TestResult.Fail)
                        {
                            cpGetFMSInfo.Result = TestResult.Pass;
                            cpGetFMSInfo.Outputs.AddParameter("Get FMS Info return all correct info", "GetFMSInfo", rtGetFMSInfo.ResultContent);
                        }
                    }
                    #endregion

                    if (isDeletePatient)
                    {
                        CheckPoint cpDelete = new CheckPoint("Delete Patient", "Test delete patient");
                        r.CheckPoints.Add(cpDelete);
                        XMLResult rltDelete = ps.deletePatient(patientUID);
                        if (rltDelete.IsErrorOccured)
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns error", "Delete Patient", rltDelete.Message);
                            cpDelete.Result = TestResult.Fail;
                        }
                        else
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns OK", "Delete Patient", rltDelete.Message);
                            cpDelete.Result = TestResult.Pass;
                        }
                    }

                    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();
        }