コード例 #1
0
ファイル: StoreSCP.cs プロジェクト: KnownSubset/DicomSharp
        private FileInfo ToFile(DataSet ds)
        {
            String studyInstanceUniqueId = null;
            try {
                studyInstanceUniqueId = ds.GetString(Tags.StudyInstanceUniqueId);
                if (studyInstanceUniqueId == null) {
                    throw new DcmServiceException(MISSING_UID, "Missing Study Instance UID");
                }
                if (ds.Vm(Tags.SeriesInstanceUniqueId) <= 0) {
                    throw new DcmServiceException(MISSING_UID, "Missing Series Instance UID");
                }
                String instanceUniqueId = ds.GetString(Tags.SOPInstanceUniqueId);
                if (instanceUniqueId == null) {
                    throw new DcmServiceException(MISSING_UID, "Missing SOP Instance UID");
                }
                String classUniqueId = ds.GetString(Tags.SOPClassUniqueId);
                if (classUniqueId == null) {
                    throw new DcmServiceException(MISSING_UID, "Missing SOP Class UID");
                }
                if (!instanceUniqueId.Equals(ds.FileMetaInfo.MediaStorageSOPInstanceUniqueId)) {
                    throw new DcmServiceException(MISMATCH_UID,
                                                  "SOP Instance UID in DataSet differs from Affected SOP Instance UID");
                }
                if (!classUniqueId.Equals(ds.FileMetaInfo.MediaStorageSOPClassUniqueId)) {
                    throw new DcmServiceException(MISMATCH_UID,
                                                  "SOP Class UID in DataSet differs from Affected SOP Class UID");
                }
            }
            catch (DcmValueException e) {
                throw new DcmServiceException(CANNOT_UNDERSTAND, e);
            }

            String pn = ToFileID(ds, Tags.PatientName) + "____";
            FileInfo dir = _archiveDirectory;
            for (int i = 0; i < dirSplitLevel; ++i) {
                dir = new FileInfo(dir.FullName + "\\" + pn.Substring(0, (i + 1) - (0)));
            }
            dir = new FileInfo(dir.FullName + "\\" + studyInstanceUniqueId);
            dir = new FileInfo(dir.FullName + "\\" + ToFileID(ds, Tags.SeriesNumber));
            var file = new FileInfo(dir.FullName + "\\" + ToFileID(ds, Tags.InstanceNumber) + ".dcm");
            return file;
        }