Exemple #1
0
        public async Task FindEntityTest()
        {
            var testNumber = 2;

            // Create a test workspace
            var workspaceItem = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Upload test data
            var uploadPath = Path.Combine(TestSettings.TestDataRootDirectory, "Sro", "mr.dcm");
            var overrides  = new UploadFileOverrides
            {
                Patient = new PatientOverridesSchema {
                    Mrn = $"{testNumber}-Mrn", Name = $"{testNumber}-Name"
                }
            };
            var uploadResults = await _proKnow.Uploads.UploadAsync(workspaceItem, uploadPath, overrides);

            var uploadProcessingResults = await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

            var uploadBatch = new UploadBatch(_proKnow, workspaceItem.Id, uploadProcessingResults.Results);

            // Get the summary views of the patient and an entity in the upload response
            var uploadPatientSummary = uploadBatch.FindPatient(uploadPath);
            var uploadEntitySummary  = uploadBatch.FindEntity(uploadPath);

            // Verify the contents
            Assert.AreEqual(workspaceItem.Id, uploadEntitySummary.WorkspaceId);
            Assert.AreEqual(uploadPatientSummary.Id, uploadEntitySummary.PatientId);
            Assert.IsNotNull(uploadEntitySummary.Id);
            Assert.AreEqual("1.2.246.352.221.470938394496317011513892701464452657827", uploadEntitySummary.Uid);
            Assert.AreEqual("image_set", uploadEntitySummary.Type);
            Assert.AreEqual("MR", uploadEntitySummary.Modality);
            Assert.AreEqual("", uploadEntitySummary.Description);
        }
Exemple #2
0
        public async Task FindSroTest()
        {
            var testNumber = 3;

            // Create a test workspace
            var workspaceItem = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Upload test data
            var uploadPath = Path.Combine(TestSettings.TestDataRootDirectory, "Sro", "reg.dcm");
            var overrides  = new UploadFileOverrides
            {
                Patient = new PatientOverridesSchema {
                    Mrn = $"{testNumber}-Mrn", Name = $"{testNumber}-Name"
                }
            };
            var uploadResults = await _proKnow.Uploads.UploadAsync(workspaceItem, uploadPath, overrides);

            var uploadProcessingResults = await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

            var uploadBatch = new UploadBatch(_proKnow, workspaceItem.Id, uploadProcessingResults.Results);

            // Get the summary views of the patient and the SRO in the upload response
            var uploadPatientSummary = uploadBatch.FindPatient(uploadPath);
            var uploadSroSummary     = uploadBatch.FindSro(uploadPath);

            // Verify the contents
            Assert.AreEqual(workspaceItem.Id, uploadSroSummary.WorkspaceId);
            Assert.AreEqual(uploadPatientSummary.Id, uploadSroSummary.PatientId);
            Assert.IsNotNull(uploadSroSummary.StudyId);
            Assert.IsNotNull(uploadSroSummary.Id);
            Assert.AreEqual("1.2.246.352.221.52738008096457865345287404867971417272", uploadSroSummary.Uid);
        }
Exemple #3
0
        public async Task UploadAsyncTest_SingleFolder()
        {
            int testNumber = 3;

            // Create a workspace
            var workspaceItem = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Create a patient
            var patientItem = await TestHelper.CreatePatientAsync(_testClassName, testNumber);

            var patientSummary = await _proKnow.Patients.FindAsync(workspaceItem.Id, p => p.Id == patientItem.Id);

            // Upload test folder
            var uploadPath = Path.Combine(TestSettings.TestDataRootDirectory, "Becker^Matthew", "CT");
            var overrides  = new UploadFileOverrides
            {
                Patient = new PatientOverridesSchema {
                    Name = patientItem.Name, Mrn = patientItem.Mrn
                }
            };
            var uploadResults = await patientSummary.UploadAsync(uploadPath, overrides);

            await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

            // Very all files were uploaded
            var uploadedFiles = Directory.GetFiles(uploadPath);
            await patientItem.RefreshAsync();

            var entitySummaries = patientItem.FindEntities(t => t.Type == "image_set");

            Assert.AreEqual(1, entitySummaries.Count);
            var entityItem = await entitySummaries[0].GetAsync() as ImageSetItem;

            Assert.AreEqual(uploadedFiles.Length, entityItem.Data.Images.Count);
        }
