|
|
@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import lombok.Data;
|
|
|
import lombok.EqualsAndHashCode;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.dao.his.outpatient.thmz.MzEmrDao;
|
|
|
@@ -24,12 +25,14 @@ import thyyxxk.webserver.entity.outpatient.thmz.MzEmrPatientVo;
|
|
|
import thyyxxk.webserver.entity.outpatient.thmz.req.MzEmrAddDirReq;
|
|
|
import thyyxxk.webserver.entity.outpatient.thmz.req.MzEmrAddFileReq;
|
|
|
import thyyxxk.webserver.entity.outpatient.thmz.req.MzSaveFileReq;
|
|
|
+import thyyxxk.webserver.entity.outpatient.thmz.vo.MzVisitListVo;
|
|
|
import thyyxxk.webserver.service.externalhttp.emr.EmrEditor;
|
|
|
import thyyxxk.webserver.service.hutoolcache.DeptCache;
|
|
|
import thyyxxk.webserver.service.hutoolcache.UserCache;
|
|
|
import thyyxxk.webserver.service.zhuyuanyisheng.emr.EmrServer;
|
|
|
import thyyxxk.webserver.utils.*;
|
|
|
|
|
|
+import javax.validation.constraints.NotBlank;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
@@ -41,6 +44,7 @@ import java.util.stream.Collectors;
|
|
|
* @Author:lihong
|
|
|
* @Date: 2023/10/18
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
|
public class MzEmrService {
|
|
|
@@ -325,5 +329,64 @@ public class MzEmrService {
|
|
|
return R.fail(ExceptionEnum.LOGICAL_ERROR, "操作失败,可能原因就诊医生不是您,或者已经完成了结束就诊了。");
|
|
|
}
|
|
|
|
|
|
+ public ResultVo<List<MzVisitListVo>> getMzVisitListVo(String patNo) {
|
|
|
+ return R.ok(dao.getMzVisitListVo(patNo));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Data
|
|
|
+ public static class AddFileV2 {
|
|
|
+
|
|
|
+ @NotBlank(message = "门诊号不能为空")
|
|
|
+ private String patNo;
|
|
|
+ private Integer times;
|
|
|
+
|
|
|
+ @NotBlank(message = "病历编码不能为空")
|
|
|
+ private String categoryCode;
|
|
|
+
|
|
|
+ @NotBlank(message = "病历Id不能为空")
|
|
|
+ private String categoryId;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public ResultVo<String> addFileV2(AddFileV2 params) {
|
|
|
+ JSONObject categoryInfo = emr.getCategoryInfo(params.getCategoryId());
|
|
|
+ if (categoryInfo.getInteger("valid") == 0) {
|
|
|
+ return R.fail(ExceptionEnum.LOGICAL_ERROR, "该病历模板已失效,请重新选择。");
|
|
|
+ }
|
|
|
+ String name = categoryInfo.getString("name");
|
|
|
+ JSONObject template = emr.getTemplate(params.getCategoryCode(), params.getCategoryId());
|
|
|
+ String id = SnowFlakeId.instance().nextId();
|
|
|
+ template.put("_id", id);
|
|
|
+ String userId = TokenUtil.getInstance().getTokenUserId();
|
|
|
+ JSONObject properties = template.getJSONObject("properties");
|
|
|
+ properties.put("creator", userId);
|
|
|
+ properties.put("createTime", DateUtil.now());
|
|
|
+
|
|
|
+ String categoryCode = properties.getString("categoryCode");
|
|
|
+ JSONObject addFileDocument = new JSONObject() {{
|
|
|
+ put("document", template);
|
|
|
+ }};
|
|
|
+ try {
|
|
|
+ emr.saveDocument(addFileDocument);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.EMR_SAVE, "病历保存错误,请重试!" + e.getMessage());
|
|
|
+ }
|
|
|
+ MzEmrPatientData insert = MzEmrPatientData.builder()
|
|
|
+ .emrCategoryCode(categoryCode)
|
|
|
+ .name(name)
|
|
|
+ .emrName(name)
|
|
|
+ .createId(userId)
|
|
|
+ .parent(null)
|
|
|
+ .patNo(params.getPatNo())
|
|
|
+ .times(params.getTimes())
|
|
|
+ .emrDocumentId(id)
|
|
|
+ .build();
|
|
|
+ dao.insert(insert);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<JSONObject> getUserConfig() {
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|