123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525 |
- 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;
- import com.diagbot.dto.SignInDTO;
- import com.diagbot.entity.DoctorInfo;
- import com.diagbot.entity.HospitalDept;
- import com.diagbot.entity.HospitalInfo;
- import com.diagbot.entity.PatientInfo;
- import com.diagbot.entity.SysSet;
- import com.diagbot.enums.SysTypeEnum;
- import com.diagbot.enums.VisibleIdTypeEnum;
- 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;
- import com.diagbot.service.impl.PatientInfoServiceImpl;
- import com.diagbot.util.BeanUtil;
- import com.diagbot.util.DateUtil;
- import com.diagbot.util.IdCard;
- import com.diagbot.util.ListUtil;
- import com.diagbot.util.StringUtil;
- import com.diagbot.vo.GetTopPatientInfoDjVO;
- import com.diagbot.vo.InquiryQuoteVO;
- import com.diagbot.vo.SignInVO;
- import com.google.common.collect.Lists;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Qualifier;
- import org.springframework.stereotype.Component;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- import java.util.stream.Collectors;
- /**
- * @Description: 对接-患者业务逻辑
- * @author: wangyu
- * @time: 2018/11/19 13:19
- */
- @Component
- public class PatientInfoDjFacade extends PatientInfoServiceImpl {
- @Autowired
- private HospitalInfoFacade hospitalInfoFacade;
- @Autowired
- private HospitalDeptFacade hospitalDeptFacade;
- @Autowired
- @Qualifier("hospitalDeptServiceImpl")
- private HospitalDeptService hospitalDeptService;
- @Autowired
- private DoctorInfoFacade doctorInfoFacade;
- @Autowired
- @Qualifier("doctorInfoServiceImpl")
- private DoctorInfoService doctorInfoService;
- @Autowired
- private SysSetFacade sysSetFacade;
- @Autowired
- private VisibleIdCreater visibleIdCreater;
- /**
- * 对接-页面顶部病人医生科室信息——查询
- *
- * @param getTopPatientInfoDjVO
- * @return
- */
- public GetTopPatientInfoDjDTO getTopPatientInfoDj(GetTopPatientInfoDjVO getTopPatientInfoDjVO) {
- GetTopPatientInfoDjDTO getTopPatientInfoDjDTO = this.baseMapper.getTopPatientInfoDj(getTopPatientInfoDjVO);
- getTopPatientInfoDjDTO.setSystemTime(DateUtil.now());
- getTopPatientInfoDjDTO.setRecordId(getTopPatientInfoDjVO.getRecordId());
- getTopPatientInfoDjDTO.setPatientAge(DateUtil.yearCompare(getTopPatientInfoDjDTO.getBirthday(), DateUtil.now()));
- List<String> hospitalCodeList = Lists.newArrayList();
- hospitalCodeList.add(getTopPatientInfoDjVO.getHospitalCode());
- if (StringUtil.isNotBlank(getTopPatientInfoDjVO.getSonHospitalCode())) {
- hospitalCodeList.add(getTopPatientInfoDjVO.getSonHospitalCode());
- }
- QueryWrapper<HospitalInfo> hospitalInfoQe = new QueryWrapper<>();
- hospitalInfoQe.in("code", hospitalCodeList);
- Map<String, HospitalInfo> hospitalInfoMap = hospitalInfoFacade.list(hospitalInfoQe)
- .stream().collect(Collectors.toMap(HospitalInfo::getCode, i -> i));
- HospitalInfo hospitalInfo = hospitalInfoMap.get(getTopPatientInfoDjVO.getHospitalCode());
- HospitalInfo sonHospitalInfo = hospitalInfoMap.get(getTopPatientInfoDjVO.getSonHospitalCode());
- getTopPatientInfoDjDTO.setHospitalId(hospitalInfo.getId());
- getTopPatientInfoDjDTO.setHospitalCode(hospitalInfo.getCode());
- getTopPatientInfoDjDTO.setHospitalName(hospitalInfo.getName());
- if (sonHospitalInfo != null) {
- getTopPatientInfoDjDTO.setSonHospitalId(sonHospitalInfo.getId());
- getTopPatientInfoDjDTO.setSonHospitalCode(sonHospitalInfo.getCode());
- getTopPatientInfoDjDTO.setSonHospitalName(sonHospitalInfo.getName());
- }
- QueryWrapper<HospitalDept> hospitalDeptQe = new QueryWrapper<>();
- hospitalDeptQe.eq("hospital_code",
- StringUtil.isBlank(getTopPatientInfoDjVO.getSonHospitalCode())
- ? getTopPatientInfoDjVO.getHospitalCode()
- : getTopPatientInfoDjVO.getSonHospitalCode());
- hospitalDeptQe.eq("code", getTopPatientInfoDjVO.getHospitalDeptCode());
- HospitalDept hospitalDept = hospitalDeptFacade.getOne(hospitalDeptQe, false);
- if (hospitalDept != null) {
- getTopPatientInfoDjDTO.setHospitalDeptId(hospitalDept.getId());
- getTopPatientInfoDjDTO.setHospitalDeptCode(hospitalDept.getCode());
- getTopPatientInfoDjDTO.setHospitalDeptName(hospitalDept.getName());
- getTopPatientInfoDjDTO.setSelfDeptName(hospitalDept.getConceptDeptName());
- }
- return getTopPatientInfoDjDTO;
- }
- /**
- * 患者登录
- *
- * @param signInVO
- * @return
- */
- public List<SignInDTO> signIn(SignInVO signInVO) {
- List<SignInDTO> retList = null;
- List<RegisterInfoDTO> rifList = getRegisterInfo(signInVO);
- if (ListUtil.isNotEmpty(rifList)) {
- generateByRif(rifList);
- retList = rifConverSin(rifList);
- } else {
- retList = autoGenePatinfo(signInVO);
- }
- if (retList == null) {
- throw new CommonException(ServiceErrorCode.IQC_NOT_FOUND);
- }
- return retList;
- }
- /**
- * 自动生成患者信息
- *
- * @param signInVO
- * @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());
- signInDTO.setHospitalName(signInVO.getHospitalName());
- signInDTO.setSonHospitalCode(signInVO.getSonHospitalCode());
- signInDTO.setSonHospitalName(signInVO.getSonHospitalName());
- 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);
- 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, false);
- if (patientInfo == null) {
- patientInfo = new PatientInfo();
- patientInfo.setGmtCreate(DateUtil.now());
- patientInfo.setHospitalCode(signInVO.getHospitalCode());
- patientInfo.setIdNo(signInVO.getPatientInfo());
- patientInfo.setIdentityNum(signInVO.getPatientInfo());
- patientInfo.setName(signInVO.getPatientName());
- patientInfo.setSex(IdCard.getGenderByIdCard(signInVO.getPatientInfo()));
- patientInfo.setBirthday(DateUtil.parseDate(IdCard.getBirthByIdCard(signInVO.getPatientInfo()), "yyyyMMdd"));
- patientInfo.setCode("" + visibleIdCreater.getNextShortId(VisibleIdTypeEnum.PATIENT_NO.getKey()));
- patientInfo.setRemark("1");//自动生成标志
- save(patientInfo);
- }
- signInDTO.setPatientCode(patientInfo.getCode());
- signInDTO.setPatientName(patientInfo.getName());
- retList.add(signInDTO);
- return retList;
- }
- /**
- * his返回的挂号信息转化给前端
- *
- * @param rifList
- * @return
- */
- private List<SignInDTO> rifConverSin(List<RegisterInfoDTO> rifList) {
- List<SignInDTO> retList = Lists.newArrayList();
- 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;
- }
- /**
- * 由挂号信息检查病人科室医生信息,有更新,无插入
- *
- * @param rifList
- */
- 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);
- 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.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());
- 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);
- }
- });
- }
- /**
- * 对接---获取挂号信息
- * 某一时刻患者只可能在一家医院,所以获取到的挂号信息只能是当前医院的,当出现江干的大小医院情况时可采用2种:
- * 1、预问诊必须选择小医院,对方接口小医院要求必传;2、his返回时间最近的一家医院挂号信息(可能不准确)。
- * 大小医院信息使用his返回来的(未选择小医院时有用)
- *
- * @param signInVO
- * @return
- */
- 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;
- }
- /**
- * 病历引用时,更新患者医生科室信息
- *
- * @param inquiryQuoteVO
- * @return
- */
- public InquiryQuoteVO inquiryQuote(InquiryQuoteVO inquiryQuoteVO) {
- List<String> hospitalCodeList = Lists.newArrayList();
- hospitalCodeList.add(inquiryQuoteVO.getHospitalCode());
- String hospitalCode = inquiryQuoteVO.getHospitalCode();
- String hospitalName = inquiryQuoteVO.getHospitalName();
- if (StringUtil.isNotBlank(inquiryQuoteVO.getSonHospitalCode())) {
- hospitalCodeList.add(inquiryQuoteVO.getSonHospitalCode());
- hospitalCode = inquiryQuoteVO.getSonHospitalCode();
- hospitalName = inquiryQuoteVO.getSonHospitalName();
- }
- QueryWrapper<HospitalInfo> hospitalInfoQe = new QueryWrapper<>();
- hospitalInfoQe.in("code", hospitalCodeList);
- Map<String, Long> hospitalInfoIdMap = hospitalInfoFacade.list(hospitalInfoQe)
- .stream().collect(Collectors.toMap(HospitalInfo::getCode, i -> i.getId()));
- inquiryQuoteVO.setHospitalId(hospitalInfoIdMap.get(inquiryQuoteVO.getHospitalCode()));
- if (StringUtil.isNotBlank(inquiryQuoteVO.getSonHospitalCode())) {
- inquiryQuoteVO.setSonHospitalId(hospitalInfoIdMap.get(inquiryQuoteVO.getSonHospitalCode()));
- }
- Date now = DateUtil.now();
- if (inquiryQuoteVO.getDeptInfo() != null) {
- QueryWrapper<HospitalDept> hospitalDeptQe = new QueryWrapper<>();
- hospitalDeptQe.eq("hospital_code", hospitalCode);
- hospitalDeptQe.eq("code", inquiryQuoteVO.getDeptInfo().getCode());
- HospitalDept hospitalDept = hospitalDeptFacade.getOne(hospitalDeptQe, false);
- Long deptId = null;
- if (hospitalDept == null) {
- hospitalDept = new HospitalDept();
- hospitalDept.setGmtCreate(now);
- hospitalDept.setHospitalCode(hospitalCode);
- hospitalDept.setHospitalName(hospitalName);
- hospitalDept.setconceptDeptName("全科");
- } else {
- deptId = hospitalDept.getId().longValue();
- }
- BeanUtil.copyProperties(inquiryQuoteVO.getDeptInfo(), hospitalDept);
- hospitalDept.setGmtModified(now);
- hospitalDept.setId(deptId);
- hospitalDeptFacade.saveOrUpdate(hospitalDept);
- inquiryQuoteVO.getDeptInfo().setId(hospitalDept.getId());
- }
- if (inquiryQuoteVO.getDoctorInfo() != null) {
- QueryWrapper<DoctorInfo> doctorInfoQe = new QueryWrapper<>();
- doctorInfoQe.eq("hospital_code", inquiryQuoteVO.getHospitalCode());
- doctorInfoQe.eq("code", inquiryQuoteVO.getDoctorInfo().getCode());
- DoctorInfo doctorInfo = doctorInfoFacade.getOne(doctorInfoQe, false);
- Long doctorId = null;
- if (doctorInfo == null) {
- doctorInfo = new DoctorInfo();
- doctorInfo.setGmtCreate(now);
- doctorInfo.setHospitalCode(inquiryQuoteVO.getHospitalCode());
- } else {
- doctorId = doctorInfo.getId().longValue();
- }
- BeanUtil.copyProperties(inquiryQuoteVO.getDoctorInfo(), doctorInfo);
- doctorInfo.setGmtModified(now);
- doctorInfo.setId(doctorId);
- doctorInfoFacade.saveOrUpdate(doctorInfo);
- inquiryQuoteVO.getDoctorInfo().setId(doctorInfo.getId());
- }
- QueryWrapper<PatientInfo> patientInfoQe = new QueryWrapper<>();
- patientInfoQe.eq("hospital_code", inquiryQuoteVO.getHospitalCode());
- patientInfoQe.eq("code", inquiryQuoteVO.getPatientInfo().getCode());
- PatientInfo patientInfo = getOne(patientInfoQe, false);
- Long patientId = null;
- if (patientInfo == null) {
- patientInfo = new PatientInfo();
- patientInfo.setGmtCreate(now);
- patientInfo.setHospitalCode(inquiryQuoteVO.getHospitalCode());
- } else {
- patientId = patientInfo.getId().longValue();
- }
- BeanUtil.copyProperties(inquiryQuoteVO.getPatientInfo(), patientInfo);
- patientInfo.setGmtModified(now);
- patientInfo.setId(patientId);
- saveOrUpdate(patientInfo);
- inquiryQuoteVO.getPatientInfo().setId(patientInfo.getId());
- return inquiryQuoteVO;
- }
- }
|