Exemple #4
0
        public async Task UploadAsyncTest_SingleFile()
        {
            int testNumber = 2;

            // Create a workspace
            var workspaceItem = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Create a patient
            var patientItem = await TestHelper.CreatePatientAsync(_testClassName, testNumber);

            var patientSummary = await _proKnow.Patients.FindAsync(workspaceItem.Id, p => p.Id == patientItem.Id);

            // Upload test file
            var uploadPath = Path.Combine(TestSettings.TestDataRootDirectory, "Becker^Matthew", "RP.dcm");
            var overrides  = new UploadFileOverrides
            {
                Patient = new PatientOverridesSchema {
                    Name = patientItem.Name, Mrn = patientItem.Mrn
                }
            };
            var uploadResults = await patientSummary.UploadAsync(uploadPath, overrides);

            await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

            // Verify file was uploaded
            await patientItem.RefreshAsync();

            var entitySummaries = patientItem.FindEntities(t => t.Type == "plan");

            Assert.AreEqual(1, entitySummaries.Count);
            Assert.AreEqual("2.16.840.1.114337.1.1.1535997926.0", entitySummaries[0].Uid);
        }
        public async Task RefreshAsyncTest()
        {
            int testNumber = 6;

            // Create a workspace
            var workspaceItem = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Create a patient with only images
            var patientItem = await TestHelper.CreatePatientAsync(_testClassName, testNumber, Path.Combine("Becker^Matthew", "CT"));

            Assert.AreEqual(1, patientItem.FindEntities(e => true).Count);

            // Upload a structure set for the same patient
            var uploadPath = Path.Combine(TestSettings.TestDataRootDirectory, Path.Combine("Becker^Matthew", "RS.dcm"));
            var overrides  = new UploadFileOverrides
            {
                Patient = new PatientOverridesSchema {
                    Mrn = patientItem.Mrn, Name = patientItem.Name
                }
            };
            var uploadResults = await _proKnow.Uploads.UploadAsync(workspaceItem, uploadPath, overrides);

            await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

            // Refresh the patient and verify that it now includes the structure set
            await patientItem.RefreshAsync();

            var entitySummaries = patientItem.FindEntities(e => true);

            Assert.AreEqual(2, entitySummaries.Count());
        }
        public async Task UploadAsyncTest_FolderPath()
        {
            int testNumber = 10;

            // Create a workspace
            var workspaceItem = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Create a patient without data
            var patientItem = await TestHelper.CreatePatientAsync(_testClassName, testNumber);

            // Upload test folder
            var uploadPath = Path.Combine(TestSettings.TestDataRootDirectory, "Becker^Matthew", "CT");
            var overrides  = new UploadFileOverrides
            {
                Patient = new PatientOverridesSchema {
                    Mrn = patientItem.Mrn, Name = patientItem.Name
                }
            };
            var uploadResults = await patientItem.UploadAsync(uploadPath, overrides);

            await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

            // Verify test folder was uploaded
            await patientItem.RefreshAsync();

            var entitySummaries = patientItem.FindEntities(t => true);

            Assert.AreEqual(1, entitySummaries.Count);
            var entityItem = await entitySummaries[0].GetAsync() as ImageSetItem;

            Assert.AreEqual(5, entityItem.Data.Images.Count);
        }
        public async Task DownloadAsyncTest_ExistingFileWithExistingParent()
        {
            var testNumber = 5;

            // Create a test workspace
            var workspaceItem = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Create a test patient with an image set and structure set
            var patientItem = await TestHelper.CreatePatientAsync(_testClassName, testNumber, "Becker^Matthew");

            var entitySummaries  = patientItem.FindEntities(e => e.Type == "structure_set");
            var structureSetItem = await entitySummaries[0].GetAsync() as StructureSetItem;

            // Create another version of that structure set, add an ROI, and commit the change
            using (var draft = await structureSetItem.DraftAsync())
            {
                await draft.CreateRoiAsync("thing1", Color.Magenta, "ORGAN");

                await draft.ApproveAsync("original + thing1");
            }

            // Get that version
            var versions = await structureSetItem.Versions.QueryAsync();

            var version = versions.First(v => v.Label == "original + thing1");

            // Download the version to an existing filename
            string downloadFolder = Path.Combine(_downloadFolderRoot, testNumber.ToString());

            Directory.CreateDirectory(downloadFolder);
            string expectedDownloadPath = Path.Combine(downloadFolder, "RS.dcm");

            File.WriteAllText(expectedDownloadPath, "This is an existing file!");
            string actualDownloadPath = await version.DownloadAsync(expectedDownloadPath);

            // Make sure it was downloaded to the expected path
            Assert.AreEqual(expectedDownloadPath, actualDownloadPath);

            // Upload it to a new patient and wait for it to be processed
            var overrides = new UploadFileOverrides
            {
                Patient = new PatientOverridesSchema {
                    Mrn = $"{patientItem.Mrn}2", Name = $"{patientItem.Name}2"
                }
            };
            var uploadResults = await _proKnow.Uploads.UploadAsync(workspaceItem, actualDownloadPath, overrides);

            await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

            // Get the uploaded structure set
            var patientSummary2 = await _proKnow.Patients.FindAsync(workspaceItem.Id, p => p.Mrn == $"{patientItem.Mrn}2");

            var patientItem2 = await patientSummary2.GetAsync();

            var entitySummary2    = patientItem2.FindEntities(e => true)[0];
            var structureSetItem2 = (await entitySummary2.GetAsync()) as StructureSetItem;

            // Verify that the version downloaded (and uploaded to a new patient) was correct
            Assert.IsTrue(structureSetItem2.Rois.Any(r => r.Name == "thing1"));
        }
        public async Task UploadAsyncTest_Overrides_Id()
        {
            int testNumber = 17;

            // Create a workspace
            var workspaceItem = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Add a test patient
            var patientItem1 = await TestHelper.CreatePatientAsync(_testClassName, testNumber, Path.Combine("Becker^Matthew", "RP.dcm"));

            // Upload a file from another patient, specifying the ID, MRN, and name of the first patient
            var uploadPath = Path.Combine(TestSettings.TestDataRootDirectory, "Jensen^Myrtle", "RP.dcm");
            var overrides  = new UploadFileOverrides
            {
                Patient = new PatientOverridesSchema {
                    Id = patientItem1.Id, Mrn = patientItem1.Mrn, Name = patientItem1.Name
                }
            };
            var uploadResults = (await _proKnow.Uploads.UploadAsync(workspaceItem, uploadPath, overrides)).ToList();

            // Wait for processing
            await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

            // Verify that the file was uploaded to the specified patient
            var patientSummary2 = await _proKnow.Patients.FindAsync(workspaceItem.Id, p => p.Id == patientItem1.Id);

            var patientItem2 = await patientSummary2.GetAsync();

            var entitySummaries = patientItem2.FindEntities(t => true);

            Assert.AreEqual(2, entitySummaries.Count);
            Assert.AreEqual(1, entitySummaries.Count(e => e.Uid == "2.16.840.1.114337.1.1.1535997926.0")); // Becker^Matthew RP.dcm
            Assert.AreEqual(1, entitySummaries.Count(e => e.Uid == "2.16.840.1.114337.1.1.1534771415.0")); // Jensen^Myrtle RP.dcm
        }
        public async Task UploadAsyncTest_Overrides_NewMrn()
        {
            int testNumber = 16;

            // Create a workspace
            var workspaceItem = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Upload a test file, overriding its MRN and name
            var uploadPath = Path.Combine(TestSettings.TestDataRootDirectory, "Becker^Matthew", "RP.dcm");
            var overrides  = new UploadFileOverrides
            {
                Patient = new PatientOverridesSchema {
                    Mrn = "a-new-mrn", Name = "A^New^Name"
                }
            };
            var uploadResults = (await _proKnow.Uploads.UploadAsync(workspaceItem, uploadPath, overrides)).ToList();

            // Wait for processing
            await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

            // Verify that the file was uploaded to a patient with the specified MRN and name
            var patientSummary = await _proKnow.Patients.FindAsync(workspaceItem.Id, p => p.Mrn == "a-new-mrn" && p.Name == "A^New^Name");

            var patientItem = await patientSummary.GetAsync();

            var entitySummaries = patientItem.FindEntities(t => true);

            Assert.AreEqual(1, entitySummaries.Count);
            Assert.AreEqual(1, entitySummaries.Count(e => e.Uid == "2.16.840.1.114337.1.1.1535997926.0")); // Becker^Matthew RP.dcm
        }
