public async Task<object> PrintReport(string BLH, string MedicalNo)
{
string PrintTitle = "";
List<object> result = new List<object>();
List<object> resultChild = new List<object>();
Dictionary<string, object> dic = new Dictionary<string, object>();
var mm2 = await _dbContext.Medicals.Where(x => x.Blh == BLH && x.MedicalNo == MedicalNo && x.IfSend==1).FirstOrDefaultAsync();
var qvisit = await _dbContext.InpatientVisits.Where(x => x.Blh == BLH).FirstOrDefaultAsync();
var query = await _dbContext.DocumentsSource.Where(x => x.BLH == BLH && x.MedicalNo == MedicalNo).ToListAsync();
var entity = await _dbContext.ImagingReports.Where(x => x.BLH == BLH && x.MedicalNo == MedicalNo).FirstOrDefaultAsync();
string InpatienName = qvisit.InpatienName;
string Sex = qvisit.Sex;
string Bch = qvisit.Bch;
string Agestr = qvisit.Agestr;
string EnterRepInfo = qvisit.EnterRepInfo;
string ImageContent = entity.ImageContent;
string ImagingConclusion = entity.ImagingConclusion;
string Remarks = entity.Remarks;
string ReleaseTime = entity.ReleaseTime.ToString();
string Creator = entity.Creator;
string Reviewer = entity.Reviewer;
string DoctorName = mm2.DoctorName;
string FeeName_str = mm2.FeeName_str;
string ExecutorDoctor = mm2.ExecutorDoctor;
string ExecutorDate = mm2.ExecutorDate.ToString();
result.Add(new
{
BLH = BLH,
MedicalNo = MedicalNo,
Sex= Sex,
Bch = Bch,
Agestr = Agestr,
EnterRepInfo = EnterRepInfo,
ImageContent = ImageContent,
ImagingConclusion = ImagingConclusion,
Remarks = Remarks,
ReleaseTime = ReleaseTime,
Creator = Creator,
Reviewer = Reviewer,
DoctorName = DoctorName,
FeeName_str = FeeName_str,
ExecutorDoctor = ExecutorDoctor,
ExecutorDate = ExecutorDate,
InpatienName= InpatienName,
});
if (query.Count>0)
{
foreach (var item in query)
{
resultChild.Add(new
{
_ImgReport = FileToBase64String(item.FilePath),
});
}
}
dic.Add("影像信息", result);
dic.Add("影像图片", resultChild);
var userInfo = await _onlineUserProvider.GetOrCreateAsync();
var obj = new PrintResult(dic, "影像报告", userInfo.PrintType);
return obj;
}```
```csharp+
private readonly IWebHostEnvironment _webHostEnvironment;
private readonly IConfiguration _configuration;
public string FileToBase64String(string Path)
{
var root = _webHostEnvironment.WebRootPath;
var sectionValue = _configuration.GetValue<string>("ContentRootPath");
if (!string.IsNullOrWhiteSpace(sectionValue))
{
root = sectionValue;
}
using (FileStream fsForRead = new FileStream(root + "" + Path, FileMode.Open))
{
string base64Str = "";
try
{
fsForRead.Seek(0, SeekOrigin.Begin);
byte[] bs = new byte[fsForRead.Length];
int log = Convert.ToInt32(fsForRead.Length);
fsForRead.Read(bs, 0, log);
base64Str = Convert.ToBase64String(bs);
return base64Str;
}
catch (Exception ex)
{
return "";
}
}
}