添加项目文件。

This commit is contained in:
DK
2022-03-28 15:27:40 +08:00
parent b620fcb0cf
commit dc78fd1a09
898 changed files with 173053 additions and 0 deletions
@@ -0,0 +1,254 @@
using IRaCIS.Application.Interfaces;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infra.EFCore;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Infrastructure.Extention;
using Microsoft.AspNetCore.Mvc;
using Panda.DynamicWebApi.Attributes;
namespace IRaCIS.Application.Services
{
/// <summary>
/// 医生文档关联关系维护
/// </summary>
[ApiExplorerSettings(GroupName = "Reviewer")]
public class AttachmentService : BaseService, IAttachmentService
{
private readonly IRepository<Attachment> attachmentrepository;
public AttachmentService(IRepository<Attachment> attachmentrepository)
{
this.attachmentrepository = attachmentrepository;
}
/// <summary>
/// 删除附件
/// </summary>
/// <param name="param"></param>
/// <returns></returns>
public async Task<IResponseOutput> DeleteAttachment([FromBody]AttachementCommand param)
{
//var attachment = _doctorAttachmentApp.GetDetailById(id);
//string file = HostingEnvironment.MapPath(attachment.Path);
//if (File.Exists(file))
//{
// File.Delete(file);
//}
//var temp = HostingEnvironment.MapPath(param.Path);
//if (File.Exists(temp))
//{
// File.Delete(temp);
//}
var success =await attachmentrepository.DeleteFromQueryAsync(a => a.Id == param.Id);
return ResponseOutput.Result(success);
}
/// <summary>
/// 根据医生Id 和 附件类型,获取记录
/// </summary>
/// <param name="doctorId">医生Id</param>
/// <param name="type">附件类型</param>
/// <returns></returns>
[HttpGet("{doctorId:guid}/{type}")]
public async Task<IEnumerable<AttachmentDTO>> GetAttachmentByType(Guid doctorId, string type)
{
var attachmentList = await attachmentrepository.Where(a => a.DoctorId == doctorId && a.Type.Equals(type)).ProjectTo<AttachmentDTO>(_mapper.ConfigurationProvider).ToListAsync();
attachmentList.ForEach(t => t.FullPath = t.Path + "?access_token=" + _userInfo.UserToken);
return attachmentList;
}
/// <summary>
/// 获取单个医生的多种证书附件
/// </summary>
/// <param name="doctorId">医生Id</param>
/// <param name="types">类型数组</param>
/// <returns></returns>
[HttpPost("{doctorId:guid}")]
public async Task<IEnumerable<AttachmentDTO>> GetAttachmentByTypes(Guid doctorId, string[] types)
{
var attachmentList =await attachmentrepository.Where(a => a.DoctorId == doctorId && types.Contains(a.Type)).OrderBy(s => s.Type).ThenBy(m => m.CreateTime).ProjectTo<AttachmentDTO>(_mapper.ConfigurationProvider).ToListAsync();
attachmentList.ForEach(t => t.FullPath = t.Path + "?access_token=" + _userInfo.UserToken);
return attachmentList;
}
/// <summary>
/// 根据医生Id获取医生附件
/// </summary>
/// <param name="doctorId">医生Id</param>
/// <returns></returns>
[HttpGet("{doctorId:guid}")]
public async Task<IEnumerable<AttachmentDTO>> GetAttachments(Guid doctorId)
{
var attachmentList =await attachmentrepository.Where(a => a.DoctorId == doctorId).OrderBy(s => s.Type).ThenBy(m => m.CreateTime).ProjectTo<AttachmentDTO>(_mapper.ConfigurationProvider).ToListAsync();
attachmentList.ForEach(t => t.FullPath = t.Path + "?access_token=" + _userInfo.UserToken);
return attachmentList;
}
[NonDynamicMethod]
public async Task<AttachmentDTO> GetDetailById(Guid attachmentId)
{
var attachment = await attachmentrepository.FirstOrDefaultAsync(a => a.Id == attachmentId).IfNullThrowException();
var temp= _mapper.Map<AttachmentDTO>(attachment);
temp.FullPath = temp.Path + "?access_token=" + _userInfo.UserToken;
return temp;
}
/// <summary>
/// 保存多个附件
/// </summary>
/// <param name="attachmentList"></param>
/// <returns></returns>
public async Task<IEnumerable<AttachmentDTO>> SaveAttachments(IEnumerable<AttachmentDTO> attachmentList)
{
var attachments = _mapper.Map<IEnumerable<Attachment>>(attachmentList).ToList();
//1 是中文 2是英文 中英文第一份简历默认设置为官方
var zhCount = attachments.Count(t => t.Language == 1);
var usCount = attachments.Count(t => t.Language == 2);
if (zhCount == 1)
{
var k = attachments.First(t => t.Language == 1);
k.IsOfficial = true;
}
if (usCount == 1)
{
var k = attachments.First(t => t.Language == 2);
k.IsOfficial = true;
}
//处理重传
var reUpload = attachmentList.FirstOrDefault(t => t.ReUpload == true);
if (reUpload != null)
{
//因为界面现实的列表用了 接口返回的列表,所以要把返回的模型对应的字段也要更改
var attach = attachments.First(t => t.Id == reUpload.Id);
attach.CreateTime = DateTime.Now;
//重传的时候,发现 相同语言的官方简历数量为2 那么将重传的简历设置为非官方
if (attachments.Count(t => t.Language == reUpload.Language && t.IsOfficial) == 2)
{
await attachmentrepository.UpdateFromQueryAsync(t => t.Id == reUpload.Id, u => new Attachment()
{
Path = reUpload.Path,
CreateTime = DateTime.Now,
Language = reUpload.Language,
IsOfficial = false
});
attach.IsOfficial = false;
}
else //相同语言的重传
{
await attachmentrepository.UpdateFromQueryAsync(t => t.Id == reUpload.Id, u => new Attachment()
{
Path = reUpload.Path,
CreateTime = DateTime.Now,
Language = reUpload.Language
});
}
}
var newAttachment = attachments.Where(t => t.Id == Guid.Empty);
await _repository.AddRangeAsync(newAttachment);
await _repository.SaveChangesAsync();
//_doctorAttachmentRepository.AddRange(newAttachment);
//_doctorAttachmentRepository.SaveChanges();
var list = _mapper.Map<IEnumerable<AttachmentDTO>>(attachments).ToList();
list.ForEach(t => t.FullPath = t.Path + "?access_token=" + _userInfo.UserToken);
return list;
}
public async Task<IResponseOutput<AttachmentDTO>> AddAttachment(AttachmentDTO attachment)
{
var newAttachment = _mapper.Map<Attachment>(attachment);
//如果这个医生不存在 这个语言的官方简历 就设置为官方简历
if (! await attachmentrepository.AnyAsync(t => t.Type == "Resume" && t.DoctorId == attachment.DoctorId && t.Language == attachment.Language && t.IsOfficial))
{
newAttachment.IsOfficial = true;
attachment.IsOfficial = true;
}
await _repository.AddAsync(newAttachment);
var success = await _repository.SaveChangesAsync();
return ResponseOutput.Result(success, attachment);
}
[NonDynamicMethod]
public async Task<string> GetDoctorOfficialCV(int language, Guid doctorId)
{
var result = await attachmentrepository.FirstOrDefaultAsync(a => a.DoctorId == doctorId &&
a.IsOfficial && a.Type.Equals("Resume") && a.Language == language);
if (result != null)
{
return result.Path;
}
return string.Empty;
}
/// <summary>
/// 将简历设置为官方简历
/// </summary>
/// <param name="doctorId"></param>
/// <param name="attachmentId"></param>
/// <param name="language"></param>
/// <returns></returns>
[HttpPost("{doctorId:guid}/{attachmentId:guid}/{language}")]
public async Task<IResponseOutput> SetOfficial(Guid doctorId, Guid attachmentId, int language)
{
var resumeList = await _repository.GetQueryable<Attachment>().Where(t => t.DoctorId == doctorId && t.Type == "Resume" && t.Language == language).ToListAsync();
foreach (var item in resumeList)
{
if (item.Id == attachmentId) item.IsOfficial = true;
else item.IsOfficial = false;
await _repository.UpdateAsync(item);
}
return ResponseOutput.Result(await _repository.SaveChangesAsync());
}
/// <summary>
/// 设置简历的语言类型
/// </summary>
/// <param name="doctorId"></param>
/// <param name="attachmentId"></param>
/// <param name="language">0-未设置,1-中文,2-英文</param>
/// <returns></returns>
[HttpPost("{doctorId:guid}/{attachmentId:guid}/{language}")]
public async Task<IResponseOutput> SetLanguage(Guid doctorId, Guid attachmentId, int language)
{
bool result =await attachmentrepository.UpdateFromQueryAsync(t => t.Id == attachmentId, a => new Attachment
{
Language = language,
IsOfficial = false
});
return ResponseOutput.Result(result);
}
}
}
@@ -0,0 +1,61 @@
namespace IRaCIS.Application.Contracts
{
public class AttachmentDTO
{
public Guid Id { get; set; }
public Guid DoctorId { get; set; }
public bool IsOfficial { get; set; }
public string Type { get; set; } = string.Empty;
public string Path { get; set; } = string.Empty;
public string FullPath { get; set; } = string.Empty;
public string FileName { get; set; } = string.Empty;
public DateTime? CreateTime { get; set; }
public int Language { get; set; }
public bool ReUpload { get; set; } = false;
}
public class ReviewerAckDTO
{
public Guid Id { get; set; }
public Guid DoctorId { get; set; }
public string Type { get; set; } = string.Empty;
public string Path { get; set; } = string.Empty;
public string FullPath => Path;
public string FileName { get; set; } = string.Empty;
}
public class TrialSOWPathDTO
{
public Guid TrialId { get; set; }
public string SowName { get; set; } = string.Empty;
public string SowPath { get; set; } = string.Empty;
}
public class DeleteSowPathDTO
{
public Guid TrialId { get; set; }
public string Path { get; set; } = string.Empty;
}
public class UploadAgreementAttachmentDTO
{
public Guid Id { get; set; }
public Guid DoctorId { get; set; }
public string Type { get; set; } = string.Empty;
public string Path { get; set; } = string.Empty;
public string FullPath => Path;
public string FileName { get; set; } = string.Empty;
}
public class AttachementCommand
{
public Guid Id { get; set; }
public string Path { get; set; } = string.Empty;
}
}
@@ -0,0 +1,12 @@
using System;
namespace IRaCIS.Application.Contracts
{
public class DoctorAccountRegisterModel : DoctorAccountLoginDTO
{
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public string EMail { get; set; } = string.Empty;
public DateTime RegisterTime { get; set; }
}
}
@@ -0,0 +1,665 @@
using System;
using System.Collections.Generic;
using IRaCIS.Core.Infrastructure.Extention;
using IRaCIS.Core.Domain.Share;
using Newtonsoft.Json;
using System.Linq;
namespace IRaCIS.Application.Contracts
{
#region
public class DoctorDTO
{
[JsonIgnore]
public List<DicView> DictionaryList { get; set; } = new List<DicView>();
//临床实践中使用的模式
public List<string> ReadingTypeList => DictionaryList.Where(t => t.ParentCode == StaticData.ReadingType).OrderBy(t => t.ShowOrder).Select(t => t.Value).ToList();
public List<string> ReadingTypeCNList => DictionaryList.Where(t => t.ParentCode == StaticData.ReadingType).OrderBy(t => t.ShowOrder).Select(t => t.ValueCN).ToList();
public List<Guid> ReadingTypeIds => DictionaryList.Where(t => t.ParentCode == StaticData.ReadingType).OrderBy(t => t.ShowOrder).Select(t => t.Id).ToList();
//第二专业
public List<string> SubspecialityList => DictionaryList.Where(t => t.ParentCode == StaticData.Subspeciality).OrderBy(t => t.ShowOrder).Select(t => t.Value).ToList();
public List<string> SubspecialityCNList => DictionaryList.Where(t => t.ParentCode == StaticData.Subspeciality).OrderBy(t => t.ShowOrder).Select(t => t.ValueCN).ToList();
public List<Guid> SubspecialityIds => DictionaryList.Where(t => t.ParentCode == StaticData.Subspeciality).OrderBy(t => t.ShowOrder).Select(t => t.Id).ToList();
public string ReadingTypeOther { get; set; } = String.Empty;
public string ReadingTypeOtherCN { get; set; } = String.Empty;
public Guid Id { get; set; }
public DateTime CreateTime { get; set; }
public string ReviewerCode { get; set; } = String.Empty;//GUID
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public string ChineseName { get; set; } = string.Empty;
public List<Guid> TitleIdList { get; set; } = new List<Guid>();
public List<string> TitleList { get; set; } = new List<string>();
public List<string> TitleCNList { get; set; } = new List<string>();
public string Phone { get; set; } = string.Empty;
public string Introduction { get; set; } = string.Empty;
public string EMail { get; set; } = string.Empty;
public string WeChat { get; set; } = string.Empty;
//部门
public string Department { get; set; } = string.Empty;
public string DepartmentCN { get; set; } = string.Empty;
public Guid? DepartmentId { get; set; }
public string DepartmentOther { get; set; } = String.Empty;
public string DepartmentOtherCN { get; set; } = String.Empty;
//增加的
public Guid? SpecialityId { get; set; } = Guid.Empty;
public string Speciality { get; set; } = string.Empty;
public string SpecialityCN { get; set; } = string.Empty;
public string SpecialityOther { get; set; } = string.Empty;
public string SpecialityOtherCN { get; set; } = string.Empty;
//职称
public string Rank { get; set; } = string.Empty;
public string RankCN { get; set; } = string.Empty;
public Guid? RankId { get; set; }
public string RankOther { get; set; } = String.Empty;
public string RankOtherCN { get; set; } = String.Empty;
//职位
public string Position { get; set; } = string.Empty;
public string PositionCN { get; set; } = string.Empty;
public Guid? PositionId { get; set; }
public string PositionOther { get; set; } = String.Empty;
public string PositionOtherCN { get; set; } = String.Empty;
public string SubspecialityOther { get; set; } = String.Empty;
public string SubspecialityOtherCN { get; set; } = String.Empty;
public int GCP { get; set; }
public Guid? GCPId { get; set; }
public string ResumePath { get; set; } = string.Empty;
public bool HasResume
{
get; set;
}
public bool Reconfirmed { get; set; }
public int CooperateStatus { get; set; }
public int ResumeStatus { get; set; }
public bool AcceptingNewTrial { get; set; } = false;
public bool ActivelyReading { get; set; } = false;
//医院
public Guid? HospitalId { get; set; }
public string HospitalOther { get; set; } = String.Empty;
public string HospitalName { get; set; } = string.Empty;
public string City { get; set; } = String.Empty;
public string Country { get; set; } = String.Empty;
public string HospitalNameCN { get; set; } = string.Empty;
public string CityCN { get; set; } = String.Empty;
public string CountryCN { get; set; } = String.Empty;
public int? Reading { get; set; }
public int? Approved { get; set; }
public int? Submitted { get; set; }
public int? Finished { get; set; }
}
/// <summary>
/// Reviewer 列表查询参数
/// </summary>
public class DoctorSearchDTO : PageInput
{
public string Name { get; set; } = string.Empty;
public List<Guid> ReadingTypeIdList { get; set; } = new List<Guid>();
public List<Guid> SubspecialityIdList { get; set; } = new List<Guid>();
public List<Guid> EvaluationCriteriaIdList { get; set; } = new List<Guid>();
public List<Guid> TitleIdList { get; set; } = new List<Guid>();
public Guid? DepartmentId { get; set; }
public Guid? SpecialityId { get; set; }
public Guid? PositionId { get; set; }
public Guid? RankId { get; set; }
public Guid? HospitalId { get; set; }
//合作状态
public ContractorStatusEnum? ContractorStatus { get; set; }
// 简历审核状态
public ResumeStatusEnum? InformationConfirmed { get; set; }
public int? EnrollStatus { get; set; } //入组状态
public bool? AcceptingNewTrial { get; set; }//是否接受新的项目
public bool? ActivelyReading { get; set; }// 是否接受新的读片任务
public int? Nation { get; set; }// 0-中国医生,2-美国医生,3-全部
}
/// <summary>
/// 入组 Selection 列表查询参数
/// </summary>
public class ReviewerSelectionQueryDTO : DoctorSearchDTO
{
public Guid TrialId { get; set; }
}
public class ReviewerSubmissionQueryDTO : PageInput
{
public Guid TrialId { get; set; } = Guid.Empty;
public int IntoGroupSearchState { get; set; }
}
public class ReviewerConfirmationQueryDTO : PageInput
{
public Guid TrialId { get; set; } = Guid.Empty;
}
public class SelectionReviewerDTO : DoctorDTO
{
public int DoctorTrialState { get; set; }
public string OptUserName { get; set; } = string.Empty;
public DateTime? OptTime { get; set; }
public string? OptTimeStr => OptTime?.ToString("yyyy-MM-dd HH:mm:ss");
}
public class DoctorOptDTO
{
public Guid Id { get; set; }
public string Code { get; set; } = String.Empty;//GUID
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public string ChineseName { get; set; } = string.Empty;
public string City { get; set; } = string.Empty;
public string HospitalName { get; set; } = string.Empty;
public string Country { get; set; } = string.Empty;
}
public class ConfirmationReviewerDTO : DoctorOptDTO
{
public int DoctorTrialState { get; set; }
public string OptUserName { get; set; } = string.Empty;
public DateTime? OptTime { get; set; }
public string? OptTimeStr => OptTime?.ToString("yyyy-MM-dd HH:mm:ss");
}
public class DoctorStateModelDTO
{
public Guid DoctorId { get; set; }
public int IntoGroupState { get; set; }
public string OptUserName { get; set; } = String.Empty;
public DateTime? OptTime { get; set; }
}
#endregion
public class DoctorDetailDTO
{
public DoctorBasicInfoDTO BasicInfoView { get; set; }
public EmploymentDTO EmploymentView { get; set; }
public SpecialtyDTO SpecialtyView { get; set; }
public IEnumerable<EducationInfoViewModel> EducationList { get; set; }
public IEnumerable<PostgraduateViewModel> PostgraduateList { get; set; }
public ResearchPublicationDTO ResearchPublicationView { get; set; }
public TrialExperienceModel TrialExperienceView { get; set; }
public ResumeConfirmDTO AuditView { get; set; }
public IEnumerable<AttachmentDTO> AttachmentList { get; set; }
public List<SowDTO> SowList { get; set; }
public List<SowDTO> AckSowList { get; set; }
public DoctorEnrollInfoDTO IntoGroupInfo { get; set; }
public bool InHoliday { get; set; }
public DoctorDetailDTO()
{
BasicInfoView = new DoctorBasicInfoDTO();
EmploymentView = new EmploymentDTO();
SpecialtyView = new SpecialtyDTO();
EducationList = new List<EducationInfoViewModel>();
PostgraduateList = new List<PostgraduateViewModel>();
ResearchPublicationView = new ResearchPublicationDTO();
TrialExperienceView = new TrialExperienceModel();
AuditView = new ResumeConfirmDTO();
AttachmentList = new List<AttachmentDTO>();
IntoGroupInfo = new DoctorEnrollInfoDTO();
SowList = new List<SowDTO>();
AckSowList = new List<SowDTO>();
}
}
public class DoctorEnrollInfoDTO
{
public Guid? DoctorId { get; set; }
public int? Submitted { get; set; }
public int? Approved { get; set; }
public int? Reading { get; set; }
}
#region
public class DoctorBasicInfo
{
public Guid? Id { get; set; }
public string ReviewerCode { get; set; } = string.Empty;
public string FirstName { get; set; } = String.Empty;
public string LastName { get; set; } = String.Empty;
public string ChineseName { get; set; } = String.Empty;
public int Sex { get; set; }
public string Phone { get; set; } = String.Empty;
public string Introduction { get; set; } = String.Empty;
public string EMail { get; set; } = String.Empty;
public string WeChat { get; set; } = String.Empty;
public int Nation { get; set; }
}
public class DoctorBasicInfoCommand : DoctorBasicInfo
{
//职称
public List<Guid> TitleIds { get; set; } = new List<Guid>();
}
public class TempObj
{
public int ShowOrder { get; set; }
public Guid TitleId { get; set; }
public string TitleCN { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
}
public class DicView
{
public int ShowOrder { get; set; }
public Guid Id { get; set; }
public string ValueCN { get; set; } = string.Empty;
public string ParentCode { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
}
public class DoctorBasicInfoDTO : DoctorBasicInfo
{
public List<DicView> DoctorDicViewDtos = new List<DicView>();
//职称
public List<Guid> TitleIds => DoctorDicViewDtos.Select(t => t.Id).ToList();
public List<string> TitleList=> DoctorDicViewDtos.Select(t => t.Value).ToList();
public List<string> TitleCNList=> DoctorDicViewDtos.Select(t => t.ValueCN).ToList();
#region ef select
//[JsonIgnore]
//public List<TempObj> TempObjList { get; set; }
////职称
//public List<Guid> TitleIds
//{
// get
// {
// if (TempObjList.Count > 0)
// {
// return TempObjList.Select(t => t.TitleId).ToList();
// }
// else
// {
// return new List<Guid>();
// }
// }
//}
//public List<string> TitleList
//{
// get
// {
// if (TempObjList.Count > 0)
// {
// return TempObjList.Select(t => t.Title).ToList();
// }
// else
// {
// return new List<string>();
// }
// }
//}
//public List<string> TitleCNList
//{
// get
// {
// if (TempObjList.Count > 0)
// {
// return TempObjList.Select(t => t.TitleCN).ToList();
// }
// else
// {
// return new List<string>();
// }
// }
//}
#endregion
}
public class SowDTO
{
public string FileName { get; set; } = string.Empty;
public string TrialCode { get; set; } = string.Empty;
public string FilePath { get; set; } = string.Empty;
public string FullPath { get { return FilePath; } }
public DateTime CreateTime { get; set; }
}
#endregion
#region
//public class DoctorHospitalView
//{
// public string HospitalName { get; set; }
// public string UniversityAffiliated { get; set; }
// public string Country { get; set; }
// public string Province { get; set; }
// public string City { get; set; }
// public string HospitalNameCN { get; set; }
// public string UniversityAffiliatedCN { get; set; }
// public string CountryCN { get; set; }
// public string ProvinceCN { get; set; }
// public string CityCN { get; set; }
//}
public class EmploymentDTO : EmploymentInfo
{
//public DoctorHospitalView Hospital { get; set; }
public string Department { get; set; } = String.Empty;
public string Rank { get; set; } = String.Empty;
public string Position { get; set; } = String.Empty;
#region
public string HospitalName { get; set; } = String.Empty;
public string UniversityAffiliated { get; set; } = String.Empty;
public string Country { get; set; } = String.Empty;
public string Province { get; set; } = String.Empty;
public string City { get; set; } = String.Empty;
#endregion
public string DepartmentCN { get; set; } = String.Empty;
public string RankCN { get; set; } = String.Empty;
public string PositionCN { get; set; } = String.Empty;
public string HospitalNameCN { get; set; } = String.Empty;
public string UniversityAffiliatedCN { get; set; } = String.Empty;
public string CountryCN { get; set; } = String.Empty;
public string ProvinceCN { get; set; } = String.Empty;
public string CityCN { get; set; } = String.Empty;
}
public class EmploymentCommand : EmploymentInfo
{
}
public class EmploymentInfo
{
public Guid Id { get; set; }
//部门
public Guid? DepartmentId { get; set; } = Guid.Empty;
public string DepartmentOther { get; set; } = string.Empty;
public string DepartmentOtherCN { get; set; } = string.Empty;
//职称
public Guid? RankId { get; set; } = Guid.Empty;
public string RankOther { get; set; } = string.Empty;
public string RankOtherCN { get; set; } = string.Empty;
//职位 主席 副主席
public Guid? PositionId { get; set; } = Guid.Empty;
public string PositionOther { get; set; } = string.Empty;
public string PositionOtherCN { get; set; } = string.Empty;
public Guid? HospitalId { get; set; } = Guid.Empty;
}
#endregion
#region Specialty模型
public class SpecialtyDTO : SpecialtyCommand
{
[JsonIgnore]
public List<DicView> DictionaryList { get; set; } = new List<DicView>();
public string Speciality { get; set; } = string.Empty;
//临床实践中使用的模式
public new List<Guid> ReadingTypeIds
{
get
{
if (DictionaryList.Count > 0)
{
return DictionaryList.Where(t => t.ParentCode == StaticData.ReadingType).Select(t => t.Id).ToList();
}
else
{
return new List<Guid>();
}
}
}
public new List<Guid> SubspecialityIds
{
get
{
if (DictionaryList.Count > 0)
{
return DictionaryList.Where(t => t.ParentCode == StaticData.Subspeciality).Select(t => t.Id).ToList();
}
else
{
return new List<Guid>();
}
}
}
public List<string> ReadingTypeList
{
get
{
if (DictionaryList.Count > 0)
{
return DictionaryList.Where(t => t.ParentCode == StaticData.ReadingType).Select(t => t.Value).ToList();
}
else
{
return new List<string>();
}
}
}
public List<string> SubspecialityList
{
get
{
if (DictionaryList.Count > 0)
{
return DictionaryList.Where(t => t.ParentCode == StaticData.Subspeciality).Select(t => t.Value).ToList();
}
else
{
return new List<string>();
}
}
}
public List<string> ReadingTypeCNList
{
get
{
if (DictionaryList.Count > 0)
{
return DictionaryList.Where(t => t.ParentCode == StaticData.ReadingType).Select(t => t.ValueCN).ToList();
}
else
{
return new List<string>();
}
}
}
public List<string> SubspecialityCNList
{
get
{
if (DictionaryList.Count > 0)
{
return DictionaryList.Where(t => t.ParentCode == StaticData.Subspeciality).Select(t => t.ValueCN).ToList();
}
else
{
return new List<string>();
}
}
}
}
public class SpecialtyCommand
{
public List<Guid> ReadingTypeIds { get; set; } = new List<Guid>();
public List<Guid> SubspecialityIds { get; set; } = new List<Guid>();
public Guid Id { get; set; }
public string OtherSkills { get; set; } = string.Empty;
public string ReadingTypeOther { get; set; } = string.Empty;
public string ReadingTypeOtherCN { get; set; } = string.Empty;
//亚专科
public string SubspecialityOther { get; set; } = string.Empty;
public string SubspecialityOtherCN { get; set; } = string.Empty;
public Guid? SpecialityId { get; set; } = Guid.Empty;
public string SpecialityCN { get; set; } = string.Empty;
public string SpecialityOther { get; set; } = string.Empty;
public string SpecialityOtherCN { get; set; } = string.Empty;
}
#endregion
#region
public class DoctorAccountLoginDTO
{
public string Phone { get; set; } = String.Empty;
public string Password { get; set; } = String.Empty;
}
public class DoctorAccountDTO
{
public Guid Id { get; set; }
public string FirstName { get; set; } = String.Empty;
public string LastName { get; set; } = String.Empty;
public string Phone { get; set; } = String.Empty;
public string PhotoPath { get; set; } = String.Empty;
}
public class DoctorAccountUpdatePasswordCommand
{
public string Phone { get; set; } = String.Empty;
public string OldPassword { get; set; } = String.Empty;
public string NewPassword { get; set; } = String.Empty;
}
#endregion
#region
public class ResumeConfirmCommand
{
//int userId, int doctorId, int status, string memo
//public Guid FromUserId { get; set; }
public Guid Id { get; set; }
public ResumeStatusEnum ResumeStatus { get; set; }
public int ReviewStatus { get; set; }
public bool AcceptingNewTrial { get; set; } = false;
public bool ActivelyReading { get; set; } = false;
public string AdminComment { get; set; } = String.Empty;
public string MessageContent { get; set; } = String.Empty;
public ContractorStatusEnum CooperateStatus { get; set; }
}
public class ResumeConfirmDTO
{
public Guid Id { get; set; }
public int CooperateStatus { get; set; }
public int ResumeStatus { get; set; }
public int ReviewStatus { get; set; } //复审状态
public bool AcceptingNewTrial { get; set; }
public bool ActivelyReading { get; set; }
public string AdminComment { get; set; } = String.Empty;
public bool InHoliday { get; set; }
}
#endregion
public class TrialPaymentPriceQueryDTO : PageInput
{
public string KeyWord { get; set; } = String.Empty;
public Guid? CroId { get; set; }
}
public class DoctorPaymentInfoQueryDTO : PageInput
{
public string SearchName { get; set; } = String.Empty;
public Guid? HospitalId { get; set; }
}
}
@@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
namespace IRaCIS.Application.Contracts
{
public class EducationCommand
{
public Guid? Id { get; set; }
public Guid DoctorId { get; set; }
public DateTime BeginDate { get; set; }
public DateTime EndDate { get; set; }
public string Degree { get; set; } = String.Empty;
public string Major { get; set; } = String.Empty;
public string Organization { get; set; } = String.Empty;
public string Country { get; set; } = String.Empty;
public string Province { get; set; } = String.Empty;
public string City { get; set; } = String.Empty;
public string DegreeCN { get; set; } = String.Empty;
public string MajorCN { get; set; } = String.Empty;
public string OrganizationCN { get; set; } = String.Empty;
public string CountryCN { get; set; } = String.Empty;
public string ProvinceCN { get; set; } = String.Empty;
public string CityCN { get; set; } = String.Empty;
}
public class EducationInfoViewModel : EducationCommand
{
public DateTime? CreateTime { get; set; }
public string BeginDateStr => BeginDate.ToString("yyyy-MM");
public string EndDateStr => EndDate.ToString("yyyy-MM");
}
public class PostgraduateCommand
{
public Guid? Id { get; set; }
public Guid DoctorId { get; set; }
public DateTime BeginDate { get; set; }
public DateTime EndDate { get; set; }
public string Training { get; set; } = String.Empty;
public string Major { get; set; } = String.Empty;
public string Hospital { get; set; } = String.Empty;
public string School { get; set; } = String.Empty;
public string Country { get; set; } = String.Empty;
public string Province { get; set; } = String.Empty;
public string City { get; set; } = String.Empty;
public string TrainingCN { get; set; } = String.Empty;
public string MajorCN { get; set; } = String.Empty;
public string HospitalCN { get; set; } = String.Empty;
public string SchoolCN { get; set; } = String.Empty;
public string CountryCN { get; set; } = String.Empty;
public string ProvinceCN { get; set; } = String.Empty;
public string CityCN { get; set; } = String.Empty;
}
public class PostgraduateViewModel: PostgraduateCommand
{
public DateTime? CreateTime { get; set; }
public string BeginDateStr => BeginDate.ToString("yyyy-MM");
public string EndDateStr => EndDate.ToString("yyyy-MM");
}
public class DoctorEducationExperienceDTO
{
public IEnumerable<EducationInfoViewModel> EducationList=new List<EducationInfoViewModel>();
public IEnumerable<PostgraduateViewModel> PostgraduateList = new List<PostgraduateViewModel>();
}
}
@@ -0,0 +1,13 @@
using System;
namespace IRaCIS.Application.Contracts
{
public class VacationCommand
{
public Guid? Id { get; set; }
public Guid DoctorId { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public int Status { get; set; } = 1;
}
}
@@ -0,0 +1,21 @@
using System;
namespace IRaCIS.Application.Contracts
{
public class ResearchPublicationDTO
{
public Guid? Id { get; set; }
public Guid DoctorId { get; set; }
public string Research { get; set; } = String.Empty;
public string Grants { get; set; } = String.Empty;
public string Publications { get; set; } = String.Empty;
public string AwardsHonors { get; set; } = String.Empty;
public string ResearchCN { get; set; } = String.Empty;
public string GrantsCN { get; set; } = String.Empty;
public string PublicationsCN { get; set; } = String.Empty;
public string AwardsHonorsCN { get; set; } = String.Empty;
}
}
@@ -0,0 +1,81 @@
namespace IRaCIS.Application.Contracts
{
public class TrialExperienceCommand
{
public Guid? Id { get; set; }
public Guid DoctorId { get; set; }
public Guid? PhaseId { get; set; }
public string EvaluationContent { get; set; } = String.Empty;
//public string Term { get; set; }
//public string EvaluationCriteria { get; set; }
public List<Guid> EvaluationCriteriaIdList { get; set; } = new List<Guid>();
}
public class TrialExperienceListDTO: TrialExperienceCommand
{
public string Phase { get; set; } = String.Empty;
public List<string> EvaluationCriteriaList { get; set; } = new List<string>();
}
//public class EvaluationCriteriaDTO
//{
// public Guid EvaluationCriteriaId { get; set; }
// public string EvaluationCriteria { get; set; }
//}
public class TrialExperienceModel : GcpAndOtherExperienceDTO
{
public List<TrialExperienceListDTO> ClinicalTrialExperienceList = new List<TrialExperienceListDTO>();
public string ExpiryDateStr { get; set; } = string.Empty;
public string GCPFullPath { get; set; } = String.Empty;
}
public class GcpAndOtherExperienceDTO
{
public Guid Id { get; set; }
public int GCP { get; set; }
public Guid? GCPId { get; set; }
public string OtherClinicalExperience { get; set; }=String.Empty;
public string OtherClinicalExperienceCN { get; set; } = String.Empty;
public string Type { get; set; } = string.Empty;
public string Path { get; set; } = string.Empty;
public string FileName { get; set; } = string.Empty;
}
public class GCPExperienceCommand
{
public Guid Id { get; set; }
public int GCP { get; set; }
public Guid? GCPId { get; set; }
}
public class ClinicalExperienceCommand
{
public Guid DoctorId { get; set; }
public string OtherClinicalExperience { get; set; } = String.Empty;
public string OtherClinicalExperienceCN { get; set; } = String.Empty;
}
}
@@ -0,0 +1,211 @@
using IRaCIS.Application.Interfaces;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Domain.Share;
using System.Linq.Dynamic.Core;
using IRaCIS.Core.Infra.EFCore;
using Microsoft.AspNetCore.Mvc;
namespace IRaCIS.Application.Services
{
[ApiExplorerSettings(GroupName = "Reviewer")]
public class DoctorListService : BaseService, IDoctorListQueryService
{
private readonly IRepository<Doctor> _doctorRepository;
public DoctorListService(IRepository<Doctor> doctorRepository)
{
_doctorRepository = doctorRepository;
}
/// <summary>
/// Reviewer列表分页查询
/// </summary>
[HttpPost]
public async Task<PageOutput<DoctorDTO>> GetDoctorSearchList(DoctorSearchDTO doctorSearch)
{
// 项目经验 多选
var evaluationCriteriaCount = doctorSearch.EvaluationCriteriaIdList.Count();
// 搜索条件 ReadingType 、Subspeciality、Title 多选
var count = doctorSearch.ReadingTypeIdList.Count + doctorSearch.TitleIdList.Count + doctorSearch.SubspecialityIdList.Count;
var guidList = doctorSearch.ReadingTypeIdList.Concat(doctorSearch.SubspecialityIdList).Concat(doctorSearch.TitleIdList);
var query = _doctorRepository.AsQueryable()
.WhereIf(doctorSearch.DepartmentId != null, t => t.DepartmentId == doctorSearch.DepartmentId)
.WhereIf(doctorSearch.SpecialityId != null, t => t.SpecialityId == doctorSearch.SpecialityId)
.WhereIf(doctorSearch.HospitalId != null, t => t.HospitalId == doctorSearch.HospitalId)
.WhereIf(doctorSearch.PositionId != null, t => t.PositionId == doctorSearch.PositionId)
.WhereIf(doctorSearch.RankId != null, t => t.RankId == doctorSearch.RankId)
.WhereIf(doctorSearch.ContractorStatus != null, t => t.CooperateStatus == doctorSearch.ContractorStatus)
.WhereIf(doctorSearch.InformationConfirmed != null, t => t.ResumeStatus == doctorSearch.InformationConfirmed)
.WhereIf(doctorSearch.AcceptingNewTrial != null, t => t.AcceptingNewTrial == doctorSearch.AcceptingNewTrial)
.WhereIf(!string.IsNullOrWhiteSpace(doctorSearch.Name), t => t.ChineseName.Contains(doctorSearch.Name) || (t.LastName + t.FirstName).Contains(doctorSearch.Name))
.WhereIf(doctorSearch.Nation != null, t => t.Nation == doctorSearch.Nation)
.WhereIf(evaluationCriteriaCount > 0, t => t.TrialExperienceCriteriaList.Count(t => doctorSearch.EvaluationCriteriaIdList.Contains(t.EvaluationCriteriaId)) == evaluationCriteriaCount)
//用户类型 看到简历的范围这里需要确认
.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ReviewerCoordinator, t => t.UserList.Any(u => u.UserId == _userInfo.Id))
.WhereIf(count > 0, t => t.DoctorDicRelationList.Count(u => guidList.Contains(u.DictionaryId)) == count)
.WhereIf(doctorSearch.EnrollStatus != null && doctorSearch.EnrollStatus == (int)ReviewerEnrollStatus.Yes, t => t.EnrollList.Any(u => u.EnrollStatus == (int)EnrollStatus.DoctorReading))
.ProjectTo<DoctorDTO>(_mapper.ConfigurationProvider);
return await query.ToPagedListAsync(doctorSearch.PageIndex, doctorSearch.PageSize, doctorSearch.SortField == string.Empty ? "CreateTime" : doctorSearch.SortField, doctorSearch.Asc);
}
#region
/// <summary>
/// 获取可筛选筛选及已经筛选的医生列表
/// </summary>
[HttpPost]
public async Task<PageOutput<SelectionReviewerDTO>> GetSelectionReviewerList(
ReviewerSelectionQueryDTO selectionQuery)
{
//项目配置需要的医生过滤 2表示混合
var nation = await _repository.Where<Trial>(s => s.Id == selectionQuery.TrialId).Select(t=>t.AttendedReviewerType).FirstOrDefaultAsync().IfNullThrowException();
// 临床项目经验 多选
var evaluationCriteriaCount = selectionQuery.EvaluationCriteriaIdList.Count();
// 搜索条件 ReadingType 、Subspeciality、Title 多选
var count = selectionQuery.ReadingTypeIdList.Count + selectionQuery.TitleIdList.Count + selectionQuery.SubspecialityIdList.Count;
var guidList = selectionQuery.ReadingTypeIdList.Concat(selectionQuery.SubspecialityIdList).Concat(selectionQuery.TitleIdList);
var query = _doctorRepository.WhereIf(nation != 2, t => t.Nation == nation)
.WhereIf(selectionQuery.DepartmentId != null, t => t.DepartmentId == selectionQuery.DepartmentId)
.WhereIf(selectionQuery.SpecialityId != null, t => t.SpecialityId == selectionQuery.SpecialityId)
.WhereIf(selectionQuery.HospitalId != null, t => t.HospitalId == selectionQuery.HospitalId)
.WhereIf(selectionQuery.PositionId != null, t => t.PositionId == selectionQuery.PositionId)
.WhereIf(selectionQuery.RankId != null, t => t.RankId == selectionQuery.RankId)
.WhereIf(selectionQuery.ContractorStatus != null, t => t.CooperateStatus == selectionQuery.ContractorStatus)
.WhereIf(selectionQuery.InformationConfirmed != null, t => t.ResumeStatus == selectionQuery.InformationConfirmed)
.WhereIf(selectionQuery.AcceptingNewTrial != null, t => t.AcceptingNewTrial == selectionQuery.AcceptingNewTrial)
.WhereIf(!string.IsNullOrWhiteSpace(selectionQuery.Name), t => t.ChineseName.Contains(selectionQuery.Name) || (t.LastName + t.FirstName).Contains(selectionQuery.Name))
.WhereIf(evaluationCriteriaCount > 0, t => t.TrialExperienceCriteriaList.Count(t => selectionQuery.EvaluationCriteriaIdList.Contains(t.EvaluationCriteriaId)) == evaluationCriteriaCount)
//用户类型 看到简历的范围这里需要确认
.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ReviewerCoordinator, t => t.UserList.Any(u => u.UserId == _userInfo.Id))
.WhereIf(count > 0, t => t.DoctorDicRelationList.Count(u => guidList.Contains(u.DictionaryId)) == count)
.WhereIf(selectionQuery.EnrollStatus != null && selectionQuery.EnrollStatus == (int)ReviewerEnrollStatus.Yes, t => t.EnrollList.Any(u => u.EnrollStatus == (int)EnrollStatus.DoctorReading))
.ProjectTo<SelectionReviewerDTO>(_mapper.ConfigurationProvider);
var result = await query.ToPagedListAsync(selectionQuery.PageIndex, selectionQuery.PageSize, selectionQuery.SortField == string.Empty ? "ReviewerCode" : selectionQuery.SortField, selectionQuery.Asc);
//是否已申请 申请时间 申请人
var doctorStateList = await _repository.Where<EnrollDetail>(x => x.TrialId == selectionQuery.TrialId && x.EnrollStatus == (int)EnrollStatus.HasApplyDownloadResume)
.ProjectTo<DoctorStateModelDTO>(_mapper.ConfigurationProvider).ToListAsync();
result.CurrentPageData.ToList().ForEach(doctor =>
{
//简历申请列表 --处理已经申请的
var doctorState = doctorStateList.FirstOrDefault(t => t.DoctorId == doctor.Id && t.IntoGroupState == (int)EnrollStatus.HasApplyDownloadResume);
if (doctorState != null)
{
doctor.DoctorTrialState = (int)EnrollStatus.HasApplyDownloadResume;
doctor.OptTime = doctorState.OptTime;
doctor.OptUserName = doctorState.OptUserName;
}
});
return result;
}
/// <summary>
/// 获取提交CRO或者CRO审核的Reviewer列表
/// </summary>
/// <summary>
/// 根据状态获取医生列表,入组 相关接口 (提交CRO-1) CRO确认-4
/// </summary>
[HttpPost]
public async Task<PageOutput<ConfirmationReviewerDTO>> GetSubmissionOrApprovalReviewerList(
ReviewerSubmissionQueryDTO param)
{
var doctorQuery = _repository.Where<Enroll>(x => x.TrialId == param.TrialId)
//提交CRO 以及下载简历列表
.WhereIf(param.IntoGroupSearchState == 1, t => t.EnrollStatus >= (int)EnrollStatus.HasApplyDownloadResume)
//CRO确认列表 状态为 已提交CRO
.WhereIf(param.IntoGroupSearchState == 4, t => t.EnrollStatus >= (int)EnrollStatus.HasCommittedToCRO)
.ProjectTo<ConfirmationReviewerDTO>(_mapper.ConfigurationProvider);
var doctorPageList = await doctorQuery.ToPagedListAsync(param.PageIndex, param.PageSize, param.SortField == "" ? "Code" : param.SortField, param.Asc);
var enrollStateList = await _repository.Where<EnrollDetail>(x => x.TrialId == param.TrialId)
//提交CRO 以及下载简历列表
.WhereIf(param.IntoGroupSearchState == 1, t => t.EnrollStatus == (int)EnrollStatus.HasCommittedToCRO)
//CRO确认列表 状态为 已提交CRO
.WhereIf(param.IntoGroupSearchState == 4, t => t.EnrollStatus == (int)EnrollStatus.InviteIntoGroup)
.ProjectTo<DoctorStateModelDTO>(_mapper.ConfigurationProvider).ToListAsync();
doctorPageList.CurrentPageData.ToList().ForEach(u =>
{
var opt = enrollStateList.FirstOrDefault(t => t.DoctorId == u.Id);
if (opt != null)
{
u.DoctorTrialState = param.IntoGroupSearchState == 1 ? (int)EnrollStatus.HasCommittedToCRO : (int)EnrollStatus.InviteIntoGroup;
u.OptTime = opt.OptTime;
u.OptUserName = opt.OptUserName;
}
});
return doctorPageList;
}
/// <summary>
/// 获取项目下医生入组状态列表[Confirmation]
/// </summary>
[HttpPost]
public async Task<PageOutput<ConfirmationReviewerDTO>> GetConfirmationReviewerList(
ReviewerConfirmationQueryDTO param)
{
var doctorQuery = _repository.Where<Enroll>(x => x.TrialId == param.TrialId && x.EnrollStatus >= (int)EnrollStatus.InviteIntoGroup)
.ProjectTo<ConfirmationReviewerDTO>(_mapper.ConfigurationProvider);
var doctorPageList = await doctorQuery.ToPagedListAsync(param.PageIndex, param.PageSize, param.SortField == "" ? "Code" : param.SortField, param.Asc);
var enrollStateList = await _repository.Where<EnrollDetail>(x => x.TrialId == param.TrialId && x.EnrollStatus > (int)EnrollStatus.InviteIntoGroup)
.ProjectTo<DoctorStateModelDTO>(_mapper.ConfigurationProvider).ToListAsync();
doctorPageList.CurrentPageData.ToList().ForEach(u =>
{
u.DoctorTrialState = (int)EnrollStatus.InviteIntoGroup;
var opt = enrollStateList.FirstOrDefault(t => t.DoctorId == u.Id);
if (opt != null)
{
u.DoctorTrialState = opt.IntoGroupState;
u.OptTime = opt.OptTime;
u.OptUserName = opt.OptUserName;
}
});
return doctorPageList;
}
#endregion
}
}
@@ -0,0 +1,558 @@
using IRaCIS.Application.Interfaces;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infra.EFCore;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infrastructure;
using Microsoft.AspNetCore.Mvc;
using System.Linq.Expressions;
namespace IRaCIS.Application.Services
{
[ApiExplorerSettings(GroupName = "Reviewer")]
public class DoctorService : BaseService, IDoctorService
{
private readonly IRepository<Doctor> _doctorRepository;
private readonly IRepository<Message> _messageRepository;
private readonly IRepository<Enroll> _enrollRepository;
private readonly IRepository<DoctorDictionary> _doctorDictionaryRepository;
private readonly IRepository<Attachment> _attachmentRepository;
private readonly IRepository<UserDoctor> _userDoctorRepository;
private readonly IRepository<Trial> _trialRepository;
private readonly IRepository<TrialPaymentPrice> _trialExtRepository;
private readonly IRepository<Vacation> _vacationRepository;
public DoctorService(IRepository<Doctor> doctorInfoRepository,
IRepository<Dictionary> dictionaryRepository,
IRepository<Message> sysMessageRepository, IRepository<Enroll> intoGroupRepository,
IRepository<DoctorDictionary> doctorDictionaryRepository,
IRepository<Attachment> attachmentRepository,
IRepository<UserDoctor> userDoctorRepository,
IRepository<Trial> trialRepository,
IRepository<TrialPaymentPrice> trialExtRepository, IRepository<Vacation> vacationRepository)
{
_doctorRepository = doctorInfoRepository;
_messageRepository = sysMessageRepository;
_enrollRepository = intoGroupRepository;
_doctorDictionaryRepository = doctorDictionaryRepository;
_attachmentRepository = attachmentRepository;
_userDoctorRepository = userDoctorRepository;
_trialRepository = trialRepository;
_trialExtRepository = trialExtRepository;
_vacationRepository = vacationRepository;
}
#region --
/// <summary>
/// 添加/更新 医生基本信息 BasicInfo
/// </summary>
[HttpPost]
public async Task<IResponseOutput<DoctorBasicInfoCommand>> AddOrUpdateDoctorBasicInfo(DoctorBasicInfoCommand basicInfoModel)
{
Expression<Func<Doctor, bool>> verifyExp = t => t.Phone == basicInfoModel.Phone || t.EMail == basicInfoModel.EMail;
var verifyPair = new KeyValuePair<Expression<Func<Doctor, bool>>, string>(verifyExp, "current phone or email number already existed");
if (basicInfoModel.Id == Guid.Empty || basicInfoModel.Id == null)
{
var doctor = _mapper.Map<Doctor>(basicInfoModel);
//验证用户手机号
if (await _doctorRepository.AnyAsync(t => t.Phone == doctor.Phone))
{
return ResponseOutput.NotOk("The current phone number already existed!", new DoctorBasicInfoCommand());
}
if (await _doctorRepository.AnyAsync(t => t.EMail == doctor.EMail))
{
return ResponseOutput.NotOk("The current email already existed!", new DoctorBasicInfoCommand());
}
doctor.Code = await _repository.GetQueryable<Doctor>().MaxAsync(t => t.Code) + 1;
doctor.ReviewerCode = AppSettings.CodePrefix + doctor.Code.ToString("D4");
doctor.Password = MD5Helper.Md5(doctor.Phone);
//插入中间表
basicInfoModel.TitleIds.ForEach(titleId => doctor.DoctorDicRelationList.Add(new DoctorDictionary() { DoctorId = doctor.Id, KeyName = StaticData.Title, DictionaryId = titleId }));
await _doctorRepository.AddAsync(doctor);
//_doctorRepository.Add(doctor);
await _repository.AddAsync(new UserDoctor() { DoctorId = doctor.Id, UserId = _userInfo.Id });
//_userDoctorRepository.Add(new UserDoctor() { DoctorId = doctor.Id, UserId = _userInfo.Id });
var success = await _repository.SaveChangesAsync();
return ResponseOutput.Result(success, _mapper.Map<DoctorBasicInfoCommand>(doctor));
}
else
{
var updateModel = basicInfoModel;
var phone = updateModel.Phone.Trim();
if ((await _doctorRepository.FirstOrDefaultAsync(t => t.Phone == phone && t.Id != updateModel.Id) )!= null)
{
return ResponseOutput.NotOk("The current phone number already existed!", new DoctorBasicInfoCommand());
}
var email = updateModel.EMail.Trim();
if (await _doctorRepository.AnyAsync(t => t.EMail == email && t.Id != updateModel.Id))
{
return ResponseOutput.NotOk("The current email already existed!", new DoctorBasicInfoCommand());
}
var doctor = await _doctorRepository.FirstOrDefaultAsync(t => t.Id == updateModel.Id).IfNullThrowException();
//删除中间表 Title对应的记录
await _repository.DeleteFromQueryAsync<DoctorDictionary>(t => t.DoctorId == updateModel.Id && t.KeyName == StaticData.Title);
var adddata=new List<DoctorDictionary>();
//重新插入新的 Title记录
updateModel.TitleIds.ForEach(titleId => adddata.Add(new DoctorDictionary() { DoctorId = updateModel.Id.Value, KeyName = StaticData.Title, DictionaryId = titleId }));
await _repository.AddRangeAsync(adddata);
_mapper.Map(basicInfoModel, doctor);
var success = await _repository.SaveChangesAsync();
return ResponseOutput.Result(success, basicInfoModel);
}
}
/// <summary>
///详情、编辑-获取 医生基本信息 BasicInfo
/// </summary>
/// <param name="doctorId">ReviewerID</param>
/// <returns></returns>
[HttpGet("{doctorId:guid}")]
public async Task<DoctorBasicInfoDTO> GetBasicInfo(Guid doctorId)
{
#region
//SELECT[t].[Id], [t].[Code], [t].[ChineseName], [t].[EMail], [t].[FirstName], [t].[Introduction], [t].[LastName], [t].[Phone], [t].[Sex], [t].[WeChat], [t].[Nation], [t0].[Title], [t0].[TitleCN], [t0].[TitleId], [t0].[ShowOrder], [t0].[Id], [t0].[Id0]
//FROM(
// SELECT TOP(1)[d].[Id], [d].[Code], [d].[ChineseName], [d].[EMail], [d].[FirstName], [d].[Introduction], [d].[LastName], [d].[Phone], [d].[Sex], [d].[WeChat], [d].[Nation]
// FROM[Doctor] AS[d] WITH(NOLOCK)
// WHERE[d].[Id] = @__doctorId_0
//) AS[t]
//LEFT JOIN(
// SELECT[d1].[Value] AS[Title], [d1].[ValueCN] AS[TitleCN], [d0].[DictionaryId] AS[TitleId], [d1].[ShowOrder], [d0].[Id], [d1].[Id] AS[Id0], [d0].[DoctorId]
// FROM [DoctorDictionary] AS [d0] WITH (NOLOCK)
// INNER JOIN[Dictionary] AS [d1] WITH (NOLOCK) ON [d0].[DictionaryId] = [d1].[Id]
// WHERE[d0].[KeyName] = N'Title'
//) AS[t0] ON[t].[Id] = [t0].[DoctorId]
//ORDER BY[t].[Id], [t0].[ShowOrder], [t0].[Id]
//var doctorQueryable = _doctorRepository
// .Find(t => t.Id == doctorId)
// .Select(doctor => new DoctorBasicInfoDTO()
// {
// Id = doctor.Id,
// Code = doctor.Code,
// ChineseName = doctor.ChineseName,
// EMail = doctor.EMail,
// FirstName = doctor.FirstName,
// Introduction = doctor.Introduction,
// LastName = doctor.LastName,
// Phone = doctor.Phone,
// Sex = doctor.Sex,
// WeChat = doctor.WeChat,
// Nation = doctor.Nation,
// //不要分三个属性查询,会做三次左连接,这样 只会一个左连接
// TempObjList = doctor.DoctorDicList.Where(t => t.KeyName == StaticData.Title)
// .Select(t => new TempObj { Title = t.Dictionary.Value, TitleCN = t.Dictionary.ValueCN, TitleId = t.DictionaryId, ShowOrder = t.Dictionary.ShowOrder }).OrderBy(k => k.ShowOrder).ToList(),
// });
//var doctorBasicInfo = doctorQueryable.FirstOrDefault();
#endregion
var doctorBasicInfo = (await _doctorRepository.Where(t => t.Id == doctorId)
.ProjectTo<DoctorBasicInfoDTO>(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException();
return doctorBasicInfo;
}
#endregion
#region Employment信息--
/// <summary>
/// 详情、编辑-获取医生工作信息 Employment
/// </summary>
[HttpGet("{doctorId:Guid}")]
public async Task<EmploymentDTO> GetEmploymentInfo(Guid doctorId)
{
#region init EF select
//var dic = GetDictionary();
//var employmentQueryable = from doctorItem in _doctorRepository
// .Where(t => t.Id == doctorId)
// join hospitalItem in _hospitalRepository.AsQueryable() on doctorItem.HospitalId equals hospitalItem.Id into g
// from hospital in g.DefaultIfEmpty()
// select new EmploymentDTO()
// {
// Id = doctorItem.Id,
// //部门
// DepartmentId = doctorItem.DepartmentId,
// DepartmentOther = doctorItem.DepartmentOther,
// DepartmentOtherCN = doctorItem.DepartmentOtherCN,
// //医院
// HospitalId = doctorItem.HospitalId,
// PositionId = doctorItem.PositionId,
// PositionOther = doctorItem.PositionOther,
// PositionOtherCN = doctorItem.PositionOtherCN,
// RankId = doctorItem.RankId,
// RankOther = doctorItem.RankOther,
// RankOtherCN = doctorItem.RankOtherCN,
// City = hospital.City,
// Country = hospital.Country,
// UniversityAffiliated = hospital.UniversityAffiliated,
// HospitalName = hospital.HospitalName,
// Province = hospital.Province,
// CityCN = hospital.CityCN,
// CountryCN = hospital.CountryCN,
// UniversityAffiliatedCN = hospital.UniversityAffiliatedCN,
// HospitalNameCN = hospital.HospitalNameCN,
// ProvinceCN = hospital.ProvinceCN
// };
//var employmentInfo = employmentQueryable.FirstOrDefault();
//if (employmentInfo != null)
//{
// //医院信息设置
// if (employmentInfo.HospitalId == Guid.Empty)
// {
// employmentInfo.City = string.Empty;
// employmentInfo.Country = string.Empty;
// employmentInfo.UniversityAffiliated = string.Empty;
// employmentInfo.HospitalName = string.Empty;
// employmentInfo.Province = string.Empty;
// }
// employmentInfo.Department = employmentInfo.DepartmentId == Guid.Empty ? employmentInfo.DepartmentOther : dic.FirstOrDefault(o => o.Id == employmentInfo.DepartmentId)?.Value ?? "";
// employmentInfo.Rank = employmentInfo.RankId == Guid.Empty ? employmentInfo.RankOther : dic.FirstOrDefault(o => o.Id == employmentInfo.RankId)?.Value ?? "";
// employmentInfo.Position = employmentInfo.PositionId == Guid.Empty ? employmentInfo.PositionOther : dic.FirstOrDefault(o => o.Id == employmentInfo.PositionId)?.Value ?? "";
// employmentInfo.DepartmentCN = employmentInfo.DepartmentId == Guid.Empty ? employmentInfo.DepartmentOther : dic.FirstOrDefault(o => o.Id == employmentInfo.DepartmentId)?.ValueCN ?? "";
// employmentInfo.RankCN = employmentInfo.RankId == Guid.Empty ? employmentInfo.RankOther : dic.FirstOrDefault(o => o.Id == employmentInfo.RankId)?.ValueCN ?? "";
// employmentInfo.PositionCN = employmentInfo.PositionId == Guid.Empty ? employmentInfo.PositionOther : dic.FirstOrDefault(o => o.Id == employmentInfo.PositionId)?.ValueCN ?? "";
//}
#endregion
var query = _doctorRepository.Where(t => t.Id == doctorId)
.ProjectTo<EmploymentDTO>(_mapper.ConfigurationProvider);
var employmentInfo = (await query.FirstOrDefaultAsync()).IfNullThrowException();
return employmentInfo;
}
[HttpPost]
public async Task<IResponseOutput> UpdateEmploymentInfo(EmploymentCommand doctorWorkInfoModel)
{
#region
//var success = _doctorRepository.Update(d => d.Id == doctorWorkInfoModel.Id, u => new Doctor()
//{
// DepartmentId = doctorWorkInfoModel.DepartmentId,
// DepartmentOther = doctorWorkInfoModel.DepartmentOther,
// DepartmentOtherCN = doctorWorkInfoModel.DepartmentOtherCN,
// SpecialityId = doctorWorkInfoModel.DepartmentId,
// SpecialityOther = doctorWorkInfoModel.DepartmentOther,
// SpecialityOtherCN = doctorWorkInfoModel.DepartmentOtherCN,
// RankId = doctorWorkInfoModel.RankId,
// RankOther = doctorWorkInfoModel.RankOther,
// RankOtherCN = doctorWorkInfoModel.RankOtherCN,
// PositionId = doctorWorkInfoModel.PositionId,
// PositionOther = doctorWorkInfoModel.PositionOther,
// PositionOtherCN = doctorWorkInfoModel.PositionOtherCN,
// HospitalId = doctorWorkInfoModel.HospitalId,
// UpdateTime = DateTime.Now
//});
//var doctor = _doctorRepository.FirstOrDefault(d => d.Id == doctorWorkInfoModel.Id);
//_mapper.Map(doctorWorkInfoModel, doctor);
//var success = _doctorRepository.SaveChanges();
#endregion
var entity = await _repository.InsertOrUpdateAsync<Doctor, EmploymentCommand>(doctorWorkInfoModel, true);
//_doctorRepository.UseMapper(_mapper).InsertOrUpdate(doctorWorkInfoModel, autoSave: true);
return ResponseOutput.Ok();
}
#endregion
#region
[HttpGet, Route("{doctorId:Guid}")]
public async Task<SpecialtyDTO> GetSpecialtyInfo(Guid doctorId)
{
#region sql ok
//var specialtyQueryable = _doctorRepository
// .Where(t => t.Id == doctorId).Include(u => u.DoctorDicRelationList)
// .Select(specialty => new SpecialtyDTO()
// {
// Id = specialty.Id,
// ReadingTypeOther = specialty.ReadingTypeOther,
// ReadingTypeOtherCN = specialty.ReadingTypeOtherCN,
// SubspecialityOther = specialty.SubspecialityOther,
// SubspecialityOtherCN = specialty.SubspecialityOtherCN,
// DictionaryList = specialty.DoctorDicRelationList.Where(t => t.KeyName == StaticData.ReadingType || t.KeyName == StaticData.Subspeciality)
// .Select(t => new SpecialtyDTO.DoctorDictionaryView() { DictionaryId = t.DictionaryId, Value = t.Dictionary.Value, ValueCN = t.Dictionary.ValueCN, ShowOrder = t.Dictionary.ShowOrder, KeyName = t.Dictionary.KeyName })
// .OrderBy(t => t.ShowOrder).ToList(),
// SpecialityId = specialty.SpecialityId,
// Speciality = specialty.Speciality.Value,
// SpecialityCN = specialty.Speciality.ValueCN,
// SpecialityOther = specialty.SpecialityOther,
// SpecialityOtherCN = specialty.SpecialityOtherCN
// });
//var specialtyInfo = specialtyQueryable.FirstOrDefault();
//return specialtyInfo;
#endregion
var test = await (_doctorRepository.Where(t => t.Id == doctorId)
.ProjectTo<SpecialtyDTO>(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException();
return test;
}
[HttpPost]
public async Task<IResponseOutput> UpdateSpecialtyInfo(SpecialtyCommand specialtyUpdateModel)
{
var doctor = await _doctorRepository.FirstOrDefaultAsync(t => t.Id == specialtyUpdateModel.Id);
if (doctor == null) return Null404NotFound(doctor);
////删除中间表
//_doctorDictionaryRepository.Delete(t =>
// t.DoctorId == specialtyUpdateModel.Id && t.KeyName == StaticData.Subspeciality);
//_doctorDictionaryRepository.Delete(t =>
// t.DoctorId == specialtyUpdateModel.Id && t.KeyName == StaticData.ReadingType);
await _repository.DeleteFromQueryAsync<DoctorDictionary>(t =>
t.DoctorId == specialtyUpdateModel.Id && (t.KeyName == StaticData.Subspeciality || t.KeyName == StaticData.ReadingType));
//重新插入新的
var adddata = new List<DoctorDictionary>();
specialtyUpdateModel.ReadingTypeIds.ForEach(readingTypeId => adddata.Add(
new DoctorDictionary()
{
DoctorId = specialtyUpdateModel.Id,
KeyName = StaticData.ReadingType,
DictionaryId = readingTypeId
}));
specialtyUpdateModel.SubspecialityIds.ForEach(subspecialityId => adddata.Add(
new DoctorDictionary()
{
DoctorId = specialtyUpdateModel.Id,
KeyName = StaticData.Subspeciality,
DictionaryId = subspecialityId
}));
await _repository.AddRangeAsync(adddata);
_mapper.Map(specialtyUpdateModel, doctor);
var success = await _repository.SaveChangesAsync();
return ResponseOutput.Result(success);
}
#endregion
#region
[HttpPost]
public async Task<IResponseOutput> UpdateAuditResume(ResumeConfirmCommand auditResumeParam)
{
var userId = _userInfo.Id;
//判断 合作协议、正式简历 是否有。如果没有,显示提示信息,并且不能保存
var attachmentList = await _repository.GetQueryable<Attachment>().Where(u => u.DoctorId == auditResumeParam.Id)
.Select(u => u.Type).ToListAsync();
if (auditResumeParam.ResumeStatus == ResumeStatusEnum.Pass && ((!attachmentList.Contains("Resume")) || (!attachmentList.Contains("Consultant Agreement"))))
{
return ResponseOutput.NotOk("Resume & Consultant Agreement must be upload ");
}
var success = await _doctorRepository.UpdateFromQueryAsync(o => o.Id == auditResumeParam.Id, u => new Doctor()
{
CooperateStatus = auditResumeParam.CooperateStatus,
ResumeStatus = auditResumeParam.ResumeStatus,
AdminComment = auditResumeParam.AdminComment,
ReviewStatus = auditResumeParam.ReviewStatus,
AcceptingNewTrial = auditResumeParam.AcceptingNewTrial,
ActivelyReading = auditResumeParam.ActivelyReading,
AuditTime = DateTime.Now,
AuditUserId = userId
});
if (success)
{
if (!string.IsNullOrWhiteSpace(auditResumeParam.MessageContent))
{
var message = new Message
{
FromUserId = userId,
ToDoctorId = auditResumeParam.Id,
Title = "Resume review results",
Content = auditResumeParam.MessageContent,
HasRead = false,
MessageTime = DateTime.Now
};
await _repository.AddAsync(message);
success = await _repository.SaveChangesAsync();
}
}
return ResponseOutput.Result(success);
}
[HttpGet("{doctorId:guid}")]
public async Task<ResumeConfirmDTO> GetAuditState(Guid doctorId)
{
var doctor = (await _doctorRepository
.ProjectTo<ResumeConfirmDTO>(_mapper.ConfigurationProvider).FirstOrDefaultAsync(t => t.Id == doctorId)).IfNullThrowException();
doctor.InHoliday = (await _repository.CountAsync<Vacation>(x=>x.DoctorId==doctorId&&x.EndDate<=DateTime.Now&&x.StartDate<=DateTime.Now)) > 0;
return doctor;
}
/// <summary>
/// 获取医生入组信息 正在提交的数量 已同意入组项目个数 正在读的
/// </summary>
[HttpPost, Route("{doctorId:guid}")]
public DoctorEnrollInfoDTO GetDoctorIntoGroupInfo(Guid doctorId)
{
var doctorQueryable =
from doctor in _doctorRepository.Where(t => t.Id == doctorId)
join intoGroupItem in _enrollRepository.AsQueryable() on doctor.Id equals intoGroupItem.DoctorId
into t
from intoGroupItem in t.DefaultIfEmpty()
group intoGroupItem by intoGroupItem.DoctorId
into g
select new DoctorEnrollInfoDTO
{
DoctorId = g.Key,
//Submitted = g.Sum(t =>
// t.EnrollStatus == (int)EnrollStatus.HasCommittedToCRO ? 1 : 0),
//Approved = g.Sum(t =>
// t.EnrollStatus == (int)EnrollStatus.InviteIntoGroup ? 1 : 0),
//Reading = g.Sum(t =>
// t.EnrollStatus == (int)EnrollStatus.DoctorReading ? 1 : 0)
Submitted = g.Count(t =>
t.EnrollStatus == (int)EnrollStatus.HasCommittedToCRO),
Approved = g.Count(t =>
t.EnrollStatus == (int)EnrollStatus.InviteIntoGroup),
Reading = g.Count(t =>
t.EnrollStatus == (int)EnrollStatus.DoctorReading)
};
return doctorQueryable.FirstOrDefault().IfNullThrowException();
}
/// <summary>
/// Get Statement of Work list.[New]
/// </summary>
[HttpGet("{doctorId:guid}")]
public List<SowDTO> GetDoctorSowList(Guid doctorId)
{
var query = from enroll in _enrollRepository.Where(u => u.DoctorId == doctorId && u.EnrollStatus >= 10)
join trialExt in _trialExtRepository.AsQueryable() on enroll.TrialId equals trialExt.TrialId
join trial in _trialRepository.AsQueryable() on enroll.TrialId equals trial.Id
select new SowDTO
{
FileName = trialExt.SowName,
FilePath = trialExt.SowPath,
TrialCode = trial.TrialCode,
CreateTime = trialExt.CreateTime
};
return query.ToList().Where(u => !string.IsNullOrWhiteSpace(u.FileName)).ToList();
}
/// <summary>
/// Get Ack Statement of Work[New]
/// </summary>
[HttpGet("{doctorId:guid}")]
public List<SowDTO> GetDoctorAckSowList(Guid doctorId)
{
var query = from enroll in _enrollRepository.Where(u => u.DoctorId == doctorId)
join attachment in _attachmentRepository.Where(u => u.DoctorId == doctorId)
on enroll.AttachmentId equals attachment.Id
join trial in _trialRepository.AsQueryable() on enroll.TrialId equals trial.Id
select new SowDTO
{
FileName = attachment.FileName,
FilePath = attachment.Path,
TrialCode = trial.TrialCode,
CreateTime = attachment.CreateTime
};
return query.ToList();
}
#endregion
}
}
@@ -0,0 +1,140 @@
using IRaCIS.Application.Interfaces;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infra.EFCore;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Application.Filter;
using IRaCIS.Core.Infrastructure.Extention;
using Microsoft.AspNetCore.Mvc;
namespace IRaCIS.Application.Services
{
[ApiExplorerSettings(GroupName = "Reviewer")]
public class EducationService : BaseService, IEducationService
{
private readonly IRepository<Postgraduate> _postgraduateRepository;
private readonly IRepository<Education> _educationRepository;
public EducationService(IRepository<Education> doctorNormalEducationRepository,
IRepository<Postgraduate> doctorContinueLearningRepository)
{
_educationRepository = doctorNormalEducationRepository;
_postgraduateRepository = doctorContinueLearningRepository;
}
/// <summary>
/// 根据医生Id获取医生教育经历和继续学习经历列表
/// </summary>
[HttpGet("{doctorId:Guid}")]
public async Task<DoctorEducationExperienceDTO> GetEducation(Guid doctorId)
{
var educationList = await _educationRepository.Where(o => o.DoctorId == doctorId)
.OrderBy(t => t.CreateTime).ProjectTo<EducationInfoViewModel>(_mapper.ConfigurationProvider).ToListAsync();
var postgraduateList = await _repository.GetQueryable<Postgraduate>().Where(o => o.DoctorId == doctorId)
.OrderBy(t => t.CreateTime).ProjectTo<PostgraduateViewModel>(_mapper.ConfigurationProvider).ToListAsync();
return new DoctorEducationExperienceDTO()
{
EducationList = educationList,
PostgraduateList = postgraduateList
};
}
/// <summary>
/// 新增医生教育经历
/// </summary>
/// <param name="educationInfoViewModel"></param>
/// <returns></returns>
[HttpPost]
public async Task<IResponseOutput> AddOrUpdateEducationInfo(EducationCommand educationInfoViewModel)
{
if (educationInfoViewModel.Id == Guid.Empty || educationInfoViewModel.Id == null)
{
var doctorEducationInfo = _mapper.Map<Education>(educationInfoViewModel);
switch (educationInfoViewModel.Degree)
{
case StaticData.Bachelor:
doctorEducationInfo.ShowOrder = 1;
break;
case StaticData.Master:
doctorEducationInfo.ShowOrder = 2;
break;
case StaticData.Doctorate:
doctorEducationInfo.ShowOrder = 3;
break;
}
await _educationRepository.AddAsync(doctorEducationInfo);
var success = await _repository.SaveChangesAsync();
return ResponseOutput.Result(success, doctorEducationInfo.Id.ToString());
}
else
{
var needUpdate = await _educationRepository.FirstOrDefaultAsync(t => t.Id == educationInfoViewModel.Id);
if (needUpdate == null) return Null404NotFound(needUpdate);
_mapper.Map(educationInfoViewModel, needUpdate);
var success = await _repository.SaveChangesAsync();
return ResponseOutput.Ok(success);
}
//_educationRepository.Update(needUpdate);
}
[HttpDelete, Route("{doctorId:guid}")]
public async Task<IResponseOutput> DeleteEducationInfo(Guid id)
{
var success = await _educationRepository.DeleteFromQueryAsync(o => o.Id == id);
return ResponseOutput.Result(success);
}
/// <summary> 添加/更新医生继续学习经历</summary>
[HttpPost]
public async Task<IResponseOutput> AddOrUpdatePostgraduateInfo(PostgraduateCommand postgraduateViewModel)
{
#region
//if (postgraduateViewModel.Id == Guid.Empty || postgraduateViewModel.Id == null)
//{
// var doctorContinueLearning = _mapper.Map<Postgraduate>(postgraduateViewModel);
// _postgraduateRepository.Add(doctorContinueLearning);
// var success = _postgraduateRepository.SaveChanges();
// return ResponseOutput.Result(success, doctorContinueLearning.Id.ToString());
//}
//else
//{
// _postgraduateRepository.Update(_mapper.Map<Postgraduate>(postgraduateViewModel));
// var success = _postgraduateRepository.SaveChanges();
// return ResponseOutput.Result(success);
//}
#endregion
var entity = await _repository.InsertOrUpdateAsync<Postgraduate, PostgraduateCommand>(postgraduateViewModel, true);
return ResponseOutput.Ok(entity.Id);
}
/// <summary>
/// 删除医生继续学习经历
/// </summary>
/// <param name="doctorId">医生Id</param>
/// <returns></returns>
[HttpDelete("{doctorId:guid}")]
public async Task<IResponseOutput> DeletePostgraduateInfo(Guid doctorId)
{
var success = await _repository.DeleteFromQueryAsync<Postgraduate>(o => o.Id == doctorId);
return ResponseOutput.Result(success);
}
}
}
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infrastructure.Extention;
namespace IRaCIS.Application.Interfaces
{
public interface IAttachmentService
{
Task<IEnumerable<AttachmentDTO>> SaveAttachments(IEnumerable<AttachmentDTO> attachmentList);
Task<IResponseOutput<AttachmentDTO>> AddAttachment(AttachmentDTO attachment);
Task<IResponseOutput> DeleteAttachment(AttachementCommand param);
Task<AttachmentDTO> GetDetailById(Guid attachmentId);
Task<IEnumerable<AttachmentDTO>> GetAttachmentByType(Guid doctorId, string type);
Task<IEnumerable<AttachmentDTO>> GetAttachmentByTypes(Guid doctorId, string[] types);
Task<IEnumerable<AttachmentDTO>> GetAttachments(Guid doctorId);
Task<string> GetDoctorOfficialCV(int language, Guid doctorId);
Task<IResponseOutput> SetOfficial(Guid doctorId, Guid attachmentId, int language);
Task<IResponseOutput> SetLanguage(Guid doctorId, Guid attachmentId, int language);
}
}
@@ -0,0 +1,14 @@
using System;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infrastructure.Extention;
namespace IRaCIS.Application.Interfaces
{
public interface IDoctorAccountService
{
IResponseOutput Register(DoctorAccountRegisterModel doctorAccount);
DoctorAccountDTO Login(DoctorAccountLoginDTO doctorAccount);
IResponseOutput UpdatePassword(DoctorAccountUpdatePasswordCommand doctorAccount);
}
}
@@ -0,0 +1,32 @@
using IRaCIS.Application.Contracts;
namespace IRaCIS.Application.Interfaces
{
public interface IDoctorListQueryService
{
/// <summary>
/// 医生多条件查询
/// </summary>
Task<PageOutput<DoctorDTO>> GetDoctorSearchList(DoctorSearchDTO param);
/// <summary>
/// 筛选医生列表
/// </summary>
/// <param name="doctorSearchModel"></param>
/// <returns></returns>
//
Task<PageOutput<SelectionReviewerDTO>> GetSelectionReviewerList(
ReviewerSelectionQueryDTO doctorSearchModel);
/// <summary>
/// //入组 相关接口 (提交CRO-1) CRO确认-4
/// </summary>
Task<PageOutput<ConfirmationReviewerDTO>> GetSubmissionOrApprovalReviewerList(
ReviewerSubmissionQueryDTO doctorIntoGroupSearchModel);
//医生确认状态列表
Task<PageOutput<ConfirmationReviewerDTO>> GetConfirmationReviewerList(
ReviewerConfirmationQueryDTO trialIdPageModel);
}
}
@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infrastructure.Extention;
namespace IRaCIS.Application.Interfaces
{
public interface IDoctorService
{
#region
/// <summary>
/// 基本信息详情展示、编辑使用
/// </summary>
/// <param name="doctorId"></param>
/// <returns></returns>
Task<DoctorBasicInfoDTO> GetBasicInfo(Guid doctorId);
/// <summary>
/// 添加医生基本信息
/// </summary>
/// <param name="addBasicInfoParam"></param>
/// <returns></returns>
Task<IResponseOutput<DoctorBasicInfoCommand>> AddOrUpdateDoctorBasicInfo(DoctorBasicInfoCommand addBasicInfoParam);
#endregion
#region
/// <summary>
/// 获取医生 工作信息
/// </summary>
/// <param name="doctorId"></param>
/// <returns></returns>
Task<EmploymentDTO> GetEmploymentInfo(Guid doctorId);
/// <summary>
/// 更新医生 工作信息
/// </summary>
/// <param name="updateDoctorWorkInfoViewModel"></param>
/// <returns></returns>
Task<IResponseOutput> UpdateEmploymentInfo(EmploymentCommand updateDoctorWorkInfoViewModel);
#endregion
/// <summary>
/// 获取医生技能信息
/// </summary>
Task<SpecialtyDTO> GetSpecialtyInfo(Guid doctorId);
/// <summary>
/// 更新医生技能信息
/// </summary>
Task<IResponseOutput> UpdateSpecialtyInfo(SpecialtyCommand specialtyUpdateModel);
/// <summary>
/// 获取医生 审核状态
/// </summary>
Task<ResumeConfirmDTO> GetAuditState(Guid doctorId);
/// <summary>
/// 审核简历 和合作关系
/// </summary>
Task<IResponseOutput> UpdateAuditResume(ResumeConfirmCommand auditResumeParam);
/// <summary> 医生详情 入组信息 </summary>
DoctorEnrollInfoDTO GetDoctorIntoGroupInfo(Guid doctorId);
/// <summary> 获取医生参与项目的Sow协议 </summary>
List<SowDTO> GetDoctorSowList(Guid doctorId);
/// <summary> 获取医生入组的 ack Sow </summary>
List<SowDTO> GetDoctorAckSowList(Guid doctorId);
}
}
@@ -0,0 +1,26 @@
using System;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infrastructure.Extention;
namespace IRaCIS.Application.Interfaces
{
public interface IEducationService
{
Task<DoctorEducationExperienceDTO> GetEducation(Guid doctorId);
#region
Task<IResponseOutput> AddOrUpdateEducationInfo(EducationCommand doctorEducationInfoViewModel);
Task<IResponseOutput> DeleteEducationInfo(Guid doctorId);
#endregion
#region
Task<IResponseOutput> AddOrUpdatePostgraduateInfo(PostgraduateCommand doctorContinueLearningViewModel);
Task<IResponseOutput> DeletePostgraduateInfo(Guid doctorId);
#endregion
}
}
@@ -0,0 +1,13 @@
using System;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infrastructure.Extention;
namespace IRaCIS.Application.Interfaces
{
public interface IResearchPublicationService
{
Task<ResearchPublicationDTO> GetResearchPublication(Guid doctorId);
Task<IResponseOutput> AddOrUpdateResearchPublication(ResearchPublicationDTO param);
}
}
@@ -0,0 +1,15 @@
using System;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infrastructure.Extention;
namespace IRaCIS.Application.Interfaces
{
public interface ITrialExperienceService
{
Task<TrialExperienceModel> GetTrialExperience(Guid doctorId);
Task<IResponseOutput> AddOrUpdateTrialExperience(TrialExperienceCommand model);
Task<IResponseOutput> DeleteTrialExperience(Guid id);
Task<IResponseOutput> UpdateGcpExperience(GCPExperienceCommand model);
Task<IResponseOutput> UpdateOtherExperience(ClinicalExperienceCommand updateOtherClinicalExperience);
}
}
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infrastructure.Extention;
namespace IRaCIS.Application.Interfaces
{
public interface IVacationService
{
Task<IResponseOutput> AddOrUpdateVacation(VacationCommand vacationViewModel);
Task<IResponseOutput> DeleteVacation(Guid id);
Task<PageOutput<VacationCommand>> GetVacationList(Guid doctorId, int pageIndex, int pageSize);
/// <summary> 判断当前时间是否在休假 </summary>
Task<IResponseOutput> OnVacation(Guid reviewerId);
}
}
@@ -0,0 +1,46 @@
using AutoMapper.QueryableExtensions;
using IRaCIS.Application.Interfaces;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infra.EFCore;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Application.Filter;
using IRaCIS.Core.Infrastructure.Extention;
using Microsoft.AspNetCore.Mvc;
namespace IRaCIS.Application.Services
{
[ApiExplorerSettings(GroupName = "Reviewer")]
public class ResearchPublicationService : BaseService, IResearchPublicationService
{
private readonly IRepository<ResearchPublication> researchPublicationRepository;
public ResearchPublicationService(IRepository<ResearchPublication> _researchPublicationRepository)
{
researchPublicationRepository = _researchPublicationRepository;
}
/// <summary>
/// 查询-医生科学研究信息
/// </summary>
/// <param name="doctorId">医生Id</param>
/// <returns></returns>
[HttpGet("{doctorId:guid}")]
public async Task<ResearchPublicationDTO> GetResearchPublication(Guid doctorId)
{
var doctorScientificResearchInfo = await researchPublicationRepository.Where(o => o.DoctorId == doctorId)
.ProjectTo<ResearchPublicationDTO>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
return doctorScientificResearchInfo;
}
[HttpPost]
public async Task<IResponseOutput> AddOrUpdateResearchPublication(ResearchPublicationDTO param)
{
var entity = await _repository.InsertOrUpdateAsync<ResearchPublication, ResearchPublicationDTO>(param, true);
return ResponseOutput.Ok(entity.Id);
}
}
}
@@ -0,0 +1,189 @@
using IRaCIS.Application.Interfaces;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infra.EFCore;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Application.Filter;
using IRaCIS.Core.Infrastructure.Extention;
using Microsoft.AspNetCore.Mvc;
namespace IRaCIS.Application.Services
{
[ApiExplorerSettings(GroupName = "Reviewer")]
public class TrialExperienceService : BaseService, ITrialExperienceService
{
//private readonly IRepository<TrialExperience> _trialExperienceRepository;
//private readonly IRepository<Doctor> _doctorRepository;
//private readonly IRepository<Attachment> _attachmentRepository;
//private readonly IRepository<TrialExperienceCriteria> _trialExperienceCriteriaRepository;
//public TrialExperienceService(IRepository<TrialExperience> trialExperienceRepository, IRepository<Doctor> doctorRepository, IRepository<Attachment> attachmentRepository,
// IRepository<TrialExperienceCriteria> trialExperienceCriteriaRepository)
//{
// _trialExperienceRepository = trialExperienceRepository;
// _doctorRepository = doctorRepository;
// _attachmentRepository = attachmentRepository;
// _trialExperienceCriteriaRepository = trialExperienceCriteriaRepository;
//}
private IQueryable<Doctor> _doctor => _repository.GetQueryable<Doctor>();
private IQueryable<Attachment> _attachment => _repository.GetQueryable<Attachment>();
private IQueryable<TrialExperience> _trialExperience => _repository.GetQueryable<TrialExperience>();
private IQueryable<TrialExperienceCriteria> _trialExperienceCriteria => _repository.GetQueryable<TrialExperienceCriteria>();
/// <summary>
/// 根据医生Id,获取临床试验经历 界面所有数据
/// </summary>
[HttpGet("{doctorId:guid}")]
public async Task<TrialExperienceModel> GetTrialExperience(Guid doctorId)
{
var trialExperience = new TrialExperienceModel();
var doctor = await _doctor.Where(o => o.Id == doctorId)
.ProjectTo<TrialExperienceModel>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
trialExperience.ClinicalTrialExperienceList = await GetTrialExperienceList(doctorId);
if (doctor != null)
{
trialExperience.GCP = doctor.GCP;
trialExperience.Id = doctor.Id;
trialExperience.OtherClinicalExperience = doctor.OtherClinicalExperience ?? "";
trialExperience.OtherClinicalExperienceCN = doctor.OtherClinicalExperienceCN ?? "";
var attachment = await _attachment.FirstOrDefaultAsync(t => t.Id == doctor.GCPId);
if (attachment != null)
{
trialExperience.ExpiryDateStr = attachment.ExpiryDate == null ? "" : attachment.ExpiryDate.Value.ToString("yyyy-MM-dd HH:mm");
trialExperience.Path = attachment.Path;
trialExperience.GCPFullPath = attachment.Path + "?access_token=" + _userInfo.UserToken;
trialExperience.Type = attachment.Type;
trialExperience.FileName = attachment.FileName;
trialExperience.GCPId = attachment.Id;
}
}
return trialExperience;
}
private async Task<List<TrialExperienceListDTO>> GetTrialExperienceList(Guid doctorId)
{
var doctorClinicalTrialExperienceList = await _trialExperience.Where(o => o.DoctorId == doctorId).OrderBy(t => t.CreateTime)
.ProjectTo<TrialExperienceListDTO>(_mapper.ConfigurationProvider).ToListAsync();
return doctorClinicalTrialExperienceList;
}
/// <summary> 添加或更新医生临床经验列表项</summary>
[HttpPost]
public async Task<IResponseOutput> AddOrUpdateTrialExperience(TrialExperienceCommand trialExperienceViewModel)
{
if (trialExperienceViewModel.Id == Guid.Empty || trialExperienceViewModel.Id == null)
{
var trialExperience =
_mapper.Map<TrialExperience>(trialExperienceViewModel);
trialExperience = await _repository.AddAsync(trialExperience);
List<TrialExperienceCriteria> criteriaList = new List<TrialExperienceCriteria>();
trialExperienceViewModel.EvaluationCriteriaIdList.ForEach(t => criteriaList.Add(new TrialExperienceCriteria()
{
DoctorId = trialExperienceViewModel.DoctorId,
//EvaluationCriteria = t.EvaluationCriteria,
EvaluationCriteriaId = t,
TrialExperienceId = trialExperience.Id
}));
await _repository.AddRangeAsync(criteriaList);
var success = await _repository.SaveChangesAsync();
return ResponseOutput.Result(success, trialExperience.Id);
}
else
{
var needUpdate = await _trialExperience.FirstOrDefaultAsync(t => t.Id == trialExperienceViewModel.Id);
if (needUpdate == null) return Null404NotFound(needUpdate);
_mapper.Map(trialExperienceViewModel, needUpdate);
await _repository.UpdateAsync(needUpdate);
await _repository.DeleteFromQueryAsync<TrialExperienceCriteria>(t => t.TrialExperienceId == needUpdate.Id);
List<TrialExperienceCriteria> criteriaList = new List<TrialExperienceCriteria>();
trialExperienceViewModel.EvaluationCriteriaIdList.ForEach(t => criteriaList.Add(new TrialExperienceCriteria()
{
DoctorId = trialExperienceViewModel.DoctorId,
EvaluationCriteriaId = t,
TrialExperienceId = needUpdate.Id
}));
await _repository.AddRangeAsync<TrialExperienceCriteria>(criteriaList);
var success = await _repository.SaveChangesAsync();
return ResponseOutput.Result(success, trialExperienceViewModel.Id);
}
}
/// <summary>
/// 删除临床经验
/// </summary>
[HttpDelete, Route("{doctorId:guid}")]
public async Task<IResponseOutput> DeleteTrialExperience(Guid doctorId)
{
var success = await _repository.DeleteFromQueryAsync<TrialExperience>(o => o.Id == doctorId);
return ResponseOutput.Result(success);
}
/// <summary>
/// 更新-GCP和其他临床经验
/// </summary>
/// <param name="updateGCPExperienceParam"></param>
/// <returns></returns>
[HttpPost]
public async Task<IResponseOutput> UpdateGcpExperience(GCPExperienceCommand updateGCPExperienceParam)
{
//_attachmentRepository.Delete(t => t.DoctorId == updateGCPExperienceParam.Id && t.Type == StaticData.GCP);
var successs = await _repository.UpdateFromQueryAsync<Doctor>(o => o.Id == updateGCPExperienceParam.Id, u => new Doctor()
{
GCP = updateGCPExperienceParam.GCP,
GCPId = updateGCPExperienceParam.GCP==0&&updateGCPExperienceParam.GCPId==null?Guid.Empty: updateGCPExperienceParam.GCPId!.Value
});
if (updateGCPExperienceParam.GCP == 0 && updateGCPExperienceParam.GCPId != null)
{
await _repository.DeleteFromQueryAsync<Attachment>(a => a.Id == updateGCPExperienceParam.GCPId);
}
return ResponseOutput.Result(successs, updateGCPExperienceParam.GCPId.ToString());
}
/// <summary>
/// 更新其他技能经验
/// </summary>
[HttpPost]
public async Task<IResponseOutput> UpdateOtherExperience(ClinicalExperienceCommand updateOtherClinicalExperience)
{
var success = await _repository.UpdateFromQueryAsync<Doctor>(o => o.Id == updateOtherClinicalExperience.DoctorId, u => new Doctor()
{
OtherClinicalExperience = updateOtherClinicalExperience.OtherClinicalExperience ?? string.Empty,
OtherClinicalExperienceCN = updateOtherClinicalExperience.OtherClinicalExperienceCN ?? string.Empty
});
return ResponseOutput.Result(success);
}
}
}
@@ -0,0 +1,88 @@
using IRaCIS.Application.Interfaces;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infra.EFCore;
using Microsoft.AspNetCore.Mvc;
using Panda.DynamicWebApi.Attributes;
namespace IRaCIS.Application.Services
{
[ ApiExplorerSettings(GroupName = "Reviewer")]
public class VacationService : BaseService, IVacationService
{
private readonly IRepository<Vacation> _vacationRepository;
public VacationService(IRepository<Vacation> vacationRepository)
{
_vacationRepository = vacationRepository;
}
/// <summary>
/// 添加休假时间段
/// </summary>
/// <param name="param">Status不传</param>
/// <returns></returns>
[HttpPost]
public async Task<IResponseOutput> AddOrUpdateVacation(VacationCommand param)
{
if (param.Id == Guid.Empty|| param.Id ==null)
{
var result = await _vacationRepository.AddAsync(_mapper.Map<Vacation>(param));
var success = await _repository.SaveChangesAsync();
return ResponseOutput.Result(success, result.Id);
}
else
{
var success = await _vacationRepository.UpdateFromQueryAsync(u => u.Id == param.Id,
h => new Vacation
{
StartDate = param.StartDate,
EndDate = param.EndDate
});
return ResponseOutput.Result(success);
}
}
/// <summary>
/// 删除休假时间段
/// </summary>
/// <param name="holidayId">记录Id</param>
/// <returns></returns>
[HttpDelete("{holidayId:guid}")]
public async Task<IResponseOutput> DeleteVacation(Guid holidayId)
{
var success = await _vacationRepository.DeleteFromQueryAsync(u => u.Id == holidayId);
return ResponseOutput.Result(success);
}
/// <summary>
/// 获取休假时间段列表
/// </summary>
/// <returns></returns>
[HttpGet("{doctorId:guid}/{pageIndex:int}/{pageSize:int}")]
public async Task<PageOutput<VacationCommand>> GetVacationList(Guid doctorId, int pageIndex, int pageSize)
{
var query = _vacationRepository.Where(u => u.DoctorId == doctorId)
.ProjectTo<VacationCommand>(_mapper.ConfigurationProvider);
return await query.ToPagedListAsync(pageIndex, pageSize, "StartDate");
}
[NonDynamicMethod]
public async Task<IResponseOutput> OnVacation(Guid doctorId)
{
var count = await _vacationRepository.CountAsync(u => u.DoctorId == doctorId && u.EndDate >= DateTime.Now && u.StartDate <= DateTime.Now);
return ResponseOutput.Result(count > 0);
}
}
}
@@ -0,0 +1,152 @@
using AutoMapper;
using AutoMapper.EquivalencyExpression;
using IRaCIS.Application.Contracts;
using IRaCIS.Application.Contracts.Pay;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Domain.Share;
namespace IRaCIS.Core.Application.Service
{
public class DoctorConfig : Profile
{
public DoctorConfig()
{
#region reviewer
//基本信息 工作信息 添加时转换使用
CreateMap<DoctorBasicInfoCommand, Doctor>().EqualityComparison((odto, o) => odto.Id == o.Id);
//学习经历 添加时转换使用
CreateMap<EducationCommand, Education>().EqualityComparison((odto, o) => odto.Id == o.Id);
CreateMap<PostgraduateCommand, Postgraduate>().EqualityComparison((odto, o) => odto.Id == o.Id);
CreateMap<ResearchPublicationDTO, ResearchPublication>().EqualityComparison((odto, o) => odto.Id == o.Id);
CreateMap<TrialExperienceCommand, TrialExperience>().EqualityComparison((odto, o) => odto.Id == o.Id);
//医生账户
CreateMap<DoctorAccountLoginDTO, Doctor>();
CreateMap<DoctorAccountRegisterModel, Doctor>();
CreateMap<VacationCommand, Vacation>().EqualityComparison((odto, o) => odto.Id == o.Id);
CreateMap<AttachmentDTO, Attachment>().EqualityComparison((odto, o) => odto.Id == o.Id);
CreateMap<ReviewerAckDTO, Attachment>().EqualityComparison((odto, o) => odto.Id == o.Id);
CreateMap<Doctor, DoctorBasicInfoCommand>();
CreateMap<Education, EducationInfoViewModel>();
CreateMap<Vacation, VacationCommand>();
CreateMap<Education, EducationInfoViewModel>();
CreateMap<ResearchPublication, ResearchPublicationDTO>();
CreateMap<Postgraduate, PostgraduateViewModel>();
CreateMap<Attachment, AttachmentDTO>();
CreateMap<Doctor, ResumeConfirmDTO>();
CreateMap<Doctor, DoctorSelectDTO>();
CreateMap<Doctor, TrialExperienceModel>();
CreateMap<TrialExperience, TrialExperienceCommand>();
CreateMap<Doctor, DoctorBasicInfo>();
#endregion
CreateMap<Dictionary, KeyNameType>();
CreateMap<Dictionary, DicViewModelDTO>();
CreateMap<AddOrUpdateDicDTO, Dictionary>().ReverseMap();
//医生列表、项目显示列表模型转换
CreateMap<DoctorDTO, SelectionReviewerDTO>();
CreateMap<User, UserBasicInfo>()
.ForMember(d => d.UserTypeShortName, u => u.MapFrom(t => t.UserTypeRole.UserTypeShortName))
.ForMember(d => d.Code, u => u.MapFrom(t => t.UserCode))
.ForMember(d => d.PermissionStr, u => u.MapFrom(t => t.UserTypeRole.PermissionStr))
.ForMember(d => d.RealName, u => u.MapFrom(user => string.IsNullOrEmpty(user.FirstName) ? user.LastName : user.LastName + " / " + user.FirstName));
CreateMap<TrialExperience, TrialExperienceListDTO>()
.ForMember(d => d.Phase, u => u.MapFrom(t => t.Phase.Value))
.ForMember(d => d.EvaluationCriteriaList, u => u.MapFrom(t => t.ExperienceCriteriaList.Select(t => t.EvaluationCriteria.Value)))
.ForMember(d => d.EvaluationCriteriaIdList, u => u.MapFrom(t => t.ExperienceCriteriaList.Select(t => t.EvaluationCriteriaId)));
CreateMap<Doctor, UserBasicInfo>()
.ForMember(d => d.Code, u => u.MapFrom(t => t.ReviewerCode))
.ForMember(d => d.RealName, u => u.MapFrom(t => t.ChineseName))
.ForMember(d => d.IsReviewer, u => u.MapFrom(t => true))
.ForMember(d => d.UserName, u => u.MapFrom(doctor => doctor.LastName + " / " + doctor.FirstName));
#region
CreateMap<Doctor, SelectionReviewerDTO>();
CreateMap<Doctor, DoctorDTO>().IncludeMembers(t => t.Hospital).Include<Doctor, SelectionReviewerDTO>()
.ForMember(d => d.Department, u => u.MapFrom(s => s.Department.Value))
.ForMember(d => d.DepartmentCN, u => u.MapFrom(s => s.Department.ValueCN))
.ForMember(d => d.Position, u => u.MapFrom(s => s.Position.Value))
.ForMember(d => d.PositionCN, u => u.MapFrom(s => s.Position.ValueCN))
.ForMember(d => d.Rank, u => u.MapFrom(s => s.Rank.Value))
.ForMember(d => d.RankCN, u => u.MapFrom(s => s.Rank.ValueCN))
.ForMember(d => d.Speciality, u => u.MapFrom(s => s.Speciality.Value))
.ForMember(d => d.SpecialityCN, u => u.MapFrom(s => s.Speciality.ValueCN))
.ForMember(d => d.HasResume, u => u.MapFrom(s => s.AttachmentList.Any(u => u.Type == "Resume" && u.IsOfficial)))
.ForMember(d => d.Submitted, u => u.MapFrom(s => s.EnrollList.Count(t => t.EnrollStatus == (int)EnrollStatus.HasCommittedToCRO)))
.ForMember(d => d.Approved, u => u.MapFrom(s => s.EnrollList.Count(t => t.EnrollStatus == (int)EnrollStatus.InviteIntoGroup)))
.ForMember(d => d.Reading, u => u.MapFrom(s => s.EnrollList.Count(t => t.EnrollStatus == (int)EnrollStatus.DoctorReading)))
.ForMember(d => d.Finished, u => u.MapFrom(s => s.EnrollList.Count(t => t.EnrollStatus == (int)EnrollStatus.Finished)))
.ForMember(d => d.Reconfirmed, u => u.MapFrom(s => s.ReviewStatus == 1))
.ForMember(o => o.DictionaryList, t => t.MapFrom(u => u.DoctorDicRelationList.Where(t => t.KeyName == StaticData.ReadingType || t.KeyName == StaticData.Subspeciality).Select(t => t.Dictionary).OrderBy(t => t.ShowOrder)));
CreateMap<Hospital, DoctorDTO>();
CreateMap<EmploymentCommand, Doctor>();
//这样会左连接三次
// CreateMap<Doctor, DoctorBasicInfoDTO>()
//.ForMember(d => d.TitleCNList, u => u.MapFrom(s => s.DoctorDicRelationList.Where(t => t.KeyName == StaticData.Title)
//.Select(t => new { TitleCN = t.Dictionary.ValueCN, ShowOrder = t.Dictionary.ShowOrder }).OrderBy(k => k.ShowOrder).Select(t => t.TitleCN)))
// .ForMember(d => d.TitleList, u => u.MapFrom(s => s.DoctorDicRelationList.Where(t => t.KeyName == StaticData.Title)
//.Select(t => new { Title = t.Dictionary.Value, ShowOrder = t.Dictionary.ShowOrder }).OrderBy(k => k.ShowOrder).Select(t => t.Title)))
// .ForMember(d => d.TitleIds, u => u.MapFrom(s => s.DoctorDicRelationList.Where(t => t.KeyName == StaticData.Title)
//.Select(t => new { TitleId = t.Dictionary.Id, ShowOrder = t.Dictionary.ShowOrder }).OrderBy(k => k.ShowOrder).Select(t => t.TitleId)));
//这样只会查询一次
CreateMap<Doctor, DoctorBasicInfoDTO>()
.ForMember(o => o.DoctorDicViewDtos, t => t.MapFrom(u => u.DoctorDicRelationList.Where(t => t.KeyName == StaticData.Title).Select(t => t.Dictionary).OrderBy(t => t.ShowOrder)));
CreateMap<Dictionary, DicView>()
.ForMember(t=>t.ParentCode,u=>u.MapFrom(c=>c.Parent.Code));
//CreateMap<DoctorDictionary, DicView>();
CreateMap<Doctor, SpecialtyDTO>()
.ForMember(o => o.Speciality, t => t.MapFrom(u => u.Speciality.Value))
.ForMember(o => o.DictionaryList, t => t.MapFrom(u => u.DoctorDicRelationList.Where(t => t.KeyName == StaticData.ReadingType || t.KeyName == StaticData.Subspeciality).Select(t => t.Dictionary).OrderBy(t => t.ShowOrder)));
CreateMap<SpecialtyCommand, Doctor>();
//医生职业信息
CreateMap<Doctor, EmploymentDTO>().IncludeMembers(t => t.Hospital)
.ForMember(d => d.Department, u => u.MapFrom(s => s.Department.Value))
.ForMember(d => d.DepartmentCN, u => u.MapFrom(s => s.Department.ValueCN))
.ForMember(d => d.Position, u => u.MapFrom(s => s.Position.Value))
.ForMember(d => d.PositionCN, u => u.MapFrom(s => s.Position.ValueCN))
.ForMember(d => d.Rank, u => u.MapFrom(s => s.Rank.Value))
.ForMember(d => d.RankCN, u => u.MapFrom(s => s.Rank.ValueCN));
CreateMap<Hospital, EmploymentDTO>();
CreateMap<EnrollDetail, DoctorStateModelDTO>()
.ForMember(d => d.IntoGroupState, u => u.MapFrom(s => s.EnrollStatus))
.ForMember(d => d.OptTime, u => u.MapFrom(s => s.CreateTime))
.ForMember(d => d.OptUserName, u => u.MapFrom(s => s.CreateUser.UserName));
CreateMap<Enroll, ConfirmationReviewerDTO>().IncludeMembers(t => t.Doctor, t => t.Doctor.Hospital)
.ForMember(d => d.Id, u => u.MapFrom(s => s.Doctor.Id));
CreateMap<Doctor, ConfirmationReviewerDTO>();
CreateMap<Hospital, ConfirmationReviewerDTO>();
#endregion
}
}
}