//Case 48: 1.3.12_SetAnalysisDescription_Normal public void Run_Analysis_Acq_SetAnalysisDescription_Case48() { int runCount = 0; string analysisContent = "<trophy type=\"analysis\" version=\"1.0\"> <trophyheader> <accesslog> <creation date=\"2011-10-25\" time=\"10:54:17\" applicationname=\"kdis2dviewer\" applicationversion=\"7.0\" /> <modification date=\"2011/10/25\" time=\"10:54:18\" applicationname=\"kdis2dviewer\" applicationversion=\"7.0\" /> </accesslog> </trophyheader> <templateheader> <object subtype=\"analysis\" instance=\"true\" name=\"Test Analysis\" uid=\"\" /> <comments /> <icon filepath=\"analysisicon.jpg\" /> <icon> <ObjectData>base64imagedata</ObjectData> </icon> <icon id=\"thumbnailid\" /> <AnalysisProp name=\"1112222\" comments=\"\" date=\"2011-10-25\" time=\"10:54:17\" arrangementmode=\"0\" /> </templateheader> <page index=\"0\" Dx=\"1280\" Dy=\"1024\" backgroundColour=\"RGB(0,0,0)\"> <Frame index=\"1\" type=\"floating panel\" x=\"938\" y=\"201\" w=\"200\" h=\"239\" Zorder=\"\"> <PanelProp paneltype=\"control panel xray\" id=\"control panel xray\" showstate=\"maximized\" /> </Frame> <Frame index=\"2\" type=\"floating panel\" x=\"938\" y=\"201\" w=\"200\" h=\"240\" Zorder=\"\"> <PanelProp paneltype=\"control panel color\" id=\"control panel color\" showstate=\"maximized\" /> </Frame> <Frame index=\"3\" type=\"image\" x=\"349\" y=\"299\" w=\"266\" h=\"355\" Zorder=\"\"> <PanelProp paneltype=\"image\" id=\"@@PSID0\" showstate=\"selected\" IdV0=\"76b3ec9d-1374-4a13-9950-6cf3f5ebc1e6\" /> </Frame> <Frame index=\"4\" type=\"image\" x=\"818\" y=\"299\" w=\"266\" h=\"354\" Zorder=\"\"> <PanelProp paneltype=\"image\" id=\"@@PSID1\" showstate=\"deselected\" IdV0=\"eb87d761-accf-4531-b4fc-9ee9861f15fd\" /> </Frame> </page></trophy>"; foreach (InputDataSet ids in this.Input.DataSets) { Round r = this.NewRound(runCount.ToString(), "Acquisition for Analysis"); CheckPoint pAnalysis = new CheckPoint("Create Analysis", "Create Analysis"); r.CheckPoints.Add(pAnalysis); XMLParameter acq = new XMLParameter("acq_info"); XMLParameter analysisInfo = new XMLParameter("analysis"); string PatientID = string.Empty; int setInfoCount = 0; for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "acquire") { if (ids.InputParameters.GetParameter(i).Key == "patient_internal_id") PatientID = ids.InputParameters.GetParameter(i).Value; acq.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } if (ids.InputParameters.GetParameter(i).Step == "AnalysisInfo") { analysisInfo.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); setInfoCount++; } } string retPsID = string.Empty; string AnalysisUID = string.Empty; string repStr = "@@PSID"; XMLParameterCollection anaUidsXML = new XMLParameterCollection(); XMLParameter anaUids = new XMLParameter("presentationstate"); XMLParameter anaUidsSet = new XMLParameter("presentationstate"); for (int acqTime = 0; acqTime < 2; acqTime++) { retPsID = AcquisitionService.AcquireImage(acq); if (retPsID != string.Empty) { analysisContent = analysisContent.Replace(repStr + acqTime, retPsID); anaUids.AddParameter("internal_id", retPsID); if (acqTime == 0) { anaUidsSet.AddParameter("internal_id", retPsID); } } } System.Threading.Thread.Sleep(20000); anaUidsXML.Add(anaUids); AnalysisService ass = new AnalysisService(); XMLResult rslCreateAnalysis = ass.createAnalysis(analysisContent, false, true, PatientID, @"D:\Test\DICOM_Imag_Lib\ImportImage\thumb.PNG", anaUidsXML); if (rslCreateAnalysis.IsErrorOccured) { pAnalysis.Result = TestResult.Fail; pAnalysis.Outputs.AddParameter("Create Analysis", "Analysis Service", rslCreateAnalysis.Message); } else { pAnalysis.Result = TestResult.Pass; AnalysisUID = rslCreateAnalysis.SingleResult; pAnalysis.Outputs.AddParameter("Create Analysis ID:", "Analysis Service", AnalysisUID); } anaUidsXML.RemoveAt(0); anaUidsXML.Add(anaUidsSet); XMLResult rslsetAnaDesc = ass.setAnalysisDescription(AnalysisUID, analysisContent, false, anaUidsXML); if (rslsetAnaDesc.IsErrorOccured) { pAnalysis.Result = TestResult.Fail; pAnalysis.Outputs.AddParameter("Set Analysis Desc Failed", "Analysis Service", rslsetAnaDesc.Message); } else { XMLResult rslGetAnaDesc = ass.getAnalysisDescription(AnalysisUID); XMLResult rslListAnalysisObject = ass.listAnalysisObjects(AnalysisUID); if (rslGetAnaDesc.IsErrorOccured || rslListAnalysisObject.IsErrorOccured) { pAnalysis.Result = TestResult.Fail; pAnalysis.Outputs.AddParameter("Get Analysis Desc Failed", "Analysis Service", rslGetAnaDesc.Message); } else { //for (int co = 0; co < rslListAnalysisObject.MultiResults.Count; co++) //{ // if (rslListAnalysisObject.MultiResults[co].Name == "presentationstate" && // rslListAnalysisObject.MultiResults[co].Parameters[0].ParameterValue == anaUidsSet.Parameters[0].ParameterValue) // { // pAnalysis.Result = TestResult.Pass; // pAnalysis.Outputs.AddParameter("Set Analysis Desc successfully", "Analysis Service", "The get presentation information match with setting"); // } //} pAnalysis.Result = TestResult.Pass; } } ass.deleteAnalysis(AnalysisUID); SaveRound(r); } Output(); }
//Case 1598: 1.1.06.21_ImportDir_MainDirectory_N01 public void Run_Import_ImportDir_MainDirectory_Case1598() { int runCount = 0; NotificationSim.ReceiveNotification rn = new ReceiveNotification(); System.Collections.Generic.List<string> topics = new System.Collections.Generic.List<string>(); topics.Add("topic.postImportCompleted"); string stopTopic = "teststop"; string stopContent = "teststop"; rn.startListon(topics, stopTopic, stopContent); foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "ImportMainDir"); CheckPoint pimp = new CheckPoint("ImportDir", "Import Additional Dir"); r.CheckPoints.Add(pimp); //create patient for import PatientService ps = new PatientService(); XMLParameter cInputPatient = new XMLParameter("patient"); cInputPatient.AddParameter("first_name", "test"); cInputPatient.AddParameter("last_name", "importmaindir"); XMLResult rslCreate = ps.createPatient(cInputPatient); if (rslCreate.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Create Patient Fail", rslCreate.Message); SaveRound(r); continue; } string patientid = rslCreate.SingleResult; try { string kdis6dir = ids.InputParameters.GetParameter("kdis6_dir").Value; int retrynum = int.Parse(ids.InputParameters.GetParameter("retrynum").Value); string flag = "import"; ImportService imps = new ImportService(); XMLResult rslimport = imps.importDir(patientid, kdis6dir, flag); if (rslimport.Code != 800) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Import Fail", rslimport.Message); SaveRound(r); ps.deletePatient(patientid); continue; } int n = 0; while (rn.getRecievedNumber() == 0) { n++; if (n < retrynum) { System.Threading.Thread.Sleep(5000); } else { break; } } if (n == retrynum) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Notification Fail", "No notification recieved after retry " + n.ToString() + " times."); SaveRound(r); ps.deletePatient(patientid); continue; } ApplicationService app = new ApplicationService(); app.sendGenericNotification(stopTopic, stopContent); System.Threading.Thread.Sleep(1000); System.Collections.Generic.List<string> mmm = rn.getNotificationContent(); System.Collections.Generic.List<string> imageids = PAS.AutoTest.TestUtility.Utility.parsePostImportResult("Image", mmm[0]); System.Collections.Generic.List<string> fmsids = PAS.AutoTest.TestUtility.Utility.parsePostImportResult("FMS", mmm[0]); System.Collections.Generic.List<string> analysisids = PAS.AutoTest.TestUtility.Utility.parsePostImportResult("Analysis", mmm[0]); int expectedimgcount = int.Parse(ids.ExpectedValues.GetParameter("imgnum").Value); int expectedfmscount = int.Parse(ids.ExpectedValues.GetParameter("fmsnum").Value); int expectedanalysiscount = int.Parse(ids.ExpectedValues.GetParameter("analysisnum").Value); //check counts if (imageids.Count != expectedimgcount) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Image Count is not correct", "Actual:" + imageids.Count.ToString() + ",Expected:" + expectedimgcount.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } if (fmsids.Count != expectedfmscount) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "FMS Count is not correct", "Actual:" + fmsids.Count.ToString() + ",Expected:" + expectedfmscount.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } if (analysisids.Count != expectedanalysiscount) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Analysis Count is not correct", "Actual:" + analysisids.Count.ToString() + ",Expected:" + expectedanalysiscount.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } //get image info ImageService imgs = new ImageService(); foreach (string imgid in imageids) { XMLParameter cInputImage = new XMLParameter("image"); cInputImage.AddParameter("internal_id", imgid); XMLResult rslget = imgs.getImageInfo(cInputImage); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "GetImage Fail", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } } //get FMS info FMSService fmss = new FMSService(); foreach (string fmsid in fmsids) { XMLResult rslget = fmss.getFMSInfo(fmsid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "GetFMS Fail", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } rslget = fmss.getFMSDescription(fmsid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "GetFMS Fail", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } } //get Analysis info AnalysisService anas = new AnalysisService(); foreach (string analysisid in analysisids) { XMLResult rslget = anas.getAnalysisInfo(analysisid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "GetAnalysis Fail", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } rslget = anas.getAnalysisDescription(analysisid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "GetAnalysis Fail", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } } //check list object NewPatientService nps = new NewPatientService(); PatientListObjectsRequestType request = new PatientListObjectsRequestType(); request.currentSpecified = true; request.current = true; request.patientInternalId = patientid; request.type = PatientListObjectsType.all; PatientListObjectsResponseType response = nps.listObjects(request); //to refresh code 800 to 0 response = nps.listObjects(request); if (!nps.LastReturnXMLValidateResult.isValid) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail", "Response is not complied with schema"); SaveRound(r); ps.deletePatient(patientid); continue; } if (response.status.code != 0) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,message: ", response.status.message); SaveRound(r); ps.deletePatient(patientid); continue; } int expectedcurrentps = int.Parse(ids.ExpectedValues.GetParameter("curpsnum").Value); int expectedcurrentfms = int.Parse(ids.ExpectedValues.GetParameter("curfmsnum").Value); int expectedcurrentanalysis = int.Parse(ids.ExpectedValues.GetParameter("curanalysisnum").Value); if (response.presentationStates.Length != expectedcurrentps) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,current image count not correct: ", "actural:" + response.presentationStates.Length.ToString() + " expect:" + expectedcurrentps.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } //get PS PresentationStateService pss = new PresentationStateService(); foreach (PresentationStateType pst in response.presentationStates) { XMLResult rslget = pss.getPresentationState(pst.uid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "get PS fail: ", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } } if (response.analysiss != null) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,current analysis count not correct: ", "Expect no analysis will be returned"); SaveRound(r); ps.deletePatient(patientid); continue; } if (response.fmss.Length != expectedcurrentfms) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,current fms count not correct: ", "actural:" + response.fmss.Length.ToString() + " expect:" + expectedcurrentfms.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } //list noncurrent objects request.currentSpecified = true; request.current = false; request.patientInternalId = patientid; request.type = PatientListObjectsType.all; response = nps.listObjects(request); int expectednoncurrentps = int.Parse(ids.ExpectedValues.GetParameter("noncurpsnum").Value); int expectednoncurrentfms = int.Parse(ids.ExpectedValues.GetParameter("noncurfmsnum").Value); int expectednoncurrentanalysis = int.Parse(ids.ExpectedValues.GetParameter("noncuranalysisnum").Value); if (response.presentationStates.Length != expectednoncurrentps) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail, non current ps count not correct: ", "actual:" + response.presentationStates.Length.ToString() + " expect:" + expectednoncurrentanalysis.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } //get PS foreach (PresentationStateType pst in response.presentationStates) { XMLResult rslget = pss.getPresentationState(pst.uid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "get PS fail: ", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } } //check 3d object if (response.volumes.Length != int.Parse(ids.ExpectedValues.GetParameter("expect3dnum").Value)) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Import 3d objects fail: ", "Count is " + response.volumes.Length.ToString() + ",expect:" + ids.ExpectedValues.GetParameter("expect3dnum").Value); SaveRound(r); ps.deletePatient(patientid); continue; } if (response.analysiss.Length != expectednoncurrentanalysis) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,non current analysis count not correct: ", "actual:" + response.analysiss.Length.ToString() + " expect:" + expectednoncurrentanalysis.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } if (response.fmss.Length != expectednoncurrentfms) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,non current fms count not correct: ", "actual:" + response.fmss.Length.ToString() + " expect:" + expectednoncurrentfms.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } //Finally the test success pimp.Result = TestResult.Pass; pimp.Outputs.AddParameter("Import Main Dir", "Success", "OK"); SaveRound(r); ps.deletePatient(patientid); } catch (Exception e) { ps.deletePatient(patientid); pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Fail", "Exception caught,message:" + e.Message); SaveRound(r); } } error: Output(); }