|
|
@@ -1,15 +1,22 @@
|
|
|
package thyyxxk.webserver.service.zhuyuanyisheng;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.dao.his.zhuyuanyisheng.EmrPatientDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
+import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrDataElement;
|
|
|
+import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrDataExtract;
|
|
|
import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrPatientData;
|
|
|
import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
import thyyxxk.webserver.utils.TokenUtil;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -75,10 +82,10 @@ public class EmrServer {
|
|
|
public ResultVo<String> insertEmrData(EmrPatientData param) {
|
|
|
param.setCreateId(TokenUtil.getTokenUserId());
|
|
|
if (dao.whetherThereIsAMedicalRecord(param.getPatNo(), param.getTimes(), param.getEmrDocumentId()).equals(1)) {
|
|
|
- dao.emrInsertForTheFirstTime(param);
|
|
|
+ dao.updateCreatedTemplate(param);
|
|
|
return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "保存成功,已覆盖原数据。");
|
|
|
} else {
|
|
|
- dao.updateCreatedTemplate(param);
|
|
|
+ dao.emrInsertForTheFirstTime(param);
|
|
|
return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "保存到本院成功");
|
|
|
}
|
|
|
}
|
|
|
@@ -105,9 +112,47 @@ public class EmrServer {
|
|
|
return ResultVoUtil.success(dao.queryWhetherThePatientHasASpecifiedMedicalRecord(param.getPatNo(), param.getTimes(), param.getEmrCategoryCode()) == 1);
|
|
|
}
|
|
|
|
|
|
- public ResultVo<String> extractDataElement() {
|
|
|
+ public ResultVo<String> extractDataElement(EmrDataElement param) {
|
|
|
+ EmrDataExtract 需要提取的数据源 = dao.extractDataSource(param.getCategoryCode());
|
|
|
+ if (需要提取的数据源 == null) {
|
|
|
+ return ResultVoUtil.success();
|
|
|
+ }
|
|
|
+ List<String> strings = JSON.parseArray(需要提取的数据源.getDataExtract(), String.class);
|
|
|
+ JSONObject elementData = JSONObject.parseObject(param.getDataElement());
|
|
|
+ Map<String, Object> extractedData = new HashMap<>(strings.size());
|
|
|
+ for (String el : strings) {
|
|
|
+ if (elementData.containsKey(el)) {
|
|
|
+ JSONObject item = (JSONObject) elementData.get(el);
|
|
|
+ Object value = item.get("value");
|
|
|
+ if (value != null) {
|
|
|
+ extractedData.put(el, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ EmrDataElement emrDataElement = dao.obtainPatientSOriginalData(param.getPatNo(), param.getTimes());
|
|
|
+ if (emrDataElement == null) {
|
|
|
+ log.info("提取到的数据:{}", JSON.toJSONString(extractedData));
|
|
|
+ dao.insertDataSource(param.getPatNo(), param.getTimes(), JSON.toJSONString(extractedData));
|
|
|
+ } else {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(emrDataElement.getDataElement());
|
|
|
+ jsonObject.putAll(extractedData);
|
|
|
+ dao.updatePatientDataSource(param.getPatNo(), param.getTimes(), JSON.toJSONString(jsonObject));
|
|
|
+ log.info("患者原来的数据:{}", jsonObject);
|
|
|
+ }
|
|
|
+
|
|
|
return ResultVoUtil.success();
|
|
|
}
|
|
|
|
|
|
+ @DS("his")
|
|
|
+ public void hotSearchSorting(String userCode, String code, String tableName) {
|
|
|
+ boolean insert = dao.queryWhetherThereIsHotSearch(userCode, code, tableName) == 0;
|
|
|
+ if (insert) {
|
|
|
+ dao.hotSearchSorting(userCode, code, tableName);
|
|
|
+ } else {
|
|
|
+ dao.updateHotSearch(userCode, code, tableName);
|
|
|
+ }
|
|
|
+ log.info("医生编码:{},搜索关键字:{},表名:{}", userCode, code, tableName);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|