Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public ActionResult SavePhotoDetails(UploadPhotoDetails details)
        {
            UploadBatch batch = Mapper.Map <UploadPhotoDetails, UploadBatch>(details);

            _mediaQueueRepository.InsertBatch(batch);

            return(Content("1"));
        }
Beispiel #4
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);
        }
        /// <summary>
        /// Adds the media to album.
        /// </summary>
        /// <param name="batch">The batch.</param>
        /// <param name="mediaId">The media id.</param>
        private void AddMediaToAlbum(UploadBatch batch, int mediaId)
        {
            if (!string.IsNullOrEmpty(batch.Albums))
            {
                string[] ids = batch.Albums.Split(',');

                foreach (string id in ids.Where(id => !string.IsNullOrEmpty(id)))
                {
                    _albumRepository.AddPhotoToAlbum(Convert.ToInt32(id), mediaId);
                }
            }
        }
        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);
        }
Beispiel #7
0
        public async Task GetStatusTest_Failed()
        {
            var testNumber = 7;

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

            // Upload test data
            var uploadPath    = Path.Combine(TestSettings.TestDataRootDirectory, "RtImage", "RTIMAGE.dcm");
            var uploadResults = await _proKnow.Uploads.UploadAsync(workspaceItem, uploadPath);

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

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

            // Verify the status
            Assert.AreEqual("failed", uploadBatch.GetStatus(uploadPath));
        }
        /// <summary>
        /// Updates the details.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <param name="batchId">The batch id.</param>
        public void UpdateDetails(Media media, Guid batchId)
        {
            UploadBatch batch = _mediaQueueRepository.GetUploadBatch(batchId);

            AddMediaToAlbum(batch, media.MediaId);
            _mediaQueueRepository.InsertBatchIdAndMediaId(batchId, media.MediaId);


            media.Tags   = batch.Tags;
            media.Day    = (batch.Day ?? media.Day);
            media.Month  = (batch.Month ?? media.Month);
            media.Year   = (batch.Year ?? media.Year);
            media.Status = batch.MediaStatus.ParseEnum <MediaStatus>();
            _mediaRepository.Save(media);

            _uploaderMediaRepository.UpdateMediaStatus(media.MediaId, MediaUploadState.Queued);
            SaveLocation(batch, media.Owner.UserId);
        }
Beispiel #9
0
        public async Task GetStatusTest_Pending_SingleUpload()
        {
            var testNumber = 5;

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

            // In one upload, upload test data that has the same Patient ID, but different Patient's Name
            var uploadPath    = Path.Combine(TestSettings.TestDataRootDirectory, "PatientNameConflict");
            var uploadResults = await _proKnow.Uploads.UploadAsync(workspaceItem, uploadPath);

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

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

            // Verify that one of the two files shows a status of "pending" (conflict)
            var uploadPath1 = Path.Combine(TestSettings.TestDataRootDirectory, "PatientNameConflict", "CT.1.dcm");
            var uploadPath2 = Path.Combine(TestSettings.TestDataRootDirectory, "PatientNameConflict", "CT.2.dcm");

            Assert.IsTrue(uploadBatch.GetStatus(uploadPath1) == "pending" || uploadBatch.GetStatus(uploadPath2) == "pending");
        }
        /// <summary>
        /// Saves the location.
        /// </summary>
        /// <param name="batch">The batch.</param>
        /// <param name="userId">The user id.</param>
        private void SaveLocation(UploadBatch batch, int userId)
        {
            if (!string.IsNullOrEmpty(batch.LocationName) &&
                batch.Latitude.HasValue &&
                batch.Longitude.HasValue &&
                batch.Zoom.HasValue &&
                !string.IsNullOrEmpty(batch.MapTypeId))
            {
                Location location = new Location
                {
                    LocationName = batch.LocationName,
                    Latitude     = batch.Latitude.GetValueOrDefault(),
                    Longitude    = batch.Longitude.GetValueOrDefault(),
                    MapTypeId    = batch.MapTypeId,
                    Zoom         = batch.Zoom.GetValueOrDefault(),
                    UserId       = userId
                };

                _locationRepository.Save(location);
            }
        }
Beispiel #11
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);
        }
Beispiel #13
0
        public async Task GetStatusTest_Duplicate()
        {
            var testNumber = 8;

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

            // Upload test data
            var uploadPath     = Path.Combine(TestSettings.TestDataRootDirectory, "Sro", "reg.dcm");
            var uploadResults1 = await _proKnow.Uploads.UploadAsync(workspaceItem, uploadPath);

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

            // Upload the same data again
            var uploadResults2 = await _proKnow.Uploads.UploadAsync(workspaceItem, uploadPath);

            var uploadProcessingResults2 = await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults2);

            var uploadBatch2 = new UploadBatch(_proKnow, workspaceItem.Id, uploadProcessingResults2.Results);

            // Verify the status is still "completed"
            Assert.AreEqual("completed", uploadBatch2.GetStatus(uploadPath));
        }
Beispiel #14
0
        public async Task GetStatusTest_Pending_MultipleUploads()
        {
            var testNumber = 6;

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

            // In two uploads, upload test data that has the same Patient ID, but different Patient's Name
            var uploadPath1    = Path.Combine(TestSettings.TestDataRootDirectory, "PatientNameConflict", "CT.1.dcm");
            var uploadResults1 = await _proKnow.Uploads.UploadAsync(workspaceItem.Id, uploadPath1);

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

            var uploadPath2    = Path.Combine(TestSettings.TestDataRootDirectory, "PatientNameConflict", "CT.2.dcm");
            var uploadResults2 = await _proKnow.Uploads.UploadAsync(workspaceItem, uploadPath2);

            var uploadProcessingResults2 = await _proKnow.Uploads.GetUploadProcessingResultsAsync(workspaceItem, uploadResults2);

            var uploadBatch2 = new UploadBatch(_proKnow, workspaceItem.Id, uploadProcessingResults2.Results);

            // Verify that the second file shows a status of "pending" (conflict)
            Assert.IsTrue(uploadBatch2.GetStatus(uploadPath2) == "pending");
        }
Beispiel #15
0
 /// <summary>
 /// Inserts the batch.
 /// </summary>
 /// <param name="batch">The batch.</param>
 public void InsertBatch(UploadBatch batch)
 {
     database.NonQuery("UploadBatch_Insert", batch);
 }