//Case 164: 1.3.8_GetFMSDescription_Normal public void Run_FMS_GetFMSDescription_Normal_Case164() { int runCount = 0; string acquireType = string.Empty; string setFmsDescriptionValue = string.Empty; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "Acquisition"); AcquisitionService acqs = new AcquisitionService(); FMSService fmss = new FMSService(); ImageService igs = new ImageService(); PresentationStateService pss = new PresentationStateService(); XMLParameter acq = new XMLParameter("acq_info"); XMLParameterCollection FmsDescColl = new XMLParameterCollection(); XMLParameter FmsDesc = new XMLParameter("fms"); XMLParameter FmsPs = new XMLParameter("presentationstate"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "acquire") { acq.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } if (ids.InputParameters.GetParameter(i).Step == "acquireType") { acquireType = ids.InputParameters.GetParameter(i).Key; } if (ids.InputParameters.GetParameter(i).Step == "FMSDesc") { FmsDesc.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); setFmsDescriptionValue = ids.InputParameters.GetParameter(i).Value.Replace("\r", ""); } } CheckPoint pAcquire = new CheckPoint("Acquire Image", "Acquisition FMS"); r.CheckPoints.Add(pAcquire); System.Diagnostics.Debug.Print("Acquire start"); XMLResult rslAcqRVG = acqs.startAcquisition(acq); System.Threading.Thread.Sleep(3000); switch (acquireType) { case "FMS": System.Diagnostics.Debug.Print("FMS Acquire"); Utility.AcqFMS(22, 60); break; default: System.Diagnostics.Debug.Print("NOT FMS/PANO/CEPH/CR Acquire"); break; } if (rslAcqRVG.IsErrorOccured) { System.Diagnostics.Debug.Print("Acquire fail:"); pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Acquire image error", "startAcquisition", rslAcqRVG.Message); } else { pAcquire.Outputs.AddParameter("Acquire session ID", "startAcquisition", rslAcqRVG.SingleResult); int DORVGcount = 0; XMLResult getAcqRVG = new XMLResult(); do { System.Threading.Thread.Sleep(3000); System.Diagnostics.Debug.Print("get acquire in do"); DORVGcount++; getAcqRVG = acqs.getAcquisitionResult(rslAcqRVG.SingleResult); if (!getAcqRVG.IsErrorOccured) { ParseXMLContent parser = new ParseXMLContent(getAcqRVG.ResultContent); // To parse the return XML string fmsID = parser.getStringWithPathAndType("trophy/object_info", "fms", "value"); string[] fmsIDs = fmsID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); int fmsCount = fmsIDs.Length; string imageID = parser.getStringWithPathAndType("trophy/object_info", "image", "value"); string[] imageIDs = imageID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); int imageCount = imageIDs.Length; string psID = parser.getStringWithPathAndType("trophy/object_info", "presentation_state", "value"); string[] psIDs = psID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); int psCount = psIDs.Length; if (fmsCount == 1 && imageCount >= 1 && psCount >= 1 && imageCount == psCount) { pAcquire.Result = TestResult.Pass; FmsDescColl.Add(FmsDesc); FmsDescColl.Add(FmsPs); CheckPoint pFMS = new CheckPoint("Set FMS Description", "FMS Service"); r.CheckPoints.Add(pFMS); string FMSInternalID = fmsIDs[0]; XMLResult rslSetFmsDesc = fmss.setFMSDescription(FmsDescColl, FMSInternalID); if (rslSetFmsDesc.IsErrorOccured) { pFMS.Result = TestResult.Fail; pFMS.Outputs.AddParameter("Set FMS Result", "FMS Service", rslSetFmsDesc.ResultContent); } XMLResult rslGetFmsDesc = fmss.getFMSDescription(FMSInternalID); if (rslGetFmsDesc.IsErrorOccured) { pFMS.Result = TestResult.Fail; pFMS.Outputs.AddParameter("Get FMS Description Fail", "FMS Service", rslGetFmsDesc.ResultContent); } else { for (int rslCount = 0; rslCount < rslGetFmsDesc.MultiResults.Count; rslCount++) { if (rslGetFmsDesc.MultiResults[rslCount].Name == "fms") { if (rslGetFmsDesc.MultiResults[rslCount].Parameters[0].ParameterName == "xml_description" && rslGetFmsDesc.MultiResults[rslCount].Parameters[0].ParameterValue == setFmsDescriptionValue) { pFMS.Result = TestResult.Pass; pFMS.Outputs.AddParameter("Get FMS Description Success", "FMS Service", "Match the setting value"); } } if (rslGetFmsDesc.MultiResults[rslCount].Name == "presentationstate") { for (int i = 0; i < rslGetFmsDesc.MultiResults[rslCount].Parameters.Count; i++) { if (!psID.Contains(rslGetFmsDesc.MultiResults[rslCount].Parameters[i].ParameterValue)) { pFMS.Result = TestResult.Fail; pFMS.Outputs.AddParameter("Get FMS Description Success", "FMS Service", "Setting PSID is not match"); break; } } } }//Check the return value for fms section and ps section }//Get FMS Description end XMLResult delFmsRls = fmss.deleteFMS("true", FMSInternalID); if (delFmsRls.IsErrorOccured) { pFMS.Result = TestResult.Fail; pFMS.Outputs.AddParameter("Delete FMS Result", "FMS Service", delFmsRls.Message); pFMS.Outputs.AddParameter("Delete FMS", "FMS Service", "Delete FMS Error"); break; } pFMS.Result = TestResult.Pass; pFMS.Outputs.AddParameter("Delete FMS Result", "FMS Service", delFmsRls.ResultContent); pFMS.Outputs.AddParameter("Delete FMS and images", "FMS Service", "All images and fms has been deleted"); } else { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("getAcquisitionResult", "FMS Service", "No Image or PS id return"); } break; } if (getAcqRVG.Code != 0 && getAcqRVG.Code != 499) { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Get acquire image error", "getAcquisitionResult", getAcqRVG.Message); break; } if (getAcqRVG.IsErrorOccured && getAcqRVG.Code != 499) continue; System.Diagnostics.Debug.Print("get acquireResult:" + DORVGcount); if (DORVGcount > 60) { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Get acquire image error", "getAcquisitionResult", "Acquire great with 3 minutes, timeout!"); break; } } while (true); } SaveRound(r); } Output(); }
// Case 1560: 1.1.04.03 SetImage_N03_Call setImage for archived image in FMS public void Run_Image_SetInfo_ImageInFMS_Case1560() { 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 fmsFullPath = string.Empty; string objectFileFullPath = string.Empty; string archivedPath = string.Empty; XMLParameter pSetImageInfo = new XMLParameter("image"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "importFMS") { if (ids.InputParameters.GetParameter(i).Key == "patient_internal_id") { patientInternalId = ids.InputParameters.GetParameter(i).Value; } else if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath") { fmsFullPath = ids.InputParameters.GetParameter(i).Value; } } else 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") { archivedPath = 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 ImportService importService = new ImportService(); FMSService fmsSvc = new FMSService(); ImageService imageService = new ImageService(); #region Step 1-1: Call ImportService.importObject to import FMS string fmsID = string.Empty; CheckPoint cpImportFMS = new CheckPoint("Import Image", "Call ImportService.importObject to import a FMS"); r.CheckPoints.Add(cpImportFMS); XMLResult rtImportFMS = importService.importObject(patientInternalId, null, fmsFullPath, null, true, "false"); if (rtImportFMS.IsErrorOccured) { cpImportFMS.Result = TestResult.Fail; cpImportFMS.Outputs.AddParameter("Import image returns error", "Import image", rtImportFMS.Message); SaveRound(r); continue; // There is error when create image, end current run } else { cpImportFMS.Result = TestResult.Pass; cpImportFMS.Outputs.AddParameter("Import image returns success", "Import image", rtImportFMS.Message); foreach (XMLParameter p in rtImportFMS.MultiResults) { if (p.Name == "fms") { fmsID = p.Parameters[0].ParameterValue; break; } } } #endregion #region Step 1-2: Call ImportService.importObject to import a image string imageInternalID = string.Empty; string currentPSID = string.Empty; 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 #region Step 1-3: Add image into FMS CheckPoint cpSetFMS = new CheckPoint("Set FMS", " Call setFMSDescription to add the archived image into it"); r.CheckPoints.Add(cpImportFMS); XMLParameterCollection pSetFMSDescription = new XMLParameterCollection(); XMLParameter pFMSDes = new XMLParameter("fms"); pFMSDes.AddParameter("xml_description", ""); XMLParameter pFMSPS = new XMLParameter("presentationstate"); foreach (XMLParameter p in rtImportFMS.MultiResults) //Add original PS { if (p.Name == "presentationstate") { pFMSPS.AddParameter("internal_id", p.Parameters[0].ParameterValue); } } pFMSPS.AddParameter("internal_id", currentPSID); pSetFMSDescription.Add(pFMSDes); pSetFMSDescription.Add(pFMSPS); XMLResult rtSetFMS = fmsSvc.setFMSDescription(pSetFMSDescription, fmsID); if (rtSetFMS.IsErrorOccured) { cpSetFMS.Result = TestResult.Fail; cpSetFMS.Outputs.AddParameter("Set FMS", "setFMSDescription return error: ", rtSetFMS.ResultContent); } else { cpSetFMS.Result = TestResult.Pass; } #endregion #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)) //&& archivedPathAfterImport == archivedPath && 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"); } 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: 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 = 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 3: Check the image is set, not newly created ////PatientService patientSvc = new PatientService(); ////patientSvc.listObjects(); ////NewPatientService newPatientSvc = new NewPatientService(); ////newPatientSvc.listObjects(); //#endregion #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 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 = 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 #region Step 10: Call FMSService.deleteFMS to delete the FMS CheckPoint cp_DeleteFMS = new CheckPoint("Delete FMS", "Call fmsService.deleteFMS to delete the FMS"); r.CheckPoints.Add(cp_DeleteFMS); XMLResult rt_DeleteFMS = fmsSvc.deleteFMS("true", fmsID); if (rt_DeleteFMS.IsErrorOccured) { cp_DeleteFMS.Result = TestResult.Fail; cp_DeleteFMS.Outputs.AddParameter("delete fms", "Delete fms returns error", rt_DeleteFMS.Message); } else { cp_DeleteFMS.Result = TestResult.Pass; cp_DeleteFMS.Outputs.AddParameter("delete fms", "Delete fms returns success", rt_DeleteFMS.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(); }