// Case 1654: 1.3.1_QueryPatients_N6_grouped by keyword in global search public void Run_Patient_QueryPatient_Case1654() { int runCount = 0; List<string> needDelete = new List<string>(); // step 1. create listed patients. foreach (InputDataSet ids in this.Input.DataSets) { bool bSkip = false; // to skip query InputDataSet for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "queryPatient") bSkip = true; } if (bSkip) continue; runCount++; Round r = this.NewRound(runCount.ToString(), "Create patient"); CheckPoint pCreate = new CheckPoint("Create Patient", "Test description"); r.CheckPoints.Add(pCreate); PatientService ps = new PatientService(); XMLParameter pa = new XMLParameter("patient"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "createPatient") pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } XMLResult result = ps.createPatient(pa); if (result.IsErrorOccured) { pCreate.Result = TestResult.Fail; pCreate.Outputs.AddParameter("Create error:", "Create Patient", result.Message); } else { pCreate.Result = TestResult.Pass; pCreate.Outputs.AddParameter("Patient ID:", "Create Patient", result.SingleResult); needDelete.Add(result.SingleResult); } SaveRound(r); } // step 2. query. foreach (InputDataSet ids in this.Input.DataSets) { bool bSkip = false; // to skip create patient InputDataSet for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "createPatient") bSkip = true; } if (bSkip) continue; runCount++; Round r = this.NewRound(runCount.ToString(), "Query patient"); CheckPoint pQuery = new CheckPoint("Query Patient", "Test description"); r.CheckPoints.Add(pQuery); PatientService ps = new PatientService(); XMLParameter query = new XMLParameter("filter"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "queryPatient") query.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } XMLResult queryPatient = ps.queryPatients(query); // should send global_search if (queryPatient.IsErrorOccured) { pQuery.Result = TestResult.Fail; pQuery.Outputs.AddParameter("Query created patient fail", "Query Patient", queryPatient.ResultContent); } else { pQuery.Outputs.AddParameter("Query created patient OK", "Query Patient", queryPatient.ResultContent); // Here should add the checker for XMLResult // int iTotalExpectedResult = 0; foreach (Parameter p in ids.ExpectedValues.Parameters) { int iStep = 0; if (System.Int32.TryParse(p.Step, out iStep)) { iTotalExpectedResult = iStep > iTotalExpectedResult ? iStep : iTotalExpectedResult; } } System.Xml.XmlDocument xmlResult = new System.Xml.XmlDocument(); xmlResult.LoadXml(queryPatient.ResultContent); int iNodelist = 0; System.Xml.XmlNodeList patientList = xmlResult.SelectNodes("trophy/patient"); foreach (System.Xml.XmlNode patient in patientList) { if (iNodelist < iTotalExpectedResult) { // find the pAttr Key, should check whether the key attribute value is in expected result. foreach (Parameter pExpected in ids.ExpectedValues.Parameters) { int iStep = 0; if (System.Int32.TryParse(pExpected.Step, out iStep)) { if (iStep == (iNodelist + 1)) { bool bChecked = false; // if iNodelist is less than expected value, should check whether this is the expected value ordered by global_search System.Xml.XmlNodeList parameterList = patient.SelectNodes("parameter"); foreach (System.Xml.XmlNode parameter in parameterList) { if (parameter.Attributes["key"].Value == pExpected.Key) { if (parameter.Attributes["value"].Value == pExpected.Value) { string step = "row (" + iStep + ")" + "key (" + pExpected.Key + ") check successful"; string key = "query patient"; string value = "value (" + pExpected.Value + ")"; pQuery.Outputs.AddParameter(step, key, value); pQuery.Result = TestResult.Pass; bChecked = true; } else { string step = "row (" + iStep + ")" + "key (" + pExpected.Key + ") check fail"; string key = "query patient"; string value = "value (" + pExpected.Value + ")"; pQuery.Outputs.AddParameter(step, key, value); pQuery.Result = TestResult.Fail; bChecked = true; } break; // find the expected key value } } if (!bChecked) // the expected value is not find in expected row { string step = "row (" + iStep + ")" + "key (" + pExpected.Key + ") check missed"; string key = "query patient"; string value = "value (" + pExpected.Value + ")"; pQuery.Outputs.AddParameter(step, key, value); pQuery.Result = TestResult.Fail; bChecked = true; } } } } } else { // here , iNodelist is greater than expected value, so this record is more than expected. string step = "row (" + (iNodelist + 1) + ") is not expected"; string key = "query patient"; string value = patient.InnerXml; pQuery.Outputs.AddParameter(step, key, value); pQuery.Result = TestResult.Fail; } iNodelist++; } if (patientList.Count == 0) { string step = "no any query results"; string key = "query patient"; string value = queryPatient.ResultContent; pQuery.Outputs.AddParameter(step, key, value); pQuery.Result = TestResult.Fail; } } SaveRound(r); } // step 3. delete listed patients. foreach (string delpa in needDelete) { PatientService ps = new PatientService(); XMLParameter query = new XMLParameter("patient"); XMLResult delPatient = ps.deletePatient(delpa); if (delPatient.IsErrorOccured) { Round r = this.NewRound(runCount.ToString(), "Delete patient"); CheckPoint pDelete = new CheckPoint("Delete Patient", "Test description"); r.CheckPoints.Add(pDelete); pDelete.Result = TestResult.Fail; pDelete.Outputs.AddParameter("Delete created patient fail", "Delete Patient", delPatient.ResultContent); SaveRound(r); } } Output(); }
//Case 1570: 1.1.06.02_Import an archived FMS_Normal_contains shortcut of archived image(French FE Tool) public void Run_Import_ArchivedFMS_Case1570() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "Import FMS1"); CheckPoint pImportFMS = new CheckPoint("Import FMS1", "Import FMS using conversiontool"); r.CheckPoints.Add(pImportFMS); string patientdir = ids.InputParameters.GetParameter("patientdir").Value; string patient_id = ids.InputParameters.GetParameter("patient_id").Value; string dpms_id = ids.InputParameters.GetParameter("dpms_id").Value; //call conversiontool to import archivedFMS System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = System.IO.Directory.GetCurrentDirectory() + "\\ConversionTool version 1.0.4.0\\conversiontool.exe"; p.StartInfo.Arguments = "-P\"" + patientdir + "\""; p.Start(); System.Threading.Thread.Sleep(20000); p.Kill(); string puid = null; PatientService ps = new PatientService(); XMLParameter cInputQuery = new XMLParameter("filter"); cInputQuery.AddParameter("dpms_id", dpms_id); cInputQuery.AddParameter("patient_id", patient_id); XMLResult rslQuery = ps.queryPatients(cInputQuery); if (rslQuery.IsErrorOccured) { pImportFMS.Result = TestResult.Fail; pImportFMS.Outputs.AddParameter("archiveFMS Import", "Query Fail:", rslQuery.Message); SaveRound(r); goto CLEANUP; } puid = rslQuery.SingleResult; //trigger the post import of FMS NewPatientService nps = new NewPatientService(); PatientListObjectsRequestType request = new PatientListObjectsRequestType(); request.type = PatientListObjectsType.all; request.currentSpecified = true; request.current = true; request.patientInternalId = puid; nps.listObjects(request); //wait the post import completed System.Threading.Thread.Sleep(10000); PatientListObjectsResponseType response = nps.listObjects(request); if (!nps.LastReturnXMLValidateResult.isValid) { pImportFMS.Result = TestResult.Fail; pImportFMS.Outputs.AddParameter("archiveFMS Import", "List Fail:", "Response is not complied with XML Schema"); SaveRound(r); goto CLEANUP; } if (response.status.code != 0) { pImportFMS.Result = TestResult.Fail; pImportFMS.Outputs.AddParameter("archiveFMS Import", "List Fail:", response.status.message); SaveRound(r); goto CLEANUP; } if (response.fmss == null) { pImportFMS.Result = TestResult.Fail; pImportFMS.Outputs.AddParameter("archiveFMS Import", "Import Fail:", "Expected 3 fms, actual none."); SaveRound(r); goto CLEANUP; } else if (response.fmss.Length != 3) { pImportFMS.Result = TestResult.Fail; pImportFMS.Outputs.AddParameter("archiveFMS Import", "Import Fail:", "Expected 3 fms, actual:" + response.fmss.Length.ToString()); SaveRound(r); goto CLEANUP; } if (response.presentationStates == null) { pImportFMS.Result = TestResult.Fail; pImportFMS.Outputs.AddParameter("archiveFMS Import", "Import Fail:", "Expected 21 PS, actual none."); SaveRound(r); goto CLEANUP; } else if (response.presentationStates.Length != 21) { pImportFMS.Result = TestResult.Fail; pImportFMS.Outputs.AddParameter("archiveFMS Import", "Import Fail:", "Expected 21 PS, actual:" + response.presentationStates.Length.ToString()); SaveRound(r); goto CLEANUP; } foreach (PresentationStateType pstate in response.presentationStates) { if (pstate.image.tags != "archived" || pstate.image.archivePath == string.Empty) { pImportFMS.Result = TestResult.Fail; pImportFMS.Outputs.AddParameter("archiveFMS Import", "Check Fail:", "archive tag or path is not correct"); SaveRound(r); goto CLEANUP; } } pImportFMS.Result = TestResult.Pass; pImportFMS.Outputs.AddParameter("archiveFMS Import", "Check Success:", "OK"); SaveRound(r); CLEANUP: if (!string.IsNullOrEmpty(puid)) { ps.deletePatient(patient_id); //delete the patient } } Output(); }
//Case 978: 1.3.17_workflow_CSI starts up and initializes public void Run_WorkFlow_CSIStartsupAndInitializes_Case978() { ApplicationService applicationService = new ApplicationService(); PatientService patientService = new PatientService(); AcquisitionService acquisitionService = new AcquisitionService(); XMLParameter queryPatientsParameter = new XMLParameter("filter"); XMLParameter queryDivicesParameter = new XMLParameter("query_devices"); XMLParameter queryLinesParameter = new XMLParameter("query_lines"); XMLParameter setAsynAcqPatientInfoParameter = new XMLParameter("acq_info"); CheckPoint pRegister = new CheckPoint("register", "register 2D Viewer"); CheckPoint pQueryPatients = new CheckPoint("queryPatients", "query the patients list"); CheckPoint pQueryDevices = new CheckPoint("queryDevices", "query installed device IDs of sensor type"); CheckPoint pQueryLines = new CheckPoint("queryLines", "query installed line IDs of device IDs"); CheckPoint pSetAsynAcqPatientInfo = new CheckPoint("setAsynAcqPatientInfo", "set asyn acq patient info"); foreach (InputDataSet ids in this.Input.DataSets) { Round r = new Round(); r.CheckPoints.Add(pRegister); r.CheckPoints.Add(pQueryPatients); r.CheckPoints.Add(pQueryDevices); r.CheckPoints.Add(pQueryLines); r.CheckPoints.Add(pSetAsynAcqPatientInfo); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "query_devices") { queryDivicesParameter.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } } #region Step 1: receive getType and then register 2D applciation to CSDM System.Threading.Thread simulator = new System.Threading.Thread(delegate() { TwoDSim.simulator si = new TwoDSim.simulator(2010); si.StartSimulater("0,2DViewer"); si.StopSimulator(60000); }); //Use simulator to simulate there is 2D running simulator.Start(); System.Threading.Thread.Sleep(3000); XMLResult registerResult = applicationService.registerApplication("2DViewer", "localhost", 2010, true); try { simulator.Join(3000); } catch (Exception ex) { throw ex; } if (registerResult.IsErrorOccured) { pRegister.Result = TestResult.Fail; System.Diagnostics.Debug.Print("2D Viewer register fail"); pRegister.Outputs.AddParameter("Register", "register 2D Viewer", registerResult.Message); SaveRound(r); break; // There is error, end test case } else { pRegister.Result = TestResult.Pass; System.Diagnostics.Debug.Print("2D Viewer register succeed"); pRegister.Outputs.AddParameter("registerApplication", "Register 2D Viewer", registerResult.Message); } #endregion #region Step 2: call queryPatients to get the patient list XMLResult queryPatientsResult = patientService.queryPatients(queryPatientsParameter); if (queryPatientsResult.IsErrorOccured) { pQueryPatients.Result = TestResult.Fail; System.Diagnostics.Debug.Print("query the patients list fail:"); pQueryPatients.Outputs.AddParameter("queryPatients", "query the patients list", queryPatientsResult.Message); SaveRound(r); break; // There is error, end test case } else { pQueryPatients.Result = TestResult.Pass; System.Diagnostics.Debug.Print("query the patients list succeed:"); pQueryPatients.Outputs.AddParameter("queryPatients", "query the patients list", queryPatientsResult.Message); } #endregion #region Step 3: call queryDevices to query installed device IDs of sensor type XMLResult queryDevicesResult = acquisitionService.queryDevices(queryDivicesParameter); if (queryDevicesResult.IsErrorOccured) { pQueryDevices.Result = TestResult.Fail; System.Diagnostics.Debug.Print("query installed device IDs of sensor type fail:"); pQueryDevices.Outputs.AddParameter("queryDevices", "query installed device IDs of sensor type", queryDevicesResult.Message); SaveRound(r); break; // There is error, end test case } else { pQueryDevices.Result = TestResult.Pass; System.Diagnostics.Debug.Print("query installed device IDs of sensor type succeed:"); pQueryDevices.Outputs.AddParameter("queryDevices", "query installed device IDs of sensor type", queryDevicesResult.Message); } #endregion #region Step 4: call queryLines to query installed line IDs of device IDs // Get the line ID sub strings from queryDevicesResult, e.g: <device id="AcqCR7400.dll"> string pattern = "<device id=\"\\S*\">"; System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(pattern); System.Text.RegularExpressions.MatchCollection matches = regex.Matches(queryDevicesResult.ResultContent); foreach (System.Text.RegularExpressions.Match match in matches) { // Get the exact device ID from the result, e.g: from <device id="AcqCR7400.dll"> to AcqCR7400.dll string deviceID = match.Value; deviceID = deviceID.Replace("<device id=\"", ""); deviceID = deviceID.Replace("\">", ""); queryLinesParameter.AddParameter("id", deviceID); } XMLResult queryLinesResult = acquisitionService.queryLines(queryLinesParameter); if (queryLinesResult.IsErrorOccured) { pQueryLines.Result = TestResult.Fail; System.Diagnostics.Debug.Print("query installed line IDs of device IDs fail:"); pQueryLines.Outputs.AddParameter("queryLines", "query installed line IDs of device IDs", queryLinesResult.Message); SaveRound(r); break; // There is error, end test case } else { pQueryLines.Result = TestResult.Pass; System.Diagnostics.Debug.Print("query installed line IDs of device IDs succeed:"); pQueryLines.Outputs.AddParameter("queryLines", "query installed line IDs of device IDs", queryLinesResult.Message); } #endregion #region Step 5: setAsynAcqPatientInfo with empty patient setAsynAcqPatientInfoParameter.AddParameter("patient_internal_id", ""); XMLResult setAsynAcqPatientInfoResult = acquisitionService.setAsynAcqPatientInfo(setAsynAcqPatientInfoParameter); if (setAsynAcqPatientInfoResult.IsErrorOccured) { pSetAsynAcqPatientInfo.Result = TestResult.Fail; System.Diagnostics.Debug.Print("Set AsynAcq PatientInfo fail:"); pSetAsynAcqPatientInfo.Outputs.AddParameter("setAsynAcqPatientInfo", "Set AsynAcq PatientInfo", setAsynAcqPatientInfoResult.Message); SaveRound(r); break; // There is error, end test case } else { pSetAsynAcqPatientInfo.Result = TestResult.Pass; System.Diagnostics.Debug.Print("Set AsynAcq PatientInfo succeed:"); pSetAsynAcqPatientInfo.Outputs.AddParameter("setAsynAcqPatientInfo", "Set AsynAcq PatientInfo", setAsynAcqPatientInfoResult.Message); } #endregion SaveRound(r); } Output(); }
// Case1572: 1.1.06.11_Import Context_Normal_contains an archived image public void Run_Import_ContextWithArchiveImage_Case1572() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { string patientdir = string.Empty; runCount++; Round r = this.NewRound(runCount.ToString(), "Acquisition"); CheckPoint pImportAnalysis = new CheckPoint("Import Context", "Import Context using conversiontool"); r.CheckPoints.Add(pImportAnalysis); PatientService pa = new PatientService(); XMLParameter query = new XMLParameter("filter"); //XMLParameter psa = new XMLParameter("presentationstate"); //XMLParameterCollection psaCollection = new XMLParameterCollection(); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "patient") { if (ids.InputParameters.GetParameter(i).Key == "patientdir") patientdir = ids.InputParameters.GetParameter(i).Value; else query.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } } System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = System.IO.Directory.GetCurrentDirectory() + "\\ConversionTool version 1.0.4.0\\conversiontool.exe"; p.StartInfo.Arguments = "-P\"" + patientdir + "\""; p.Start(); System.Threading.Thread.Sleep(20000); p.Kill(); XMLResult rslQuery = pa.queryPatients(query); string puid = null; if (rslQuery.IsErrorOccured) { pImportAnalysis.Result = TestResult.Fail; pImportAnalysis.Outputs.AddParameter("archiveFMS Import", "Query Fail:", rslQuery.Message); goto CLEANUP; } else { puid = rslQuery.SingleResult; } NewPatientService nps = new NewPatientService(); PatientListObjectsRequestType request = new PatientListObjectsRequestType(); request.type = PatientListObjectsType.all; request.currentSpecified = true; request.current = true; request.patientInternalId = puid; nps.listObjects(request); System.Threading.Thread.Sleep(10000); PatientListObjectsResponseType response = nps.listObjects(request); if (!nps.LastReturnXMLValidateResult.isValid) { pImportAnalysis.Result = TestResult.Fail; pImportAnalysis.Outputs.AddParameter("archiveContext Import", "List Fail:", "Response is not complied with XML Schema"); goto CLEANUP; } if (response.status.code != 0) { pImportAnalysis.Result = TestResult.Fail; pImportAnalysis.Outputs.AddParameter("archiveContext Import", "List Fail:", response.status.message); goto CLEANUP; } if (ids.ExpectedValues.GetParameter("currentps").Value != null) { if (response.presentationStates.Length.ToString() != ids.ExpectedValues.GetParameter("currentps").Value) { pImportAnalysis.Result = TestResult.Fail; pImportAnalysis.Outputs.AddParameter("archiveContext Import", "Import Fail:", "Expected" + ids.ExpectedValues.GetParameter("currentps").Value + "PS, actual:" + response.presentationStates.Length.ToString()); goto CLEANUP; } } request.current = false; // below to check non-current PS and analysis response = nps.listObjects(request); if (!nps.LastReturnXMLValidateResult.isValid) { pImportAnalysis.Result = TestResult.Fail; pImportAnalysis.Outputs.AddParameter("archiveContext Import", "List Fail:", "Response is not complied with XML Schema"); goto CLEANUP; } if (response.status.code != 0) { pImportAnalysis.Result = TestResult.Fail; pImportAnalysis.Outputs.AddParameter("archiveContext Import", "List Fail:", response.status.message); goto CLEANUP; } if (ids.ExpectedValues.GetParameter("noncurrentps").Value != null) { if (response.presentationStates == null || response.presentationStates.Length.ToString() != ids.ExpectedValues.GetParameter("noncurrentps").Value) { pImportAnalysis.Result = TestResult.Fail; pImportAnalysis.Outputs.AddParameter("archiveContext Import", "Import Fail:", "Expected" + ids.ExpectedValues.GetParameter("noncurrentps").Value + "NON Current PS, actual response:" + nps.LastReturnXML); goto CLEANUP; } } if (ids.ExpectedValues.GetParameter("noncurrentanalysis").Value != null) { if (response.analysiss == null || response.analysiss.Length.ToString() != ids.ExpectedValues.GetParameter("noncurrentanalysis").Value) { pImportAnalysis.Result = TestResult.Fail; pImportAnalysis.Outputs.AddParameter("archiveContext Import", "Import Fail:", "Expected" + ids.ExpectedValues.GetParameter("noncurrentanalysis").Value + "NON Current Analysis, actual response:" + nps.LastReturnXML); goto CLEANUP; } } pImportAnalysis.Result = TestResult.Pass; pImportAnalysis.Outputs.AddParameter("archiveContext Import", "success import the context", "OK"); CLEANUP: if (!string.IsNullOrEmpty(puid)) { pa.deletePatient(puid); } SaveRound(r); } Output(); }