|
@@ -22,12 +22,15 @@ import com.diagbot.vo.data.ADeleteFlagVO;
|
|
|
import com.diagbot.vo.data.AMedicalRecordVO;
|
|
|
import com.diagbot.vo.data.APlaceFileVO;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import io.swagger.models.auth.In;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -158,19 +161,33 @@ public class ABehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
*/
|
|
|
private Long initQcTypeId(BehospitalInfo s) {
|
|
|
Long qcTypeId = Long.valueOf("0");
|
|
|
+ //判断一下是否是日间病例
|
|
|
+ if (null != s.getLeaveHospitalDate()&& null !=s.getBehospitalDate()){
|
|
|
+ if (this.differentDays(s.getBehospitalDate(),s.getLeaveHospitalDate())<=1) {
|
|
|
+ return qcTypeId;
|
|
|
+ }
|
|
|
+ }
|
|
|
//判断文书表中是否有入院记录文书
|
|
|
- MedicalRecord medicalRecord= aMedicalRecordFacade.getOne(new QueryWrapper<MedicalRecord>()
|
|
|
+ List<MedicalRecord> medicalRecordList= aMedicalRecordFacade.list(new QueryWrapper<MedicalRecord>()
|
|
|
.eq("mode_id",1)
|
|
|
.eq("behospital_code",s.getBehospitalCode())
|
|
|
.eq("hospital_id",s.getHospitalId())
|
|
|
.eq("is_deleted",IsDeleteEnum.N));
|
|
|
- if (medicalRecord != null){
|
|
|
- //根据科室
|
|
|
+ //根据疾病来判断是否有对映的质控类型
|
|
|
+ List<QcType> qcTypes =qcTypeFacade.list(new QueryWrapper<QcType>()
|
|
|
+ .eq("name", StringUtils.isNotEmpty(s.getDiagnose())?s.getDiagnose():"")
|
|
|
+ .eq("hospital_id",s.getHospitalId())
|
|
|
+ .eq("is_deleted",IsDeleteEnum.N));
|
|
|
+ if (qcTypes.size()>0){
|
|
|
+ qcTypeId=qcTypes.get(0).getId();
|
|
|
+ }else if (medicalRecordList.size()>=1){
|
|
|
+ //根据科室来判断是否有对映的质控类型
|
|
|
List<QcType> qcTypeList =qcTypeFacade.list(new QueryWrapper<QcType>()
|
|
|
.eq("beh_dept_id",s.getBehDeptId())
|
|
|
.eq("hospital_id",s.getHospitalId())
|
|
|
.eq("is_deleted",IsDeleteEnum.N));
|
|
|
if (qcTypeList.size()==0){
|
|
|
+ //没有对映的科室就根据病人的性别来判断
|
|
|
QcType qcType = qcTypeFacade.getOne(new QueryWrapper<QcType>()
|
|
|
.eq("default_module",1)
|
|
|
.eq("hospital_id",s.getHospitalId())
|
|
@@ -180,6 +197,7 @@ public class ABehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
}else if (qcTypeList.size()==1){
|
|
|
qcTypeId =qcTypeList.get(0).getId();
|
|
|
}else {
|
|
|
+ //有多个科室信息就根据病人的男女来判断有对映的质控类型
|
|
|
QcType qcType =new QcType();
|
|
|
qcTypeList.forEach(qc->{
|
|
|
if (qc.getSex().equals(s.getSex()))
|
|
@@ -187,26 +205,6 @@ public class ABehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
});
|
|
|
qcTypeId =qcType.getId();
|
|
|
}
|
|
|
-// //根据科室查找对应质控类型
|
|
|
-// QcType qcTypeList = qcTypeFacade.getOne(new QueryWrapper<QcType>()
|
|
|
-// .eq("beh_dept_id", s.getBehDeptId())
|
|
|
-// .eq("hospital_id", s.getHospitalId())
|
|
|
-// .eq("default_module", 0)
|
|
|
-// .eq("sex",s.getSex())
|
|
|
-// .eq("is_deleted", IsDeleteEnum.N));
|
|
|
-// if(qcTypeList == null){
|
|
|
-// //无质控类型时,新增后初始化
|
|
|
-// QcType qcType = qcTypeFacade.getOne(new QueryWrapper<QcType>()
|
|
|
-// .eq("default_module", 1)
|
|
|
-// .eq("hospital_id", s.getHospitalId())
|
|
|
-// .eq("sex",s.getSex())
|
|
|
-// .eq("is_deleted", IsDeleteEnum.N));
|
|
|
-// if(qcType!=null){
|
|
|
-// qcTypeId = qcType.getId();
|
|
|
-// }
|
|
|
-// }else {
|
|
|
-// qcTypeId = qcTypeList.getId();
|
|
|
-// }
|
|
|
}
|
|
|
return qcTypeId;
|
|
|
}
|
|
@@ -260,4 +258,39 @@ public class ABehospitalInfoFacade extends BehospitalInfoServiceImpl {
|
|
|
return RespDTO.onError(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public int differentDays(Date date1,Date date2) {
|
|
|
+ Calendar cal1 = Calendar.getInstance();
|
|
|
+ cal1.setTime(date1);
|
|
|
+
|
|
|
+ Calendar cal2 = Calendar.getInstance();
|
|
|
+ cal2.setTime(date2);
|
|
|
+ int day1= cal1.get(Calendar.DAY_OF_YEAR);
|
|
|
+ int day2 = cal2.get(Calendar.DAY_OF_YEAR);
|
|
|
+
|
|
|
+ int year1 = cal1.get(Calendar.YEAR);
|
|
|
+ int year2 = cal2.get(Calendar.YEAR);
|
|
|
+ if(year1 != year2) //不同一年
|
|
|
+ {
|
|
|
+ int timeDistance = 0 ;
|
|
|
+ for(int i = year1 ; i < year2 ; i ++)
|
|
|
+ {
|
|
|
+ if(i%4==0 && i%100!=0 || i%400==0) //闰年
|
|
|
+ {
|
|
|
+ timeDistance += 366;
|
|
|
+ }
|
|
|
+ else //不是闰年
|
|
|
+ {
|
|
|
+ timeDistance += 365;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return timeDistance + (day2-day1) ;
|
|
|
+ }
|
|
|
+ else //同一年
|
|
|
+ {
|
|
|
+ System.out.println("判断day2 - day1 : " + (day2-day1));
|
|
|
+ return day2-day1;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|