|
|
@@ -1,6 +1,7 @@
|
|
|
package com.fs.hisStore.service.impl;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
@@ -380,7 +381,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
return fsUserInformationCollection;
|
|
|
}
|
|
|
|
|
|
- //个微信息采集确认并生成医生待开处方
|
|
|
+ //个微信息采集用户确认并生成医生待开处方
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R generateFormalPrescription(CollectionInfoConfirmParam param) {
|
|
|
@@ -397,8 +398,8 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
collection.setPersonalCollectStatus(PostPayPrescStatusEnum.FULLY_COLLECTED_DATA.getCode());
|
|
|
if (fsUserInformationCollectionMapper.updateFsUserInformationCollection(collection) > 0) {
|
|
|
//新增fs_prescribe处方信息
|
|
|
- FsPrescribe fsPrescribe = transformCollectionDtoToFsPrescribe(param, collection);
|
|
|
- fsPrescribe.setCollectionId(collection.getId());
|
|
|
+ FsPrescribe fsPrescribe = transformCollectionParamToFsPrescribe(param, collection);
|
|
|
+
|
|
|
int addPrescribeResult = fsPrescribeMapper.insertFsPrescribe(fsPrescribe);
|
|
|
|
|
|
//存入医生确认统计时间数据
|
|
|
@@ -415,7 +416,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
return R.error("用户确认失败");
|
|
|
}
|
|
|
|
|
|
- private FsPrescribe transformCollectionDtoToFsPrescribe(CollectionInfoConfirmParam param, FsUserInformationCollection fsUserInformationCollection) {
|
|
|
+ private FsPrescribe transformCollectionParamToFsPrescribe(CollectionInfoConfirmParam param, FsUserInformationCollection fsUserInformationCollection) {
|
|
|
//构建处方编号
|
|
|
String prescribeCode = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
FsPrescribe fsPrescribe = new FsPrescribe();
|
|
|
@@ -424,21 +425,8 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
fsPrescribe.setDoctorConfirm(0);//未确认
|
|
|
fsPrescribe.setUsageJson(JSON.toJSONString(param.getAnswers()));
|
|
|
fsPrescribe.setHistoryAllergic(fsUserInformationCollection.getAllergy());
|
|
|
-
|
|
|
fsPrescribe.setPrescribeCode(prescribeCode);
|
|
|
- fsPrescribe.setPatientAge(String.valueOf(fsUserInformationCollection.getAge()));
|
|
|
- fsPrescribe.setPatientId(fsUserInformationCollection.getUserId());
|
|
|
-
|
|
|
- fsPrescribe.setPatientName(fsUserInformationCollection.getUserName());
|
|
|
-
|
|
|
- fsPrescribe.setPatientGender(String.valueOf(fsUserInformationCollection.getSex() == 1 ? 1 : 0));
|
|
|
- fsPrescribe.setPatientAge(String.valueOf(fsUserInformationCollection.getAge()));
|
|
|
- FsUser fsUser = fsUserMapper.selectFsUserById(fsUserInformationCollection.getUserId());
|
|
|
- if (fsUser == null) {
|
|
|
- log.error("用户信息获取异常:" + fsUserInformationCollection.getUserId());
|
|
|
- throw new CustomException("网络异常,请稍后再试!");
|
|
|
- }
|
|
|
- fsPrescribe.setPatientTel(fsUser.getPhone());
|
|
|
+ fsPrescribe.setCollectionId(fsUserInformationCollection.getId());
|
|
|
//查询销售绑定医生
|
|
|
CompanyUser companyUser = companyUserMapper.selectCompanyUserByCompanyUserId(fsUserInformationCollection.getCompanyUserId());
|
|
|
if (companyUser == null || companyUser.getDoctorId() == null) {
|
|
|
@@ -452,7 +440,6 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
log.error("开方医生信息获取异常:" + companyUser.getDoctorId());
|
|
|
throw new CustomException("网络异常,请稍后再试!");
|
|
|
}
|
|
|
-
|
|
|
fsPrescribe.setPrescribeDoctorId(fsDoctor.getDoctorId());
|
|
|
fsPrescribe.setPrescribeDoctorSignUrl(fsDoctor.getSignUrl());
|
|
|
//分配在线的随机药师
|
|
|
@@ -467,6 +454,14 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
log.error("分配药师失败 - 处方号:{}", prescribeCode, e);
|
|
|
throw new CustomException("网络异常,请稍后再试!");
|
|
|
}
|
|
|
+ //组装处方表里的患者信息
|
|
|
+ String birthday = String.valueOf(param.getPatientInfo().getBirthday());
|
|
|
+ fsPrescribe.setPatientBirthday(birthday);
|
|
|
+ fsPrescribe.setPatientAge(String.valueOf(calculateAge(birthday)));
|
|
|
+ fsPrescribe.setPatientId(param.getPatientInfo().getPatientId());
|
|
|
+ fsPrescribe.setPatientName(param.getPatientInfo().getPatientName());
|
|
|
+ fsPrescribe.setPatientTel(param.getPatientInfo().getMobile());
|
|
|
+ fsPrescribe.setPatientGender(String.valueOf(param.getPatientInfo().getSex()));
|
|
|
return fsPrescribe;
|
|
|
}
|
|
|
|
|
|
@@ -477,6 +472,42 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据出生日期计算年龄
|
|
|
+ * @param birthday 出生日期,格式:yyyy-MM-dd
|
|
|
+ * @return Integer类型的年龄,如果入参无效返回null
|
|
|
+ */
|
|
|
+ public static Integer calculateAge(String birthday) {
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(birthday)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ sdf.setLenient(false);
|
|
|
+ Date birthDate = sdf.parse(birthday);
|
|
|
+
|
|
|
+ Calendar birthCal = Calendar.getInstance();
|
|
|
+ birthCal.setTime(birthDate);
|
|
|
+
|
|
|
+ Calendar nowCal = Calendar.getInstance();
|
|
|
+
|
|
|
+ int age = nowCal.get(Calendar.YEAR) - birthCal.get(Calendar.YEAR);
|
|
|
+
|
|
|
+ // 如果今年还没过生日,年龄减1
|
|
|
+ if (nowCal.get(Calendar.MONTH) < birthCal.get(Calendar.MONTH) ||
|
|
|
+ (nowCal.get(Calendar.MONTH) == birthCal.get(Calendar.MONTH) &&
|
|
|
+ nowCal.get(Calendar.DAY_OF_MONTH) < birthCal.get(Calendar.DAY_OF_MONTH))) {
|
|
|
+ age--;
|
|
|
+ }
|
|
|
+
|
|
|
+ return age;
|
|
|
+
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new CustomException("用户年龄计算异常", 500);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 批量删除用户信息采集
|
|
|
*
|
|
|
@@ -1646,7 +1677,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
@Override
|
|
|
public List<FsUserInformationCollectionOverviewVo> fullyCollectionInfoList(FsUserInformationCollectionOverviewDTO queryDto) {
|
|
|
queryDto.setCompleteStatus(1);//已完善信息标识
|
|
|
- queryDto.setQwTag(1);//个微采集表
|
|
|
+ queryDto.setQwTag(1);//个微标识
|
|
|
PageHelper.startPage(queryDto.getPageNum(), queryDto.getPageSize());
|
|
|
List<FsUserInformationCollectionOverviewVo> resultList=fsUserInformationCollectionMapper.selectUserInformationCollectionOverviewByPage(queryDto);
|
|
|
if (CollectionUtils.isEmpty(resultList)){
|