234 lines
8.7 KiB
C#
234 lines
8.7 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using IRaCIS.Api.Filter;
|
||
using IRaCIS.Application.Interfaces;
|
||
using IRaCIS.Application.ViewModels;
|
||
using IRaCIS.Core.Application.Contracts.RequestAndResponse;
|
||
using IRaCIS.Core.Domain.Share.AuthUser;
|
||
using Microsoft.AspNetCore.Authorization;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
|
||
namespace IRaCIS.Api.Controllers
|
||
{
|
||
/// <summary>
|
||
/// 项目基本信息维护
|
||
/// </summary>
|
||
[Route("trial")]
|
||
[ApiController, Authorize, ApiExplorerSettings(GroupName = "Trial")]
|
||
public class TrialController : ControllerBase
|
||
{
|
||
private readonly ITrialService _trialService;
|
||
|
||
private readonly ITrialWorkloadService _trialWorkloadService;
|
||
private readonly IUserInfo _userInfo;
|
||
private readonly ICalculateService _calculateService;
|
||
|
||
public TrialController(ITrialService trialService,
|
||
ITrialWorkloadService trialWorkloadService,IUserInfo userInfo,ICalculateService calculateService)
|
||
{
|
||
_trialService = trialService;
|
||
_trialWorkloadService = trialWorkloadService;
|
||
_userInfo = userInfo;
|
||
_calculateService = calculateService;
|
||
}
|
||
|
||
#region 项目查询
|
||
/// <summary> 分页获取临床实验项目列表(查询条件)</summary>
|
||
/// <param name="param">查询参数</param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("getTrialList")]
|
||
public IResponseOutput<PageOutput<TrialDetailDTO>> GetTrialList(TrialQueryDTO param)
|
||
{
|
||
var userId = Guid.Parse(User.FindFirst("id").Value);
|
||
return ResponseOutput.Ok(_trialService.GetTrialList(param, userId)) ;
|
||
|
||
}
|
||
|
||
/// <summary> 查询项目基本信息 </summary>
|
||
/// <param name="trialId">项目Id</param>
|
||
/// <returns></returns>
|
||
[HttpGet, Route("getTrialInfo/{trialId:guid}")]
|
||
public IResponseOutput<TrialDetailDTO> GetTrialInfoAndLockState(Guid trialId)
|
||
{
|
||
var trial = _trialService.GetTrialInfoAndLockState(trialId);
|
||
|
||
return ResponseOutput.Ok(trial);
|
||
|
||
}
|
||
|
||
/// <summary> 查询项目基本信息 和项目最大状态,</summary>
|
||
/// <param name="trialId">项目Id</param>
|
||
/// <returns></returns>
|
||
|
||
[HttpGet, Route("getTrialInfoAndMaxTrialState/{trialId:guid}")]
|
||
public IResponseOutput<TrialAndTrialStateVieModel> GetTrialInfoAndMaxTrialState(Guid trialId)
|
||
{
|
||
var result = new TrialAndTrialStateVieModel()
|
||
{
|
||
TrialView = _trialService.GetTrialInfoAndLockState(trialId),
|
||
TrialMaxState = _trialService.GetTrialMaxState(trialId)
|
||
};
|
||
|
||
return ResponseOutput.Ok(result);
|
||
|
||
}
|
||
|
||
/// <summary> 查询项目加急状态</summary>
|
||
/// <param name="trialId">项目Id</param>
|
||
/// <returns></returns>
|
||
[HttpGet, Route("getTrialExpeditedState/{trialId:guid}")]
|
||
public IResponseOutput<int> GetTrialExpeditedState(Guid trialId)
|
||
{
|
||
|
||
return ResponseOutput.Ok(_trialService.GetTrialExpeditedState(trialId));
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据项目状态获取医生项目列表[New]
|
||
/// </summary>
|
||
/// <param name="param">5-Submitted,8-Approved,10-Reading</param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("getDoctorTrialListByStatus")]
|
||
[AllowAnonymous]
|
||
public IResponseOutput<PageOutput<TrialDetailDTO>> GetDoctorTrialListByStatus(
|
||
TrialByStatusQueryDTO param)
|
||
{
|
||
return ResponseOutput.Ok(_trialService.GetReviewerTrialListByEnrollmentStatus(param)) ;
|
||
}
|
||
#endregion
|
||
|
||
#region 项目更新删除
|
||
|
||
/// <summary> 添加实验项目-返回新增Id[AUTH]</summary>
|
||
/// <param name="param"></param>
|
||
/// <returns>新记录Id</returns>
|
||
[LogFilter]
|
||
[HttpPost, Route("addOrUpdateTrial")]
|
||
public IResponseOutput AddOrUpdateTrial(TrialCommand param)
|
||
{
|
||
var userId = Guid.Parse(User.FindFirst("id").Value);
|
||
var result= _trialService.AddOrUpdateTrial(param, userId);
|
||
|
||
if (_trialService.TrialExpeditedChange)
|
||
{
|
||
var needCalReviewerIds = _trialService.GetTrialEnrollmentReviewerIds(param.Id);
|
||
var calcList = _calculateService.GetNeedCalculateReviewerList(Guid.Empty, string.Empty);
|
||
|
||
calcList.ForEach(t=> {
|
||
if (needCalReviewerIds.Contains(t.DoctorId))
|
||
{
|
||
_calculateService.CalculateMonthlyPayment(new CalculateDoctorAndMonthDTO()
|
||
{
|
||
NeedCalculateReviewers = new List<Guid>()
|
||
{
|
||
t.DoctorId
|
||
},
|
||
CalculateMonth = DateTime.Parse(t.YearMonth)
|
||
}, User.FindFirst("id").Value);
|
||
|
||
} });
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
[LogFilter]
|
||
[HttpPost, Route("confirmTrialVisitPlan/{trialId:guid}")]
|
||
public IResponseOutput ConfirmTrialVisitPlan(Guid trialId)
|
||
{
|
||
return _trialService.ConfirmTrialVisitPlan(trialId);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 手动更新项目状态
|
||
/// </summary>
|
||
/// <param name="trialId">项目Id</param>
|
||
/// <param name="statusStr">状态值</param>
|
||
/// <returns></returns>
|
||
[LogFilter]
|
||
[HttpPost, Route("updateTrialStatus/{trialId:guid}/{statusStr}")]
|
||
public IResponseOutput UpdateTrialStatusStr(Guid trialId, string statusStr)
|
||
{
|
||
if (string.IsNullOrWhiteSpace(statusStr))
|
||
{
|
||
return ResponseOutput.NotOk("please select status.");
|
||
}
|
||
var result = _trialService.UpdateTrialStatus(trialId, statusStr);
|
||
|
||
return result;
|
||
}
|
||
|
||
/// <summary> 删除临床项目 </summary>
|
||
/// <param name="trialId">临床试验项目Id</param>
|
||
[LogFilter]
|
||
[HttpDelete, Route("deleteTrial/{trialId:guid}")]
|
||
public IResponseOutput DeleteTrial(Guid trialId)
|
||
{
|
||
return _trialService.DeleteTrial(trialId);
|
||
|
||
}
|
||
#endregion
|
||
|
||
#region ack sow
|
||
/// <summary>
|
||
/// 保存协议- ack Sow [AUTH]
|
||
/// </summary>
|
||
[HttpPost, Route("uploadReviewerAckSOW/{trialId}")]
|
||
public IResponseOutput UploadReviewerAckSOW(Guid trialId, ReviewerAckDTO attachmentViewModel)
|
||
{
|
||
var userId = Guid.Parse(User.FindFirst("id").Value);
|
||
return _trialWorkloadService.UploadReviewerAckSOW(userId, trialId, attachmentViewModel);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除协议
|
||
/// </summary>
|
||
[HttpDelete, Route("deleteReviewerAckSOW/{trialId}/{doctorId}/{attachmentId}")]
|
||
public IResponseOutput DeleteReviewerAckSOW(Guid trialId, Guid doctorId, Guid attachmentId)
|
||
{
|
||
return _trialWorkloadService.DeleteReviewerAckSOW(trialId, doctorId, attachmentId);
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 0代表裁判和Tp 都可以 1、代表Tp 2 代表裁判
|
||
/// </summary>
|
||
/// <param name="trialId"></param>
|
||
/// <param name="doctorId"></param>
|
||
/// <param name="reviewerReadingType"></param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("updateReviewerReadingType/{trialId}/{doctorId}/{reviewerReadingType}")]
|
||
public IResponseOutput UpdateReviewerReadingType(Guid trialId, Guid doctorId, int reviewerReadingType)
|
||
{
|
||
return _trialWorkloadService.UpdateReviewerReadingType(trialId, doctorId, reviewerReadingType);
|
||
}
|
||
#endregion
|
||
|
||
#region 医生用户接口
|
||
/// <summary> 分页获取医生参与的临床实验项目列表(查询条件)</summary>
|
||
/// <param name="param">查询参数</param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("getTrialListByReviewer")]
|
||
public IResponseOutput<PageOutput<TrialDetailDTO>> GetTrialListByReviewer(ReviewerTrialQueryDTO param)
|
||
{
|
||
var userId = Guid.Parse(User.FindFirst("id").Value);
|
||
return ResponseOutput.Ok(_trialService.GetTrialListByReviewer(param, userId));
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 医生确认入组或拒绝入组
|
||
/// </summary>
|
||
/// <param name="trialId">项目Id</param>
|
||
/// <param name="status">9-拒绝入组,10-确认入组</param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("updateEnrollStatus/{trialId:guid}/{status:int}")]
|
||
public IResponseOutput UpdateTrialStatusStr(Guid trialId, int status)
|
||
{
|
||
return _trialService.UpdateEnrollStatus(trialId, status);
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
} |