|
|
@@ -6,7 +6,6 @@ import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import thyyxxk.webserver.config.exception.BizException;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.dao.his.zhuyuanyisheng.emr.EmrPatientDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
@@ -18,6 +17,7 @@ import thyyxxk.webserver.utils.SnowFlakeId;
|
|
|
import thyyxxk.webserver.utils.TokenUtil;
|
|
|
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Slf4j
|
|
|
@@ -28,21 +28,12 @@ public class AutoCreateEmrServer {
|
|
|
private final EmrPatientDao dao;
|
|
|
private final EmrEditor editor;
|
|
|
|
|
|
- public ResultVo<String> createEmr(AutoCreateEmrParams.Params params) {
|
|
|
- createEmrAsync(params);
|
|
|
- return R.ok(ExceptionEnum.SUCCESS_AND_EL_MESSAGE, "创建成功。");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 异步执行次方法
|
|
|
- *
|
|
|
- * @param params
|
|
|
- */
|
|
|
- @Async
|
|
|
- public void createEmrAsync(AutoCreateEmrParams.Params params) {
|
|
|
+ public ResultVo<Map<String, String>> createEmr(AutoCreateEmrParams.Params params) {
|
|
|
if (StrUtil.isBlank(params.getCreateCode())) {
|
|
|
params.setCreateCode(TokenUtil.getInstance().getTokenUserId());
|
|
|
}
|
|
|
+ Map<String, String> messageMap = new HashMap<>();
|
|
|
+ String currentKey = "";
|
|
|
for (Map.Entry<String, AutoCreateEmr> item : autoCreateEmrList.entrySet()) {
|
|
|
if (ListUtil.notBlank(params.getTaskName())) {
|
|
|
if (!params.getTaskName().contains(item.getKey())) {
|
|
|
@@ -50,6 +41,7 @@ public class AutoCreateEmrServer {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
+ currentKey = item.getKey();
|
|
|
try {
|
|
|
String documentId = SnowFlakeId.instance().nextId();
|
|
|
AutoCreateEmrParams.AutoCreateEmrVo rst = item.getValue().create(params);
|
|
|
@@ -67,20 +59,41 @@ public class AutoCreateEmrServer {
|
|
|
.emrName(rst.getName())
|
|
|
.name(rst.getName())
|
|
|
.build();
|
|
|
+ if (StrUtil.isNotBlank(rst.getCreateCode())) {
|
|
|
+ build.setCreateId(rst.getCreateCode());
|
|
|
+ }
|
|
|
// 调用接口
|
|
|
- postEmrApi(rst);
|
|
|
- // 插入数据
|
|
|
- dao.insert(build);
|
|
|
+ String errMessage = postEmrApi(rst);
|
|
|
+ if (StrUtil.isNotBlank(errMessage)) {
|
|
|
+ messageMap.put(item.getKey(), errMessage);
|
|
|
+ } else {
|
|
|
+ // 插入数据
|
|
|
+ dao.insert(build);
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
log.error("入参:{}", JSONObject.toJSONString(params));
|
|
|
log.error("生成病历错误", e);
|
|
|
- throw new BizException(ExceptionEnum.ERROR_EL_MESSAGE, StrUtil.format("生成:【{}】任务错误,错误如下:{}", item.getKey(), e.getMessage()));
|
|
|
+ messageMap.put(currentKey, StrUtil.format("生成:【{}】任务错误,错误如下:{}", item.getKey(), e.getMessage()));
|
|
|
}
|
|
|
}
|
|
|
+ if (!messageMap.isEmpty()) {
|
|
|
+ return R.fail(ExceptionEnum.ERROR_EL_MESSAGE, messageMap);
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 异步执行次方法
|
|
|
+ *
|
|
|
+ * @param params
|
|
|
+ */
|
|
|
+ @Async
|
|
|
+ public void createEmrAsync(AutoCreateEmrParams.Params params) {
|
|
|
+ createEmr(params);
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void postEmrApi(AutoCreateEmrParams.AutoCreateEmrVo rst) {
|
|
|
+ public String postEmrApi(AutoCreateEmrParams.AutoCreateEmrVo rst) {
|
|
|
AutoCreateEmrParams.EmrParams emrParams = new AutoCreateEmrParams.EmrParams();
|
|
|
emrParams.setDocumentId(rst.getDocumentId());
|
|
|
emrParams.setCategoryId(rst.getCategoryId());
|
|
|
@@ -89,9 +102,9 @@ public class AutoCreateEmrServer {
|
|
|
log.info("上传数据:{}", emrParams);
|
|
|
JSONObject jsonObject = editor.dataFill(emrParams);
|
|
|
if (rst.getDocumentId().equals(jsonObject.getString("documentId"))) {
|
|
|
- return;
|
|
|
+ return "";
|
|
|
}
|
|
|
- throw new RuntimeException(StrUtil.format("文档id,不一致:{}", jsonObject.toString()));
|
|
|
+ return StrUtil.format("文档id,不一致:{}", jsonObject.toString());
|
|
|
}
|
|
|
|
|
|
|