Exemple #10
0
        public async Task FindPatientTest()
        {
            var testNumber = 1;

            // Create a test workspace
            var workspaceItem = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Upload test data
            var mrUploadPath  = Path.Combine(TestSettings.TestDataRootDirectory, "Sro", "mr.dcm");
            var sroUploadPath = Path.Combine(TestSettings.TestDataRootDirectory, "Sro", "reg.dcm");
            var uploadPaths   = new List <String>()
            {
                mrUploadPath, sroUploadPath
            };
            var overrides = new UploadFileOverrides
            {
                Patient = new PatientOverridesSchema {
                    Mrn = $"{testNumber}-Mrn", Name = $"{testNumber}-Name"
                }
            };
            var uploadResults = await _proKnow.Uploads.UploadAsync(workspaceItem, uploadPaths, overrides);

            var uploadProcessingResults = await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

            var uploadBatch = new UploadBatch(_proKnow, workspaceItem.Id, uploadProcessingResults.Results);

            // Get the summary view of the patient in the upload response
            var uploadPatientSummary = uploadBatch.FindPatient(mrUploadPath);

            // Verify the contents at the patient level
            Assert.AreEqual(workspaceItem.Id, uploadPatientSummary.WorkspaceId);
            Assert.IsNotNull(uploadPatientSummary.Id);
            Assert.AreEqual(overrides.Patient.Mrn, uploadPatientSummary.Mrn);
            Assert.AreEqual(overrides.Patient.Name, uploadPatientSummary.Name);
            Assert.AreEqual(1, uploadPatientSummary.Entities.Count);
            Assert.AreEqual(1, uploadPatientSummary.Sros.Count);

            // Verify the contents at the entity level
            var uploadEntitySummary = uploadPatientSummary.Entities[0];

            Assert.AreEqual(workspaceItem.Id, uploadEntitySummary.WorkspaceId);
            Assert.AreEqual(uploadPatientSummary.Id, uploadEntitySummary.PatientId);
            Assert.IsNotNull(uploadEntitySummary.Id);
            Assert.AreEqual("1.2.246.352.221.470938394496317011513892701464452657827", uploadEntitySummary.Uid);
            Assert.AreEqual("image_set", uploadEntitySummary.Type);
            Assert.AreEqual("MR", uploadEntitySummary.Modality);
            Assert.AreEqual("", uploadEntitySummary.Description);

            // Verify the contents at the SRO level
            var uploadSroSummary = uploadPatientSummary.Sros[0];

            Assert.AreEqual(workspaceItem.Id, uploadSroSummary.WorkspaceId);
            Assert.AreEqual(uploadPatientSummary.Id, uploadSroSummary.PatientId);
            Assert.IsNotNull(uploadSroSummary.StudyId);
            Assert.IsNotNull(uploadSroSummary.Id);
            Assert.AreEqual("1.2.246.352.221.52738008096457865345287404867971417272", uploadSroSummary.Uid);
        }
