From 913b726b3ebc7cc4f34f88c50994f09c92f65004 Mon Sep 17 00:00:00 2001 From: changpengfei Date: Tue, 14 Sep 2021 10:30:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=82=A3=E8=80=85=E8=B4=AD=E4=B9=B0=E5=8D=A1?= =?UTF-8?q?=E4=B8=80=E8=A1=8C=E5=8F=98=E5=A4=9A=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PatientController.java | 266 ++++++++++----------- 1 file changed, 132 insertions(+), 134 deletions(-) diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java index c39bb07..fa8e7b3 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java @@ -40,7 +40,7 @@ public class PatientController { private LymsIllnessService lymsIllnessService;//疾病 @Autowired - private LymsTkcardService lymsTkcardService;//问诊记录 + private LymsTkcardService lymsTkcardService;//问诊记录 @Autowired private PatientInfoService patientInfoService;//患者视图 @@ -62,41 +62,42 @@ public class PatientController { private LymsDoctorService lymsDoctorService; //关注 @Autowired - private LymsAttentionService lymsAttentionService; + private LymsAttentionService lymsAttentionService; /** * 获取患者列表 + * * @param patientInfo * @param current * @param size * @return */ @GetMapping("sltPatientLst") - public BaseResponse sltPatientLst(PatientInfo patientInfo, int current, int size,@RequestParam(required = false) Integer qtype){ - BaseResponse baseResponse=new BaseResponse(); - Page page=new Page<>(current,size); + public BaseResponse sltPatientLst(PatientInfo patientInfo, int current, int size, @RequestParam(required = false) Integer qtype) { + BaseResponse baseResponse = new BaseResponse(); + Page page = new Page<>(current, size); QueryWrapper queryWrapper = Wrappers.query(patientInfo); - if (Objects.nonNull(qtype) &&qtype==1){//从小程序购买 - queryWrapper.inSql("id","SELECT t.`pid` FROM lyms_tcard t WHERE t.`fid`=1"); + if (Objects.nonNull(qtype) && qtype == 1) {//从小程序购买 + queryWrapper.inSql("id", "SELECT t.`pid` FROM lyms_tcard t WHERE t.`fid`=1"); } - if (Objects.nonNull(qtype) && qtype==2){//从医院购买 - queryWrapper.inSql("id","SELECT t.`pid` FROM lyms_tcard t WHERE t.`fid`=2"); + if (Objects.nonNull(qtype) && qtype == 2) {//从医院购买 + queryWrapper.inSql("id", "SELECT t.`pid` FROM lyms_tcard t WHERE t.`fid`=2"); } - Page patientPagePage=patientInfoService.page(page, queryWrapper); - List pLst=patientInfoService.list(queryWrapper); - int daiCnt=pLst.parallelStream().mapToInt(PatientInfo::getCcnt).sum();//待使用数量 + Page patientPagePage = patientInfoService.page(page, queryWrapper); + List pLst = patientInfoService.list(queryWrapper); + int daiCnt = pLst.parallelStream().mapToInt(PatientInfo::getCcnt).sum();//待使用数量 - List pids=pLst.parallelStream().map(PatientInfo::getId).collect(Collectors.toList()); + List pids = pLst.parallelStream().map(PatientInfo::getId).collect(Collectors.toList()); - LymsTcard tcard=new LymsTcard(); + LymsTcard tcard = new LymsTcard(); QueryWrapper tWrapper = Wrappers.query(tcard); - if(pids.size()==0){ + if (pids.size() == 0) { pids.add(-1); } - tWrapper.in("pid",pids); - int sum=lymsTcardService.list(tWrapper).parallelStream().mapToInt(LymsTcard::getCnt).sum(); + tWrapper.in("pid", pids); + int sum = lymsTcardService.list(tWrapper).parallelStream().mapToInt(LymsTcard::getCnt).sum(); - log.error("统计需要改动数据结构:daiCnt:{} sum:{}",daiCnt,sum); + log.error("统计需要改动数据结构:daiCnt:{} sum:{}", daiCnt, sum); baseResponse.setObject(patientPagePage); return baseResponse; @@ -104,149 +105,146 @@ public class PatientController { /** * 保存或更新患者信息 + * * @param patient * @return */ @PostMapping("savePatient") - public BaseResponse savePatient(@Validated LymsPatient patient, BindingResult result, LymsPcase pcase, String illness){ - BaseResponse baseResponse=new BaseResponse(); + public BaseResponse savePatient(@Validated LymsPatient patient, BindingResult result, LymsPcase pcase, String illness) { + BaseResponse baseResponse = new BaseResponse(); log.info(">>>>>>>>>>>>>>>登记病例"); baseResponse.setErrormsg(""); - LymsPatient patient2=lymsPatientService.getOne(Wrappers.query(patient).eq("idno",patient.getIdno())); - if(patient2==null){ + LymsPatient patient2 = lymsPatientService.getOne(Wrappers.query(patient).eq("idno", patient.getIdno())); + if (patient2 == null) { patient.setCreatedtime(new Date()); - }else{ + } else { patient.setId(patient2.getId()); patient.setUpdatedtime(new Date()); } - if(result.hasErrors()){ + if (result.hasErrors()) { baseResponse.setErrorcode(1); - result.getAllErrors().forEach(e->{ - baseResponse.setErrormsg(baseResponse.getErrormsg()+e.getDefaultMessage()); + result.getAllErrors().forEach(e -> { + baseResponse.setErrormsg(baseResponse.getErrormsg() + e.getDefaultMessage()); }); baseResponse.setErrorcode(1); return baseResponse; } - boolean f=lymsPatientService.saveOrUpdate(patient); + boolean f = lymsPatientService.saveOrUpdate(patient); // 添加病例 pcase.setCreatedby(patient.getCreatedby()); pcase.setPid(patient.getId()); pcase.setCreatedtime(new Date()); - f=lymsPcaseService.saveOrUpdate(pcase); - String[] iArr=illness.split(","); + f = lymsPcaseService.saveOrUpdate(pcase); + String[] iArr = illness.split(","); log.info(patient); log.info(pcase); - Map param=new HashMap(); + Map param = new HashMap(); for (int i = 0; i < iArr.length; i++) { - LymsIllness ness=new LymsIllness(); + LymsIllness ness = new LymsIllness(); ness.setCreatedby(patient.getCreatedby()); ness.setPcid(pcase.getPcid()); ness.setIid(Integer.parseInt(iArr[i])); ness.setCreatedtime(new Date()); param.clear(); - param.put("pcid",pcase.getPcid()); - param.put("iid",iArr[i]); - List iLst=lymsIllnessService.listByMap(param); - if(iLst.size()>0){ + param.put("pcid", pcase.getPcid()); + param.put("iid", iArr[i]); + List iLst = lymsIllnessService.listByMap(param); + if (iLst.size() > 0) { ness.setId(iLst.get(0).getId()); } - f=lymsIllnessService.saveOrUpdate(ness); + f = lymsIllnessService.saveOrUpdate(ness); log.info(ness.toString()); } + Date instDate=new Date(); //需要添加医院购买卡记录 - LymsTcard tcard=new LymsTcard(); - tcard.setCnt(patient.getCcnt()); - tcard.setPcid(pcase.getPcid()); - tcard.setPid(patient.getId()); - tcard.setFid(2); - - param.clear(); - param.put("pcid",pcase.getPcid()); - List tLst=lymsTcardService.listByMap(param); - if(tLst.size()>0){ - tcard.setId(tLst.get(0).getId()); - tcard.setUpdatedby(pcase.getUpdatedby()); - tcard.setUpdatedTime(new Date()); - }else{ + for (int i = 0; i < patient.getCcnt(); i++) { + LymsTcard tcard = new LymsTcard(); + tcard.setCnt(1); + tcard.setPcid(pcase.getPcid()); + tcard.setPid(patient.getId()); + tcard.setFid(2); tcard.setCreatedby(patient.getCreatedby()); - tcard.setCreatedtime(new Date()); - } + tcard.setCreatedtime(instDate); - lymsTcardService.saveOrUpdate(tcard); + lymsTcardService.saveOrUpdate(tcard); + } - baseResponse.setErrorcode(f==true?0:1); + baseResponse.setErrorcode(f == true ? 0 : 1); return baseResponse; } /** * 删除患者 + * * @param id * @return */ @GetMapping("delPatient") - public BaseResponse delPatient(int id){ - BaseResponse baseResponse=new BaseResponse(); - boolean f=lymsPatientService.removeById(id); - baseResponse.setErrorcode(f==true?0:1); + public BaseResponse delPatient(int id) { + BaseResponse baseResponse = new BaseResponse(); + boolean f = lymsPatientService.removeById(id); + baseResponse.setErrorcode(f == true ? 0 : 1); return baseResponse; } /** * 删除患者病例ID + * * @param pcid * @return */ @GetMapping("delPcase") - public BaseResponse delPcase(int pcid){ - BaseResponse baseResponse=new BaseResponse(); - boolean f=lymsPcaseService.removeById(pcid); - baseResponse.setErrorcode(f==true?0:1); + public BaseResponse delPcase(int pcid) { + BaseResponse baseResponse = new BaseResponse(); + boolean f = lymsPcaseService.removeById(pcid); + baseResponse.setErrorcode(f == true ? 0 : 1); return baseResponse; } /** * 患者登录 + * * @param patient * @return */ @PostMapping("loginPatient") - public BaseResponse loginPatient(@RequestBody LymsPatient patient){ - BaseResponse baseResponse=new BaseResponse(); - List dLst=lymsPatientService.list(Wrappers.query(patient)); + public BaseResponse loginPatient(@RequestBody LymsPatient patient) { + BaseResponse baseResponse = new BaseResponse(); + List dLst = lymsPatientService.list(Wrappers.query(patient)); baseResponse.setErrorcode(1); - if (dLst.size()>0) { - patient=dLst.get(0); + if (dLst.size() > 0) { + patient = dLst.get(0); String jwt = JwtUtils.createJWT("1", patient.getIdno(), Constant.JWT_TTL); - Map map=new HashMap<>(); + Map map = new HashMap<>(); patient.setIslogin(1); - if(patient.getHxid()==null ){ - JSONObject json=hxService.addUser(patient.getIdno(),Constant.COMMON_PASSWD,patient.getPname()); - JSONArray rArr=json.getJSONArray("entities"); - if(rArr.size()>0){ + if (patient.getHxid() == null) { + JSONObject json = hxService.addUser(patient.getIdno(), Constant.COMMON_PASSWD, patient.getPname()); + JSONArray rArr = json.getJSONArray("entities"); + if (rArr.size() > 0) { patient.setHxid(rArr.getJSONObject(0).getString("uuid")); } lymsPatientService.saveOrUpdate(patient); } patient.setPpasswd(null); - map.put("patient",patient); - map.put("token",jwt); + map.put("patient", patient); + map.put("token", jwt); baseResponse.setErrorcode(0); baseResponse.setObject(map); - LymsLogs logEntity=new LymsLogs(); + LymsLogs logEntity = new LymsLogs(); logEntity.setFunc("loginPatient"); logEntity.setLogDate(new Date()); - logEntity.setMessage(String.format("login:%s name:%s",patient.getIdno(),patient.getPname())); + logEntity.setMessage(String.format("login:%s name:%s", patient.getIdno(), patient.getPname())); lymsLogsService.save(logEntity); } return baseResponse; @@ -254,13 +252,14 @@ public class PatientController { /** * 查询单个患者信息 + * * @param patientInfo * @return */ @GetMapping("queryPatient") - public BaseResponse queryPatient(PatientInfo patientInfo){ - BaseResponse baseResponse=new BaseResponse(); - PatientInfo patientInfo2=patientInfoService.getOne(Wrappers.query(patientInfo)); + public BaseResponse queryPatient(PatientInfo patientInfo) { + BaseResponse baseResponse = new BaseResponse(); + PatientInfo patientInfo2 = patientInfoService.getOne(Wrappers.query(patientInfo)); baseResponse.setObject(patientInfo2); return baseResponse; } @@ -268,13 +267,14 @@ public class PatientController { /** * 传入患者id,获取病历对应的医院列表 + * * @param lymsPcase * @return */ @GetMapping("getPatientHospitals") - public BaseResponse getPatientHospitals(LymsPcase lymsPcase){ + public BaseResponse getPatientHospitals(LymsPcase lymsPcase) { BaseResponse baseResponse = new BaseResponse(); - List pcases =lymsPcaseService.list(Wrappers.query(lymsPcase)); + List pcases = lymsPcaseService.list(Wrappers.query(lymsPcase)); baseResponse.setObject(pcases); return baseResponse; } @@ -283,29 +283,30 @@ public class PatientController { /** * 查询患者在某个医院的详细诊断病历 * 需要传入患者id和医院id - * @param pid 患者id - * @param hid 医院id + * + * @param pid 患者id + * @param hid 医院id * @return */ @GetMapping("getPatientHospitalPcase") - public BaseResponse getPatientHospitalPcase(int pid,int hid, - @RequestParam(required = false) String keyword){ + public BaseResponse getPatientHospitalPcase(int pid, int hid, + @RequestParam(required = false) String keyword) { BaseResponse baseResponse = new BaseResponse(); Map data = new HashMap(5); LymsPatient patient = lymsPatientService.getById(pid); //患者基本信息 - data.put("patient",patient); + data.put("patient", patient); //医院信息 LymsHospital hospital = lymsHospitalService.getById(pid); - data.put("hospital",hospital); + data.put("hospital", hospital); List ilist = new ArrayList<>(); - if (StringUtil.isNotEmpty(keyword)){ + if (StringUtil.isNotEmpty(keyword)) { LambdaQueryWrapper iwrapper = new QueryWrapper().lambda(); iwrapper.like(LymsIllness::getIname, keyword); List illnesses = lymsIllnessService.list(iwrapper); - if (CollectionUtils.isNotEmpty(illnesses)){ + if (CollectionUtils.isNotEmpty(illnesses)) { illnesses.stream().forEach(i -> { ilist.add(i.getPcid()); }); @@ -315,9 +316,9 @@ public class PatientController { LambdaQueryWrapper wrapper = new QueryWrapper().lambda(); wrapper.eq(LymsPcase::getPid, pid); wrapper.eq(LymsPcase::getHid, hid); - if (StringUtil.isNotEmpty(keyword)){ + if (StringUtil.isNotEmpty(keyword)) { wrapper.and(i -> i.like(LymsPcase::getDname, keyword).or().like(LymsPcase::getDtname, keyword)); - if (CollectionUtils.isNotEmpty(ilist)){ + if (CollectionUtils.isNotEmpty(ilist)) { wrapper.or(i -> i.in(LymsPcase::getPcid, ilist)); } } @@ -325,7 +326,7 @@ public class PatientController { List lymsPcaseList = lymsPcaseService.list(wrapper); List pcases = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(lymsPcaseList)){ + if (CollectionUtils.isNotEmpty(lymsPcaseList)) { lymsPcaseList.forEach(destModel -> { PatientPcaseResult result = new PatientPcaseResult(); result.setPid(destModel.getPid()); @@ -342,7 +343,7 @@ public class PatientController { pcases.add(result); }); } - data.put("pcases",pcases); + data.put("pcases", pcases); baseResponse.setObject(data); return baseResponse; @@ -351,11 +352,12 @@ public class PatientController { /** * 通过患者id查询患者的基本信息 + * * @param lymsPatient * @return */ @GetMapping("getPatientBaseInfo") - public BaseResponse getPatientBaseInfo(LymsPatient lymsPatient){ + public BaseResponse getPatientBaseInfo(LymsPatient lymsPatient) { BaseResponse baseResponse = new BaseResponse(); @@ -368,13 +370,12 @@ public class PatientController { wrapper.orderByDesc(LymsPcase::getCreatedtime); List lymsPcaseList = lymsPcaseService.list(wrapper); - data.put("pid",patients.getId()); - data.put("pname",patients.getPname()); - data.put("psex",patients.getSex()); - data.put("birth",patients.getBirth()); - if (CollectionUtils.isNotEmpty(lymsPcaseList)) - { - data.put("mobile",lymsPcaseList.get(0).getMobile()); + data.put("pid", patients.getId()); + data.put("pname", patients.getPname()); + data.put("psex", patients.getSex()); + data.put("birth", patients.getBirth()); + if (CollectionUtils.isNotEmpty(lymsPcaseList)) { + data.put("mobile", lymsPcaseList.get(0).getMobile()); } baseResponse.setObject(data); return baseResponse; @@ -383,12 +384,13 @@ public class PatientController { /** * 更新患者信息 + * * @param request * @return */ @PutMapping("updatePatientInfo") - public BaseResponse updatePatientInfo(@RequestBody PatientInfoRequest request){ - BaseResponse baseResponse=new BaseResponse(); + public BaseResponse updatePatientInfo(@RequestBody PatientInfoRequest request) { + BaseResponse baseResponse = new BaseResponse(); LymsPatient patients = lymsPatientService.getById(request.getPid()); patients.setBirth(request.getBirth()); patients.setPname(request.getPname()); @@ -400,8 +402,7 @@ public class PatientController { wrapper.eq(LymsPcase::getPid, request.getPid()); wrapper.orderByDesc(LymsPcase::getCreatedtime); List lymsPcaseList = lymsPcaseService.list(wrapper); - if (CollectionUtils.isNotEmpty(lymsPcaseList)) - { + if (CollectionUtils.isNotEmpty(lymsPcaseList)) { lymsPcaseList.forEach(lymsPcase -> { lymsPcase.setMobile(request.getMobile()); lymsPcaseService.updateById(lymsPcase); @@ -413,11 +414,12 @@ public class PatientController { /** * 患者的问诊记录接口 + * * @param lymsTkrecord 传入患者id参数 * @return */ @GetMapping("getPatienttkrecord") - public BaseResponse getPatienttkrecord(LymsTkrecord lymsTkrecord){ + public BaseResponse getPatienttkrecord(LymsTkrecord lymsTkrecord) { BaseResponse baseResponse = new BaseResponse(); LymsPatient patients = lymsPatientService.getById(lymsTkrecord.getPid()); @@ -426,38 +428,35 @@ public class PatientController { LambdaQueryWrapper wrapper = new QueryWrapper().lambda(); wrapper.eq(LymsTkrecord::getPid, lymsTkrecord.getPid()); wrapper.orderByDesc(LymsTkrecord::getCreatedtime); - List lymsTkrecords = lymsTkcardService.list(wrapper); + List lymsTkrecords = lymsTkcardService.list(wrapper); List list = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(lymsTkrecords)) - { - for(LymsTkrecord record : lymsTkrecords) - { + if (CollectionUtils.isNotEmpty(lymsTkrecords)) { + for (LymsTkrecord record : lymsTkrecords) { LymsPcase pcase = lymsPcaseService.getById(record.getPcid()); Map data = new HashMap(20); - data.put("hospitalName",pcase.getHname()); - data.put("hospitalLevel",""); - data.put("doctorName",pcase.getDtname()); - data.put("departName",pcase.getDname()); - data.put("doctorLevel",""); - data.put("patientName",patients.getPname()); + data.put("hospitalName", pcase.getHname()); + data.put("hospitalLevel", ""); + data.put("doctorName", pcase.getDtname()); + data.put("departName", pcase.getDname()); + data.put("doctorLevel", ""); + data.put("patientName", patients.getPname()); StringBuilder sb = new StringBuilder(); LambdaQueryWrapper iwrapper = new QueryWrapper().lambda(); iwrapper.like(LymsIllness::getPcid, pcase.getPcid()); List illnesses = lymsIllnessService.list(iwrapper); - if (CollectionUtils.isNotEmpty(illnesses)) - { + if (CollectionUtils.isNotEmpty(illnesses)) { illnesses.forEach(lymsIllness -> { sb.append(lymsIllness.getIname()); sb.append(" "); }); } - data.put("iname",sb.toString()); - data.put("createTime",DateUtil.getDateTime(record.getCreatedtime(),DateUtil.YYYY_MM_DD)); - data.put("stat",record.getStat()); + data.put("iname", sb.toString()); + data.put("createTime", DateUtil.getDateTime(record.getCreatedtime(), DateUtil.YYYY_MM_DD)); + data.put("stat", record.getStat()); list.add(data); @@ -469,33 +468,32 @@ public class PatientController { /** * 查询患者关注的医生记录 + * * @param lymsAttention 传入患者id参数 * @return */ @GetMapping("getPatientAttentions") - public BaseResponse getPatientAttentions(LymsAttention lymsAttention){ + public BaseResponse getPatientAttentions(LymsAttention lymsAttention) { BaseResponse baseResponse = new BaseResponse(); //查询患者的关注医生记录 LambdaQueryWrapper wrapper = new QueryWrapper().lambda(); wrapper.eq(LymsAttention::getPid, lymsAttention.getPid()); wrapper.orderByDesc(LymsAttention::getCreatedtime); - List lymsAttentions = lymsAttentionService.list(wrapper); + List lymsAttentions = lymsAttentionService.list(wrapper); List list = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(lymsAttentions)) - { - for(LymsAttention attention : lymsAttentions) - { + if (CollectionUtils.isNotEmpty(lymsAttentions)) { + for (LymsAttention attention : lymsAttentions) { LymsDoctor doctor = lymsDoctorService.getById(attention.getDid()); Map data = new HashMap(20); - data.put("doctorName",doctor.getDname()); - data.put("departName",doctor.getDdname()); - data.put("doctorLevel",""); - data.put("hospitalName",doctor.getHname()); - data.put("hospitalLevel",""); - data.put("doctorDesc",doctor.getIntro()); + data.put("doctorName", doctor.getDname()); + data.put("departName", doctor.getDdname()); + data.put("doctorLevel", ""); + data.put("hospitalName", doctor.getHname()); + data.put("hospitalLevel", ""); + data.put("doctorDesc", doctor.getIntro()); list.add(data); } } -- 1.8.3.1