| | |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.itextpdf.text.Element; |
| | | import com.itextpdf.text.Paragraph; |
| | | import com.ltkj.common.core.domain.AjaxResult; |
| | | import com.ltkj.hosp.domain.TjCustomer; |
| | | import com.ltkj.hosp.domain.TjOrder; |
| | | import com.ltkj.hosp.domain.TjOrderYcxm; |
| | | import com.ltkj.hosp.mapper.TjCustomerMapper; |
| | | import com.ltkj.hosp.service.ITjOrderDetailService; |
| | | import com.ltkj.hosp.service.ITjOrderService; |
| | | import com.ltkj.hosp.service.TjOrderYcxmService; |
| | | import com.ltkj.hosp.vodomain.ShenGaoTiZhongVo; |
| | | import com.ltkj.system.service.ISysConfigService; |
| | | import com.ltkj.web.config.pdfutils.PdfUtils; |
| | | import com.ltkj.web.controller.system.TjCheckController; |
| | | import com.ltkj.web.controller.system.TjReportController; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import java.io.IOException; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ltkj.framework.datasource.DynamicDataSourceContextHolder.log; |
| | | |
| | |
| | | private ITjOrderDetailService detailService; |
| | | @Autowired |
| | | private ISysConfigService sysConfigService; |
| | | @Autowired |
| | | private TjOrderYcxmService tjOrderYcxmService; |
| | | |
| | | /** |
| | | * 提供给三方调用的报告查看接口 |
| | |
| | | return AjaxResult.error("暂无数据!!"); |
| | | } |
| | | JSONObject entries = JSONUtil.parseObj(tjCheckController.updateCheckType(tjNum)); |
| | | |
| | | LambdaQueryWrapper<TjOrderYcxm> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(TjOrderYcxm::getTjh, tjNum); |
| | | List<TjOrderYcxm> ycxms = tjOrderYcxmService.list(wq); |
| | | Map<String, List<TjOrderYcxm>> stringListMap = ycxms.stream() |
| | | .collect(Collectors.groupingBy(TjOrderYcxm::getParentName)); |
| | | JSONArray jczs = JSONUtil.createArray(); |
| | | JSONArray ysjy = JSONUtil.createArray(); |
| | | int xmXh = 1; |
| | | for (Map.Entry<String, List<TjOrderYcxm>> entry : stringListMap.entrySet()) { |
| | | List<TjOrderYcxm> details = entry.getValue(); |
| | | String xmmc = entry.getKey(); |
| | | details.sort(Comparator.comparing(TjOrderYcxm::getJcxm)); |
| | | |
| | | JSONObject jczObject = processDetails(details, xmmc, xmXh, true); |
| | | jczs.add(jczObject); |
| | | |
| | | JSONObject ysjyObject = processDetails(details, xmmc, xmXh, false); |
| | | ysjy.add(ysjyObject); |
| | | } |
| | | |
| | | entries.putOpt("jczs", jczs); |
| | | entries.putOpt("ysjy", ysjy); |
| | | |
| | | removeNullFields(entries); |
| | | return JSONUtil.toBean(entries, AjaxResult.class); |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | private JSONObject processDetails(List<TjOrderYcxm> details, String xmmc, int xmXh, boolean isJcz) { |
| | | JSONObject object = JSONUtil.createObj(); |
| | | boolean isXmWrite = false; |
| | | int index = 1; |
| | | for (TjOrderYcxm detail : details) { |
| | | if (!isXmWrite) { |
| | | object.putOpt("xh", xmXh++); |
| | | object.putOpt("xmmc", xmmc); |
| | | isXmWrite = true; |
| | | } |
| | | String result = detail.getJcjg(); |
| | | if (StrUtil.isNotBlank(result)) { |
| | | result = result.replaceAll("本报告仅对本次检查负责,临床医生依据病情如有疑问,请及时复查或进一步检查", "") |
| | | .replaceAll("\n", "").trim(); |
| | | if (StrUtil.isNotBlank(result)) { |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.append(" (").append(index).append(")").append(detail.getJcxm()) |
| | | .append(": ").append(result).append("\n"); |
| | | index++; |
| | | result = builder.toString(); |
| | | } |
| | | } |
| | | |
| | | if (StrUtil.isNotBlank(result)) { |
| | | object.putOpt("result", result); |
| | | } else { |
| | | object.putOpt("result", isJcz ? result : "建议定期复查"); |
| | | } |
| | | if (!isJcz) { |
| | | JSONArray contents = processJynr(detail.getJynr()); |
| | | object.putOpt("contents", contents); |
| | | } |
| | | } |
| | | return object; |
| | | } |
| | | |
| | | private JSONArray processJynr(String jynr) { |
| | | JSONArray contents = JSONUtil.createArray(); |
| | | List<Map<String, Object>> maps = JSONUtil.parseArray(jynr).stream() |
| | | .map(o -> { |
| | | JSONObject jsonObject = (JSONObject) o; |
| | | Map<String, Object> map = new HashMap<>(); |
| | | String bt = jsonObject.getStr("bt"); |
| | | String nr = jsonObject.getStr("nr"); |
| | | if (StrUtil.isNotBlank(bt) || StrUtil.isNotBlank(nr)) { |
| | | map.put("bt", bt); |
| | | map.put("nr", nr); |
| | | } |
| | | return map; |
| | | }) |
| | | .filter(map -> !map.isEmpty()) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | |
| | | for (Map<String, Object> map : maps) { |
| | | String content = " " + map.get("bt") + map.get("nr"); |
| | | contents.add(StrUtil.isBlank(content) ? " " : content); |
| | | } |
| | | return contents; |
| | | } |
| | | |
| | | } |