using IRaCIS.Core.Application.Contracts.Dicom;
using IRaCIS.Core.Application.Contracts.Dicom.DTO;
using IRaCIS.Core.Application.Contracts.RequestAndResponse;
using IRaCIS.Core.Application.Dicom;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Net.Http;
namespace IRaCIS.Api.Controllers
{
///
/// Series
///
[Route("series")]
[ApiController, Authorize, ApiExplorerSettings(GroupName = "Image")]
public class SeriesController : ControllerBase
{
private readonly IDicomArchiveService _dicomArchiveService;
public SeriesController(IDicomArchiveService dicomArchiveService)
{
_dicomArchiveService = dicomArchiveService;
}
///// 指定资源Id,获取Dicom检查所属序列信息列表
///// Dicom检查的Id
//[HttpGet, Route("list/{studyId:guid}")]
//[AllowAnonymous]
//public IEnumerable GetSeriesList(Guid studyId)
//{
// return _dicomArchiveService.GetSeriesList(studyId);
//}
/// 指定资源Id,获取Dicom检查所属序列信息列表
/// Dicom检查的Id
///
[HttpGet, Route("serieslist/{studyId:guid}")]
[AllowAnonymous]
public IResponseOutput> GetSeriesList(Guid studyId,string tpCode)
{
return ResponseOutput.Ok( _dicomArchiveService.GetSeriesWithLabelList(studyId, tpCode));
}
[HttpGet, Route("list/{studyId:guid}/{tpCode?}")]
[AllowAnonymous]
public IEnumerable GetSeriesWithLabelList(Guid studyId, string tpCode)
{
return _dicomArchiveService.GetSeriesWithLabelList(studyId, tpCode);
}
/// 指定资源Id,渲染Dicom序列的Jpeg预览图像
/// Dicom序列的Id
[HttpGet, Route("preview/{seriesId:guid}")]
[AllowAnonymous]
public FileContentResult GetSeriesPreview(Guid seriesId)
{
string path = _dicomArchiveService.GetSeriesPreview(seriesId);
using (var sw = DicomRenderingHelper.RenderPreviewJpeg(path))
{
var bytes = new byte[sw.Length];
sw.Read(bytes, 0, bytes.Length);
sw.Close();
return new FileContentResult(bytes, "image/jpeg");
}
}
}
}