Esempio n. 1
0
        public void Delete(long tag)
        {
            DicomElement element = _Dataset.FindFirstElement(null, tag, false);

            if (element != null)
            {
                _Dataset.DeleteElement(element);
            }
        }
Esempio n. 2
0
        public static void RemoveTag(this DicomDataSet ds, long tag)
        {
            DicomElement element = ds.FindFirstElement(null, tag, false);

            if (element != null)
            {
                ds.DeleteElement(element);
            }
        }
Esempio n. 3
0
        public bool AddPatient(string authenticationCookie, PatientInfo_Json patientInfo, string userData)
        {
            try
            {
                string userName;

                userName = ServiceUtils.Authorize(authenticationCookie, PermissionsTable.Instance.CanStore);

                StoreItemInfo storeItemInfo = new StoreItemInfo();
                storeItemInfo.MimeType = SupportedMimeTypes.DICOM;
                DicomDataSet ds = new DicomDataSet();
                ds.Initialize(DicomClassType.Patient, DicomDataSetInitializeFlags.AddMandatoryElementsOnly);

                // The 2014 specification has added ReferencedStudySequence to the Patient Module (Retired) as a mandatory element
                // Remove this element for adding the patient
                DicomElement element = ds.FindFirstElement(null, DicomTag.ReferencedStudySequence, true);
                if (element != null)
                {
                    ds.DeleteElement(element);
                }

                SetPatientInfo(patientInfo, ds, DicomCharacterSetType.UnicodeInUtf8);

                MemoryStream ms = new MemoryStream();
                ds.Save(ms, DicomDataSetSaveFlags.None);

                //TODO: Store Patient information (Need to determine how this will be handled in the DB. Same for the unapproved captured images)

                QueryOptions queryOptions = new QueryOptions();
                queryOptions.PatientsOptions           = new PatientsQueryOptions();
                queryOptions.PatientsOptions.PatientID = patientInfo.PatientId;

                // If patientID already exists, return 'false'
                PatientData[] patientData = _queryAddin.FindPatients(userName, queryOptions);
                if (patientData.Length > 0)
                {
                    return(false);
                }

                // Otherwise, add the patient
                _storeAddin.StoreItem(ms, storeItemInfo);

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
Esempio n. 4
0
        private void OnMatchFound(DicomDataSet response)
        {
            try
            {
                if (null != MatchFound)
                {
                    try
                    {
                        GatewaySession.Log(__Client, DicomCommandType.CFind, LogType.Debug, MessageDirection.Output, null,
                                           "[Gateway] Sending C-Find response to client \"" + (__Client.IsAssociated() ? __Client.Association.Calling : string.Empty) + "\"");

                        DicomElement element = response.FindFirstElement(null, DicomTag.RetrieveAETitle, true);

                        if (null != element)
                        {
                            response.DeleteElement(element);
                        }

                        response.InsertElementAndSetValue(DicomTag.InstanceAvailability, "NEARLINE");

                        MatchFound(this, new MatchFoundEventArgs(response));

                        GatewaySession.Log(__Client, DicomCommandType.CFind, LogType.Debug, MessageDirection.Output, null,
                                           "[Gateway] C-Find response sent successfully to client \"" + (__Client.IsAssociated() ? __Client.Association.Calling : string.Empty) + "\"");
                    }
                    catch (Exception exception)
                    {
                        GatewaySession.Log(__Client, DicomCommandType.CFind, LogType.Error, MessageDirection.Output, null,
                                           "[Gateway] Faild to send C-Find response to client \"" + (__Client.IsAssociated() ? __Client.Association.Calling : string.Empty) + "\"\n"
                                           + exception.Message);
                    }
                }
            }
            finally
            {
                response.Dispose();
            }
        }
Esempio n. 5
0
 private void SetSomeTag(DicomDataSet ds, string FileName)
 {
     try
     {
         
         DicomElement element = ds.FindFirstElement(null, DicomTag.PatientID, false);
         if (element != null)
         {
             ds.DeleteElement(element);
             ds = ds.InsertElementAndSetValue(DicomTag.PatientID, txtID2.Text.Trim());
         }
         if (element == null) ds = ds.InsertElementAndSetValue(DicomTag.PatientID, txtID2.Text.Trim());
         //RegistrationSequence
         element = ds.FindFirstElement(null, DicomTag.RegistrationSequence, false);
         if (element != null)
         {
             ds.DeleteElement(element);
             ds = ds.InsertElementAndSetValue(DicomTag.RegistrationSequence, txtRegNumber2.Text.Trim());
         }
         if (element == null) ds = ds.InsertElementAndSetValue(DicomTag.RegistrationSequence, txtRegNumber2.Text.Trim());
         //Sex
         element = ds.FindFirstElement(null, DicomTag.PatientSex, false);
         if (element != null)
         {
             ds.DeleteElement(element);
             ds = ds.InsertElementAndSetValue(DicomTag.PatientSex, Sex);
         }
         if (element == null) ds = ds.InsertElementAndSetValue(DicomTag.PatientSex, Sex);
         //CreatedDate
         element = ds.FindFirstElement(null, DicomTag.DateTime, false);
         if (element != null)
         {
             ds.DeleteElement(element);
             ds = ds.InsertElementAndSetValue(DicomTag.DateTime, RegDate.ToLongTimeString());
         }
         if (element == null) ds = ds.InsertElementAndSetValue(DicomTag.DateTime, RegDate.ToLongTimeString());
         //pBirthdate
         element = ds.FindFirstElement(null, DicomTag.PatientBirthDate, false);
         if (element != null)
         {
             ds.DeleteElement(element);
             ds = ds.InsertElementAndSetValue(DicomTag.PatientBirthDate, BirthDate);
         }
         if (element == null) ds = ds.InsertElementAndSetValue(DicomTag.PatientBirthDate, BirthDate);
         //pName
         element = ds.FindFirstElement(null, DicomTag.PatientName, false);
         if (element != null)
         {
             ds.DeleteElement(element);
             ds = ds.InsertElementAndSetValue(DicomTag.PatientName, Bodau(txtName2.Text.Trim()));
         }
         if (element == null) ds = ds.InsertElementAndSetValue(DicomTag.PatientName, Bodau(txtName2.Text.Trim()));
         //pAge
         element = ds.FindFirstElement(null, DicomTag.PatientAge, false);
         if (element != null)
         {
             ds.DeleteElement(element);
             ds = ds.InsertElementAndSetValue(DicomTag.PatientAge, txtAge.Text.Trim());
         }
         if (element == null) ds = ds.InsertElementAndSetValue(DicomTag.PatientAge, txtAge.Text.Trim());
     }
     catch
     {
     }
 }