| | |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.entity.SysUserDept; |
| | | import com.ruoyi.common.core.domain.entity.SysUserRole; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.mapper.PatMedOuthospMapper; |
| | | import com.smartor.mapper.SysUser2Mapper; |
| | | import com.smartor.mapper.SysUserImportMapper; |
| | | import com.smartor.mapper.*; |
| | | import com.smartor.service.IPatArchiveService; |
| | | import com.smartor.service.IPatMedInhospService; |
| | | import com.smartor.service.IServiceSLTDHealthcareRecordService; |
| | | import com.sun.org.apache.bcel.internal.generic.NEW; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.lang.reflect.Array; |
| | | import java.lang.reflect.Type; |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | |
| | | public class ServiceSLTDHealthcareRecordServiceImpl implements IServiceSLTDHealthcareRecordService { |
| | | |
| | | private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; |
| | | private static final String APP_KEY = "ak-zUMiOWhqXiJQWPB1pCbz0pjr"; |
| | | public static final String APP_KEY = "ak-zUMiOWhqXiJQWPB1pCbz0pjr"; |
| | | |
| | | @Autowired |
| | | private IPatArchiveService patArchiveService; |
| | |
| | | @Autowired |
| | | private SysUser2Mapper sysUser2Mapper; |
| | | |
| | | @Autowired |
| | | private SysDept2Mapper sysDeptMapper; |
| | | |
| | | @Autowired |
| | | private SysUserDeptMapper sysUserDeptMapper; |
| | | |
| | | @Autowired |
| | | private SysUserRole2Mapper sysUserRoleMapper; |
| | | |
| | | @Value("${sltd_pub_path}") |
| | | private String sltdPubPath; |
| | | |
| | | @Value("${userPwd}") |
| | | private String userPwd; |
| | | |
| | | @Override |
| | | public List<ServiceSLTDInhospResDTO> queryHealthcareRecordList(ServiceSLTDInhospReqVO reqVO) { |
| | | log.info("【queryHealthcareRecordList】开始调用省立同德健康记录查询接口,请求参数:{}", reqVO); |
| | | try { |
| | | log.info("【queryHealthcareRecordList】开始调用省立同德健康记录查询接口,请求参数:{}", reqVO); |
| | | Map<String, Object> requestParams = buildRequestParams(reqVO); |
| | | Map<String, String> headers = buildRequestHeaders(); |
| | | |
| | | String result = HttpUtils.sendPostByHeader(sltdPubPath + "osj/hbos-thirdparty-integration/standard/common/healthcareRecord/dtcQueryHealthcareRecordList", new Gson().toJson(requestParams), headers); |
| | | log.info("【queryHealthcareRecordList】接口响应结果:{}", result); |
| | | |
| | | String cry = determineCry(reqVO); |
| | | return parseResponseData(result, reqVO.getHealthcareRecordTypeList().get(0), cry); |
| | | return parseResponseData(result, reqVO.getHealthcareRecordTypeList(), cry, reqVO.getCampusId()); |
| | | } catch (Exception e) { |
| | | log.error("【queryHealthcareRecordList】调用省立同德健康记录查询接口异常,请求参数:{}", reqVO, e); |
| | | throw new RuntimeException("调用省立同德健康记录查询接口失败", e); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 采集科室病区信息 |
| | | * |
| | | * @param serviceSLTDDeptReqVO |
| | | * @return 参考 |
| | | * { |
| | | * "orgId": 20001001, |
| | | * "campusIds": 30001002, |
| | | * "unitIds": null, |
| | | * "relationType": null, |
| | | * "searchText": null, |
| | | * "status": 1 |
| | | * } |
| | | */ |
| | | @Override |
| | | public Boolean queryDeptWardAreaInfoList(ServiceSLTDDeptReqVO serviceSLTDDeptReqVO) { |
| | | log.info("【queryDeptWardAreaInfoList】开始调用省立同德科室病区查询接口,请求参数:{}", serviceSLTDDeptReqVO); |
| | | try { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | if (serviceSLTDDeptReqVO.getOrgId() != null) { |
| | | params.put("orgId", Long.parseLong(serviceSLTDDeptReqVO.getOrgId())); |
| | | } |
| | | if (serviceSLTDDeptReqVO.getCampusIds() != null) { |
| | | params.put("campusIds", serviceSLTDDeptReqVO.getCampusIds()); |
| | | } |
| | | params.put("subjectCode", serviceSLTDDeptReqVO.getSubjectCode()); |
| | | params.put("orgSubjectCode", serviceSLTDDeptReqVO.getOrgSubjectCode()); |
| | | |
| | | params.put("deptDimensions", serviceSLTDDeptReqVO.getDeptDimensions()); |
| | | |
| | | params.put("serviceScopes", serviceSLTDDeptReqVO.getServiceScopes()); |
| | | params.put("inpatientArea", serviceSLTDDeptReqVO.getInpatientArea()); |
| | | params.put("status", serviceSLTDDeptReqVO.getStatus()); |
| | | |
| | | |
| | | Map<String, String> headers = buildRequestHeaders(); |
| | | String result = HttpUtils.sendPostByHeader(sltdPubPath + "/osj/hbos-thirdparty-integration/standard/common/dept/queryDeptList", new Gson().toJson(params), headers); |
| | | log.info("【queryDeptWardAreaInfoList】接口响应结果:{}", result); |
| | | List<Map<String, Object>> dataList = getDataList(result); |
| | | log.info("-----------dataList接口响应结果:{}", dataList.size()); |
| | | for (Map<String, Object> dataItem : dataList) { |
| | | SysDept sysDept = new SysDept(); |
| | | sysDept.setOrgid("" + serviceSLTDDeptReqVO.getCampusIds().get(0)); |
| | | sysDept.setHisDeptId("" + getLongValue(dataItem, "deptId")); |
| | | sysDept.setHisParentId(getStringValue(dataItem, "parentDeptId")); |
| | | //通过his的父科室ID去找到科室ID,填充parentId |
| | | if (StringUtils.isNotEmpty(getStringValue(dataItem, "parentDeptId"))) { |
| | | SysDept sd = new SysDept(); |
| | | sd.setHisDeptId(getStringValue(dataItem, "parentDeptId")); |
| | | sd.setOrgid(getStringValue(dataItem, "orgId")); |
| | | List<SysDept> sysDepts = sysDeptMapper.selectDeptList(sd); |
| | | if (CollectionUtils.isNotEmpty(sysDepts)) { |
| | | SysDept sysDept1 = sysDepts.get(0); |
| | | sysDept.setParentId(sysDept1.getDeptId()); |
| | | sysDept.setParentName(sysDept1.getDeptName()); |
| | | } |
| | | } |
| | | sysDept.setDeptName(getStringValue(dataItem, "deptName")); |
| | | Integer inpatientArea = getIntegerValue(dataItem, "inpatientArea"); |
| | | if (inpatientArea != null && inpatientArea == 0) sysDept.setDeptType("1"); |
| | | else if (inpatientArea != null && inpatientArea == 1) sysDept.setDeptType("2"); |
| | | sysDept.setLeader(""); |
| | | Integer status = getIntegerValue(dataItem, "status"); |
| | | if (status != null & status == 0) sysDept.setStatus("1"); |
| | | if (status != null & status == 1) sysDept.setStatus("0"); |
| | | sysDept.setType(""); |
| | | sysDept.setDeptCode("" + getLongValue(dataItem, "deptId")); |
| | | sysDept.setCreateBy(null); |
| | | sysDept.setCreateTime(new Date()); |
| | | sysDept.setUpdateTime(new Date()); |
| | | sysDept.setUpdateBy(null); |
| | | |
| | | SysDept sysDept1 = sysDeptMapper.selectDeptByCode(sysDept.getDeptCode(), sysDept.getOrgid()); |
| | | if (Objects.isNull(sysDept1)) { |
| | | int i = sysDeptMapper.insertDept(sysDept); |
| | | log.info("ServiceExternalServiceImpl---addDeptInfo是否新增成功:{}", i); |
| | | } else { |
| | | sysDept.setDeptId(sysDept1.getDeptId()); |
| | | int i = sysDeptMapper.updateDept(sysDept); |
| | | log.info("ServiceExternalServiceImpl---addDeptInfo是否修改成功04:{}", i); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 采集医院用户信息 |
| | |
| | | public Boolean queryHospUserInfoList(ServiceSLTDInhospReqVO reqVO) { |
| | | Map<String, Object> requestParams = buildRequestParams(reqVO); |
| | | Map<String, String> headers = buildRequestHeaders(); |
| | | String result = HttpUtils.sendPostByHeader(sltdPubPath + "osj/hbos-thirdparty-integration/standard/common/healthcareRecord/dtcQueryHealthcareRecordList", new Gson().toJson(requestParams), headers); |
| | | String result = HttpUtils.sendPostByHeader(sltdPubPath + "/osj/hbos-thirdparty-integration/standard/common/staff/queryStaffList", new Gson().toJson(requestParams), headers); |
| | | log.info("【queryHealthcareRecordList】接口响应结果:{}", result); |
| | | List<Map<String, Object>> dataList = getDataList(result); |
| | | for (Map<String, Object> dataItem : dataList) { |
| | | SysUser sysUser = new SysUser(); |
| | | if (StringUtils.isEmpty(getStringValue(dataItem, "accountNo"))) { |
| | | continue; |
| | | } |
| | | sysUser.setUserName(getStringValue(dataItem, "accountNo")); |
| | | sysUser.setNickName(getStringValue(dataItem, "name")); |
| | | List diagnosisObjList = (List<?>) dataItem.get("qualifications"); |
| | |
| | | if (diagnosis instanceof Map) { |
| | | Map<String, Object> diagnosisMap = (Map<String, Object>) diagnosis; |
| | | String professionalTitleName = getStringValue(diagnosisMap, "professionalTitleName"); |
| | | if (professionalTitleName.contains("医师")) sysUser.setUserType("医生"); |
| | | if (professionalTitleName.contains("护")) sysUser.setUserType("护士"); |
| | | if (professionalTitleName.contains("医师")) { |
| | | sysUser.setUserType("医生"); |
| | | sysUser.setSearchscope("1"); |
| | | } |
| | | if (professionalTitleName.contains("护")) { |
| | | sysUser.setUserType("护士"); |
| | | sysUser.setSearchscope("2"); |
| | | } |
| | | sysUser.setTitle(getStringValue(diagnosisMap, "professionalTitleName")); |
| | | } |
| | | } |
| | | } |
| | | sysUser.setDeptCode(getStringValue(dataItem, "accountNo")); |
| | | sysUser.setDeptName(getStringValue(dataItem, "personnelDeptName")); |
| | | |
| | | sysUser.setPhonenumber(getStringValue(dataItem, "telephone")); |
| | | sysUser.setUserCode(getStringValue(dataItem, "jobNumber")); |
| | | //设置性别 |
| | | String genderName = getStringValue(dataItem, "genderName"); |
| | | if ("男".equals(genderName)) sysUser.setSex("0"); |
| | |
| | | sysUser.setUpdateTime(new Date()); |
| | | sysUser.setUpdateBy("admin"); |
| | | sysUser.setCreateBy("admin"); |
| | | sysUser.setCreateBy("admin"); |
| | | sysUser.setOrgid(reqVO.getCampusId().toString()); |
| | | BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
| | | sysUser.setPassword(passwordEncoder.encode(userPwd)); |
| | | |
| | | sysUser2Mapper.insertUser(sysUser); |
| | | |
| | | // 处理用户与部门的关系 |
| | | List personnelDepts = (List<?>) dataItem.get("personnelDepts"); |
| | | if (CollectionUtils.isEmpty(personnelDepts)) { |
| | | continue; |
| | | } |
| | | |
| | | List<List<String>> deptInfoList = new ArrayList<>(); |
| | | List<List<String>> hospInfoList = new ArrayList<>(); |
| | | for (Object personnelDept : personnelDepts) { |
| | | if (personnelDept instanceof Map) { |
| | | Map<String, Object> personnelDeptMap = (Map<String, Object>) personnelDept; |
| | | // Long hisDeptId = (Long) personnelDeptMap.get("deptId"); |
| | | String hisDeptId = getStringValue(personnelDeptMap, "deptId"); |
| | | //在这里,hisDeptId就是deptCode |
| | | SysDept sysDept = sysDeptMapper.selectDeptByCode(hisDeptId, reqVO.getCampusId().toString()); |
| | | if (Objects.isNull(sysDept)) continue; |
| | | SysUserDept sysUserDept = new SysUserDept(); |
| | | sysUserDept.setUserId(sysUser.getUserId()); |
| | | sysUserDept.setDeptType(sysDept.getDeptType()); |
| | | sysUserDept.setDeptId(sysDept.getDeptId()); |
| | | sysUserDept.setDeptCode(sysDept.getDeptCode()); |
| | | sysUserDept.setDeptName(sysDept.getDeptName()); |
| | | sysUserDept.setOrgid(sysDept.getOrgid()); |
| | | sysUserDept.setCreateTime(new Date()); |
| | | sysUserDept.setDelFlag(0L); |
| | | sysUserDeptMapper.insertSysUserDept(sysUserDept); |
| | | if (StringUtils.isNotEmpty(sysDept.getDeptType()) && sysDept.getDeptType().equals("1")) { |
| | | hospInfoList.add(Arrays.asList(sysDept.getDeptCode())); |
| | | } else if (StringUtils.isNotEmpty(sysDept.getDeptType()) && sysDept.getDeptType().equals("2")) { |
| | | deptInfoList.add(Arrays.asList(sysDept.getDeptCode())); |
| | | } |
| | | } |
| | | } |
| | | //将部门我病区放到指定字段中 |
| | | Gson gson = new Gson(); |
| | | sysUser.setHospInfo(gson.toJson(hospInfoList)); |
| | | sysUser.setDeptInfo(gson.toJson(deptInfoList)); |
| | | sysUser2Mapper.updateUser(sysUser); |
| | | |
| | | //设置一个默认角色(医生角色) |
| | | List<SysUserRole> userRoleList = new ArrayList(); |
| | | SysUserRole sur = new SysUserRole(); |
| | | sur.setUserId(sysUser.getUserId()); |
| | | sur.setRoleId(3L); |
| | | sur.setOrgid(sysUser.getOrgid()); |
| | | userRoleList.add(sur); |
| | | sysUserRoleMapper.batchUserRole(userRoleList); |
| | | |
| | | } |
| | | |
| | | return true; |
| | |
| | | if (reqVO.getHealthcareRecordTypeList().contains("FH0108.02")) { |
| | | if (reqVO.getStartHeadTime() != null && reqVO.getStartTailTime() != null) { |
| | | return "0"; |
| | | } else if (reqVO.getPreOutHospitalHeadDate() != null && reqVO.getPreOutHospitalTailDate() != null) { |
| | | } else if (StringUtils.isNotEmpty(reqVO.getPreOutHospitalHeadDate()) && StringUtils.isNotEmpty(reqVO.getPreOutHospitalTailDate())) { |
| | | return "1"; |
| | | } |
| | | } |
| | |
| | | if (reqVO.getOrgId() != null) { |
| | | params.put("orgId", Long.parseLong(reqVO.getOrgId())); |
| | | } |
| | | if (reqVO.getCampusIds() != null) { |
| | | params.put("campusIds", reqVO.getCampusIds()); |
| | | if (reqVO.getCampusId() != null) { |
| | | params.put("campusId", reqVO.getCampusId()); |
| | | } |
| | | if (reqVO.getStartHeadTime() != null) { |
| | | params.put("startHeadTime", reqVO.getStartHeadTime()); |
| | | } |
| | | if (reqVO.getStartTailTime() != null) { |
| | | params.put("startTailTime", reqVO.getStartTailTime()); |
| | | } |
| | | if (reqVO.getEncounterTimeStart() != null) { |
| | | params.put("encounterTimeStart", reqVO.getEncounterTimeStart()); |
| | | } |
| | | if (reqVO.getEncounterTimeEnd() != null) { |
| | | params.put("encounterTimeEnd", reqVO.getEncounterTimeEnd()); |
| | | } |
| | | if (reqVO.getPreOutHospitalHeadDate() != null) { |
| | | params.put("preOutHospitalHeadDate", reqVO.getPreOutHospitalHeadDate()); |
| | | } |
| | | if (reqVO.getPreOutHospitalTailDate() != null) { |
| | | params.put("preOutHospitalTailDate", reqVO.getPreOutHospitalTailDate()); |
| | | } |
| | | if (reqVO.getHealthcareRecordTypeList() != null && !reqVO.getHealthcareRecordTypeList().isEmpty()) { |
| | | params.put("healthcareRecordTypeList", reqVO.getHealthcareRecordTypeList()); |
| | |
| | | } |
| | | params.put("serviceScopes", null); |
| | | params.put("inpatientArea", null); |
| | | params.put("status", reqVO.getStatusList() != null && !reqVO.getStatusList().isEmpty() ? reqVO.getStatusList() : null); |
| | | params.put("status", reqVO.getStatusList() != null && !reqVO.getStatusList().isEmpty() ? reqVO.getStatusList().get(0) : null); |
| | | return params; |
| | | } |
| | | |
| | |
| | | return headers; |
| | | } |
| | | |
| | | private List<ServiceSLTDInhospResDTO> parseResponseData(String result, String type, String cry) { |
| | | private List<ServiceSLTDInhospResDTO> parseResponseData(String result, List<String> types, String cry, Long orgid) { |
| | | try { |
| | | |
| | | List<Map<String, Object>> dataList = getDataList(result); |
| | |
| | | } |
| | | log.info("【parseResponseData】成功解析{}条健康记录数据", resultList.size()); |
| | | |
| | | processResultList(resultList, type, cry); |
| | | processResultList(resultList, types, cry, orgid); |
| | | return resultList; |
| | | } catch (Exception e) { |
| | | log.error("【parseResponseData】解析响应数据异常,响应内容:{}", result, e); |
| | |
| | | Type mapType = new TypeToken<Map<String, Object>>() { |
| | | }.getType(); |
| | | Map<String, Object> responseMap = gson.fromJson(result, mapType); |
| | | |
| | | Number codeObj = (Number) responseMap.get("code"); |
| | | if (codeObj == null || codeObj.intValue() != 200) { |
| | | log.error("【parseResponseData】接口返回失败,响应码:{},响应内容:{}", codeObj, result); |
| | | throw new RuntimeException("接口调用失败,响应码:" + codeObj); |
| | | Number codeNum = (Number) responseMap.get("code"); |
| | | String code = BigDecimal.valueOf(codeNum.longValue()).toPlainString(); |
| | | if (StringUtils.isEmpty(code) || !code.equals("200")) { |
| | | log.error("【parseResponseData】接口返回失败,响应码:{},响应内容:{}", code, result); |
| | | throw new RuntimeException("接口调用失败,响应码:" + code); |
| | | } |
| | | |
| | | Object dataObj = responseMap.get("data"); |
| | | if (dataObj == null) { |
| | | log.warn("【parseResponseData】接口返回数据为空"); |
| | | log.info("【parseResponseData】接口返回数据为空"); |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | |
| | | return dataList; |
| | | } |
| | | |
| | | private void processResultList(List<ServiceSLTDInhospResDTO> resultList, String type, String cry) { |
| | | private void processResultList(List<ServiceSLTDInhospResDTO> resultList, List<String> types, String cry, Long orgid) { |
| | | for (String type : types) |
| | | switch (type) { |
| | | case "FH0108.01": |
| | | log.info("【parseResponseData】解析门诊数据"); |
| | | outHospitalDate(resultList); |
| | | outHospitalDate(resultList, orgid); |
| | | break; |
| | | case "FH0108.02": |
| | | log.info("【parseResponseData】解析住院数据"); |
| | | inHospitalDate(resultList, cry); |
| | | inHospitalDate(resultList, cry, orgid); |
| | | break; |
| | | case "FH0108.03": |
| | | log.info("【parseResponseData】解析急诊数据"); |
| | | outHospitalDate(resultList); |
| | | outHospitalDate(resultList, orgid); |
| | | break; |
| | | default: |
| | | log.warn("【parseResponseData】未知的数据类型:{}", type); |
| | |
| | | } |
| | | } |
| | | |
| | | private Boolean outHospitalDate(List<ServiceSLTDInhospResDTO> resultList) { |
| | | private Boolean outHospitalDate(List<ServiceSLTDInhospResDTO> resultList, Long orgid) { |
| | | for (ServiceSLTDInhospResDTO dto : resultList) { |
| | | PatArchive patArchive = processPatientArchive(dto); |
| | | PatMedOuthosp patMedOuthosp = buildPatMedOuthosp(dto, patArchive); |
| | | if (Objects.isNull(dto)) continue; |
| | | PatArchive patArchive = processPatientArchive(dto, orgid); |
| | | PatMedOuthosp patMedOuthosp = buildPatMedOuthosp(dto, patArchive, orgid); |
| | | patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private PatMedOuthosp buildPatMedOuthosp(ServiceSLTDInhospResDTO dto, PatArchive patArchive) { |
| | | private PatMedOuthosp buildPatMedOuthosp(ServiceSLTDInhospResDTO dto, PatArchive patArchive, Long orgid) { |
| | | PatMedOuthosp patMedOuthosp = new PatMedOuthosp(); |
| | | patMedOuthosp.setOuthospno(dto.getHealthcareRecordNo()); |
| | | patMedOuthosp.setSerialnum(dto.getHealthcareRecordNo()); |
| | |
| | | patMedOuthosp.setMainsuit(dto.getDiagnosisName()); |
| | | patMedOuthosp.setHpi(null); |
| | | patMedOuthosp.setCreateTime(new Date()); |
| | | patMedOuthosp.setOrgid("" + orgid); |
| | | return patMedOuthosp; |
| | | } |
| | | |
| | | private Date parseDate(String dateStr) { |
| | | if (StringUtils.isEmpty(dateStr)) { |
| | | return null; |
| | | } |
| | | try { |
| | | return new SimpleDateFormat(DATE_FORMAT).parse(dateStr); |
| | | } catch (ParseException e) { |
| | |
| | | } |
| | | } |
| | | |
| | | private Boolean inHospitalDate(List<ServiceSLTDInhospResDTO> resultList, String cry) { |
| | | private Boolean inHospitalDate(List<ServiceSLTDInhospResDTO> resultList, String cry, Long orgid) { |
| | | for (ServiceSLTDInhospResDTO dto : resultList) { |
| | | PatArchive patArchive = processPatientArchive(dto); |
| | | processPatientInhospInfo(dto, patArchive, cry); |
| | | if (Objects.isNull(dto)) continue; |
| | | PatArchive patArchive = processPatientArchive(dto, orgid); |
| | | processPatientInhospInfo(dto, patArchive, cry, orgid); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private void processPatientInhospInfo(ServiceSLTDInhospResDTO dto, PatArchive patArchive, String cry) { |
| | | PatMedInhosp patMedInhosp = buildPatientInhospInfo(dto, patArchive, cry); |
| | | private void processPatientInhospInfo(ServiceSLTDInhospResDTO dto, PatArchive patArchive, String cry, Long orgid) { |
| | | PatMedInhosp patMedInhosp = buildPatientInhospInfo(dto, patArchive, cry, orgid); |
| | | PatMedInhosp queryInhosp = new PatMedInhosp(); |
| | | queryInhosp.setPatno(patArchive.getPatientno()); |
| | | queryInhosp.setSerialnum(patMedInhosp.getSerialnum()); |
| | | queryInhosp.setOrgid("" + orgid); |
| | | log.info("----------------这里的入参为:{}", queryInhosp); |
| | | List<PatMedInhosp> existingInhosps = patMedInhospService.selectPatMedInhospList(queryInhosp); |
| | | |
| | | log.info("----------------这里的返参为:{}", existingInhosps); |
| | | if (CollectionUtils.isNotEmpty(existingInhosps)) { |
| | | patMedInhosp.setInhospid(existingInhosps.get(0).getInhospid()); |
| | | patMedInhospService.updatePatMedInhosp(patMedInhosp); |
| | |
| | | } |
| | | } |
| | | |
| | | private PatMedInhosp buildPatientInhospInfo(ServiceSLTDInhospResDTO dto, PatArchive patArchive, String cry) { |
| | | private PatMedInhosp buildPatientInhospInfo(ServiceSLTDInhospResDTO dto, PatArchive patArchive, String cry, Long orgid) { |
| | | log.info("----------------buildPatientInhospInfo这里进来了吗?{}", cry); |
| | | PatMedInhosp patMedInhosp = new PatMedInhosp(); |
| | | patMedInhosp.setPatid(patArchive.getId()); |
| | | patMedInhosp.setPatno(patArchive.getPatientno()); |
| | |
| | | patMedInhosp.setNurseName(dto.getChiefNurseName()); |
| | | patMedInhosp.setSerialnum(dto.getHealthcareRecordNo()); |
| | | patMedInhosp.setFuflag("1"); |
| | | patMedInhosp.setInhospstate("0".equals(cry) ? "0" : "1"); |
| | | if ("0".equals(cry)) patMedInhosp.setInhospstate("0"); |
| | | if ("1".equals(cry)) patMedInhosp.setInhospstate("1"); |
| | | patMedInhosp.setHospitalcode(dto.getOrgId()); |
| | | patMedInhosp.setBedNo(dto.getBedNumber()); |
| | | patMedInhosp.setStarttime(parseDate(dto.getStartTime())); |
| | |
| | | patMedInhosp.setDrcode("" + dto.getDoctorId()); |
| | | patMedInhosp.setSchemestatus("0".equals(cry) ? 1L : 2L); |
| | | patMedInhosp.setDelFlag("0"); |
| | | patMedInhosp.setOrgid("1"); |
| | | patMedInhosp.setOrgid("" + orgid); |
| | | return patMedInhosp; |
| | | } |
| | | |
| | |
| | | patMedInhosp.setHospitaldistrictname(dto.getAreaName()); |
| | | } |
| | | |
| | | private PatArchive processPatientArchive(ServiceSLTDInhospResDTO dto) { |
| | | private PatArchive processPatientArchive(ServiceSLTDInhospResDTO dto, Long orgid) { |
| | | PatArchive queryArchive = new PatArchive(); |
| | | queryArchive.setIdcardno(dto.getIdCardNo().trim()); |
| | | queryArchive.setIdcardno(StringUtils.isEmpty(dto.getIdCardNo()) ? "" + dto.getMedicalCardId() : dto.getIdCardNo().trim()); |
| | | List<PatArchive> existingArchives = patArchiveService.selectPatArchiveList(queryArchive); |
| | | |
| | | PatArchive patArchive = buildPatientArchive(dto); |
| | | PatArchive patArchive = buildPatientArchive(dto, orgid); |
| | | |
| | | if (CollectionUtils.isEmpty(existingArchives)) { |
| | | patArchiveService.insertPatArchive(patArchive); |
| | |
| | | return patArchive; |
| | | } |
| | | |
| | | private PatArchive buildPatientArchive(ServiceSLTDInhospResDTO dto) { |
| | | private PatArchive buildPatientArchive(ServiceSLTDInhospResDTO dto, Long orgid) { |
| | | PatArchive patArchive = new PatArchive(); |
| | | patArchive.setPatientno(dto.getMedicalRecordNo()); |
| | | patArchive.setIdcardno(dto.getIdCardNo().trim()); |
| | | patArchive.setPatientno("" + dto.getPatientId()); |
| | | patArchive.setIdcardno(StringUtils.isEmpty(dto.getIdCardNo()) ? "" + dto.getMedicalCardId() : dto.getIdCardNo().trim()); |
| | | patArchive.setName(dto.getPatientName()); |
| | | patArchive.setSourcefrom(2); |
| | | patArchive.setPattype("2"); |
| | |
| | | patArchive.setDelFlag("0"); |
| | | patArchive.setCreateTime(new Date()); |
| | | patArchive.setUpdateTime(new Date()); |
| | | patArchive.setOrgid("" + orgid); |
| | | return patArchive; |
| | | } |
| | | |
| | |
| | | |
| | | private String getStringValue(Map<String, Object> map, String key) { |
| | | Object value = map.get(key); |
| | | return value != null ? value.toString() : null; |
| | | if (value == null) { |
| | | return null; |
| | | } |
| | | |
| | | // 只处理数字类型,避免科学计数法 |
| | | return value instanceof Number ? new BigDecimal(value.toString()).toPlainString() : value.toString(); |
| | | } |
| | | |
| | | private Long getLongValue(Map<String, Object> map, String key) { |