@ -33,7 +33,8 @@ namespace Shentun.Peis.ReportTemplates
private readonly IRepository < SumSuggestionHeader > _sumSuggestionHeaderRepository ;
private readonly IRepository < CustomerOrg , Guid > _customerOrgRepository ;
private readonly CacheService _cacheService ;
private readonly IRepository < Diagnosis , Guid > _diagnosisRepository ;
private readonly IRepository < Suggestion , Guid > _suggestionRepository ;
private readonly string DirectoryName = System . AppDomain . CurrentDomain . BaseDirectory + @"\ReportFile" ;
public CustomerOrgReportManager (
@ -48,7 +49,9 @@ namespace Shentun.Peis.ReportTemplates
IRepository < SumDiagnosis > sumDiagnosisRepository ,
IRepository < SumSuggestionHeader > sumSuggestionHeaderRepository ,
IRepository < CustomerOrg , Guid > customerOrgRepository ,
CacheService cacheService )
CacheService cacheService ,
IRepository < Diagnosis , Guid > diagnosisRepository ,
IRepository < Suggestion , Guid > suggestionRepository )
{
_patientRegisterRepository = patientRegisterRepository ;
_customerOrgManager = customerOrgManager ;
@ -62,6 +65,8 @@ namespace Shentun.Peis.ReportTemplates
_sumSuggestionHeaderRepository = sumSuggestionHeaderRepository ;
_customerOrgRepository = customerOrgRepository ;
_cacheService = cacheService ;
_diagnosisRepository = diagnosisRepository ;
_suggestionRepository = suggestionRepository ;
}
@ -260,7 +265,8 @@ namespace Shentun.Peis.ReportTemplates
table6 . Rows [ rowIndex ] . Cells [ 4 ] . Paragraphs [ 0 ] . Append ( item . TotalNumber . ToString ( ) ) ;
table6 . Rows [ rowIndex ] . Cells [ 5 ] . Paragraphs [ 0 ] . Append ( item . MaleRatio ) ;
table6 . Rows [ rowIndex ] . Cells [ 6 ] . Paragraphs [ 0 ] . Append ( item . FemaleRatio ) ;
table6 . Rows [ rowIndex ] . Cells [ 7 ] . Paragraphs [ 0 ] . Append ( item . AverageRatio ) ;
table6 . Rows [ rowIndex ] . Cells [ 7 ] . Paragraphs [ 0 ] . Append ( "" ) ;
// table6.Rows[rowIndex].Cells[7].Paragraphs[0].Append(item.AverageRatio);
rowIndex + + ;
if ( rowIndex - 2 < table6Data . Count ) table6 . InsertRow ( ) ;
}
@ -600,9 +606,9 @@ namespace Shentun.Peis.ReportTemplates
p3Row2 . Cells [ 4 ] . Paragraphs [ 0 ] . AppendDocProperty ( p3_Register_TotalNumber ) . Font ( f ) . FontSize ( 1 0.5 ) . Alignment = Alignment . center ;
p3Row2 . Cells [ 5 ] . Paragraphs [ 0 ] . AppendDocProperty ( p3_Register_MaleRatio ) . Font ( f ) . FontSize ( 1 0.5 ) . Alignment = Alignment . center ;
p3Row2 . Cells [ 6 ] . Paragraphs [ 0 ] . AppendDocProperty ( p3_Register_FemaleRatio ) . Font ( f ) . FontSize ( 1 0.5 ) . Alignment = Alignment . center ;
p3Row2 . Cells [ 7 ] . Paragraphs [ 0 ] . Append ( "100% " ) . Font ( f ) . FontSize ( 1 0.5 ) . Alignment = Alignment . center ;
p3Row2 . Cells [ 8 ] . Paragraphs [ 0 ] . Append ( "100% " ) . Font ( f ) . FontSize ( 1 0.5 ) . Alignment = Alignment . center ;
p3Row2 . Cells [ 9 ] . Paragraphs [ 0 ] . Append ( "100% " ) . Font ( f ) . FontSize ( 1 0.5 ) . Alignment = Alignment . center ;
p3Row2 . Cells [ 7 ] . Paragraphs [ 0 ] . Append ( "" ) . Font ( f ) . FontSize ( 1 0.5 ) . Alignment = Alignment . center ;
p3Row2 . Cells [ 8 ] . Paragraphs [ 0 ] . Append ( "" ) . Font ( f ) . FontSize ( 1 0.5 ) . Alignment = Alignment . center ;
p3Row2 . Cells [ 9 ] . Paragraphs [ 0 ] . Append ( "" ) . Font ( f ) . FontSize ( 1 0.5 ) . Alignment = Alignment . center ;
Row p3Row3 = p3rowsContent [ 3 ] ;
p3Row3 . Cells [ 0 ] . Paragraphs [ 0 ] . Append ( "实检" ) . Font ( f ) . FontSize ( 1 0.5 ) . Alignment = Alignment . center ;
@ -778,7 +784,7 @@ namespace Shentun.Peis.ReportTemplates
p5Table2Row1 . Cells [ 5 ] . FillColor = Color . FromArgb ( 2 0 9 , 2 4 5 , 2 0 3 ) ;
p5Table2Row1 . Cells [ 6 ] . Paragraphs [ 0 ] . Append ( "女性" ) . Font ( f ) . FontSize ( 1 0.5 ) . Alignment = Alignment . center ;
p5Table2Row1 . Cells [ 6 ] . FillColor = Color . FromArgb ( 2 0 9 , 2 4 5 , 2 0 3 ) ;
p5Table2Row1 . Cells [ 7 ] . Paragraphs [ 0 ] . Append ( "平均 " ) . Font ( f ) . FontSize ( 1 0.5 ) . Alignment = Alignment . center ;
p5Table2Row1 . Cells [ 7 ] . Paragraphs [ 0 ] . Append ( "" ) . Font ( f ) . FontSize ( 1 0.5 ) . Alignment = Alignment . center ;
p5Table2Row1 . Cells [ 7 ] . FillColor = Color . FromArgb ( 2 0 9 , 2 4 5 , 2 0 3 ) ;
p5Content1 . InsertTableAfterSelf ( p5Contenttable2 ) ;
@ -1495,7 +1501,7 @@ namespace Shentun.Peis.ReportTemplates
Math . Round ( s . Where ( m = > m . SexId = = SexFlag . Female ) . Count ( ) * 1 0 0 M / s . Where ( m = > m . SexId = = SexFlag . Male | | m . SexId = = SexFlag . Female ) . Count ( ) , 2 ) . ToString ( ) + "%" : "0%" ,
AverageRatio = s . Where ( m = > m . SexId = = SexFlag . Male | | m . SexId = = SexFlag . Female ) . Count ( ) ! = 0 ?
Math . Round ( ( Math . Round ( s . Where ( m = > m . SexId = = SexFlag . Male ) . Count ( ) * 1 0 0 M / s . Where ( m = > m . SexId = = SexFlag . Male | | m . SexId = = SexFlag . Female ) . Count ( ) , 2 )
+ Math . Round ( s . Where ( m = > m . SexId = = SexFlag . Female ) . Count ( ) * 1 0 0 M / s . Where ( m = > m . SexId = = SexFlag . Male | | m . SexId = = SexFlag . Female ) . Count ( ) , 2 ) ) / 2 , 2 ) . ToString ( ) : "0%"
+ Math . Round ( s . Where ( m = > m . SexId = = SexFlag . Female ) . Count ( ) * 1 0 0 M / s . Where ( m = > m . SexId = = SexFlag . Male | | m . SexId = = SexFlag . Female ) . Count ( ) , 2 ) ) / 2 , 2 ) . ToString ( ) + "%" : "0%"
} ) . OrderByDescending ( o = > o . TotalNumber ) ;
documentData . MedicalAbnormalResultStatistics = medicalAbnormalResultStatistics . ToList ( ) ;
@ -1504,30 +1510,34 @@ namespace Shentun.Peis.ReportTemplates
/// <summary>
/// 生成本次体检异常结果检出统计 数据 5
/// 本次体检前十大异常结果分析 数据 5
/// </summary>
/// <param name="documentData">数据</param>
/// <param name="customerOrgs">参数</param>
/// <returns></returns>
public async Task CreateMedicalTenAbnormalResultsData ( UnitPhysicalExaminationReportExportWordData documentData , CreateInspectionPersonnelPara customerOrgs )
{
#region 查询
var query = from a in ( await _sumDiagnosisRepository . GetQueryableAsync ( ) ) . Include ( x = > x . Diagnosis )
join b in await _patientRegisterRepository . GetQueryableAsync ( ) on a . PatientRegisterId equals b . Id
join c in ( await _sumSuggestionHeaderRepository . GetQueryableAsync ( ) ) . Include ( x = > x . SumSuggestionContents ) on a . SumSuggestionHeaderId equals c . Id into cc
from ac in cc . DefaultIfEmpty ( )
where b . CompleteFlag = = PatientRegisterCompleteFlag . SumCheck
var query = from sumDiagnosis in await _sumDiagnosisRepository . GetQueryableAsync ( )
join diagnosis in await _diagnosisRepository . GetQueryableAsync ( ) on sumDiagnosis . DiagnosisId equals diagnosis . Id
join patientRegister in await _patientRegisterRepository . GetQueryableAsync ( ) on sumDiagnosis . PatientRegisterId equals patientRegister . Id
join suggestion in await _suggestionRepository . GetQueryableAsync ( ) on sumDiagnosis . DiagnosisId equals suggestion . DiagnosisId into suggestionTemp
from suggestionEmpty in suggestionTemp . DefaultIfEmpty ( )
where patientRegister . CompleteFlag = = PatientRegisterCompleteFlag . SumCheck
& & suggestionEmpty . SuggestionType = = SuggestionTypeFlag . HealthGuidance
select new
{
CustomerOrgGroupId = b . CustomerOrgGroupId ,
CustomerOrgRegisterId = b . CustomerOrgRegisterId ,
CustomerOrgId = b . CustomerOrgId ,
CreationTime = b . CreationTime ,
MedicalStartDate = b . MedicalStartDate ,
SummaryDate = b . SummaryDate ,
DiagnosisId = a . DiagnosisId ,
DiagnosisName = a . Diagnosis ! = null ? a . Diagnosis . DisplayName : "" ,
ac
CustomerOrgGroupId = patientRegister . CustomerOrgGroupId ,
CustomerOrgRegisterId = patientRegister . CustomerOrgRegisterId ,
CustomerOrgId = patientRegister . CustomerOrgId ,
CreationTime = patientRegister . CreationTime ,
MedicalStartDate = patientRegister . MedicalStartDate ,
SummaryDate = patientRegister . SummaryDate ,
DiagnosisId = sumDiagnosis . DiagnosisId ,
DiagnosisName = diagnosis . DisplayName ,
suggestionEmpty ,
sumDiagnosis
} ;
@ -1559,13 +1569,86 @@ namespace Shentun.Peis.ReportTemplates
}
#endregion
var medicalTenAbnormalResults = query . ToList ( ) . GroupBy ( g = > g . DiagnosisId ) . Select ( s = > new UnitPhysicalExaminationReportExportWordData_MedicalTenAbnormalResult
{
DiagnosisName = s . FirstOrDefault ( ) . DiagnosisName ,
DiagnosisSuggestion = DataHelper . SetSumSuggestionInReport ( s . Where ( m = > m . ac ! = null ) . Select ( ss = > ss . ac ) . ToList ( ) )
} ) ;
var sumDiagnosisGroup = query . ToList ( ) . GroupBy ( g = > g . sumDiagnosis )
. Select ( s = > new
{
DiagnosisId = s . FirstOrDefault ( ) . DiagnosisId ,
DiagnosisName = s . FirstOrDefault ( ) . DiagnosisName ,
SuggestionEmpty = s . Where ( m = > m . suggestionEmpty ! = null ) . Select ( ss = > ss . suggestionEmpty ) . Distinct ( ) . ToList ( )
} ) . ToList ( ) ;
var medicalTenAbnormalResults = sumDiagnosisGroup . GroupBy ( g = > g . DiagnosisId )
. OrderByDescending ( o = > o . Count ( ) )
. Take ( 1 0 )
. Select ( s = > new UnitPhysicalExaminationReportExportWordData_MedicalTenAbnormalResult
{
DiagnosisName = s . FirstOrDefault ( ) . DiagnosisName ,
DiagnosisSuggestion = DataHelper . SetSuggestionInReport ( s . FirstOrDefault ( ) . DiagnosisName , s . FirstOrDefault ( ) . SuggestionEmpty )
} ) ;
documentData . MedicalTenAbnormalResults = medicalTenAbnormalResults . ToList ( ) ;
// #region 查询
// var query = from a in (await _sumDiagnosisRepository.GetQueryableAsync()).Include(x => x.Diagnosis)
// join b in await _patientRegisterRepository.GetQueryableAsync() on a.PatientRegisterId equals b.Id
// join c in (await _sumSuggestionHeaderRepository.GetQueryableAsync()).Include(x => x.SumSuggestionContents) on a.SumSuggestionHeaderId equals c.Id into cc
// from ac in cc.DefaultIfEmpty()
// where b.CompleteFlag == PatientRegisterCompleteFlag.SumCheck
// select new
// {
// CustomerOrgGroupId = b.CustomerOrgGroupId,
// CustomerOrgRegisterId = b.CustomerOrgRegisterId,
// CustomerOrgId = b.CustomerOrgId,
// CreationTime = b.CreationTime,
// MedicalStartDate = b.MedicalStartDate,
// SummaryDate = b.SummaryDate,
// DiagnosisId = a.DiagnosisId,
// DiagnosisName = a.Diagnosis != null ? a.Diagnosis.DisplayName : "",
// ac
// };
// if (customerOrgs.CustomerOrgGroupId.Any())
// {
// query = query.Where(m => m.CustomerOrgGroupId != null && customerOrgs.CustomerOrgGroupId.Contains(m.CustomerOrgGroupId.Value));
// }
// if (customerOrgs.CustomerOrgRegisterId != GuidFlag.PersonCustomerOrgRegisterId)
// {
// query = query.Where(m => m.CustomerOrgRegisterId == customerOrgs.CustomerOrgRegisterId);
// }
// var customerOrgIds = await _customerOrgManager.GetCustomerOrgChildrenId(customerOrgs.CustomerOrgId);
// query = query.Where(m => customerOrgIds.Contains(m.CustomerOrgId));
// if (customerOrgs.DateType == '1')
// {
// query = query.Where(m => m.CreationTime >= Convert.ToDateTime(customerOrgs.StartDate) &&
// m.CreationTime < Convert.ToDateTime(customerOrgs.EndDate).AddDays(1));
// }
// else if (customerOrgs.DateType == '2')
// {
// query = query.Where(m => m.MedicalStartDate != null && m.MedicalStartDate.Value >= Convert.ToDateTime(customerOrgs.StartDate) &&
// m.MedicalStartDate.Value < Convert.ToDateTime(customerOrgs.EndDate).AddDays(1));
// }
// else if (customerOrgs.DateType == '3')
// {
// query = query.Where(m => m.SummaryDate != null && m.SummaryDate.Value >= Convert.ToDateTime(customerOrgs.StartDate) &&
//m.SummaryDate.Value < Convert.ToDateTime(customerOrgs.EndDate).AddDays(1));
// }
// #endregion
// var medicalTenAbnormalResults = query.ToList().GroupBy(g => g.DiagnosisId).Select(s => new UnitPhysicalExaminationReportExportWordData_MedicalTenAbnormalResult
// {
// DiagnosisName = s.FirstOrDefault().DiagnosisName,
// DiagnosisSuggestion = DataHelper.SetSumSuggestionInReport(s.Where(m => m.ac != null).Select(ss => ss.ac).ToList())
// });
// documentData.MedicalTenAbnormalResults = medicalTenAbnormalResults.ToList();
}