package com.ltkj.web.controller.his; import cn.hutool.core.bean.BeanUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.ltkj.common.core.domain.AjaxResult; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; import java.util.List; import java.util.Map; @Slf4j @RestController @RequestMapping("/his/getData") public class TestGetController { @Autowired private HisApiGetMethodService apiGetMethodService; @PostMapping("test") public AjaxResult test(@RequestBody String json){ HashMap pdfInfoMap = new HashMap<>(); JSONObject jsonObject = JSONUtil.parseObj(json); HashMap hashMap = new HashMap<>(); // 2.4.2 ----- 2.4.7 // 由前面的接口生成 20240604000160 hashMap.put("his_registration_id",jsonObject.getStr("his_registration_id")); hashMap.put("ksbm","0101"); // 由前面的接口生成 20220427000227 hashMap.put("pationid",jsonObject.getStr("pationid")); hashMap.put("ksrq",jsonObject.getStr("ksrq")); hashMap.put("jsrq",jsonObject.getStr("jsrq")); hashMap.put("pagecount",jsonObject.getInt("pagecount")); hashMap.put("page",jsonObject.getInt("page")); // 获取检验报告记录信息 AjaxResult getlabreportinfo = apiGetMethodService.getHISDataNew("Getlabreportinfo", hashMap); log.info("getlabreportinfo ->{}",getlabreportinfo); if (getlabreportinfo.get("code").toString().equals("200")){ makePDFInfo(pdfInfoMap,getlabreportinfo,"检验报告记录信息"); List> data = (List>) getlabreportinfo.get("data"); Map resultMap = data.get(0); String jybgid = (String) resultMap.get("JYBGID"); // 获取检验结果记录信息 hashMap = new HashMap<>(); hashMap.put("jybgid",jybgid); AjaxResult getlabdetailinfo = apiGetMethodService.getHISDataNew("Getlabdetailinfo", hashMap); makePDFInfo(pdfInfoMap,getlabdetailinfo,"检验结果记录"); // 获取微生物报告记录信息 AjaxResult getlabgermrepinfo = apiGetMethodService.getHISDataNew("Getlabgermrepinfo", hashMap); makePDFInfo(pdfInfoMap,getlabgermrepinfo,"微生物报告记录"); // 获取微生物药敏信息 AjaxResult getlabgermdetailinfo = apiGetMethodService.getHISDataNew("Getlabgermdetailinfo", hashMap); makePDFInfo(pdfInfoMap,getlabgermdetailinfo,"微生物药敏信息"); // 获取危急值信息 AjaxResult getlaburgentinfo = apiGetMethodService.getHISDataNew("Getlaburgentinfo", hashMap); makePDFInfo(pdfInfoMap,getlaburgentinfo,"危机值信息"); } return AjaxResult.success(); } // TODO 从2.3.1开始到2.4.7获取报告信息 然后生成pdf // his_registration_id 和 ksbm public List> makePDFInfo(HashMap map,AjaxResult ajaxResult,String key){ List> data = null; if (Integer.parseInt(ajaxResult.get("code").toString()) == 200) { data = (List>) ajaxResult.get("data"); List> parent = (List>) map.get(key); if (parent!=null){ parent.addAll(data); }else { map.put(key,data); } } return data; } @PostMapping("test_all") public AjaxResult testALL(@RequestBody String json){ // pdf信息集合 HashMap pdfInfoMap = new HashMap<>(); JSONObject jsonObject = JSONUtil.parseObj(json); // 第一次请求 必填his_registration_id、ksbm科室编码、ksrq开始日期、jsrq结束日期 // mzorzy业务类型:门诊、住院、体检、其他、cardtype卡类型, 1 电子健康卡 2 身份证 3诊疗卡 4患者ID 5就诊流水号 默认4 患者ID // String hisRegistrationId = jsonObject.getStr("his_registration_id"); // String ksbm = jsonObject.getStr("ksbm"); Map params = BeanUtil.beanToMap(jsonObject); String hisRegistrationId = params.get("his_registration_id").toString(); String ksrq = params.get("ksrq").toString(); String jsrq = params.get("jsrq").toString(); String mzorzy = params.get("mzorzy").toString(); String cardtype = params.get("cardtype").toString(); String ksbm = params.get("ksbm").toString(); String pationid = null; // 获取检查申请信息 // AjaxResult getexamapplyinfo = apiGetMethodService.getHISDataNew("Getexamapplyinfo", params); List> list; // List> list = makePDFInfo(pdfInfoMap, getexamapplyinfo, "获取检查申请信息"); // if (list != null){ // pationid = list.get(0).get("pationid").toString(); // params.clear(); // // 获取检查报告信息 // params.put("pationid",pationid); // params.put("his_registration_id",hisRegistrationId); // params.put("page",1); // params.put("pagecount",10); // AjaxResult getexamreportinfo = apiGetMethodService.getHISDataNew("Getexamreportinfo", params); // makePDFInfo(pdfInfoMap,getexamreportinfo,"获取检查报告信息"); // }else { // return AjaxResult.error("未获取到检查申请信息"); // } // params.clear(); // 获取检查危急值信息 // params.put("his_registration_id",hisRegistrationId); // params.put("ksrq",ksrq); // params.put("jsrq",jsrq); // params.put("pagecount",10); // params.put("page",1); // AjaxResult getexamurgentinfo = apiGetMethodService.getHISDataNew("Getexamurgentinfo", params); // makePDFInfo(pdfInfoMap,getexamurgentinfo,"获取检查危急值信息"); // 获取检验申请信息 // params.clear(); // params.put("mzorzy",mzorzy); // params.put("ksbm",ksbm); // params.put("cardtype",cardtype); // params.put("his_registration_id",hisRegistrationId); // AjaxResult getlabapplyinfo = apiGetMethodService.getHISDataNew("Getlabapplyinfo", params); // makePDFInfo(pdfInfoMap,getlabapplyinfo,"获取检验申请信息"); // 获取检验报告记录信息 params.clear(); params.put("his_registration_id",hisRegistrationId); params.put("ksbm",ksbm); params.put("pationid",pationid); params.put("ksrq",ksrq); params.put("jsrq",jsrq); params.put("pagecount",10); params.put("page",1); AjaxResult getlabreportinfo = apiGetMethodService.getHISDataNew("Getlabreportinfo", params); list = makePDFInfo(pdfInfoMap,getlabreportinfo,"获取检验报告记录信息"); if (list != null){ params.clear(); for (Map stringObjectMap : list) { String jybgid = stringObjectMap.get("JYBGID").toString(); params.put("jybgid",jybgid); // 获取检验结果记录信息 AjaxResult getlabdetailinfo = apiGetMethodService.getHISDataNew("Getlabdetailinfo", params); makePDFInfo(pdfInfoMap,getlabdetailinfo,"检验结果记录"); // 获取微生物报告记录信息 AjaxResult getlabgermrepinfo = apiGetMethodService.getHISDataNew("Getlabgermrepinfo", params); makePDFInfo(pdfInfoMap,getlabgermrepinfo,"微生物报告记录"); // 获取微生物药敏信息 AjaxResult getlabgermdetailinfo = apiGetMethodService.getHISDataNew("Getlabgermdetailinfo", params); makePDFInfo(pdfInfoMap,getlabgermdetailinfo,"微生物药敏信息"); // 获取危急值信息 AjaxResult getlaburgentinfo = apiGetMethodService.getHISDataNew("Getlaburgentinfo", params); makePDFInfo(pdfInfoMap,getlaburgentinfo,"危机值信息"); } System.out.println(JSONUtil.toJsonStr(pdfInfoMap)); // 返回中文字段替换 // {"获取检验报告记录信息":[{"床位号":"3","报告类别代码":"null","门诊住院标志":"1","申请日期时间":"2024-05-22T10:38:00","西医诊断代码":"","病房号":"","检验报告单号":"240522000899","报告单类别":"微生物检验报告单","报告医生代码":"02172","门诊急诊号":"0","申请医生姓名":"袁小海","检验报告 ID":"240522000899","患者姓名":"张海涛","档案保存机构名称":"泾川县人民医院","档案保存机构地址":"泾川县人民医院","医疗机构代码":"43899007-X","个人标识号":"20240522000046","电话号码":"15294040899","采样日期时间":"2024-05-22T11:09:16.51","修改标志":"0","打印日期":"2024-06-03T10:28:28.743","文件链接":"-","审核人员姓名":"王惠惠","申请日期":"2024-05-22T10:38:00","记录医生代码":"02172","检验项目名称":"普通细菌培养+药敏(痰)","审核人员代码":"02172","患者类型代码":"1","标本类型":"痰液","审核人员姓名":"王芳","标本状态":"已采样","标本代码":"null","检验项目代码":"600","报告科室代码":"0016","报告科室名称":"生化室","检验报告结果":"已审","检验备注":"-","报告日期":"2024-06-03T10:28:28.743","报告医生姓名":"王惠惠","申请机构名称":"泾川县人民医院","记录医生姓名":"王芳","申请机构代码":"43899007-X","送检时间":"2024-06-03T10:28:20.203","档案保存机构代码":"43899007-X","行数":"1","年龄":"82","申请科室名称":"内七科","标本编号":"2024060302","申请科室代码":"0072","患者科室名称":"内七科","检验样本编号":"yl2024052200000622","报告医生代码":"02188","申请医生代码":"00123"},{"床位号":"4","报告类别代码":"null","门诊住院标志":"1","申请日期时间":"2024-06-02T09:56:00","西医诊断代码":"","病房号":"","检验报告单号":"240602000236","报告单类别":"微生物检验报告单","报告医生代码":"03089","门诊急诊号":"0","申请医生姓名":"蔺芳芳","检验报告 ID":"240602000236","患者姓名":"张海涛","档案保存机构名称":"泾川县人民医院","档案保存机构地址":"泾川县人民医院","医疗机构代码":"43899007-X","个人标识号":"20240522000046","电话号码":"15294040899","采样日期时间":"2024-06-02T09:58:50","修改标志":"0","打印日期":"2024-06-03T08:34:15.843","文件链接":"-","审核人员姓名":"鲁红娟","申请日期":"2024-06-02T09:56:00","记录医生代码":"03089","检验项目名称":"普通细菌培养+药敏(痰)","审核人员代码":"03089","患者类型代码":"1","标本类型":"痰液","审核人员姓名":"王芳","标本状态":"未采样","标本代码":"null","检验项目代码":"600","报告科室代码":"0016","报告科室名称":"生化室","检验报告结果":"已审","检验备注":"-","报告日期":"2024-06-03T08:34:15.843","报告医生姓名":"鲁红娟","申请机构名称":"泾川县人民医院","记录医生姓名":"王芳","申请机构代码":"43899007-X","送检时间":"2024-06-03T08:34:14.26","档案保存机构代码":"43899007-X","行数":"2","年龄":"82","申请科室名称":"内七科","标本编号":"2024060301","申请科室代码":"0072","患者科室名称":"内七科","检验样本编号":"yl2024060200000185","报告医生代码":"02188","申请医生代码":"00337"}]} return AjaxResult.success(); }else { return AjaxResult.error("未获取到检验报告记录信息"); } } }