Exemple #11
0
        public async Task UploadAsyncTest_MultipleFilesAndOrFolders()
        {
            int testNumber = 4;

            // Create a workspace
            var workspaceItem = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Create a patient
            var patientItem = await TestHelper.CreatePatientAsync(_testClassName, testNumber);

            var patientSummary = await _proKnow.Patients.FindAsync(workspaceItem.Id, p => p.Id == patientItem.Id);

            // Upload test folder and file
            var uploadPath1 = Path.Combine(TestSettings.TestDataRootDirectory, "Becker^Matthew", "CT");
            var uploadPath2 = Path.Combine(TestSettings.TestDataRootDirectory, "Becker^Matthew", "RP.dcm");
            var uploadPaths = new List <string>()
            {
                uploadPath1, uploadPath2
            };
            var overrides = new UploadFileOverrides
            {
                Patient = new PatientOverridesSchema {
                    Name = patientItem.Name, Mrn = patientItem.Mrn
                }
            };
            var uploadResults = await patientSummary.UploadAsync(uploadPaths, overrides);

            await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

            // Verify all CT files were uploaded
            var uploadedCtFiles = Directory.GetFiles(uploadPath1);
            await patientItem.RefreshAsync();

            var entitySummaries = patientItem.FindEntities(t => t.Type == "image_set");

            Assert.AreEqual(1, entitySummaries.Count);
            var entityItem = await entitySummaries[0].GetAsync() as ImageSetItem;

            Assert.AreEqual(uploadedCtFiles.Length, entityItem.Data.Images.Count);

            // Verify plan file was uploaded
            await patientItem.RefreshAsync();

            entitySummaries = patientItem.FindEntities(t => t.Type == "plan");
            Assert.AreEqual(1, entitySummaries.Count);
            Assert.AreEqual("2.16.840.1.114337.1.1.1535997926.0", entitySummaries[0].Uid);
        }
        public async Task GetAsyncTest()
        {
            var testNumber = 1;

            // Create a test workspace
            var workspaceItem = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Upload test data
            var uploadPath = Path.Combine(TestSettings.TestDataRootDirectory, "Sro");
            var overrides  = new UploadFileOverrides
            {
                Patient = new PatientOverridesSchema {
                    Mrn = $"{testNumber}-Mrn", Name = $"{testNumber}-Name"
                }
            };
            var uploadResults = await _proKnow.Uploads.UploadAsync(workspaceItem, uploadPath, overrides);

            var uploadProcessingResults = await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

            var uploadBatch = new UploadBatch(_proKnow, workspaceItem.Id, uploadProcessingResults.Results);

            // Get the summary views of the patient, entities, and SRO in the upload response
            var uploadPatientSummary  = uploadBatch.FindPatient(Path.Combine(uploadPath, "reg.dcm"));
            var uploadCtEntitySummary = uploadBatch.FindEntity(Path.Combine(uploadPath, "ct.dcm"));
            var uploadMrEntitySummary = uploadBatch.FindEntity(Path.Combine(uploadPath, "mr.dcm"));
            var uploadSroSummary      = uploadBatch.FindSro(Path.Combine(uploadPath, "reg.dcm"));

            // Get the full representation of the patient, entities, and SRO
            var ctImageSetItem = await uploadCtEntitySummary.GetAsync();

            var mrImageSetItem = await uploadMrEntitySummary.GetAsync();

            var sroItem = await uploadSroSummary.GetAsync();

            // Verify the contents
            Assert.AreEqual(workspaceItem.Id, sroItem.WorkspaceId);
            Assert.AreEqual(uploadPatientSummary.Id, sroItem.PatientId);
            Assert.AreEqual(ctImageSetItem.StudyId, sroItem.StudyId);
            Assert.IsNotNull(sroItem.Id);
            Assert.AreEqual("1.2.246.352.221.52738008096457865345287404867971417272", sroItem.Uid);
            Assert.AreEqual("2018-02-19 09:06:05", sroItem.Name);
            Assert.AreEqual("rigid", sroItem.Type);
            Assert.AreEqual(mrImageSetItem.FrameOfReferenceUid, sroItem.Source.FrameOfReferenceUid);
            Assert.AreEqual(mrImageSetItem.Id, sroItem.Source.ImageSetId);
            Assert.AreEqual(ctImageSetItem.FrameOfReferenceUid, sroItem.Target.FrameOfReferenceUid);
            Assert.AreEqual(ctImageSetItem.Id, sroItem.Target.ImageSetId);
        }
