| | |
| | | package com.smartor.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.json.JSON; |
| | | import cn.hutool.json.JSONUtil; |
| | | 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.redis.RedisCache; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.AesUtils; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.domain.entity.ServiceSubtaskEntity; |
| | | import com.smartor.mapper.*; |
| | | import com.smartor.service.IPatMedOuthospService; |
| | | import com.smartor.service.IServiceExternalService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import netscape.javascript.JSObject; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | |
| | | sysUser.setCampusid("1"); |
| | | //根据userName判断一下,是不是之前有新增 |
| | | SysUser sysUser1 = null; |
| | | if(StringUtils.isEmpty(sysUser.getUserName()) || StringUtils.isEmpty(sysUser.getOrgid())){ |
| | | if (StringUtils.isEmpty(sysUser.getUserName()) || StringUtils.isEmpty(sysUser.getOrgid())) { |
| | | return false; |
| | | } |
| | | List<SysUser> sysUserList = sysUserMapper.selectUserList(sysUser); |
| | |
| | | if (CollectionUtils.isNotEmpty(epli)) externalInHospPatientLiaisonInfo = epli2.get(0); |
| | | List<HashMap<String, Object>> bingRenKZXXList = ObjectUtils.isNotEmpty(yeWuXX) ? (List<HashMap<String, Object>>) yeWuXX.get("BingRenKZXXList") : null; |
| | | if (CollectionUtils.isNotEmpty(bingRenKZXXList)) { |
| | | for(HashMap<String, Object> bingRenKZXX : bingRenKZXXList){ |
| | | for (HashMap<String, Object> bingRenKZXX : bingRenKZXXList) { |
| | | String XiangMuDM = ObjectUtils.isNotEmpty(bingRenKZXX.get("XiangMuDM")) ? bingRenKZXX.get("XiangMuDM").toString() : null; |
| | | if(StringUtils.isNotEmpty(XiangMuDM) && XiangMuDM.equals("DuanHaoXX")){ |
| | | if (StringUtils.isNotEmpty(XiangMuDM) && XiangMuDM.equals("DuanHaoXX")) { |
| | | externalInHospPatientInfo.setDuanHaoXX(ObjectUtils.isNotEmpty(bingRenKZXX.get("XiangMuZMC")) ? bingRenKZXX.get("XiangMuZMC").toString() : null); |
| | | break; |
| | | } |
| | |
| | | patMedInhosp1.setDeptcode(externalInHospPatientInfo.getDangQianKSID()); |
| | | |
| | | if (ObjectUtils.isNotEmpty(SuiFangJH)) { |
| | | patMedInhosp1.setFuflag(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangBS")) ? SuiFangJH.get("SuiFangBS").toString() : null); |
| | | patMedInhosp1.setFuflag(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangBS")) ? SuiFangJH.get("SuiFangBS").toString() : "1"); |
| | | if (ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangRQ"))) { |
| | | try { |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | patMedInhosp1.setInhospstate("1"); |
| | | if (deathFlag) { |
| | | //病人死亡无须随访 |
| | | patMedInhosp1.setFuflag("1"); |
| | | patMedInhosp1.setFuflag("0"); |
| | | //更新病人 notrequiredFlag |
| | | patArchive.setNotrequiredFlag("1"); |
| | | patArchive.setNotrequiredreason("患者已离世"); |
| | | patArchiveMapper.updatePatArchive(patArchive); |
| | | //对已经生成的随访任务进行处理 |
| | | ServiceSubtaskEntity serviceSubtaskVO = new ServiceSubtaskEntity(); |
| | |
| | | serviceSubtaskVO.setSendstate(2L); |
| | | List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO); |
| | | for (ServiceSubtask serviceSubtask : serviceSubtaskList) { |
| | | serviceSubtask.setSendstate(6L); |
| | | serviceSubtask.setRemark(serviceSubtask.getRemark() + ";病人已死亡,不随访"); |
| | | serviceSubtask.setSendstate(4L); |
| | | serviceSubtask.setRemark(serviceSubtask.getRemark() + ";患者已离世,不随访"); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | } |
| | | } |
| | |
| | | patMedInhosp1.setCampusid("1"); |
| | | if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedInhosp1.getOrgid())) { |
| | | //不需要长期任务随访 |
| | | patMedInhosp1.setFuflag("1"); |
| | | patMedInhosp1.setFuflag("0"); |
| | | } |
| | | int i = patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | if (i != 1) return false; |
| | |
| | | patMedInhosp1.setCreateTime(new Date()); |
| | | if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedInhosp1.getOrgid())) { |
| | | //不需要长期任务随访 |
| | | patMedInhosp1.setFuflag("1"); |
| | | patMedInhosp1.setFuflag("0"); |
| | | } |
| | | |
| | | int i = patMedInhospMapper.insertPatMedInhosp(patMedInhosp1); |
| | |
| | | patMedInhosp1.setDeptcode(externalInHospPatientInfo.getDangQianKSID()); |
| | | |
| | | if (ObjectUtils.isNotEmpty(SuiFangJH)) { |
| | | patMedInhosp1.setFuflag(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangBS")) ? SuiFangJH.get("SuiFangBS").toString() : null); |
| | | patMedInhosp1.setFuflag(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangBS")) ? SuiFangJH.get("SuiFangBS").toString() : "1"); |
| | | if (ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangRQ"))) { |
| | | try { |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | patMedInhosp1.setOrgid(ObjectUtils.isNotEmpty(BingRenXX) && ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null); |
| | | if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedInhosp1.getOrgid())) { |
| | | //不需要长期任务随访 |
| | | patMedInhosp1.setFuflag("1"); |
| | | patMedInhosp1.setFuflag("0"); |
| | | } |
| | | int i = patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | if (i != 1) return false; |
| | |
| | | patMedInhosp1.setCreateTime(new Date()); |
| | | if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedInhosp1.getOrgid())) { |
| | | //不需要长期任务随访 |
| | | patMedInhosp1.setFuflag("1"); |
| | | patMedInhosp1.setFuflag("0"); |
| | | } |
| | | int i = patMedInhospMapper.insertPatMedInhosp(patMedInhosp1); |
| | | if (i != 1) return false; |
| | |
| | | patMedInhosp1.setDeptcode(externalInHospPatientInfo.getDangQianKSID()); |
| | | |
| | | if (ObjectUtils.isNotEmpty(SuiFangJH)) { |
| | | patMedInhosp1.setFuflag(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangBS")) ? SuiFangJH.get("SuiFangBS").toString() : null); |
| | | patMedInhosp1.setFuflag(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangBS")) ? SuiFangJH.get("SuiFangBS").toString() : "1"); |
| | | if (ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangRQ"))) { |
| | | try { |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | patMedOuthosp.setDrcode(externalDiagnosisInfo.getZhenDuanYSID()); |
| | | patMedOuthosp.setDrname(externalDiagnosisInfo.getZhenDuanYSXM()); |
| | | patMedOuthosp.setIcd10code(externalDiagnosisInfo.getIcd10()); |
| | | patMedOuthosp.setFuflag("0"); |
| | | patMedOuthosp.setFuflag("1"); |
| | | } |
| | | } |
| | | for (ExternalWZInfo externalWZInfo : ExternalWZInfoList) { |
| | |
| | | patMedOuthosp.setUpdateTime(new Date()); |
| | | if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedOuthosp.getOrgid())) { |
| | | //不需要长期任务随访,由医生自己去随访(丽水中医院首次提出) |
| | | patMedOuthosp.setFuflag("1"); |
| | | patMedOuthosp.setFuflag("0"); |
| | | } |
| | | i = patMedOuthospService.updatePatMedOuthosp(patMedOuthosp); |
| | | } else { |
| | |
| | | patMedOuthosp.setUpdateTime(new Date()); |
| | | if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedOuthosp.getOrgid())) { |
| | | //不需要长期任务随访 |
| | | patMedOuthosp.setFuflag("1"); |
| | | patMedOuthosp.setFuflag("0"); |
| | | } |
| | | i = patMedOuthospService.insertPatMedOuthosp(patMedOuthosp); |
| | | |
| | |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> query360PatInfolwl(Long patid, SysUser sysUser) { |
| | | PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patid); |
| | | Map<String, String> headers = buildRequestHeaders(); |
| | | Map<String, Object> requestParams = buildRequestParams(sysUser,patArchive); |
| | | String result = HttpUtils.sendPostByHeader("http://cfdata.nhyfy.cn/kapi/hbos-h360/open/getNoLoginUrl", new Gson().toJson(requestParams), headers); |
| | | log.info("============result的值为:{}",result); |
| | | Gson gson = new Gson(); |
| | | Map<String, Object> map = null; |
| | | if (result != null) { |
| | | map = gson.fromJson(result, new TypeToken<Map<String, Object>>() { |
| | | }.getType()); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | private Boolean getType(String type, Map dataMap) { |
| | | switch (type) { |
| | | case "BR_DA_DangAnJL": |
| | |
| | | return ageMap; |
| | | } |
| | | |
| | | |
| | | private Map<String, String> buildRequestHeaders() { |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | headers.put("app-key", "ak-0p5Qi0J1I4AL67ztEYQL1j9v"); |
| | | return headers; |
| | | } |
| | | |
| | | private Map<String, Object> buildRequestParams(SysUser sysUser,PatArchive patArchive) { |
| | | Map<String, Object> requestParams = new HashMap<>(); |
| | | requestParams.put("key", sysUser.getUserName()); |
| | | requestParams.put("windowOpen", false); |
| | | requestParams.put("isShowHeader", false); |
| | | requestParams.put("encode", 1); |
| | | |
| | | Map<String, Object> params = new HashMap<>(); |
| | | //病历号 |
| | | params.put("patientMainIndexNum", patArchive.getPatientno()); |
| | | params.put("sourceSystem", "pacs"); |
| | | params.put("workId", sysUser.getUserName()); |
| | | params.put("workName", sysUser.getNickName()); |
| | | params.put("hisDepName", sysUser.getDeptName()); |
| | | params.put("hisDepCode", sysUser.getDeptCode()); |
| | | params.put("hisOrgName", "南华大学附属第一医院"); |
| | | params.put("hisOrgCode", "20001001"); |
| | | params.put("hisHosName", "南华大学附属第一医院"); |
| | | params.put("hisHosCode", "30001002"); |
| | | requestParams.put("params", params); |
| | | return requestParams; |
| | | } |
| | | |
| | | } |