|
@@ -46,6 +46,78 @@ public class MzEmrService {
|
|
|
private final EmrEditor emr;
|
|
|
private final UserCache userCache;
|
|
|
private final DeptCache deptCache;
|
|
|
+ private final EmrPatientDao emrPatientDao;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description:查询 1住院 2当前 3历史记录
|
|
|
+ * @author: lihong
|
|
|
+ * @date: 2023/10/18 16:51
|
|
|
+ * @param: type
|
|
|
+ * @return: java.util.Map<java.lang.String, java.util.List < com.alibaba.fastjson.JSONObject>>
|
|
|
+ **/
|
|
|
+ public List<MzEmrPatientData> queryMzEmrTree(MzEmrPatientVo param) {
|
|
|
+ List<MzEmrPatientData> result;
|
|
|
+ QueryWrapper<MzEmrPatientData> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("pat_no", param.getPatientId());
|
|
|
+ String strTemplate = "";
|
|
|
+ List<MzEmrPatientData> list;
|
|
|
+ if (param.getType() == 1) {
|
|
|
+ String patNo = dao.selectPatNo(param.getPatientId());
|
|
|
+ list = emrPatientDao.selectDataByPatNo(patNo);
|
|
|
+ strTemplate = "第{}住院记录";
|
|
|
+ } else if (param.getType() == 2) {
|
|
|
+ queryWrapper.eq("times", param.getTimes());
|
|
|
+ list = dao.selectList(queryWrapper);
|
|
|
+ return list;
|
|
|
+ } else {
|
|
|
+ strTemplate = "第{}就诊记录";
|
|
|
+ queryWrapper.ne("times", param.getTimes());
|
|
|
+ list = dao.selectList(queryWrapper);
|
|
|
+ }
|
|
|
+ result = getTree(list, strTemplate);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<MzEmrPatientData> getTree(List<MzEmrPatientData> list, String strTemplate) {
|
|
|
+ if (CollUtil.isEmpty(list)) return list;
|
|
|
+ List<MzEmrPatientData> result = new ArrayList<>();
|
|
|
+ Map<Integer, List<MzEmrPatientData>> collect = list.stream().collect(Collectors.groupingBy(MzEmrPatientData::getTimes));
|
|
|
+ int index = 1;
|
|
|
+ for (Integer key : collect.keySet()) {
|
|
|
+ MzEmrPatientData tem = new MzEmrPatientData();
|
|
|
+ tem.setId(index);
|
|
|
+ tem.setName(StrUtil.format(strTemplate, key));
|
|
|
+ tem.setChildren(collect.get(key));
|
|
|
+ result.add(tem);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String> saveMzEmrModel(MzEmrPatientData param) {
|
|
|
+ AssertUtil.isnotBlank(param.getEmrDocumentId(), "文档id不能为空");
|
|
|
+ AssertUtil.isnotBlank(param.getUserIdCode(), "用户不能为空");
|
|
|
+ JSONObject saveJson = new JSONObject();
|
|
|
+ saveJson.put("document", param.getDocumentData());
|
|
|
+ try {
|
|
|
+ emr.saveDocument(saveJson);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.EMR_SAVE, "病历保存错误,请重试!" + e.getMessage());
|
|
|
+ }
|
|
|
+ QueryWrapper<MzEmrPatientData> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("emr_document_id", param.getEmrDocumentId());
|
|
|
+ MzEmrPatientData mzEmrPatientData = dao.selectOne(queryWrapper);
|
|
|
+ if (mzEmrPatientData == null) {
|
|
|
+ param.setCreateId(param.getUserIdCode());
|
|
|
+ dao.insert(param);
|
|
|
+ } else {
|
|
|
+ param.setModifyId(param.getUserIdCode());
|
|
|
+ param.setModifyDate(new Date());
|
|
|
+ UpdateWrapper<MzEmrPatientData> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.eq("emr_document_id", param.getEmrDocumentId());
|
|
|
+ dao.update(param, updateWrapper);
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE, "保存成功");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
public JSONArray getMzEmrModel() {
|