Exemple #13
0
        /// <summary>
        /// Creates a patient asynchronously in workspace {testClassName} with MRN {testNumber}-Mrn and name {testNumber}-Name
        /// </summary>
        /// <param name="testClassName">The test class name</param>
        /// <param name="testNumber">The test number</param>
        /// <param name="testData">The optional test data subdirectory or file to upload</param>
        /// <param name="birthDate">The optional birthdate in the format "YYYY-MM-DD"</param>
        /// <param name="sex">The optional sex, one of "M", "F", or "O"</param>
        /// <param name="metadata">The optional metadata (custom metrics) names and values</param>
        /// <returns></returns>
        public static async Task <PatientItem> CreatePatientAsync(string testClassName, int testNumber, string testData = null,
                                                                  string birthDate = null, string sex = null, IDictionary <string, object> metadata = null)
        {
            // Find the workspace for this test
            var workspaceName = $"SDK-{testClassName}-{testNumber}";
            var workspaceItem = await _proKnow.Workspaces.ResolveByNameAsync(workspaceName);

            // Create the patient
            var mrn         = $"{testNumber}-Mrn";
            var name        = $"{testNumber}-Name";
            var patientItem = await _proKnow.Patients.CreateAsync(workspaceItem.Id, mrn, name, birthDate, sex);

            // Upload test files, if requested
            if (testData != null)
            {
                var uploadPath = Path.Combine(TestSettings.TestDataRootDirectory, testData);
                var overrides  = new UploadFileOverrides
                {
                    Patient = new PatientOverridesSchema {
                        Mrn = mrn, Name = name
                    }
                };
                var uploadResults = await _proKnow.Uploads.UploadAsync(workspaceItem, uploadPath, overrides);

                await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

                // Refresh patient
                await patientItem.RefreshAsync();
            }

            // Add custom metric values
            if (metadata != null)
            {
                await patientItem.SetMetadataAsync(metadata);

                await patientItem.SaveAsync();

                await patientItem.RefreshAsync();
            }

            return(patientItem);
        }
