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