Example #1
0
            private bool ModifyDICOMInfo(string srcFilePath, ref string newSrcFilePath, out string message)
            {
                newSrcFilePath = "";
                message        = "";
                string savePath = Utilities.GenerateTempSaveFolder() + _uploadTask.UploadFileTaskWorkDto.FileID;

                if (File.Exists(savePath))
                {
                    newSrcFilePath = savePath;
                    return(true);
                }
                Utilities.DeleteOutdatedFolder();
                bool isModify = DCMParser.ModifyAccNoAndPatientID(srcFilePath, savePath, _uploadTask.UploadFileTaskWorkDto.DicomPrefix, out message);

                if (isModify)
                {
                    newSrcFilePath = savePath;
                }
                else
                {
                    DeleteTask(_uploadTask.UploadFileTaskWorkDto.UniqueID);
                    _logger.Debug("can not modify dcm file:" + srcFilePath);
                    return(false);
                }
                return(true);
            }
        private static void RegisterDCMEMRFileItems(EMRFileItemDto emrFileItemDto, List <string> files, DamDetail dam)
        {
            List <DCMInfo> dcmInfoList = new List <DCMInfo>();

            try
            {
                DCMParser.GetDcmInfo(files, out dcmInfoList);
            }
            catch (Exception ex)
            {
                _logger.Error("DCMParser error:" + ex.ToString());
            }
            if (dcmInfoList.Count > 0)
            {
                //dcm list
                List <DCMDto> dcmList = new List <DCMDto>();
                foreach (DCMInfo dcmInfo in dcmInfoList)
                {
                    DCMDto dcmDto = new DCMDto();
                    dcmDto.StudyDto             = dcmInfo.StudyDto;
                    dcmDto.StudyDto.AccessionNo = emrFileItemDto.DicomPrefix + dcmDto.StudyDto.AccessionNo;
                    dcmDto.StudyDto.PatientID   = emrFileItemDto.DicomPrefix + dcmDto.StudyDto.PatientID;

                    dcmDto.SeriesDto = dcmInfo.SeriesDto;

                    dcmDto.ImageDto = dcmInfo.ImageDto;
                    dcmDto.ImageDto.ExtraConfigID = emrFileItemDto.ExtraConfigID;
                    dcmDto.ImageDto.SrcInfo       = emrFileItemDto.SrcInfo;
                    dcmDto.ImageDto.CreatorID     = emrFileItemDto.CreatorID;
                    dcmDto.ImageDto.CreateTime    = emrFileItemDto.CreateTime;
                    dcmDto.ImageDto.ObjectFile    = System.DateTime.Now.ToString("yyyy-MM-dd") + "\\" + dcmDto.StudyDto.AccessionNo + "\\" + dcmDto.ImageDto.UniqueID + ".dcm";
                    dcmDto.EMRFileItemDto         = CreateDCMEMRFileItem(emrFileItemDto, dcmInfo.StudyDto);
                    dcmList.Add(dcmDto);
                }
                if (dcmList.Count > 0)
                {
                    try
                    {
                        using (var client = new HttpClient())
                        {
                            var parameters = "/api/v1/registration/dcmitems";
                            HttpResponseMessage response = client.PostAsync <List <DCMDto> >(dam.WebApiurl + parameters, dcmList, new JsonMediaTypeFormatter()).Result;
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error("dcmitems error:" + ex.ToString());
                    }
                }
            }
        }