|
@@ -13,6 +13,7 @@ import com.diagbot.enums.SysTypeEnum;
|
|
|
import com.diagbot.enums.VisibleIdTypeEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.exception.ServiceErrorCode;
|
|
|
import com.diagbot.idc.VisibleIdCreater;
|
|
|
import com.diagbot.service.DoctorInfoService;
|
|
|
import com.diagbot.service.HospitalDeptService;
|
|
@@ -71,7 +72,7 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
|
|
|
String hospitalCode = getTopPatientInfoDjVO.getHospitalCode();
|
|
|
QueryWrapper<SysSet> sysSetQe = new QueryWrapper<>();
|
|
|
sysSetQe.eq("hospital_code", hospitalCode);
|
|
|
- sysSetQe.eq("sys_type", 17);
|
|
|
+ sysSetQe.eq("sys_type", SysTypeEnum.PREC_SERVICE.getKey());
|
|
|
sysSetQe.eq("code", "junior_hospital");
|
|
|
SysSet sysSet = sysSetFacade.getOne(sysSetQe, true);
|
|
|
if (sysSet != null && StringUtil.isNotBlank(sysSet.getValue())) {
|
|
@@ -112,23 +113,18 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
|
|
|
public List<SignInDTO> signIn(SignInVO signInVO) {
|
|
|
List<SignInDTO> retList = null;
|
|
|
|
|
|
- QueryWrapper<SysSet> sysSetQe = new QueryWrapper<>();
|
|
|
- sysSetQe.eq("hospital_code", signInVO.getHospitalCode());
|
|
|
- sysSetQe.eq("sys_type", SysTypeEnum.PREC_SERVICE.getKey());
|
|
|
- sysSetQe.and(i -> i.eq("code", "patientinfo").or().eq("code", "junior_hospital"));
|
|
|
- Map<String, String> sysSetCodeValue = sysSetFacade.list(sysSetQe).stream()
|
|
|
- .collect(Collectors.toMap(SysSet::getCode, i -> i.getValue()));
|
|
|
-
|
|
|
RegisterInfoDTO rif = getRegisterInfo(signInVO);
|
|
|
if (rif != null) {
|
|
|
- generateByRif(rif, StringUtil.isNotBlank(sysSetCodeValue.get("junior_hospital")));
|
|
|
+ generateByRif(rif);
|
|
|
retList = rifConverSin(rif);
|
|
|
- } else if (signInVO.getPatientInfoType().equals("101")
|
|
|
- && StringUtil.isNotBlank(sysSetCodeValue.get("patientinfo"))
|
|
|
- && sysSetCodeValue.get("patientinfo").equals("1")) {
|
|
|
+ } else {
|
|
|
retList = autoGenePatinfo(signInVO);
|
|
|
}
|
|
|
|
|
|
+ if (retList == null) {
|
|
|
+ throw new CommonException(ServiceErrorCode.IQC_NOT_FOUND);
|
|
|
+ }
|
|
|
+
|
|
|
return retList;
|
|
|
}
|
|
|
|
|
@@ -139,6 +135,27 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
|
|
|
* @return
|
|
|
*/
|
|
|
private List<SignInDTO> autoGenePatinfo(SignInVO signInVO) {
|
|
|
+ QueryWrapper<SysSet> sysSetQe = new QueryWrapper<>();
|
|
|
+ sysSetQe.eq("sys_type", SysTypeEnum.PREC_SERVICE.getKey());
|
|
|
+ sysSetQe.and(qe1 -> qe1
|
|
|
+ .and(qe2 -> qe2
|
|
|
+ .eq("hospital_code", signInVO.getHospitalCode())
|
|
|
+ .eq("code", "patientinfo"))
|
|
|
+ .or(qe3 -> qe3
|
|
|
+ .eq("hospital_code",
|
|
|
+ StringUtil.isBlank(signInVO.getSonHospitalCode()) ? signInVO.getHospitalCode()
|
|
|
+ : signInVO.getSonHospitalCode())
|
|
|
+ .eq("code", "default_dept")));
|
|
|
+ Map<String, String> sysSetCodeValue = sysSetFacade.list(sysSetQe).stream()
|
|
|
+ .collect(Collectors.toMap(SysSet::getCode, i -> i.getValue()));
|
|
|
+
|
|
|
+ if (StringUtil.isBlank(sysSetCodeValue.get("patientinfo")) || !sysSetCodeValue.get("patientinfo").equals("1")) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (!signInVO.getPatientInfoType().equals("101")) {
|
|
|
+ throw new CommonException(ServiceErrorCode.IDCARD_LOGIN);
|
|
|
+ }
|
|
|
+
|
|
|
List<SignInDTO> retList = Lists.newArrayList();
|
|
|
SignInDTO signInDTO = new SignInDTO();
|
|
|
signInDTO.setHospitalCode(signInVO.getHospitalCode());
|
|
@@ -146,27 +163,22 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
|
|
|
signInDTO.setSonHospitalCode(signInVO.getSonHospitalCode());
|
|
|
signInDTO.setSonHospitalName(signInVO.getSonHospitalName());
|
|
|
|
|
|
- QueryWrapper<SysSet> sysSetQe = new QueryWrapper<>();
|
|
|
- sysSetQe.eq("hospital_code",
|
|
|
- StringUtil.isBlank(signInVO.getSonHospitalCode()) ? signInVO.getHospitalCode() : signInVO.getSonHospitalCode());
|
|
|
- sysSetQe.eq("sys_type", SysTypeEnum.PREC_SERVICE.getKey());
|
|
|
- sysSetQe.eq("code", "default_dept");
|
|
|
- String hospitalDeptCode = sysSetFacade.getOne(sysSetQe).getValue();
|
|
|
+ String hospitalDeptCode = sysSetCodeValue.get("default_dept");
|
|
|
signInDTO.setHospitalDeptCode(hospitalDeptCode);
|
|
|
|
|
|
QueryWrapper<HospitalDept> hospitalDeptQe = new QueryWrapper<>();
|
|
|
hospitalDeptQe.eq("hospital_code",
|
|
|
StringUtil.isBlank(signInVO.getSonHospitalCode()) ? signInVO.getHospitalCode() : signInVO.getSonHospitalCode());
|
|
|
hospitalDeptQe.eq("code", hospitalDeptCode);
|
|
|
- String hospitalDeptName = hospitalDeptFacade.getOne(hospitalDeptQe, true).getName();
|
|
|
- signInDTO.setHospitalDeptName(hospitalDeptName);
|
|
|
+ signInDTO.setHospitalDeptName(hospitalDeptFacade.getOne(hospitalDeptQe, false).getName());
|
|
|
|
|
|
QueryWrapper<PatientInfo> patientInfoQe = new QueryWrapper<>();
|
|
|
patientInfoQe.eq("id_no", signInVO.getPatientInfo());
|
|
|
patientInfoQe.eq("name", signInVO.getPatientName());
|
|
|
- PatientInfo patientInfo = getOne(patientInfoQe, true);
|
|
|
+ PatientInfo patientInfo = getOne(patientInfoQe, false);
|
|
|
if (patientInfo == null) {
|
|
|
patientInfo = new PatientInfo();
|
|
|
+ patientInfo.setName(signInVO.getPatientName());
|
|
|
patientInfo.setSex(IdCard.getGenderByIdCard(signInVO.getPatientInfo()));
|
|
|
patientInfo.setBirthday(DateUtil.parseDate(IdCard.getBirthByIdCard(signInVO.getPatientInfo()), "yyyyMMdd"));
|
|
|
|
|
@@ -216,9 +228,8 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
|
|
|
* 由挂号信息检查病人科室医生信息,有更新,无插入
|
|
|
*
|
|
|
* @param rif
|
|
|
- * @param isHason 是否有子医院
|
|
|
*/
|
|
|
- private void generateByRif(RegisterInfoDTO rif, boolean isHason) {
|
|
|
+ private void generateByRif(RegisterInfoDTO rif) {
|
|
|
String hospitalCode = rif.getHospitalCode();
|
|
|
String hospitalName = rif.getHospitalName();
|
|
|
String sonHospitalCode = rif.getSonHospitalCode();
|
|
@@ -228,7 +239,7 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
|
|
|
QueryWrapper<PatientInfo> patientInfoQe = new QueryWrapper<>();
|
|
|
patientInfoQe.eq("hospital_code", hospitalCode);
|
|
|
patientInfoQe.eq("code", patientInfo.getCode());
|
|
|
- PatientInfo patientInfoQuery = getOne(patientInfoQe, true);
|
|
|
+ PatientInfo patientInfoQuery = getOne(patientInfoQe, false);
|
|
|
if (patientInfoQuery == null) {
|
|
|
patientInfo.setHospitalCode(hospitalCode);
|
|
|
save(patientInfo);
|
|
@@ -242,7 +253,7 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
|
|
|
.map(i -> i.getHospitalDeptCode())
|
|
|
.collect(Collectors.toList());
|
|
|
QueryWrapper<HospitalDept> hospitalDeptQe = new QueryWrapper<>();
|
|
|
- hospitalDeptQe.eq("hospital_code", isHason ? sonHospitalCode : hospitalCode);
|
|
|
+ hospitalDeptQe.eq("hospital_code", StringUtil.isBlank(sonHospitalCode) ? hospitalCode : sonHospitalCode);
|
|
|
hospitalDeptQe.in("code", deptCodeList);
|
|
|
Map<String, HospitalDept> deptMap = hospitalDeptFacade.list(hospitalDeptQe)
|
|
|
.stream()
|
|
@@ -254,8 +265,8 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
|
|
|
HospitalDept hospitalDeptQuery = deptMap.get(i.getHospitalDeptCode());
|
|
|
if (hospitalDeptQuery == null) {
|
|
|
HospitalDept hospitalDept = new HospitalDept();
|
|
|
- hospitalDept.setHospitalCode(isHason ? sonHospitalCode : hospitalCode);
|
|
|
- hospitalDept.setHospitalName(isHason ? sonHospitalName : hospitalName);
|
|
|
+ hospitalDept.setHospitalCode(StringUtil.isNotBlank(sonHospitalCode) ? sonHospitalCode : hospitalCode);
|
|
|
+ hospitalDept.setHospitalName(StringUtil.isNotBlank(sonHospitalCode) ? sonHospitalName : hospitalName);
|
|
|
hospitalDept.setCode(i.getHospitalDeptCode());
|
|
|
hospitalDept.setName(i.getHospitalDeptName());
|
|
|
hospitalDept.setconceptDeptName("全科");
|
|
@@ -285,13 +296,11 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
|
|
|
.forEach(i -> {
|
|
|
DoctorInfo doctorInfo = new DoctorInfo();
|
|
|
DoctorInfo doctorInfoQuery = doctorMap.get(i.getCode());
|
|
|
- if (doctorInfoQuery == null) {
|
|
|
- BeanUtil.copyProperties(i, doctorInfo);
|
|
|
- doctorInfo.setHospitalCode(hospitalCode);
|
|
|
- } else {
|
|
|
+ if (doctorInfoQuery != null) {
|
|
|
BeanUtil.copyProperties(doctorInfoQuery, doctorInfo);
|
|
|
- BeanUtil.copyProperties(i, doctorInfo);
|
|
|
}
|
|
|
+ BeanUtil.copyProperties(i, doctorInfo);
|
|
|
+ doctorInfo.setHospitalCode(hospitalCode);
|
|
|
doctorSaveOrUpdateList.add(doctorInfo);
|
|
|
});
|
|
|
if (ListUtil.isNotEmpty(doctorSaveOrUpdateList)) {
|