示例#1
0
        public async Task SaveAsync(StudyInfo entity)
        {
            try
            {
                if (entity == null)
                {
                    return;
                }

                using (var timeLineContext = _contextFactory.GetTimeLineContext())
                {
                    var entityModel = await timeLineContext
                                      .StudyInfos
                                      .FirstOrDefaultAsync(item => item.Id.Equals(entity.Id));

                    if (entityModel == null)
                    {
                        entityModel = new DA.StudyInfo();
                        MapForUpdateentity(entity, entityModel);
                        await timeLineContext.StudyInfos.AddAsync(entityModel);
                    }
                    else
                    {
                        MapForUpdateentity(entity, entityModel);
                    }


                    timeLineContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
文件: StudyUI.cs 项目: Zeppar/Voice
    private void InitFile()
    {
        Util.DeleteChildren(parent);
        string path = "";

#if UNITY_EDITOR
        path = Application.streamingAssetsPath + "/Study";
#else
        path = Application.persistentDataPath + "/Study";
#endif
        path = Application.streamingAssetsPath + "/Study";
        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }
        DirectoryInfo direction = new DirectoryInfo(path);
        FileInfo[]    files     = direction.GetFiles(".", SearchOption.AllDirectories);
        index = 1;
        for (int i = 0; i < files.Length; i++)
        {
            if (files[i].Name.EndsWith(".txt") /* || files[i].Name.EndsWith(".pdf") || files[i].Name.EndsWith(".word")*/)
            {
                Debug.Log(files[i].Name);
                StudyInfo info = new StudyInfo();
                info.name = files[i].Name;
                info.url  = files[i].FullName;
                info.type = FileType.TXT;
                StudyItem item = Instantiate(itemPrefab);
                item.SetContent(info);
                item.transform.SetParent(parent, false);
            }
        }
    }
示例#3
0
        public void DicomType_IsStudy()
        {
            // Arrange 
            var study = new StudyInfo();

            // Act + Assert
            Assert.That(study.DicomType, Is.EqualTo(DicomInfoType.Study));
        }
示例#4
0
 public async Task <IActionResult> Put([FromBody] StudyInfo value)
 {
     try
     {
         var entity = _mapper.Map <BL.StudyInfo>(value);
         var id     = _service.SaveAsync(entity);
         return(Ok(id));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
示例#5
0
 public void SetContent(StudyInfo _info)
 {
     info = _info;
     gameObject.SetActive(true);
     if (_info.type == FileType.TXT)
     {
         StartCoroutine(LoadStudyFile(info.url));
     }
     else if (_info.type == FileType.WORD)
     {
         LoadWord(info.url);
     }
 }
示例#6
0
        public void StudyInstanceUID_Setter_AfterGettingHashCode_ThrowsException()
        {
            // Arrange
            var study = new StudyInfo
            {
                StudyInstanceUID = new InfoIdentifier("123")
            };

            // Act
            study.GetHashCode();

            // Assert
            Assert.That(() => study.StudyInstanceUID = new InfoIdentifier("321"), Throws.InvalidOperationException);
        }
示例#7
0
        private void OnStudyOpen(StudyInfo studyInfo, string username, string sessionId)
        {
            DisposeViewer();

            var viewer = new ImageViewer(new StartViewerApplicationRequest
            {
                StudyInstanceUid = new Collection <string> {
                    studyInfo.StudyInstanceUid
                },
                Username = username
            })
            ;

            ImageViewerContainer.Children.Add(viewer);
        }
示例#8
0
        public void Equals_StudiesWithSameUIDAreNotEqual()
        {
            // Arrange
            var study1 = new StudyInfo
            {
                StudyInstanceUID = new InfoIdentifier("123")
            };
            var study2 = new StudyInfo
            {
                StudyInstanceUID = new InfoIdentifier("321")
            };

            // Act
            var result = study1.Equals(study2);

            // Assert
            Assert.That(result, Is.False);
        }
示例#9
0
    void loadData()
    {
        string filePath = Path.Combine(Application.dataPath, sceneDataFileName);

        if (File.Exists(filePath))
        {
            // Read the json from the file into a string
            string dataAsJson = File.ReadAllText(filePath);
            // Pass the json to JsonUtility, and tell it to create a StudyInfo object from it
            StudyInfo loadedData = JsonUtility.FromJson <StudyInfo>(dataAsJson);

            // Retrieve the experiments property of loadedData
            experiment_info = loadedData.experiments;
        }
        else
        {
            Debug.LogError("Cannot load game data!");
        }
    }
示例#10
0
        public void Equals_WithItself_ReturnsTrue()
        {
            // Arrange
            var infoIdentifier = new InfoIdentifier("123");
            var study = new StudyInfo
            {
                StudyInstanceUID = infoIdentifier
            };

            // Act
            var result = study.Equals(study);

            // Assert
            Assert.That(result, Is.True);
        }
示例#11
0
 public void SetContent(StudyInfo _info)
 {
     info             = _info;
     nameText.text    = info.name;
     showImage.sprite = sps[(int)info.type];
 }
        /// <summary>
        /// Creates all the SOP instances associated with the key object selection and the content presentation states.
        /// </summary>
        public IDictionary <IStudySource, List <DicomFile> > CreateSopInstances(NextSeriesNumberDelegate nextSeriesNumberDelegate)
        {
            if (!HasChanges || !Items.Any())
            {
                return(new Dictionary <IStudySource, List <DicomFile> >(0));
            }

            // update the author field
            Author = GetUserName();

            // the series index ensures consistent series level data because we only create one KO series and one PR series per study
            var studyIndex = new Dictionary <string, StudyInfo>();

            var secondaryCaptureImageFactory = new SecondaryCaptureImageFactory(nextSeriesNumberDelegate);
            var framePresentationStates      = new List <KeyValuePair <KeyImageReference, PresentationStateReference> >();

            // create presentation states for the images in the clipboard
            var presentationStates = new List <DicomSoftcopyPresentationState>();

            foreach (var item in Items.Where(i => i.Item is IPresentationImage))
            {
                var image = (IPresentationImage)item.Item;

                // if the item is a placeholder image (e.g. because source study wasn't available), simply reserialize the original sop references
                if (image is KeyObjectPlaceholderImage)
                {
                    // because source study wasn't available, we don't have enough information to create the identical KO for that study
                    // and thus an entry in the study index table is not needed
                    var ko = (KeyObjectPlaceholderImage)image;
                    framePresentationStates.Add(new KeyValuePair <KeyImageReference, PresentationStateReference>(ko.KeyImageReference, ko.PresentationStateReference));
                    continue;
                }

                var provider = image as IImageSopProvider;
                if (provider == null)
                {
                    continue;
                }

                StudyInfo studyInfo;
                var       studyInstanceUid = provider.ImageSop.StudyInstanceUid;
                if (!studyIndex.TryGetValue(studyInstanceUid, out studyInfo))
                {
                    studyIndex.Add(studyInstanceUid, studyInfo = new StudyInfo(provider, nextSeriesNumberDelegate));

                    // keep the previous series number if the one we know about is the same study as this new document
                    // otherwise, pre-allocate a series number for the KO now (ensures the number will be lower than any SC and PR series)
                    if (_parentStudyInstanceUid == studyInstanceUid && _seriesNumber.HasValue)
                    {
                        studyInfo.KeyObjectSeriesNumber = _seriesNumber.Value;
                    }
                    else
                    {
                        studyInfo.AllocateKeyObjectSeriesNumber();
                    }
                }

                // if the item doesn't have changes and the presentation state is DICOM, simply reserialize the original sop references
                if (!item.HasChanges() && image is IDicomPresentationImage)
                {
                    var dicomPresentationState = ((IDicomPresentationImage)image).PresentationState as DicomSoftcopyPresentationState;
                    framePresentationStates.Add(new KeyValuePair <KeyImageReference, PresentationStateReference>(provider.Frame, dicomPresentationState));
                    continue;
                }

                // if the image is not a permanent stored instance (i.e. it was dynamically generated), create a secondary capture from it
                if (!provider.Sop.DataSource.IsStored)
                {
                    image    = secondaryCaptureImageFactory.CreateSecondaryCapture(image);
                    provider = (IImageSopProvider)image;
                }

                var presentationState = DicomSoftcopyPresentationState.IsSupported(image)
                                                                ? DicomSoftcopyPresentationState.Create
                                            (image, ps =>
                {
                    ps.PresentationSeriesInstanceUid = studyInfo.PresentationSeriesUid;
                    ps.PresentationSeriesNumber      = studyInfo.PresentationSeriesNumber;
                    ps.PresentationSeriesDateTime    = studyInfo.PresentationSeriesDateTime;
                    ps.PresentationInstanceNumber    = studyInfo.GetNextPresentationInstanceNumber();
                    ps.SourceAETitle = provider.ImageSop.DataSource[DicomTags.SourceApplicationEntityTitle].ToString();
                }) : null;
                if (presentationState != null)
                {
                    presentationStates.Add(presentationState);
                }
                framePresentationStates.Add(new KeyValuePair <KeyImageReference, PresentationStateReference>(provider.Frame, presentationState));
            }

            // serialize the key image document
            var serializer = new KeyImageSerializer();

            serializer.Author            = Author;
            serializer.Description       = Description;
            serializer.DocumentTitle     = DocumentTitle;
            serializer.SeriesDescription = SeriesDescription;
            foreach (var presentationFrame in framePresentationStates)
            {
                serializer.AddImage(presentationFrame.Key, presentationFrame.Value);
            }

            // collect all the SOP instances that were created (SC, PR and KO)
            var documents = new List <DicomFile>();

            documents.AddRange(serializer.Serialize(koSeries =>
            {
                var uid = koSeries.StudyInstanceUid;
                if (studyIndex.ContainsKey(uid))
                {
                    koSeries.SeriesDateTime    = studyIndex[uid].KeyObjectSeriesDateTime;
                    koSeries.SeriesNumber      = studyIndex[uid].KeyObjectSeriesNumber;
                    koSeries.SeriesInstanceUid = studyIndex[uid].KeyObjectSeriesUid;
                    return(studyIndex[uid].DataSource);
                }
                return(null);
            }
                                                    ));
            documents.AddRange(secondaryCaptureImageFactory.Files);
            documents.AddRange(presentationStates.Select(ps => ps.DicomFile));

            // return the created instances grouped by study (and thus study origin/source)
            return(documents.GroupBy(f => (IStudySource)studyIndex[f.DataSet[DicomTags.StudyInstanceUid].ToString()]).ToDictionary(g => g.Key, g => g.ToList()));
        }
		/// <summary>
		/// Creates all the SOP instances associated with the key object selection and the content presentation states.
		/// </summary>
		public IDictionary<IStudySource, List<DicomFile>> CreateSopInstances(NextSeriesNumberDelegate nextSeriesNumberDelegate = null)
		{
			if (!HasChanges || !Items.Any()) return new Dictionary<IStudySource, List<DicomFile>>(0);

			// the series index ensures consistent series level data because we only create one KO series and one PR series per study
			var studyIndex = new Dictionary<string, StudyInfo>();

			var framePresentationStates = new List<KeyValuePair<KeyImageReference, PresentationStateReference>>();

			// create presentation states for the images in the clipboard
			var presentationStates = new List<DicomSoftcopyPresentationState>();
			foreach (var item in Items.Where(i => i.Item is IPresentationImage))
			{
				var image = (IPresentationImage) item.Item;

				// if the item is a placeholder image (e.g. because source study wasn't available), simply reserialize the original sop references
				if (image is KeyObjectPlaceholderImage)
				{
					// because source study wasn't available, we don't have enough information to create the identical KO for that study
					// and thus an entry in the study index table is not needed
					var ko = (KeyObjectPlaceholderImage) image;
					framePresentationStates.Add(new KeyValuePair<KeyImageReference, PresentationStateReference>(ko.KeyImageReference, ko.PresentationStateReference));
					continue;
				}

				var provider = image as IImageSopProvider;
				if (provider == null) continue;

				StudyInfo studyInfo;
				var studyInstanceUid = provider.ImageSop.StudyInstanceUid;
				if (!studyIndex.TryGetValue(studyInstanceUid, out studyInfo))
				{
					studyIndex.Add(studyInstanceUid, studyInfo = new StudyInfo(provider, nextSeriesNumberDelegate));

					// keep the previous series number if the one we know about is the same study as this new document
					if (_parentStudyInstanceUid == studyInstanceUid && _seriesNumber.HasValue)
						studyInfo.KeyObjectSeriesNumber = _seriesNumber.Value;
				}

				// if the item doesn't have changes and the presentation state is DICOM, simply reserialize the original sop references
				if (!item.HasChanges() && image is IDicomPresentationImage)
				{
					var dicomPresentationState = ((IDicomPresentationImage) image).PresentationState as DicomSoftcopyPresentationState;
					framePresentationStates.Add(new KeyValuePair<KeyImageReference, PresentationStateReference>(provider.Frame, dicomPresentationState));
					continue;
				}

				var presentationState = DicomSoftcopyPresentationState.IsSupported(image)
				                        	? DicomSoftcopyPresentationState.Create
				                        	  	(image, ps =>
				                        	  	        	{
				                        	  	        		ps.PresentationSeriesInstanceUid = studyInfo.PresentationSeriesUid;
				                        	  	        		ps.PresentationSeriesNumber = studyInfo.PresentationSeriesNumber;
				                        	  	        		ps.PresentationSeriesDateTime = studyInfo.PresentationSeriesDateTime;
				                        	  	        		ps.PresentationInstanceNumber = studyInfo.GetNextPresentationInstanceNumber();
				                        	  	        		ps.SourceAETitle = provider.ImageSop.DataSource[DicomTags.SourceApplicationEntityTitle].ToString();
				                        	  	        	}) : null;
				if (presentationState != null) presentationStates.Add(presentationState);
				framePresentationStates.Add(new KeyValuePair<KeyImageReference, PresentationStateReference>(provider.Frame, presentationState));
			}

			// serialize the key image document
			var serializer = new KeyImageSerializer();
			serializer.Author = Author;
			serializer.Description = Description;
			serializer.DocumentTitle = DocumentTitle;
			serializer.SeriesDescription = SeriesDescription;
			foreach (var presentationFrame in framePresentationStates)
				serializer.AddImage(presentationFrame.Key, presentationFrame.Value);

			// collect all the SOP instances that were created (both PR and KO)
			var documents = new List<DicomFile>();
			documents.AddRange(serializer.Serialize(koSeries =>
			                                        	{
			                                        		var uid = koSeries.StudyInstanceUid;
			                                        		if (studyIndex.ContainsKey(uid))
			                                        		{
			                                        			koSeries.SeriesDateTime = studyIndex[uid].KeyObjectSeriesDateTime;
			                                        			koSeries.SeriesNumber = studyIndex[uid].KeyObjectSeriesNumber;
			                                        			koSeries.SeriesInstanceUid = studyIndex[uid].KeyObjectSeriesUid;
			                                        			return studyIndex[uid].DataSource;
			                                        		}
			                                        		return null;
			                                        	}
			                   	));
			documents.AddRange(presentationStates.Select(ps => ps.DicomFile));

			// return the created instances grouped by study (and thus study origin/source)
			return documents.GroupBy(f => (IStudySource) studyIndex[f.DataSet[DicomTags.StudyInstanceUid].ToString()]).ToDictionary(g => g.Key, g => g.ToList());
		}
示例#14
0
        public void GetHashCode_PatientsWithSameIDAndNameAreEqual()
        {
            // Arrange
            var infoIdentifier = new InfoIdentifier("123");
            var study1 = new StudyInfo
            {
                StudyInstanceUID = infoIdentifier
            };
            var study2 = new StudyInfo
            {
                StudyInstanceUID = infoIdentifier
            };

            // Act
            var hash1 = study1.GetHashCode();
            var hash2 = study2.GetHashCode();

            // Assert
            Assert.That(hash1, Is.EqualTo(hash2));
        }
示例#15
0
 private void MapForUpdateentity(StudyInfo entity, DA.StudyInfo daEntity)
 {
     daEntity.Id = entity.Id;
 }
示例#16
0
        public void Equals_WithDifferentType_ReturnsFalse()
        {
            var infoIdentifier = new InfoIdentifier("123");
            var study = new StudyInfo
            {
                StudyInstanceUID = infoIdentifier
            };

            // Act
            var result = study.Equals(new object());

            // Assert
            Assert.That(result, Is.False);
        }
示例#17
0
        public void Equals_WithNull_ReturnsFalse()
        {
            // Arrange
            var infoIdentifier = new InfoIdentifier("123");
            var study = new StudyInfo
            {
                StudyInstanceUID = infoIdentifier
            };

            // Act
            var result = study.Equals(null);

            // Assert
            Assert.That(result, Is.False);
        }
示例#18
0
        public void SerializeToJson_CorrectOutput(string birthNumber, string studyUid, string expectedResult)
        {
            // Arrange
            var study = new StudyInfo
            {
                PatientID = new BirthNumber(birthNumber),
                StudyInstanceUID = new InfoIdentifier(studyUid)
            };

            // Act
            var result = JsonConvert.SerializeObject(study);

            // Assert
            Assert.That(result, Is.EqualTo(expectedResult));
        }
示例#19
0
        public void GetHashCode_PatientsWithDifferencNameAndIDAreNotEqual()
        {
            // Arrange
            var study1 = new StudyInfo
            {
                StudyInstanceUID = new InfoIdentifier("123")
            };
            var study2 = new StudyInfo
            {
                StudyInstanceUID = new InfoIdentifier("321")
            };

            // Act
            var hash1 = study1.GetHashCode();
            var hash2 = study2.GetHashCode();

            // Assert
            Assert.That(hash1, Is.Not.EqualTo(hash2));
        }