private void ImportDocument(Patient patient, MailAttachmentPatientDocumentDto dto)
        {
            var message = _imapMessageFetcher.FetchMessage(dto.MailFolderName, dto.MailId);

            if (message == null || message.Attachments.Count == 0)
            {
                throw new ApplicationException("Couldn't find the attachment.");
            }

            //TODO: Right now, only get the first attachment
            dto.Document = message.Attachments[0].ContentBytes;
            dto.FileName = message.Attachments[0].FileName;

            var patientDocumentType = _mappingHelper.MapLookupField <PatientDocumentType> (dto.PatientDocumentType);
            var patientDocument     = _patientDocumentFactory.CreatePatientDocument(patient, patientDocumentType, dto.Document, dto.FileName);

            var clinicalDateRange = new DateRange(dto.ClinicalStartDate, dto.ClinicalEndDate);

            patientDocument.ReviseClinicalDateRange(clinicalDateRange);
            patientDocument.ReviseDescription(dto.Description);
            patientDocument.ReviseDocumentProviderName(dto.DocumentProviderName);
            patientDocument.ReviseOtherDocumentTypeName(dto.OtherDocumentTypeName);

            _patientDocumentRepository.MakePersistent(patientDocument);
        }
Пример #2
0
        /// <summary>
        /// Creates the new.
        /// </summary>
        /// <param name="dto">The data transfer object.</param>
        /// <returns>A <see cref="Rem.Domain.Clinical.PatientModule.PatientDocument"/></returns>
        protected override PatientDocument CreateNew(PatientDocumentDto dto)
        {
            var patient             = _patientRepository.GetByKey(dto.PatientKey);
            var patientDocumentType = _mappingHelper.MapLookupField <PatientDocumentType> (dto.PatientDocumentType);
            var entity = _patientDocumentFactory.CreatePatientDocument(patient, patientDocumentType, dto.Document, dto.FileName);

            return(entity);
        }
        /// <summary>
        /// Creates the new.
        /// </summary>
        /// <param name="dto">The data transfer object.</param>
        /// <returns>A <see cref="Rem.Domain.Clinical.PatientModule.PatientDocument"/></returns>
        protected override PatientDocument CreateNew(MailAttachmentPatientDocumentDto dto)
        {
            var message = _imapMessageFetcher.FetchMessage(dto.MailFolderName, dto.MailId);

            if (message == null || message.Attachments.Count == 0)
            {
                throw new ApplicationException("Couldn't find the attachment.");
            }

            //TODO: Right now, only get the first attachment
            dto.Document = message.Attachments[0].ContentBytes;
            dto.FileName = message.Attachments[0].FileName;

            var patient             = _patientRepository.GetByKey(dto.PatientKey);
            var patientDocumentType = _mappingHelper.MapLookupField <PatientDocumentType> (dto.PatientDocumentType);
            var entity = _patientDocumentFactory.CreatePatientDocument(patient, patientDocumentType, dto.Document, dto.FileName);

            return(entity);
        }