@ -7,7 +7,6 @@ import com.ccsens.util.PdfUtil;
import io.swagger.annotations.ApiModel ;
import io.swagger.annotations.ApiModelProperty ;
import lombok.Data ;
import org.springframework.beans.factory.annotation.Autowired ;
import java.util.* ;
@ -129,12 +128,17 @@ public class PatientReportVo {
"病案号:" + this . hospitalNumber )
) ;
//第四栏
Date date = new Date ( ) ;
date . setTime ( this . reportTime ) ;
Date date = null ;
if ( this . reportTime > 0 ) {
date = new Date ( ) ;
date . setTime ( this . reportTime ) ;
}
rows . add (
fillRow (
"临床诊断:" + this . clinicalDiagnosis ,
"检查日期:" + DateUtil . format ( date , "yyyy-MM-dd" ) )
"" ,
"检查日期:" + ( date = = null ? "" : DateUtil . format ( date , "yyyy-MM-dd" ) ) )
) ;
return rows ;
@ -181,31 +185,39 @@ public class PatientReportVo {
}
public List < PdfUtil . Row > toRow ( ) {
int colNum = 8 ;
int headNum = 2 ;
List < PdfUtil . Row > rows = new ArrayList < > ( ) ;
if ( CollectionUtil . isEmpty ( subReport ) ) {
PdfUtil . Row row = new PdfUtil . Row ( ) ;
PdfUtil . Cell cell1 = new PdfUtil . Cell ( ) ;
cell1 . setContent ( this . name + ( StrUtil . isBlank ( this . remark ) ? "" : "(" + this . remark + ")" ) ) ;
cell1 . setContent ( this . code + ( StrUtil . isBlank ( this . remark ) ? "" : "(" + this . remark + ")" ) ) ;
cell1 . setColSpan ( headNum ) ;
PdfUtil . Cell cell2 = new PdfUtil . Cell ( ) ;
cell2 . setContent ( this . score = = null ? "" : this . score + ( this . totalScore > 0 ? "/" + this . totalScore : "" ) ) ;
cell2 . setColSpan ( colNum - headNum ) ;
row . addCell ( cell1 ) ;
row . addCell ( cell2 ) ;
rows . add ( row ) ;
return rows ;
} else {
String mmse = "MMSE" ;
String npi = "NPI" ;
if ( mmse . equalsIgnoreCase ( this . code ) | | npi . equalsIgnoreCase ( this . code ) ) {
PdfUtil . Row row1 = new PdfUtil . Row ( ) ;
PdfUtil . Cell cell = new PdfUtil . Cell ( ) ;
cell . setContent ( this . nam e + ( StrUtil . isBlank ( this . remark ) ? "" : "(" + this . remark + ")" ) ) ;
cell . setContent ( this . cod e + ( StrUtil . isBlank ( this . remark ) ? "" : "(" + this . remark + ")" ) ) ;
cell . setRowSpan ( 2 ) ;
cell . setColSpan ( npi . equalsIgnoreCase ( this . code ) ? headNum : 1 ) ;
row1 . addCell ( cell ) ;
//被合并cell
PdfUtil . Row row2 = new PdfUtil . Row ( ) ;
// fillBlankCell(row2);
//子测评项
this . subReport . forEach ( reportScore - > {
fillRow ( row1 , row2 , reportScore . getName ( ) , reportScore . score = = null ? "" : reportScore . score + ( reportScore . totalScore > 0 ? "/" + reportScore . totalScore : "" ) ) ;
fillRow ( row1 , row2 , reportScore . getName ( ) , reportScore . score = = null ? "" : reportScore . score + ( reportScore . totalScore > 0 ? "/" + reportScore . totalScore : "" ) , npi . equalsIgnoreCase ( this . code ) ? new int [ ] { 3 , 3 } : null ) ;
} ) ;
// 总分
if ( mmse . equalsIgnoreCase ( this . code ) ) {
fillRow ( row1 , row2 , "总分" , this . score = = null ? "" : this . score + ( this . totalScore > 0 ? "/" + this . totalScore : "" ) ) ;
}
@ -213,75 +225,110 @@ public class PatientReportVo {
rows . add ( row2 ) ;
} else {
//moca
int firstIndex = 6 ;
int firstIndex = 5 ;
PdfUtil . Row row1 = new PdfUtil . Row ( ) ;
PdfUtil . Cell cell = new PdfUtil . Cell ( ) ;
cell . setContent ( this . name + ( StrUtil . isBlank ( this . remark ) ? "" : "(" + this . remark + ")" ) ) ;
cell . setRowSpan ( 5 ) ;
row1 . addCell ( cell ) ;
PdfUtil . Row row2 = new PdfUtil . Row ( ) ;
// fillBlankCell(row2);
for ( int i = 0 ; i < firstIndex ; i + + ) {
ReportScore reportScore = this . subReport . get ( i ) ;
String jy = "JY" ;
if ( jy . equalsIgnoreCase ( reportScore . getCode ( ) ) ) {
fillRow ( row1 , row2 , reportScore . getName ( ) , "" ) ;
fillRow ( row1 , row2 , reportScore . getName ( ) , "" , i = = 0 ? new int [ ] { 2 , 2 } : null ) ;
} else {
fillRow ( row1 , row2 , reportScore . getName ( ) , reportScore . score = = null ? "" : reportScore . score + ( reportScore . totalScore > 0 ? "/" + reportScore . totalScore : "" ) ) ;
fillRow ( row1 , row2 , reportScore . getName ( ) , reportScore . score = = null ? "" : reportScore . score + ( reportScore . totalScore > 0 ? "/" + reportScore . totalScore : "" ) , i = = 0 ? new int [ ] { 2 , 2 } : null ) ;
}
}
PdfUtil . Cell scoreNameCell = new PdfUtil . Cell ( ) ;
scoreNameCell . setContent ( "总分" ) ;
row1 . addCell ( scoreNameCell ) ;
PdfUtil . Cell scoreCell = new PdfUtil . Cell ( ) ;
scoreNameCell . setContent ( "总分" ) ;
row1 . addCell ( scoreNameCell ) ;
for ( ReportScore score : this . subReport ) {
if ( firstIndex = = 6 ) {
//设置总分
PdfUtil . Cell scoreTitleCell = new PdfUtil . Cell ( ) ;
scoreTitleCell . setContent ( "总分" ) ;
row1 . addCell ( scoreTitleCell ) ;
PdfUtil . Cell scoreScoreCell = new PdfUtil . Cell ( ) ;
scoreScoreCell . setContent ( this . score = = null ? "" : this . score + ( this . totalScore > 0 ? "/" + this . totalScore : "" ) ) ;
scoreScoreCell . setRowSpan ( 4 ) ;
row2 . addCell ( scoreScoreCell ) ;
rows . add ( row1 ) ;
rows . add ( row2 ) ;
//换行
row1 = new PdfUtil . Row ( ) ;
row2 = new PdfUtil . Row ( ) ;
}
firstIndex + + ;
}
scoreCell . setContent ( this . score = = null ? "" : this . score + ( this . totalScore > 0 ? "/" + this . totalScore : "" ) ) ;
scoreCell . setRowSpan ( 4 ) ;
row2 . addCell ( scoreCell ) ;
// fillBlankCell(row1, row2);
rows . add ( row1 ) ;
rows . add ( row2 ) ;
//下一行
PdfUtil . Row row3 = new PdfUtil . Row ( ) ;
PdfUtil . Row row4 = new PdfUtil . Row ( ) ;
PdfUtil . Row row5 = new PdfUtil . Row ( ) ;
// fillBlankCell(row3, row4, row5);
//延迟回忆特殊处理
String ychy = "YCHY" ;
for ( int i = firstIndex ; i < this . subReport . size ( ) ; i + + ) {
ReportScore reportScore = this . subReport . get ( i ) ;
//设置名字
PdfUtil . Cell scoreTitleCell = new PdfUtil . Cell ( ) ;
scoreTitleCell . setContent ( reportScore . getName ( ) ) ;
scoreTitleCell . setColSpan ( ychy . equalsIgnoreCase ( reportScore . getCode ( ) ) ? 2 : 1 ) ;
row3 . addCell ( scoreTitleCell ) ;
//设置子类
if ( ychy . equalsIgnoreCase ( reportScore . getCode ( ) ) ) {
for ( int j = 0 ; j < reportScore . subReport . size ( ) ; j + + ) {
ReportScore subScore = reportScore . getSubReport ( ) . get ( j ) ;
PdfUtil . Cell subCell = new PdfUtil . Cell ( ) ;
subCell . setContent ( subScore . name + ( subScore . getScore ( ) = = null ? " " : subScore . getScore ( ) ) + subScore . getRemark ( ) ) ;
if ( j = = 0 ) {
row4 . addCell ( subCell ) ;
} else {
row5 . addCell ( subCell ) ;
}
}
}
PdfUtil . Cell scoreScoreCell = new PdfUtil . Cell ( ) ;
scoreScoreCell . setContent ( reportScore . score = = null ? "" : reportScore . score + ( reportScore . totalScore > 0 ? "/" + reportScore . totalScore : "" ) ) ;
scoreScoreCell . setRowSpan ( 2 ) ;
row4 . addCell ( scoreScoreCell ) ;
// fillBlankCell(row5);
}
// fillBlankCell(row3);
// fillBlankCell(row3, row4, row5);
rows . add ( row3 ) ;
rows . add ( row4 ) ;
rows . add ( row5 ) ;
}
}
PdfUtil . Row row = new PdfUtil . Row ( ) ;
PdfUtil . Row descR ow = new PdfUtil . Row ( ) ;
PdfUtil . Cell cell = new PdfUtil . Cell ( ) ;
cell . setColSpan ( colNum ) ;
cell . setContent ( this . description ) ;
descRow . addCell ( cell ) ;
rows . add ( descRow ) ;
return rows ;
}
private void fillRow ( PdfUtil . Row row1 , PdfUtil . Row row2 , String name , String score ) {
/ * *
* 添加一个空格
* @param rows
* /
private void fillBlankCell ( PdfUtil . Row . . . rows ) {
for ( PdfUtil . Row row : rows ) {
PdfUtil . Cell cell = new PdfUtil . Cell ( ) ;
row . addCell ( cell ) ;
}
}
private void fillRow ( PdfUtil . Row row1 , PdfUtil . Row row2 , String name , String score , int . . . colspan ) {
//名称
PdfUtil . Cell cell1 = new PdfUtil . Cell ( ) ;
cell1 . setContent ( name ) ;
cell1 . setColSpan ( colspan = = null | | colspan . length = = 0 ? 1 : colspan [ 0 ] ) ;
row1 . addCell ( cell1 ) ;
//分数
PdfUtil . Cell cell2 = new PdfUtil . Cell ( ) ;
cell2 . setContent ( score ) ;
cell2 . setColSpan ( colspan = = null | | colspan . length < = 1 ? 1 : colspan [ 1 ] ) ;
row2 . addCell ( cell2 ) ;
}
}