Ejemplo n.º 1
0
        /*
         * Sets a DicomElement that is either a DicomDateValue or DicomTimeValue
         */

        private void SetTimeDateKeyElement(DicomDataSet ResponseDS, DateTime dt, long tag, bool bTimeValue)
        {
            try
            {
                DicomElement element = ResponseDS.FindFirstElement(null, tag, false);
                if (element != null)
                {
                    if (bTimeValue)
                    {
                        DicomTimeValue[] dtv = new DicomTimeValue[1];
                        dtv[0] = new DicomTimeValue(dt);
                        ResponseDS.SetTimeValue(element, dtv);
                    }
                    else
                    {
                        DicomDateValue[] ddv = new DicomDateValue[1];
                        ddv[0] = new DicomDateValue(dt);
                        ResponseDS.SetDateValue(element, ddv);
                    }
                }
            }
            catch (Exception ex)
            {
                server.mf.Log("Error setting time or date element:\r\n\r\n" + ex.ToString());
                return;
            }
        }
Ejemplo n.º 2
0
        public static DicomDateRangeValue?ToDicomDateRange(int?month, int?day, int?year)
        {
            if (!year.HasValue || !month.HasValue || !day.HasValue)
            {
                return(null);
            }
            var dv  = new DicomDateValue(year.Value, month.Value, day.Value);
            var drv = new DicomDateRangeValue(DicomRangeType.None, dv, dv);

            return(drv);
        }
Ejemplo n.º 3
0
        private void SetPatientInfo(PatientInfo_Json patientInfo, DicomDataSet ds, DicomCharacterSetType characterSetType)
        {
            DicomDateValue dateValue = GetDateTimeValue(patientInfo.BirthDate);

            ds.InsertElementAndSetValue(DicomTag.PatientID, patientInfo.PatientId);
            ds.InsertElementAndSetValue(DicomTag.PatientName, patientInfo.Name);
            ds.InsertElementAndSetValue(DicomTag.PatientBirthDate, dateValue);
            ds.InsertElementAndSetValue(DicomTag.PatientSex, patientInfo.Sex);
            ds.InsertElementAndSetValue(DicomTag.PatientComments, patientInfo.Comments);
            ds.InsertElementAndSetValue(DicomTag.EthnicGroup, patientInfo.EthnicGroup);

            ds.InsertElementAndSetValue(DicomTag.StudyInstanceUID, DicomUtilities.GenerateDicomUniqueIdentifier());
            ds.InsertElementAndSetValue(DicomTag.SeriesInstanceUID, DicomUtilities.GenerateDicomUniqueIdentifier());
            ds.InsertElementAndSetValue(DicomTag.SOPInstanceUID, DicomUtilities.GenerateDicomUniqueIdentifier());
        }
Ejemplo n.º 4
0
 /*
  * Converts a DicomDateValue object into a string formatted as yyyy-mm-dd
  */
 private string ConvertDicomDateToQueryDate(DicomDateValue ddv)
 {
     try
     {
         // Add 0s to beginning if necessary, e.g. yyyy-m-dd needs to be yyyy-mm-dd
         return(ddv.Year.ToString().PadLeft(4, '0') + "-" +
                ddv.Month.ToString().PadLeft(2, '0') + "-" +
                ddv.Day.ToString().PadLeft(2, '0'));
     }
     catch (Exception ex)
     {
         server.mf.Log("Error Converting date:\r\n\r\n" + ex.ToString());
         return("");
     }
 }