|
@@ -1,5 +1,6 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.diagbot.dto.GetTopPatientInfoDjDTO;
|
|
|
import com.diagbot.dto.RegisterInfoDTO;
|
|
@@ -118,10 +119,10 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
|
|
|
public List<SignInDTO> signIn(SignInVO signInVO) {
|
|
|
List<SignInDTO> retList = null;
|
|
|
|
|
|
- RegisterInfoDTO rif = getRegisterInfo(signInVO);
|
|
|
- if (rif != null) {
|
|
|
- generateByRif(rif);
|
|
|
- retList = rifConverSin(rif);
|
|
|
+ List<RegisterInfoDTO> rifList = getRegisterInfo(signInVO);
|
|
|
+ if (ListUtil.isNotEmpty(rifList)) {
|
|
|
+ generateByRif(rifList);
|
|
|
+ retList = rifConverSin(rifList);
|
|
|
} else {
|
|
|
retList = autoGenePatinfo(signInVO);
|
|
|
}
|
|
@@ -207,28 +208,30 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
|
|
|
/**
|
|
|
* his返回的挂号信息转化给前端
|
|
|
*
|
|
|
- * @param rif
|
|
|
+ * @param rifList
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<SignInDTO> rifConverSin(RegisterInfoDTO rif) {
|
|
|
+ private List<SignInDTO> rifConverSin(List<RegisterInfoDTO> rifList) {
|
|
|
List<SignInDTO> retList = Lists.newArrayList();
|
|
|
- rif.getDetail().forEach(i -> {
|
|
|
- SignInDTO signInDTO = new SignInDTO(
|
|
|
- rif.getHospitalCode(),
|
|
|
- rif.getHospitalName(),
|
|
|
- rif.getSonHospitalCode(),
|
|
|
- rif.getSonHospitalName(),
|
|
|
- i.getHospitalDeptCode(),
|
|
|
- i.getHospitalDeptName(),
|
|
|
- i.getDoctorInfo().getCode(),
|
|
|
- i.getDoctorInfo().getName(),
|
|
|
- rif.getPatientInfo().getCode(),
|
|
|
- rif.getPatientInfo().getName(),
|
|
|
- i.getRecordTime(),
|
|
|
- i.getRecordId(),
|
|
|
- i.getRegisterNum()
|
|
|
- );
|
|
|
- retList.add(signInDTO);
|
|
|
+ rifList.forEach(rif -> {
|
|
|
+ rif.getDetail().forEach(i -> {
|
|
|
+ SignInDTO signInDTO = new SignInDTO(
|
|
|
+ rif.getHospitalCode(),
|
|
|
+ rif.getHospitalName(),
|
|
|
+ rif.getSonHospitalCode(),
|
|
|
+ rif.getSonHospitalName(),
|
|
|
+ i.getHospitalDeptCode(),
|
|
|
+ i.getHospitalDeptName(),
|
|
|
+ i.getDoctorInfo().getCode(),
|
|
|
+ i.getDoctorInfo().getName(),
|
|
|
+ rif.getPatientInfo().getCode(),
|
|
|
+ rif.getPatientInfo().getName(),
|
|
|
+ i.getRecordTime(),
|
|
|
+ i.getRecordId(),
|
|
|
+ i.getRegisterNum()
|
|
|
+ );
|
|
|
+ retList.add(signInDTO);
|
|
|
+ });
|
|
|
});
|
|
|
return retList;
|
|
|
}
|
|
@@ -236,85 +239,97 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
|
|
|
/**
|
|
|
* 由挂号信息检查病人科室医生信息,有更新,无插入
|
|
|
*
|
|
|
- * @param rif
|
|
|
+ * @param rifList
|
|
|
*/
|
|
|
- private void generateByRif(RegisterInfoDTO rif) {
|
|
|
- String hospitalCode = rif.getHospitalCode();
|
|
|
- String hospitalName = rif.getHospitalName();
|
|
|
- String sonHospitalCode = rif.getSonHospitalCode();
|
|
|
- String sonHospitalName = rif.getSonHospitalName();
|
|
|
-
|
|
|
- PatientInfo patientInfo = rif.getPatientInfo();
|
|
|
- QueryWrapper<PatientInfo> patientInfoQe = new QueryWrapper<>();
|
|
|
- patientInfoQe.eq("hospital_code", hospitalCode);
|
|
|
- patientInfoQe.eq("code", patientInfo.getCode());
|
|
|
- PatientInfo patientInfoQuery = getOne(patientInfoQe, false);
|
|
|
- if (patientInfoQuery == null) {
|
|
|
+ private void generateByRif(List<RegisterInfoDTO> rifList) {
|
|
|
+ rifList.forEach(rif -> {
|
|
|
+ String hospitalCode = rif.getHospitalCode();
|
|
|
+ String hospitalName = rif.getHospitalName();
|
|
|
+ String sonHospitalCode = rif.getSonHospitalCode();
|
|
|
+ String sonHospitalName = rif.getSonHospitalName();
|
|
|
+
|
|
|
+ PatientInfo patientInfo = rif.getPatientInfo();
|
|
|
+ QueryWrapper<PatientInfo> patientInfoQe = new QueryWrapper<>();
|
|
|
+ patientInfoQe.eq("hospital_code", hospitalCode);
|
|
|
+ patientInfoQe.eq("code", patientInfo.getCode());
|
|
|
+ PatientInfo patientInfoQuery = getOne(patientInfoQe, false);
|
|
|
+ PatientInfo saveOrUpat = new PatientInfo();
|
|
|
+ Long patId = null;
|
|
|
+ if (patientInfoQuery != null) {
|
|
|
+ patId = patientInfoQuery.getId();
|
|
|
+ }
|
|
|
+ BeanUtil.copyProperties(patientInfoQuery, saveOrUpat);
|
|
|
+ BeanUtil.copyProperties(patientInfo, saveOrUpat);
|
|
|
+ patientInfo.setId(patId);
|
|
|
patientInfo.setHospitalCode(hospitalCode);
|
|
|
- save(patientInfo);
|
|
|
- } else {
|
|
|
- BeanUtil.copyProperties(patientInfo, patientInfoQuery);
|
|
|
- updateById(patientInfoQuery);
|
|
|
- }
|
|
|
+ saveOrUpdate(saveOrUpat);
|
|
|
|
|
|
- List<String> deptCodeList = rif.getDetail().stream()
|
|
|
- .filter(i -> StringUtil.isNotBlank(i.getHospitalDeptCode()) && StringUtil.isNotBlank(i.getHospitalDeptName()))
|
|
|
- .map(i -> i.getHospitalDeptCode())
|
|
|
- .collect(Collectors.toList());
|
|
|
- QueryWrapper<HospitalDept> hospitalDeptQe = new QueryWrapper<>();
|
|
|
- hospitalDeptQe.eq("hospital_code", StringUtil.isBlank(sonHospitalCode) ? hospitalCode : sonHospitalCode);
|
|
|
- hospitalDeptQe.in("code", deptCodeList);
|
|
|
- Map<String, HospitalDept> deptMap = hospitalDeptFacade.list(hospitalDeptQe)
|
|
|
- .stream()
|
|
|
- .collect(Collectors.toMap(HospitalDept::getCode, i -> i));
|
|
|
- List<HospitalDept> deptSaveOrUpdateList = Lists.newArrayList();
|
|
|
- rif.getDetail().stream()
|
|
|
- .filter(i -> StringUtil.isNotBlank(i.getHospitalDeptCode()) && StringUtil.isNotBlank(i.getHospitalDeptName()))
|
|
|
- .forEach(i -> {
|
|
|
- HospitalDept hospitalDeptQuery = deptMap.get(i.getHospitalDeptCode());
|
|
|
- if (hospitalDeptQuery == null) {
|
|
|
- HospitalDept hospitalDept = new HospitalDept();
|
|
|
- hospitalDept.setHospitalCode(StringUtil.isNotBlank(sonHospitalCode) ? sonHospitalCode : hospitalCode);
|
|
|
- hospitalDept.setHospitalName(StringUtil.isNotBlank(sonHospitalCode) ? sonHospitalName : hospitalName);
|
|
|
- hospitalDept.setCode(i.getHospitalDeptCode());
|
|
|
- hospitalDept.setName(i.getHospitalDeptName());
|
|
|
- hospitalDept.setconceptDeptName("全科");
|
|
|
- deptSaveOrUpdateList.add(hospitalDept);
|
|
|
- } else {
|
|
|
- hospitalDeptQuery.setName(i.getHospitalDeptName());
|
|
|
- deptSaveOrUpdateList.add(hospitalDeptQuery);
|
|
|
- }
|
|
|
- });
|
|
|
- if (ListUtil.isNotEmpty(deptSaveOrUpdateList)) {
|
|
|
- hospitalDeptService.saveBatch(deptSaveOrUpdateList);
|
|
|
- }
|
|
|
+ List<String> deptCodeList = rif.getDetail().stream()
|
|
|
+ .filter(i -> StringUtil.isNotBlank(i.getHospitalDeptCode()) && StringUtil.isNotBlank(i.getHospitalDeptName()))
|
|
|
+ .map(i -> i.getHospitalDeptCode())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ QueryWrapper<HospitalDept> hospitalDeptQe = new QueryWrapper<>();
|
|
|
+ hospitalDeptQe.eq("hospital_code", StringUtil.isBlank(sonHospitalCode) ? hospitalCode : sonHospitalCode);
|
|
|
+ hospitalDeptQe.in("code", deptCodeList);
|
|
|
+ Map<String, HospitalDept> deptMap = hospitalDeptFacade.list(hospitalDeptQe)
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(HospitalDept::getCode, i -> i));
|
|
|
+ List<HospitalDept> deptSaveOrUpdateList = Lists.newArrayList();
|
|
|
+ rif.getDetail().stream()
|
|
|
+ .filter(i -> StringUtil.isNotBlank(i.getHospitalDeptCode()) && StringUtil.isNotBlank(i.getHospitalDeptName()))
|
|
|
+ .forEach(i -> {
|
|
|
+ HospitalDept hospitalDeptQuery = deptMap.get(i.getHospitalDeptCode());
|
|
|
+ if (hospitalDeptQuery == null) {
|
|
|
+ HospitalDept hospitalDept = new HospitalDept();
|
|
|
+ hospitalDept.setHospitalCode(StringUtil.isNotBlank(sonHospitalCode) ? sonHospitalCode : hospitalCode);
|
|
|
+ hospitalDept.setHospitalName(StringUtil.isNotBlank(sonHospitalCode) ? sonHospitalName : hospitalName);
|
|
|
+ hospitalDept.setCode(i.getHospitalDeptCode());
|
|
|
+ hospitalDept.setName(i.getHospitalDeptName());
|
|
|
+ hospitalDept.setconceptDeptName("全科");
|
|
|
+ deptSaveOrUpdateList.add(hospitalDept);
|
|
|
+ } else {
|
|
|
+ hospitalDeptQuery.setName(i.getHospitalDeptName());
|
|
|
+ deptSaveOrUpdateList.add(hospitalDeptQuery);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (ListUtil.isNotEmpty(deptSaveOrUpdateList)) {
|
|
|
+ hospitalDeptService.saveOrUpdateBatch(deptSaveOrUpdateList);
|
|
|
+ }
|
|
|
|
|
|
- List<String> doctorCodeList = rif.getDetail().stream()
|
|
|
- .filter(i -> i.getDoctorInfo() != null).map(i -> i.getDoctorInfo())
|
|
|
- .filter(i -> StringUtil.isNotBlank(i.getCode()) && StringUtil.isNotBlank(i.getName()))
|
|
|
- .map(i -> i.getCode()).collect(Collectors.toList());
|
|
|
- QueryWrapper<DoctorInfo> doctorInfoQe = new QueryWrapper<>();
|
|
|
- doctorInfoQe.eq("hospital_code", hospitalCode);
|
|
|
- doctorInfoQe.in("code", doctorCodeList);
|
|
|
- Map<String, DoctorInfo> doctorMap = doctorInfoFacade.list(doctorInfoQe)
|
|
|
- .stream().collect(Collectors.toMap(DoctorInfo::getCode, i -> i));
|
|
|
- List<DoctorInfo> doctorSaveOrUpdateList = Lists.newArrayList();
|
|
|
- rif.getDetail().stream()
|
|
|
- .filter(i -> i.getDoctorInfo() != null).map(i -> i.getDoctorInfo())
|
|
|
- .filter(i -> StringUtil.isNotBlank(i.getCode()) && StringUtil.isNotBlank(i.getName()))
|
|
|
- .forEach(i -> {
|
|
|
- DoctorInfo doctorInfo = new DoctorInfo();
|
|
|
- DoctorInfo doctorInfoQuery = doctorMap.get(i.getCode());
|
|
|
- if (doctorInfoQuery != null) {
|
|
|
- BeanUtil.copyProperties(doctorInfoQuery, doctorInfo);
|
|
|
- }
|
|
|
- BeanUtil.copyProperties(i, doctorInfo);
|
|
|
- doctorInfo.setHospitalCode(hospitalCode);
|
|
|
- doctorSaveOrUpdateList.add(doctorInfo);
|
|
|
- });
|
|
|
- if (ListUtil.isNotEmpty(doctorSaveOrUpdateList)) {
|
|
|
- doctorInfoService.saveOrUpdateBatch(doctorSaveOrUpdateList);
|
|
|
- }
|
|
|
+ List<String> doctorCodeList = rif.getDetail().stream()
|
|
|
+ .filter(i -> i.getDoctorInfo() != null).map(i -> i.getDoctorInfo())
|
|
|
+ .filter(i -> StringUtil.isNotBlank(i.getCode()) && StringUtil.isNotBlank(i.getName()))
|
|
|
+ .map(i -> i.getCode()).collect(Collectors.toList());
|
|
|
+ QueryWrapper<DoctorInfo> doctorInfoQe = new QueryWrapper<>();
|
|
|
+ doctorInfoQe.eq("hospital_code", hospitalCode);
|
|
|
+ doctorInfoQe.in("code", doctorCodeList);
|
|
|
+ Map<String, DoctorInfo> doctorMap = doctorInfoFacade.list(doctorInfoQe)
|
|
|
+ .stream().collect(Collectors.toMap(DoctorInfo::getCode, i -> i));
|
|
|
+ List<DoctorInfo> doctorSaveOrUpdateList = Lists.newArrayList();
|
|
|
+ rif.getDetail().stream()
|
|
|
+ .filter(i -> i.getDoctorInfo() != null).map(i -> i.getDoctorInfo())
|
|
|
+ .filter(i -> StringUtil.isNotBlank(i.getCode()) && StringUtil.isNotBlank(i.getName()))
|
|
|
+ .forEach(i -> {
|
|
|
+ DoctorInfo doctorInfo = new DoctorInfo();
|
|
|
+ DoctorInfo doctorInfoQuery = doctorMap.get(i.getCode());
|
|
|
+ Long docId = null;
|
|
|
+ if (doctorInfoQuery != null) {
|
|
|
+ BeanUtil.copyProperties(doctorInfoQuery, doctorInfo);
|
|
|
+ docId = doctorInfoQuery.getId();
|
|
|
+ }
|
|
|
+ BeanUtil.copyProperties(i, doctorInfo);
|
|
|
+ doctorInfo.setHospitalCode(hospitalCode);
|
|
|
+ doctorInfo.setId(docId);
|
|
|
+ if (!doctorSaveOrUpdateList.stream()
|
|
|
+ .map(doc -> doc.getCode()).distinct()
|
|
|
+ .collect(Collectors.toList()).contains(doctorInfo.getCode())) {
|
|
|
+ doctorSaveOrUpdateList.add(doctorInfo);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (ListUtil.isNotEmpty(doctorSaveOrUpdateList)) {
|
|
|
+ doctorInfoService.saveOrUpdateBatch(doctorSaveOrUpdateList);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -326,28 +341,92 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
|
|
|
* @param signInVO
|
|
|
* @return
|
|
|
*/
|
|
|
- private RegisterInfoDTO getRegisterInfo(SignInVO signInVO) {
|
|
|
- // String time = DateUtil.formatDateTime(new Date());
|
|
|
- // List<SignInDTO> list = Lists.newArrayList();
|
|
|
- // list.add(new SignInDTO("A001", "浙江大学医学院附属邵逸夫医院",
|
|
|
- // "D01", "全科", "YS001", "付医生",
|
|
|
- // "1600", "王明明", time, "4468352", "15"));
|
|
|
- // list.add(new SignInDTO("A001", "浙江大学医学院附属邵逸夫医院",
|
|
|
- // "D02", "儿科", "YS001", "付医生",
|
|
|
- // "1600", "王明明", time, "4468352", "18"));
|
|
|
- // if (signInVO.getPatientInfoType().equals("101")) {
|
|
|
- // if (signInVO.getPatientInfo().equals("10123439991230120X")) {
|
|
|
- // list.remove(1);
|
|
|
- // } else if (signInVO.getPatientInfo().equals("666666180002301234")) {
|
|
|
- // list.clear();
|
|
|
- // } else if (signInVO.getPatientInfo().equals("100000201901010000")) {
|
|
|
- // return null;
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- RegisterInfoDTO registerInfoDTO = new RegisterInfoDTO();
|
|
|
-
|
|
|
- return null;
|
|
|
+ private List<RegisterInfoDTO> getRegisterInfo(SignInVO signInVO) {
|
|
|
+ if (!signInVO.getHospitalCode().equals("33010400")){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String retJson = " [{"
|
|
|
+ + "\"hospitalCode\": \"33010400\","
|
|
|
+ + "\"hospitalName\": \"江干区卫计局\","
|
|
|
+ + "\"sonHospitalCode\": \"33010480\","
|
|
|
+ + "\"sonHospitalName\": \"四季青街道社区卫生服务中心\","
|
|
|
+ + "\"patientInfo\": {"
|
|
|
+ + " \"birthday\": \"1984-10-08 10:20:23\","
|
|
|
+ + "\"code\": \"1747\","
|
|
|
+ + "\"idNo\": \"330104198410083034\","
|
|
|
+ + " \"hospitalCode\": \"33010400\","
|
|
|
+ + " \"sex\": 1,"
|
|
|
+ + " \"identityNum\": \"330104198410083034\","
|
|
|
+ + " \"name\": \"沈利峰\""
|
|
|
+ + "},"
|
|
|
+ + "\"detail\": [{"
|
|
|
+ + " \"hospitalDeptCode\": \"2127\","
|
|
|
+ + " \"hospitalDeptName\": \"中医科\","
|
|
|
+ + " \"doctorInfo\": {"
|
|
|
+ + " \"code\": \"000\","
|
|
|
+ + " \"hospitalCode\": \"33010400\","
|
|
|
+ + " \"name\": \"普通\""
|
|
|
+ + "},"
|
|
|
+ + " \"recordId\": \"9043516\","
|
|
|
+ + " \"recordTime\": \"2019-12-05 12:29:55\","
|
|
|
+ + " \"registerNum\": \"1\""
|
|
|
+ + "},{"
|
|
|
+ + "\"hospitalDeptCode\": \"2533\","
|
|
|
+ + " \"hospitalDeptName\": \"机神全科\","
|
|
|
+ + " \"doctorInfo\": {"
|
|
|
+ + "\"code\": \"000\","
|
|
|
+ + " \"hospitalCode\": \"33010400\","
|
|
|
+ + "\"name\": \"普通\""
|
|
|
+ + "},"
|
|
|
+ + " \"recordId\": \"9043512\","
|
|
|
+ + " \"recordTime\": \"2019-12-05 12:23:09\","
|
|
|
+ + " \"registerNum\": \"1\""
|
|
|
+ + "}]"
|
|
|
+ + "},"
|
|
|
+ + "{"
|
|
|
+ + " \"hospitalCode\": \"33010400\","
|
|
|
+ + "\"hospitalName\": \"江干区卫计局\","
|
|
|
+ + " \"sonHospitalCode\": \"33010490\","
|
|
|
+ + " \"sonHospitalName\": \"闸弄口街道社区卫生服务中心\","
|
|
|
+ + "\"patientInfo\": {"
|
|
|
+ + " \"birthday\": \"1984-10-08 10:20:23\","
|
|
|
+ + "\"code\": \"1747\","
|
|
|
+ + " \"idNo\": \"330104198410083034\","
|
|
|
+ + " \"hospitalCode\": \"33010400\","
|
|
|
+ + " \"sex\": 1,"
|
|
|
+ + " \"identityNum\": \"330104198410083034\","
|
|
|
+ + " \"name\": \"沈利峰\""
|
|
|
+ + "},"
|
|
|
+ + " \"detail\": [{"
|
|
|
+ + " \"hospitalDeptCode\": \"2127\","
|
|
|
+ + "\"hospitalDeptName\": \"中医科\","
|
|
|
+ + " \"doctorInfo\": {"
|
|
|
+ + " \"code\": \"000\","
|
|
|
+ + " \"hospitalCode\": \"33010400\","
|
|
|
+ + " \"name\": \"普通\""
|
|
|
+ + "},"
|
|
|
+ + " \"recordId\": \"9043516\","
|
|
|
+ + " \"recordTime\": \"2019-12-05 12:29:55\","
|
|
|
+ + " \"registerNum\": \"1\""
|
|
|
+ + "},{"
|
|
|
+ + " \"hospitalDeptCode\": \"2533\","
|
|
|
+ + " \"hospitalDeptName\": \"机神全科\","
|
|
|
+ + " \"doctorInfo\": {"
|
|
|
+ + " \"code\": \"000\","
|
|
|
+ + " \"hospitalCode\": \"33010400\","
|
|
|
+ + " \"name\": \"普通\""
|
|
|
+ + "},"
|
|
|
+ + "\"recordId\": \"9043512\","
|
|
|
+ + " \"recordTime\": \"2019-12-05 12:23:09\","
|
|
|
+ + " \"registerNum\": \"1\""
|
|
|
+ + "}]"
|
|
|
+ + "}"
|
|
|
+ + "]";
|
|
|
+
|
|
|
+ // List<RegisterInfoDTO> rifList = GsonUtil.toList(retJson, RegisterInfoDTO.class);
|
|
|
+ List<RegisterInfoDTO> rifList = JSON.parseArray(retJson, RegisterInfoDTO.class);
|
|
|
+ System.out.println(rifList);
|
|
|
+ return rifList;
|
|
|
}
|
|
|
|
|
|
/**
|