Exemple #14
0
        public async Task GetAsyncTest()
        {
            var testNumber = 1;

            // Create a test workspace
            var workspaceItem = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Upload test data
            var uploadPath = Path.Combine(TestSettings.TestDataRootDirectory, "Sro", "ct.dcm");
            var overrides  = new UploadFileOverrides
            {
                Patient = new PatientOverridesSchema {
                    Mrn = $"{testNumber}-Mrn", Name = $"{testNumber}-Name"
                }
            };
            var uploadResults = await _proKnow.Uploads.UploadAsync(workspaceItem, uploadPath, overrides);

            var uploadProcessingResults = await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

            var uploadBatch = new UploadBatch(_proKnow, workspaceItem.Id, uploadProcessingResults.Results);

            // Get the summary views of the patient and entity in the upload response
            var uploadPatientSummary = uploadBatch.FindPatient(uploadPath);
            var uploadEntitySummary  = uploadBatch.FindEntity(uploadPath);

            // Get the full representation of the entity
            var imageSetItem = await uploadEntitySummary.GetAsync() as ImageSetItem;

            // Verify the contents
            Assert.AreEqual(workspaceItem.Id, imageSetItem.WorkspaceId);
            Assert.AreEqual(uploadPatientSummary.Id, imageSetItem.PatientId);
            Assert.AreEqual("1.2.246.352.221.5093062159960566210763150553104377477", imageSetItem.FrameOfReferenceUid);
            Assert.IsNotNull(imageSetItem.Id);
            Assert.AreEqual("image_set", imageSetItem.Type);
            Assert.AreEqual("1.2.246.352.221.563569281719761951014104635106765053066", imageSetItem.Uid);
            Assert.AreEqual("CT", imageSetItem.Modality);
            Assert.AreEqual("", imageSetItem.Description);
            Assert.IsTrue(imageSetItem.Metadata.Count == 0);
            Assert.AreEqual("completed", imageSetItem.Status);
        }
        public async Task GetAsyncTest()
        {
            var testNumber = 1;

            // Create a test workspace
            var workspaceItem = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Upload test data
            var uploadPath = Path.Combine(TestSettings.TestDataRootDirectory, "Sro", "ct.dcm");
            var overrides  = new UploadFileOverrides
            {
                Patient = new PatientOverridesSchema {
                    Mrn = $"{testNumber}-Mrn", Name = $"{testNumber}-Name"
                }
            };
            var uploadResults = await _proKnow.Uploads.UploadAsync(workspaceItem, uploadPath, overrides);

            var uploadProcessingResults = await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

            var uploadBatch = new UploadBatch(_proKnow, workspaceItem.Id, uploadProcessingResults.Results);

            // Get the summary view of the patient in the upload response
            var uploadPatientSummary = uploadBatch.FindPatient(uploadPath);

            // Get the full representation of the patient
            var patientItem = await uploadPatientSummary.GetAsync();

            // Verify the contents
            Assert.AreEqual(workspaceItem.Id, patientItem.WorkspaceId);
            Assert.IsNotNull(patientItem.Id);
            Assert.AreEqual(overrides.Patient.Mrn, patientItem.Mrn);
            Assert.AreEqual(overrides.Patient.Name, patientItem.Name);
            Assert.AreEqual(1, patientItem.Studies.Count);
            Assert.AreEqual(workspaceItem.Id, patientItem.Studies[0].WorkspaceId);
            Assert.AreEqual(patientItem.Id, patientItem.Studies[0].PatientId);
            Assert.IsNotNull(patientItem.Studies[0].Id);
            Assert.AreEqual(1, patientItem.Studies[0].Entities.Count);
            Assert.AreEqual(0, patientItem.Studies[0].Sros.Count);
        }
        public async Task UploadAsyncTest_MultiplePaths()
        {
            int testNumber = 11;

            // Create a workspace
            var workspaceItem = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Create a patient without data
            var patientItem = await TestHelper.CreatePatientAsync(_testClassName, testNumber);

            // Upload test folder and test file
            var uploadPath1 = Path.Combine(TestSettings.TestDataRootDirectory, "Becker^Matthew", "CT");
            var uploadPath2 = Path.Combine(TestSettings.TestDataRootDirectory, "Becker^Matthew", "RS.dcm");
            var uploadPaths = new List <string>()
            {
                uploadPath1, uploadPath2
            };
            var overrides = new UploadFileOverrides
            {
                Patient = new PatientOverridesSchema {
                    Mrn = patientItem.Mrn, Name = patientItem.Name
                }
            };
            var uploadResults = await patientItem.UploadAsync(uploadPaths, overrides);

            await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults);

            // Verify test folder and test file were uploaded
            await patientItem.RefreshAsync();

            var entitySummaries = patientItem.FindEntities(t => true);

            Assert.AreEqual(2, entitySummaries.Count);
            var imageSetSummary = patientItem.FindEntities(t => t.Type == "image_set")[0];
            var entityItem      = await imageSetSummary.GetAsync() as ImageSetItem;

            Assert.AreEqual(5, entityItem.Data.Images.Count);
            Assert.AreEqual(1, patientItem.FindEntities(t => t.Type == "structure_set").Count);
        }
Exemple #17
0
 /// <summary>
 /// Upload files asynchronously
 /// </summary>
 /// <param name="paths">The folder and/or file paths</param>
 /// <param name="overrides">Optional overrides to be applied after the files are uploaded</param>
 /// <returns>The upload results</returns>
 public Task <IList <UploadResult> > UploadAsync(IList <string> paths, UploadFileOverrides overrides = null)
 {
     return(_proKnow.Uploads.UploadAsync(WorkspaceId, paths, overrides));
 }