diff --git a/postdischarge-common/src/main/java/com/xinelu/common/enums/RouteNodeNameEnum.java b/postdischarge-common/src/main/java/com/xinelu/common/enums/RouteNodeNameEnum.java index a98c9291..67489e71 100644 --- a/postdischarge-common/src/main/java/com/xinelu/common/enums/RouteNodeNameEnum.java +++ b/postdischarge-common/src/main/java/com/xinelu/common/enums/RouteNodeNameEnum.java @@ -13,37 +13,52 @@ public enum RouteNodeNameEnum { /** * 出院后 */ - AFTER_DISCHARGE("AFTER_DISCHARGE"), + AFTER_DISCHARGE("AFTER_DISCHARGE", "出院后"), /** * 入院后 */ - AFTER_ADMISSION("AFTER_ADMISSION"), + AFTER_ADMISSION("AFTER_ADMISSION", "入院后"), /** * 就诊后 */ - AFTER_CONSULTATION("AFTER_CONSULTATION"), + AFTER_CONSULTATION("AFTER_CONSULTATION", "就诊后"), /** * 就诊/出院后 */ - AFTER_VISIT_DISCHARGE("AFTER_VISIT_DISCHARGE"), + AFTER_VISIT_DISCHARGE("AFTER_VISIT_DISCHARGE", "就诊/出院后"), /** * 术前 */ - PREOPERATIVE("PREOPERATIVE"), + PREOPERATIVE("PREOPERATIVE", "术前"), /** * 术后 */ - POSTOPERATIVE("POSTOPERATIVE"), + POSTOPERATIVE("POSTOPERATIVE", "术后"), ; final private String info; + final private String name; - RouteNodeNameEnum(String info) { + RouteNodeNameEnum(String info, String name) { this.info = info; + this.name = name; } + + public String getName() { + return name; + } + + public static RouteNodeNameEnum getNameByInfo(String info) { + for (RouteNodeNameEnum routeNodeName : RouteNodeNameEnum.values()) { + if (info.equals(routeNodeName.getInfo())) { + return routeNodeName; + } + } + return RouteNodeNameEnum.AFTER_VISIT_DISCHARGE; + } } \ No newline at end of file diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/patientinfo/PatientInfoController.java b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/patientinfo/PatientInfoController.java index 02db950b..064dbb1b 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/patientinfo/PatientInfoController.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/patientinfo/PatientInfoController.java @@ -113,4 +113,5 @@ public class PatientInfoController extends BaseController { public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(patientInfoService.deletePatientInfoByIds(ids)); } + } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/signpatientmanageroute/SignPatientManageRouteController.java b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/signpatientmanageroute/SignPatientManageRouteController.java index 68c19ad7..744d1eb0 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/signpatientmanageroute/SignPatientManageRouteController.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/signpatientmanageroute/SignPatientManageRouteController.java @@ -3,6 +3,7 @@ package com.xinelu.manage.controller.signpatientmanageroute; import com.xinelu.common.annotation.Log; import com.xinelu.common.core.controller.BaseController; import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.common.core.domain.R; import com.xinelu.common.core.page.TableDataInfo; import com.xinelu.common.custominterface.Insert; import com.xinelu.common.enums.BusinessType; @@ -16,6 +17,7 @@ import com.xinelu.manage.vo.signpatientmanageroute.SignPatientManageRouteVO; import com.xinelu.manage.vo.signpatientmanageroutenode.SignPatientManageNodeAuditVo; import com.xinelu.manage.vo.specialdiseaseroute.SpecialDiseaseRouteAuditVo; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; @@ -139,9 +141,10 @@ public class SignPatientManageRouteController extends BaseController { * @param signRecordId 患者签约主键 * @return 主路径信息及节点、子路径信息及节点 */ + @ApiOperation("路径审核->路径信息") @GetMapping("/getRouteAuditInfo/{signRecordId}") - public SpecialDiseaseRouteAuditVo getRouteAuditInfo(@PathVariable("signRecordId") Long signRecordId){ - return signPatientManageRouteService.getRouteAuditInfo(signRecordId); + public R getRouteAuditInfo(@PathVariable("signRecordId") Long signRecordId){ + return R.ok(signPatientManageRouteService.getRouteAuditInfo(signRecordId)); } /** @@ -149,8 +152,10 @@ public class SignPatientManageRouteController extends BaseController { * @param signRecordId 患者签约主键 * @return 节点详细信息 */ + @ApiOperation("路径审核->路径任务") @GetMapping("/getRouteNodeInfo/{signRecordId}") - public List getRouteNodeInfo(@PathVariable("signRecordId") Long signRecordId) { - return signPatientManageRouteService.getRouteNodeInfo(signRecordId); + public R> getRouteNodeInfo(@PathVariable("signRecordId") Long signRecordId) { + return R.ok(signPatientManageRouteService.getRouteNodeInfo(signRecordId)); } + } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/signpatientrecord/SignPatientRecordController.java b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/signpatientrecord/SignPatientRecordController.java index 492f19fa..c5425b54 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/signpatientrecord/SignPatientRecordController.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/signpatientrecord/SignPatientRecordController.java @@ -4,6 +4,7 @@ import com.xinelu.common.core.controller.BaseController; import com.xinelu.common.core.domain.R; import com.xinelu.common.core.page.TableDataInfo; import com.xinelu.manage.dto.signpatientrecord.IntentionalSignDto; +import com.xinelu.manage.dto.signpatientrecord.RouteCheckDto; import com.xinelu.manage.dto.signpatientrecord.SignPatientAddDto; import com.xinelu.manage.dto.signpatientrecord.SignPatientListDto; import com.xinelu.manage.dto.signpatientrecord.SignPatientStatusDto; @@ -103,4 +104,33 @@ public class SignPatientRecordController extends BaseController { int flag = signPatientRecordService.updateSignStatus(updateSignStatus); return flag < 0 ? R.fail() : R.ok(); } + + /** + * 路径审核->左侧画像信息列表 + */ + @ApiOperation("路径审核->左侧画像信息列表") + @GetMapping("/getPortaitInfo/{patientId}") + public R getPortaitInfo(@PathVariable("patientId") Long patientId) { + signPatientRecordService.getPortaitInfo(patientId); + return R.ok(); + } + + /** + * 画像审核 + */ + @ApiOperation("画像审核") + @PostMapping("/updatePortaitCheckStatus") + public R updatePortaitCheckStatus(@RequestBody RouteCheckDto checkDto) { + int flag = signPatientRecordService.updatePortaitCheckStatus(checkDto); + return flag < 0 ? R.fail() : R.ok(); + } + /** + * 路径审核 + */ + @ApiOperation("路径审核") + @PostMapping("/updateRouteCheckStatus") + public R updateRouteCheckStatus(@RequestBody RouteCheckDto routeCheckDto) { + int flag = signPatientRecordService.updateRouteCheckStatus(routeCheckDto); + return flag < 0 ? R.fail() : R.ok(); + } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/signpatientrecord/SignPatientRecord.java b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/signpatientrecord/SignPatientRecord.java index caffe789..52d855c2 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/signpatientrecord/SignPatientRecord.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/signpatientrecord/SignPatientRecord.java @@ -227,6 +227,24 @@ public class SignPatientRecord extends BaseEntity { @ApiModelProperty(value = "健康管理师姓名") private String healthManageName; + /** + * 画像审核状态,同意:AGREE,不同意:DISAGREE + */ + @ApiModelProperty(value = "画像审核状态,同意:AGREE,不同意:DISAGREE") + private String portaitCheckStatus; + + /** + * 画像审核人姓名 + */ + @ApiModelProperty(value = "画像审核人姓名") + private String portaitCheckPerson; + + /** + * 画像审核时间 + */ + @ApiModelProperty(value = "画像审核时间") + private LocalDateTime portaitCheckDate; + /** * 专病路径审核状态,同意:AGREE,不同意:DISAGREE */ diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/dto/signpatientrecord/RouteCheckDto.java b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/signpatientrecord/RouteCheckDto.java new file mode 100644 index 00000000..1e6bcae9 --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/signpatientrecord/RouteCheckDto.java @@ -0,0 +1,28 @@ +package com.xinelu.manage.dto.signpatientrecord; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @description: 路径审核传世对象 + * @author: haown + * @create: 2024-06-26 13:41 + **/ +@Data +public class RouteCheckDto { + + @ApiModelProperty("签约记录主键") + private Long signPatientRecordId; + + /** + * 专病路径审核状态,同意:AGREE,不同意:DISAGREE + */ + @ApiModelProperty(value = "专病路径审核状态,同意:AGREE,不同意:DISAGREE") + private String routeCheckStatus; + + /** + * 专病路径审核备注信息,存储审核备注信息以及审核不通过原因等信息 + */ + @ApiModelProperty(value = "专病路径审核备注信息,存储审核备注信息以及审核不通过原因等信息") + private String routeCheckRemark; +} diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.java index 06f7d716..d64e4d64 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.java @@ -103,9 +103,15 @@ public interface SignPatientManageRouteNodeMapper { /** * 任务审核,查询手动创建的任务节点详情 - * @param manageIds 路径主键列表 + * @param manageRouteIds 路径主键列表 * @return 节点详细信息列表 */ - List selectAuditNodeInfo(List manageIds); + List selectAuditNodeInfo(@Param("manageRouteIds") List manageRouteIds); + /** + * 根据路径主键列表查询节点列表 + * @param manageRouteIds 路径主键列表 + * @return 节点列表 + */ + List selectNodesByManageIds(@Param("manageRouteIds") List manageRouteIds); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/ISignPatientManageRouteService.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/ISignPatientManageRouteService.java index 0694e6ee..f06f6318 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/ISignPatientManageRouteService.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/ISignPatientManageRouteService.java @@ -104,4 +104,5 @@ public interface ISignPatientManageRouteService { * @return 节点详细信息列表 */ List getRouteNodeInfo(Long signRecordId); + } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/impl/SignPatientManageRouteServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/impl/SignPatientManageRouteServiceImpl.java index ec5c1948..e543eecc 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/impl/SignPatientManageRouteServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroute/impl/SignPatientManageRouteServiceImpl.java @@ -8,6 +8,7 @@ import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.enums.NodeExecuteStatusEnum; import com.xinelu.common.enums.PhoneConnectStatusEnum; import com.xinelu.common.enums.PhoneMessageRemindEnum; +import com.xinelu.common.enums.RouteNodeNameEnum; import com.xinelu.common.enums.TaskContentEnum; import com.xinelu.common.enums.TaskCreateTypeEnum; import com.xinelu.common.exception.ServiceException; @@ -157,7 +158,7 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout @Transactional(rollbackFor = Exception.class) @Override public AjaxResult insertSignPatientManageRoute(SignPatientManageRouteVO signPatientManageRoute) { - //新增主表 + // 新增主表 signPatientManageRoute.setTaskCreateType(TaskCreateTypeEnum.MANUAL_CREATE.getInfo()); signPatientManageRoute.setCreateBy(SecurityUtils.getUsername()); signPatientManageRoute.setCreateTime(LocalDateTime.now()); @@ -165,7 +166,7 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout if (insertRoute < 0) { return AjaxResult.error("新增签约患者管理任务路径失败!请联系管理员!"); } - //新增节点表 + // 新增节点表 List signPatientManageRouteNodes = new ArrayList<>(); for (SignPatientManageRouteNode routeNode : signPatientManageRoute.getRouteNodeList()) { if (Objects.isNull(routeNode) || StringUtils.isBlank(routeNode.getTaskType()) || (" ").equals(routeNode.getTaskType()) || StringUtils.isBlank(routeNode.getRouteNodeName()) || Objects.isNull(routeNode.getRouteNodeDay())) { @@ -400,6 +401,9 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout } SignPatientManageRoute signPatientManageRoute = manageRouteList.get(0); SpecialDiseaseRouteAuditVo specialDiseaseRouteAuditVo = specialDiseaseRouteService.getRouteAuditInfo(signPatientManageRoute.getRouteId()); + if (ObjectUtils.isEmpty(specialDiseaseRouteAuditVo)) { + throw new ServiceException("未找到该专病管理路径请联系管理员"); + } // 计算子路径的节点执行时间 PatientVisitRecord patientVisitRecord = patientVisitRecordMapper.selectPatientVisitRecordById(signPatientRecord.getPatientVisitRecordId()); if (ObjectUtils.isEmpty(patientVisitRecord)) { @@ -435,6 +439,7 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout }); } + specialDiseaseRouteAuditVo.setRouteCheckStatus(signPatientRecord.getRouteCheckStatus()); return specialDiseaseRouteAuditVo; } @@ -457,6 +462,9 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout List nodeList = specialDiseaseNodeService.getByParentRouteId(signPatientManageRoute.getRouteId()); // 查询患者画像信息 List labelFieldContentList = labelFieldContentMapper.selectByPatientId(signPatientRecord.getPatientId()); + if (CollectionUtils.isEmpty(labelFieldContentList)) { + throw new ServiceException("请先维护画像信息"); + } // 组装数据 nodeList.forEach(node -> { SignPatientManageNodeAuditVo manageRouteNode = new SignPatientManageNodeAuditVo(); @@ -465,51 +473,54 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout manageRouteNode.setId(null); manageRouteNode.setRouteNodeId(node.getId()); manageRouteNode.setExecuteTime(node.getExecutionTime()); + manageRouteNode.setRouteNodeNameCN(RouteNodeNameEnum.getNameByInfo(node.getRouteNodeName()).getName()); JSONObject templateDetail = new JSONObject(); // 根据模板类型,存放模板字段 - switch(node.getTemplateType()) { - // 宣教 - case TemplateTypeConstants.PROPAGANDA: - manageRouteNode.setPropagandaInfoId(node.getTemplateId()); - manageRouteNode.setPropagandaTitle(node.getTemplateName()); - // 查询宣教表 - PropagandaMaterialsVo propagandaMaterialsVo = propagandaInfoService.selectPropagandaInfoById(node.getTemplateId()); - templateDetail = JSONObject.parseObject(JSONObject.toJSONString(propagandaMaterialsVo)); - manageRouteNode.setTemplateType(TemplateTypeConstants.PROPAGANDA); - manageRouteNode.setTemplateDetail(templateDetail); - break; - // 问卷 - case TemplateTypeConstants.QUESTIONNAIRE: - manageRouteNode.setQuestionInfoId(node.getTemplateId()); - manageRouteNode.setQuestionnaireName(node.getTemplateName()); - // 查询问卷详情 - QuestionVO questionVO = questionInfoService.selectQuestionInfoById(node.getTemplateId()); - if (ObjectUtils.isNotEmpty(questionVO)) { - templateDetail = JSONObject.parseObject(JSONObject.toJSONString(questionVO)); - manageRouteNode.setTemplateType(TemplateTypeConstants.QUESTIONNAIRE); + if(StringUtils.isNotBlank(node.getTemplateType())) { + switch(node.getTemplateType()) { + // 宣教 + case TemplateTypeConstants.PROPAGANDA: + manageRouteNode.setPropagandaInfoId(node.getTemplateId()); + manageRouteNode.setPropagandaTitle(node.getTemplateName()); + // 查询宣教表 + PropagandaMaterialsVo propagandaMaterialsVo = propagandaInfoService.selectPropagandaInfoById(node.getTemplateId()); + templateDetail = JSONObject.parseObject(JSONObject.toJSONString(propagandaMaterialsVo)); + manageRouteNode.setTemplateType(TemplateTypeConstants.PROPAGANDA); manageRouteNode.setTemplateDetail(templateDetail); - } - break; - // 话术 - case TemplateTypeConstants.SCRIPT: - manageRouteNode.setPhoneId(node.getTemplateId()); - // 查询话术 - ScriptInfo scriptInfo = scriptInfoMapper.selectScriptInfoById(node.getTemplateId()); - if (ObjectUtils.isNotEmpty(scriptInfo)) { - // 话术库json内容替换 - manageRouteNode.setPhoneNodeContent(getFlowScheme(scriptInfo.getFlowScheme(), labelFieldContentList)); - templateDetail = JSONObject.parseObject(JSONObject.toJSONString(scriptInfo)); - manageRouteNode.setTemplateType(TemplateTypeConstants.SCRIPT); - manageRouteNode.setTemplateDetail(templateDetail); - - // 电话短信内容 - if (node.getPhoneMessageTemplateId() != null) { - // 查询短信库 - manageRouteNode.setPhoneMessageTemplateContent(replaceMessageInfo(node.getPhoneMessageTemplateId(), labelFieldContentList)); + break; + // 问卷 + case TemplateTypeConstants.QUESTIONNAIRE: + manageRouteNode.setQuestionInfoId(node.getTemplateId()); + manageRouteNode.setQuestionnaireName(node.getTemplateName()); + // 查询问卷详情 + QuestionVO questionVO = questionInfoService.selectQuestionInfoById(node.getTemplateId()); + if (ObjectUtils.isNotEmpty(questionVO)) { + templateDetail = JSONObject.parseObject(JSONObject.toJSONString(questionVO)); + manageRouteNode.setTemplateType(TemplateTypeConstants.QUESTIONNAIRE); + manageRouteNode.setTemplateDetail(templateDetail); } - } - break; + break; + // 话术 + case TemplateTypeConstants.SCRIPT: + manageRouteNode.setPhoneId(node.getTemplateId()); + // 查询话术 + ScriptInfo scriptInfo = scriptInfoMapper.selectScriptInfoById(node.getTemplateId()); + if (ObjectUtils.isNotEmpty(scriptInfo)) { + // 话术库json内容替换 + manageRouteNode.setPhoneNodeContent(getFlowScheme(scriptInfo.getFlowScheme(), labelFieldContentList)); + templateDetail = JSONObject.parseObject(JSONObject.toJSONString(scriptInfo)); + manageRouteNode.setTemplateType(TemplateTypeConstants.SCRIPT); + manageRouteNode.setTemplateDetail(templateDetail); + + // 电话短信内容 + if (node.getPhoneMessageTemplateId() != null) { + // 查询短信库 + manageRouteNode.setPhoneMessageTemplateContent(replaceMessageInfo(node.getPhoneMessageTemplateId(), labelFieldContentList)); + } + } + break; + } } // 替换短信、公众号、小程序内容 replaceTemplateInfo(manageRouteNode, node, labelFieldContentList); @@ -520,72 +531,77 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout } else { manageNodeList.add(manageRouteNode); } - manageNodeAuditList.addAll(manageNodeList); }); // 查询手动创建的节点 manageRouteQuery.setTaskCreateType(TaskCreateTypeConstant.MANUAL_CREATE); List createRouteList = signPatientManageRouteMapper.selectSignPatientManageRouteList(manageRouteQuery); - List manageRouteIds = createRouteList.stream().map(SignPatientManageRoute::getId).collect(Collectors.toList()); - List manageNodeList = signPatientManageRouteNodeMapper.selectAuditNodeInfo(manageRouteIds); - // 根据node去替换模板信息 - manageNodeList.forEach(manageNode -> { - JSONObject templateDetail = new JSONObject(); - switch(manageNode.getTaskType()) { - // 电话外呼--话术 - case TaskContentConstants.PHONE_OUTBOUND: - ScriptInfo scriptInfo = scriptInfoMapper.selectScriptInfoById(manageNode.getPhoneId()); - if (ObjectUtils.isNotEmpty(scriptInfo)) { - // 话术库json内容替换 - manageNode.setPhoneNodeContent(getFlowScheme(scriptInfo.getFlowScheme(), labelFieldContentList)); - templateDetail = JSONObject.parseObject(JSONObject.toJSONString(scriptInfo)); - manageNode.setTemplateType(TemplateTypeConstants.SCRIPT); - manageNode.setTemplateDetail(templateDetail); + if (CollectionUtils.isNotEmpty(createRouteList)) { + List manageRouteIds = createRouteList.stream().map(SignPatientManageRoute::getId).collect(Collectors.toList()); + List manageNodeList = signPatientManageRouteNodeMapper.selectAuditNodeInfo(manageRouteIds); + // 根据node去替换模板信息 + manageNodeList.forEach(manageNode -> { + manageNode.setRouteNodeNameCN(RouteNodeNameEnum.getNameByInfo(manageNode.getRouteNodeName()).getName()); + JSONObject templateDetail = new JSONObject(); + switch(manageNode.getTaskType()) { + // 电话外呼--话术 + case TaskContentConstants.PHONE_OUTBOUND: + ScriptInfo scriptInfo = scriptInfoMapper.selectScriptInfoById(manageNode.getPhoneId()); + if (ObjectUtils.isNotEmpty(scriptInfo)) { + // 话术库json内容替换 + manageNode.setPhoneNodeContent(getFlowScheme(scriptInfo.getFlowScheme(), labelFieldContentList)); + templateDetail = JSONObject.parseObject(JSONObject.toJSONString(scriptInfo)); + manageNode.setTemplateType(TemplateTypeConstants.SCRIPT); + manageNode.setTemplateDetail(templateDetail); - // 电话短信内容 - if (manageNode.getPhoneMessageTemplateId() != null) { - // 查询短信库 - manageNode.setPhoneMessageTemplateContent(replaceMessageInfo(manageNode.getPhoneMessageTemplateId(), labelFieldContentList)); + // 电话短信内容 + if (manageNode.getPhoneMessageTemplateId() != null) { + // 查询短信库 + manageNode.setPhoneMessageTemplateContent(replaceMessageInfo(manageNode.getPhoneMessageTemplateId(), labelFieldContentList)); + } } - } - break; + break; // 问卷 - case TaskContentConstants.QUESTIONNAIRE_SCALE: - // 查询问卷详情 - QuestionVO questionVO = questionInfoService.selectQuestionInfoById(manageNode.getQuestionInfoId()); - if (ObjectUtils.isNotEmpty(questionVO)) { - templateDetail = JSONObject.parseObject(JSONObject.toJSONString(questionVO)); - manageNode.setTemplateType(TemplateTypeConstants.QUESTIONNAIRE); - manageNode.setTemplateDetail(templateDetail); - } - break; + case TaskContentConstants.QUESTIONNAIRE_SCALE: + // 查询问卷详情 + QuestionVO questionVO = questionInfoService.selectQuestionInfoById(manageNode.getQuestionInfoId()); + if (ObjectUtils.isNotEmpty(questionVO)) { + templateDetail = JSONObject.parseObject(JSONObject.toJSONString(questionVO)); + manageNode.setTemplateType(TemplateTypeConstants.QUESTIONNAIRE); + manageNode.setTemplateDetail(templateDetail); + } + break; // 宣教 - case TaskContentConstants.PROPAGANDA_ARTICLE: - // 查询宣教详情 - PropagandaMaterialsVo propagandaMaterialsVo = propagandaInfoService.selectPropagandaInfoById(manageNode.getPropagandaInfoId()); - if (ObjectUtils.isNotEmpty(propagandaMaterialsVo)) { - templateDetail = JSONObject.parseObject(JSONObject.toJSONString(propagandaMaterialsVo)); - manageNode.setTemplateType(TemplateTypeConstants.PROPAGANDA); - manageNode.setTemplateDetail(templateDetail); - } - break; + case TaskContentConstants.PROPAGANDA_ARTICLE: + // 查询宣教详情 + PropagandaMaterialsVo propagandaMaterialsVo = propagandaInfoService.selectPropagandaInfoById(manageNode.getPropagandaInfoId()); + if (ObjectUtils.isNotEmpty(propagandaMaterialsVo)) { + templateDetail = JSONObject.parseObject(JSONObject.toJSONString(propagandaMaterialsVo)); + manageNode.setTemplateType(TemplateTypeConstants.PROPAGANDA); + manageNode.setTemplateDetail(templateDetail); + } + break; // 文字提醒 - //case TaskContentConstants.TEXT_REMIND: - // manageNode.setTemplateType(TemplateTypeConstants.PROPAGANDA); - // break; - // 人工随访 - case TaskContentConstants.ARTIFICIAL_FOLLOW_UP: - // 查询问卷详情 - QuestionVO questionVO1 = questionInfoService.selectQuestionInfoById(Long.valueOf(manageNode.getPhoneTemplateId())); - if (ObjectUtils.isNotEmpty(questionVO1)) { - templateDetail = JSONObject.parseObject(JSONObject.toJSONString(questionVO1)); - manageNode.setTemplateType(TemplateTypeConstants.QUESTIONNAIRE); - manageNode.setTemplateDetail(templateDetail); - } - break; - } - manageNodeAuditList.add(manageNode); - }); + case TaskContentConstants.TEXT_REMIND: + manageNode.setTemplateType(TaskContentConstants.TEXT_REMIND); + break; + // 人工随访 + case TaskContentConstants.ARTIFICIAL_FOLLOW_UP: + // 查询问卷详情 + if (StringUtils.isNotBlank(manageNode.getPhoneTemplateId())) { + QuestionVO questionVO1 = questionInfoService.selectQuestionInfoById(Long.valueOf(manageNode.getPhoneTemplateId())); + if (ObjectUtils.isNotEmpty(questionVO1)) { + templateDetail = JSONObject.parseObject(JSONObject.toJSONString(questionVO1)); + manageNode.setTemplateType(TemplateTypeConstants.QUESTIONNAIRE); + manageNode.setTemplateDetail(templateDetail); + } + } + break; + } + manageNodeAuditList.add(manageNode); + }); + } + return manageNodeAuditList; } @@ -630,7 +646,7 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout /** * 塞值 */ - private static void extracted(SignPatientManageRouteVO signPatientManageRoute, List signPatientManageRouteNodes, SignPatientManageRouteNode routeNode) { + private void extracted(SignPatientManageRouteVO signPatientManageRoute, List signPatientManageRouteNodes, SignPatientManageRouteNode routeNode) { SignPatientManageRouteNode signPatientManageRouteNode = new SignPatientManageRouteNode(); if (Objects.nonNull(routeNode) && TaskContentEnum.PHONE_OUTBOUND.getInfo().equals(routeNode.getTaskType())) { signPatientManageRouteNode.setPhonePushSign(Objects.isNull(routeNode.getPhonePushSign()) ? null : routeNode.getPhonePushSign()); @@ -643,7 +659,7 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout signPatientManageRouteNode.setPhoneMessageRemind(StringUtils.isBlank(routeNode.getPhoneMessageRemind()) ? null : routeNode.getPhoneMessageRemind()); signPatientManageRouteNode.setPhoneMessageTemplateId(Objects.isNull(routeNode.getPhoneMessageTemplateId()) ? null : routeNode.getPhoneMessageTemplateId()); signPatientManageRouteNode.setPhoneMessageTemplateName(StringUtils.isBlank(routeNode.getPhoneMessageTemplateName()) ? null : routeNode.getPhoneMessageTemplateName()); - } + } if (Objects.nonNull(routeNode) && TaskContentEnum.QUESTIONNAIRE_SCALE.getInfo().equals(routeNode.getTaskType())) { signPatientManageRouteNode.setQuestionInfoId(Objects.isNull(routeNode.getQuestionInfoId()) ? null : routeNode.getQuestionInfoId()); signPatientManageRouteNode.setQuestionnaireName(StringUtils.isBlank(routeNode.getQuestionnaireName()) ? null : routeNode.getQuestionnaireName()); @@ -730,16 +746,16 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout } private void replaceTemplateInfo(SignPatientManageNodeAuditVo manageRouteNode, RouteTaskAuditVo node, List labelFieldContentList) { - if (node.getMessagePushSign() == 1) { + if (node.getMessagePushSign() != null && node.getMessagePushSign() == 1) { // 替换短信模板 manageRouteNode.setMessageNodeContent(replaceMessageInfo(node.getMessageTemplateId(), labelFieldContentList)); } // 替换公众号模板 - if (node.getOfficialPushSign() == 1) { + if (node.getOfficialPushSign() != null && node.getOfficialPushSign() == 1) { manageRouteNode.setOfficialNodeContent(replaceWeChatTemplate(node.getOfficialTemplateId(), labelFieldContentList)); } // 替换小程序模板 - if (node.getAppletPushSign() == 1) { + if (node.getAppletPushSign() != null && node.getAppletPushSign() == 1) { manageRouteNode.setAppletNodeContent(replaceWeChatTemplate(node.getOfficialTemplateId(), labelFieldContentList)); } } @@ -779,25 +795,30 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout Map> groupbyPartition = labelFieldContentList.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getTaskPartitionDictId)); List nodeParamList = groupbyPartition.get(node.getTaskPartitionDictId()); // 参数按照序列号分组 - Map> groupBySn = nodeParamList.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getPortraitSn)); + if (CollectionUtils.isNotEmpty(nodeParamList)) { + Map> groupBySn = nodeParamList.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getPortraitSn)); - for (String portraitSn : groupBySn.keySet()) { - SignPatientManageNodeAuditVo manageNode = new SignPatientManageNodeAuditVo(); - BeanUtils.copyBeanProp(manageNode, manageRouteNode); - // 替换文本 - List nodeParams = groupBySn.get(portraitSn); - Map map = nodeParams.stream().collect(Collectors.toMap(LabelFieldInfoContentVo::getFieldCode,LabelFieldInfoContentVo::getFieldValue,(key1,key2)->key2)); - Document document = Jsoup.parse(manageNode.getNodeContent()); - // 需要提取的span - Elements spanlist = document.select("span[data-w-e-type]"); - for (Element span : spanlist) { - String paramKey = span.attr("data-fieldMark"); - span.text(map.getOrDefault(paramKey, "")); - span.unwrap(); + for (String portraitSn : groupBySn.keySet()) { + SignPatientManageNodeAuditVo manageNode = new SignPatientManageNodeAuditVo(); + BeanUtils.copyBeanProp(manageNode, manageRouteNode); + // 替换文本 + List nodeParams = groupBySn.get(portraitSn); + Map map = nodeParams.stream().collect(Collectors.toMap(LabelFieldInfoContentVo::getFieldCode,LabelFieldInfoContentVo::getFieldValue,(key1,key2)->key2)); + Document document = Jsoup.parse(manageNode.getNodeContent()); + // 需要提取的span + Elements spanlist = document.select("span[data-w-e-type]"); + for (Element span : spanlist) { + String paramKey = span.attr("data-fieldMark"); + span.text(map.getOrDefault(paramKey, "")); + span.unwrap(); + } + manageNode.setNodeContent(document.body().html()); + manageNodeList.add(manageNode); } - manageNode.setNodeContent(document.body().html()); - manageNodeList.add(manageNode); + } else { + throw new ServiceException("请维护该患者【"+node.getTaskPartitionDictName()+ "】的画像信息"); } + return manageNodeList; } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/ISignPatientManageRouteNodeService.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/ISignPatientManageRouteNodeService.java index d41cf7ff..468178c5 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/ISignPatientManageRouteNodeService.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/ISignPatientManageRouteNodeService.java @@ -140,4 +140,16 @@ public interface ISignPatientManageRouteNodeService { void generateTask(Long manageRouteNodeId, String taskType); LocalDateTime getExecuteTime(LocalTime executeTime, String routeNodeName, Integer routeNodeDay, PatientVisitRecord patientVisitRecord); + + /** + * 画像审核通过/路径审核通过后生成主路径任务 + * @param signRecordId 签约记录主键 + */ + void generateMainRouteTask(Long signRecordId); + + /** + * 手动创建的任务标签替换 + * @param signRecordId 签约记录主键 + */ + void manualCreateTaskLabelReplace(Long signRecordId); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/impl/SignPatientManageRouteNodeServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/impl/SignPatientManageRouteNodeServiceImpl.java index e684938d..55001df9 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/impl/SignPatientManageRouteNodeServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientmanageroutenode/impl/SignPatientManageRouteNodeServiceImpl.java @@ -24,11 +24,13 @@ import com.xinelu.manage.domain.signpatientrecord.SignPatientRecord; import com.xinelu.manage.domain.specialdiseasenode.SpecialDiseaseNode; import com.xinelu.manage.domain.specialdiseasetriggercondition.SpecialDiseaseTriggerCondition; import com.xinelu.manage.domain.textmessage.TextMessage; +import com.xinelu.manage.domain.wechattemplate.WechatTemplate; import com.xinelu.manage.dto.patientinfo.PatientInfoDto; import com.xinelu.manage.dto.signpatientmanageroutenode.AppletPatientTaskDto; import com.xinelu.manage.dto.signpatientmanageroutenode.PatientTaskDto; import com.xinelu.manage.dto.signpatientmanageroutenode.RouteNodeCheckDto; import com.xinelu.manage.dto.signpatientmanageroutenode.SignPatientManageRouteNodeDto; +import com.xinelu.manage.mapper.labelfieldcontent.LabelFieldContentMapper; import com.xinelu.manage.mapper.patientinfo.PatientInfoMapper; import com.xinelu.manage.mapper.patientvisitrecord.PatientVisitRecordMapper; import com.xinelu.manage.mapper.scriptInfo.ScriptInfoMapper; @@ -38,10 +40,12 @@ import com.xinelu.manage.mapper.signpatientrecord.SignPatientRecordMapper; import com.xinelu.manage.mapper.specialdiseasenode.SpecialDiseaseNodeMapper; import com.xinelu.manage.mapper.specialdiseasetriggercondition.SpecialDiseaseTriggerConditionMapper; import com.xinelu.manage.mapper.textmessage.TextMessageMapper; +import com.xinelu.manage.mapper.wechattemplate.WechatTemplateMapper; import com.xinelu.manage.service.propagandainfo.IPropagandaInfoService; import com.xinelu.manage.service.questioninfo.IQuestionInfoService; import com.xinelu.manage.service.signpatientmanageroutenode.ISignPatientManageRouteNodeService; import com.xinelu.manage.service.specialdiseaseroute.ISpecialDiseaseRouteService; +import com.xinelu.manage.vo.labelfieldcontent.LabelFieldInfoContentVo; import com.xinelu.manage.vo.propagandainfo.PropagandaMaterialsVo; import com.xinelu.manage.vo.questionInfo.QuestionVO; import com.xinelu.manage.vo.signpatientmanageroutenode.AppletRouteNodeListVo; @@ -59,6 +63,9 @@ import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.annotation.Resource; import org.apache.commons.collections4.CollectionUtils; @@ -102,6 +109,10 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage private TextMessageMapper textMessageMapper; @Resource private SpecialDiseaseTriggerConditionMapper triggerConditionMapper; + @Resource + private LabelFieldContentMapper labelFieldContentMapper; + @Resource + private WechatTemplateMapper wechatTemplateMapper; /** * 查询签约患者管理任务路径节点 @@ -584,6 +595,132 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage return executeDateTime; } + @Override public void generateMainRouteTask(Long signRecordId) { + List nodeSaveList = new ArrayList<>(); + // 查询专病路径节点和手动创建的任务节点 + SignPatientRecord signPatientRecord = signPatientRecordMapper.selectByPrimaryKey(signRecordId); + if (ObjectUtils.isEmpty(signPatientRecord)) { + throw new ServiceException("未找到该患者签约信息"); + } + SignPatientManageRoute manageRouteQuery = new SignPatientManageRoute(); + manageRouteQuery.setSignPatientRecordId(signRecordId); + manageRouteQuery.setTaskCreateType(TaskCreateTypeConstant.MANUAL_MATCHE); + List manageRouteList = signRouteMapper.selectSignPatientManageRouteList(manageRouteQuery); + if (CollectionUtils.isEmpty(manageRouteList)) { + throw new ServiceException("未找到签约管理路径"); + } + SignPatientManageRoute signPatientManageRoute = manageRouteList.get(0); + // 查询路径节点 + SpecialDiseaseNode specialDiseaseNodeQuery = new SpecialDiseaseNode(); + specialDiseaseNodeQuery.setRouteId(signPatientManageRoute.getRouteId()); + List nodeList = specialDiseaseNodeMapper.selectSpecialDiseaseNodeList(specialDiseaseNodeQuery); + // 查询患者画像信息 + List labelFieldContentList = labelFieldContentMapper.selectByPatientId(signPatientRecord.getPatientId()); + if (CollectionUtils.isEmpty(labelFieldContentList)) { + throw new ServiceException("请先维护画像信息"); + } + // 组装数据 + nodeList.forEach(node -> { + SignPatientManageRouteNode manageRouteNode = new SignPatientManageRouteNode(); + BeanUtils.copyBeanProp(manageRouteNode, node); + manageRouteNode.setManageRouteId(signPatientManageRoute.getId()); + manageRouteNode.setManageRouteName(signPatientManageRoute.getRouteName()); + manageRouteNode.setId(null); + manageRouteNode.setRouteNodeId(node.getId()); + manageRouteNode.setExecuteTime(node.getExecutionTime()); + + // 根据模板类型,存放模板字段 + if(StringUtils.isNotBlank(node.getTemplateType())) { + switch(node.getTemplateType()) { + // 宣教 + case TemplateTypeConstants.PROPAGANDA: + manageRouteNode.setPropagandaInfoId(node.getTemplateId()); + manageRouteNode.setPropagandaTitle(node.getTemplateName()); + break; + // 问卷 + case TemplateTypeConstants.QUESTIONNAIRE: + manageRouteNode.setQuestionInfoId(node.getTemplateId()); + manageRouteNode.setQuestionnaireName(node.getTemplateName()); + break; + // 话术 + case TemplateTypeConstants.SCRIPT: + manageRouteNode.setPhoneId(node.getTemplateId()); + // 查询话术 + ScriptInfo scriptInfo = scriptInfoMapper.selectScriptInfoById(node.getTemplateId()); + if (ObjectUtils.isNotEmpty(scriptInfo)) { + // 话术库json内容替换 + manageRouteNode.setPhoneNodeContent(getFlowScheme(scriptInfo.getFlowScheme(), labelFieldContentList)); + + // 电话短信内容 + if (node.getPhoneMessageTemplateId() != null) { + // 查询短信库 + manageRouteNode.setPhoneMessageTemplateContent(replaceMessageInfo(node.getPhoneMessageTemplateId(), labelFieldContentList)); + } + } + break; + } + } + // 替换短信、公众号、小程序内容 + replaceTemplateInfo(manageRouteNode, node, labelFieldContentList); + // 替换nodeContent + List manageNodeList = new ArrayList<>(); + if (StringUtils.contains(node.getNodeContent(), "data-w-e-type")) { + manageNodeList = replaceNodeContent(manageRouteNode, node, labelFieldContentList); + } else { + manageNodeList.add(manageRouteNode); + } + nodeSaveList.addAll(manageNodeList); + // 保存 + signPatientManageRouteNodeMapper.insertBatch(nodeSaveList); + }); + } + + @Override + public void manualCreateTaskLabelReplace(Long signRecordId) { + SignPatientManageRoute manageRouteQuery = new SignPatientManageRoute(); + manageRouteQuery.setSignPatientRecordId(signRecordId); + manageRouteQuery.setTaskCreateType(TaskCreateTypeConstant.MANUAL_CREATE); + List manageRouteList = signRouteMapper.selectSignPatientManageRouteList(manageRouteQuery); + if (CollectionUtils.isNotEmpty(manageRouteList)) { + // 查询患者画像信息 + List labelFieldContentList = labelFieldContentMapper.selectByPatientId(manageRouteList.get(0).getPatientId()); + if (CollectionUtils.isEmpty(labelFieldContentList)) { + throw new ServiceException("请先维护画像信息"); + } + List manageRouteIds = manageRouteList.stream().map(SignPatientManageRoute::getId).collect(Collectors.toList()); + List manageNodeList = signPatientManageRouteNodeMapper.selectNodesByManageIds(manageRouteIds); + // 根据node去替换模板信息 + manageNodeList.forEach(manageNode -> { + switch(manageNode.getTaskType()) { + // 电话外呼--话术 + case TaskContentConstants.PHONE_OUTBOUND: + ScriptInfo scriptInfo = scriptInfoMapper.selectScriptInfoById(manageNode.getPhoneId()); + if (ObjectUtils.isNotEmpty(scriptInfo)) { + // 话术库json内容替换 + manageNode.setPhoneNodeContent(getFlowScheme(scriptInfo.getFlowScheme(), labelFieldContentList)); + + // 电话短信内容 + if (manageNode.getPhoneMessageTemplateId() != null) { + // 查询短信库 + manageNode.setPhoneMessageTemplateContent(replaceMessageInfo(manageNode.getPhoneMessageTemplateId(), labelFieldContentList)); + } + } + break; + // 问卷 + case TaskContentConstants.QUESTIONNAIRE_SCALE: + // 宣教 + case TaskContentConstants.PROPAGANDA_ARTICLE: + // 文字提醒 + case TaskContentConstants.TEXT_REMIND: + // 人工随访 + case TaskContentConstants.ARTIFICIAL_FOLLOW_UP: + break; + } + signPatientManageRouteNodeMapper.updateSignPatientManageRouteNode(manageNode); + }); + } + } + /** * 生成子路径任务 * @param patientId 患者主键 @@ -611,4 +748,130 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage return document.body().html(); } + /** + * 话术json参数替换 + * @param flowScheme 话术json + * @param labelFieldContentList 患者画像信息 + * @return + */ + private String getFlowScheme(String flowScheme, List labelFieldContentList) { + // 话术库json内容替换 + if (org.apache.commons.lang3.StringUtils.isNotBlank(flowScheme) && org.apache.commons.lang3.StringUtils.contains(flowScheme, "{{") && org.apache.commons.lang3.StringUtils.contains(flowScheme, "}}")) { + // 替换{{}}中的内容 + Pattern pattern = Pattern.compile("\\{\\{([^\\{\\}}]+)\\}\\}"); + Matcher matcher = pattern.matcher(flowScheme); + while (matcher.find()) { + //过滤出符合条件的对象,不匹配返回null。 + LabelFieldInfoContentVo labelFieldContent = labelFieldContentList.stream().filter(s -> Objects.equals(s.getFieldCode(), matcher.group(1))).findFirst().orElse(null); + if (ObjectUtils.isNotEmpty(labelFieldContent)) { + flowScheme = flowScheme.replaceAll("\\{\\{([^\\{\\}}]+)\\}\\}", ObjectUtils.isEmpty(labelFieldContent) ? "" : labelFieldContent.getFieldValue()); + } + } + } + return flowScheme; + } + + /** + * * 短信模板内容 + * @param messageTemplateId 短信模板主键 + * @param labelFieldContentList 患者画像信息 + * @return + */ + private String replaceMessageInfo(Long messageTemplateId, List labelFieldContentList) { + // 查询短信模板 + TextMessage textMessage = textMessageMapper.selectTextMessageById(messageTemplateId); + String textMessageContent = textMessage.getTextMessageContent(); + // 替换{{}}中的内容 + Pattern pattern = Pattern.compile("\\{\\{([^\\{\\}}]+)\\}\\}"); + Matcher matcher = pattern.matcher(textMessage.getTextMessageContent()); + while (matcher.find()) { + // 过滤出符合条件的对象,不匹配返回null。 + LabelFieldInfoContentVo labelFieldContent = labelFieldContentList.stream().filter(s -> Objects.equals(s.getFieldCode(), matcher.group(1))).findFirst().orElse(null); + if (ObjectUtils.isNotEmpty(labelFieldContent)) { + textMessageContent = textMessageContent.replaceAll("\\{\\{([^\\{\\}}]+)\\}\\}", ObjectUtils.isEmpty(labelFieldContent) ? "" : labelFieldContent.getFieldValue()); + } + } + return textMessageContent; + } + + /** + * 替换短信、公众号、小程序内容 + * @param manageRouteNode 签约路径节点 + * @param node + * @param labelFieldContentList + */ + private void replaceTemplateInfo(SignPatientManageRouteNode manageRouteNode, SpecialDiseaseNode node, List labelFieldContentList) { + if (node.getMessagePushSign() != null && node.getMessagePushSign() == 1) { + // 替换短信模板 + manageRouteNode.setMessageNodeContent(replaceMessageInfo(node.getMessageTemplateId(), labelFieldContentList)); + } + // 替换公众号模板 + if (node.getOfficialPushSign() != null && node.getOfficialPushSign() == 1) { + manageRouteNode.setOfficialNodeContent(replaceWeChatTemplate(node.getOfficialTemplateId(), labelFieldContentList)); + } + // 替换小程序模板 + if (node.getAppletPushSign() != null && node.getAppletPushSign() == 1) { + manageRouteNode.setAppletNodeContent(replaceWeChatTemplate(node.getOfficialTemplateId(), labelFieldContentList)); + } + } + + /** + * 替换公众号、小程序模板内容 + * @param templateId 微信库模板id + * @param labelFieldContentList 患者画像信息 + */ + private String replaceWeChatTemplate(Long templateId, List labelFieldContentList) { + WechatTemplate wechatTemplate = wechatTemplateMapper.selectWechatTemplateById(templateId); + if (ObjectUtils.isEmpty(wechatTemplate)){ + return null; + } + String templateContent = wechatTemplate.getTemplateContent(); + Pattern pattern = Pattern.compile("\\{\\{([^\\{\\}}]+)\\}\\}"); + Matcher matcher = pattern.matcher(templateContent); + while (matcher.find()) { + // 过滤出符合条件的对象,不匹配返回null。 + LabelFieldInfoContentVo labelFieldContent = labelFieldContentList.stream().filter(s -> Objects.equals(s.getFieldCode(), matcher.group(1))).findFirst().orElse(null); + if (ObjectUtils.isNotEmpty(labelFieldContent)) { + templateContent = templateContent.replaceAll("\\{\\{([^\\{\\}}]+)\\}\\}", ObjectUtils.isEmpty(labelFieldContent) ? "" : labelFieldContent.getFieldValue()); + } + } + return templateContent; + } + + /** + * 替换节点内容 + * @param node 节点 + * @param labelFieldContentList 画像信息 + * @return 替换标签后的节点列表 + */ + private List replaceNodeContent(SignPatientManageRouteNode manageRouteNode, SpecialDiseaseNode node, List labelFieldContentList) { + List manageNodeList = new ArrayList<>(); + // 按照任务细分分组 + Map> groupbyPartition = labelFieldContentList.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getTaskPartitionDictId)); + List nodeParamList = groupbyPartition.get(node.getTaskSubdivision()); + // 参数按照序列号分组 + if (CollectionUtils.isNotEmpty(nodeParamList)) { + Map> groupBySn = nodeParamList.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getPortraitSn)); + + for (String portraitSn : groupBySn.keySet()) { + SignPatientManageRouteNode manageNode = new SignPatientManageRouteNode(); + BeanUtils.copyBeanProp(manageNode, manageRouteNode); + // 替换文本 + List nodeParams = groupBySn.get(portraitSn); + Map map = nodeParams.stream().collect(Collectors.toMap(LabelFieldInfoContentVo::getFieldCode,LabelFieldInfoContentVo::getFieldValue,(key1,key2)->key2)); + Document document = Jsoup.parse(manageNode.getNodeContent()); + // 需要提取的span + Elements spanlist = document.select("span[data-w-e-type]"); + for (Element span : spanlist) { + String paramKey = span.attr("data-fieldMark"); + span.text(map.getOrDefault(paramKey, "")); + span.unwrap(); + } + manageNode.setNodeContent(document.body().html()); + manageNodeList.add(manageNode); + } + } + + return manageNodeList; + } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientrecord/ISignPatientRecordService.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientrecord/ISignPatientRecordService.java index 48ae71d7..a76eac57 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientrecord/ISignPatientRecordService.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientrecord/ISignPatientRecordService.java @@ -1,6 +1,7 @@ package com.xinelu.manage.service.signpatientrecord; import com.xinelu.manage.dto.signpatientrecord.IntentionalSignDto; +import com.xinelu.manage.dto.signpatientrecord.RouteCheckDto; import com.xinelu.manage.dto.signpatientrecord.SignPatientAddDto; import com.xinelu.manage.dto.signpatientrecord.SignPatientListDto; import com.xinelu.manage.dto.signpatientrecord.SignPatientStatusDto; @@ -46,4 +47,19 @@ public interface ISignPatientRecordService { * @return */ int intentionalSign(IntentionalSignDto intentionalSignDto); + + void getPortaitInfo(Long patientId); + /** + * 画像审核 + * @param checkDto 画像审核传输对象 + * @return + */ + int updatePortaitCheckStatus(RouteCheckDto checkDto); + + /** + * 路径审核 + * @param routeCheckDto 路径审核传输对象 + * @return + */ + int updateRouteCheckStatus(RouteCheckDto routeCheckDto); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientrecord/impl/SignPatientRecordServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientrecord/impl/SignPatientRecordServiceImpl.java index 9f60ca40..e6c8bbef 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientrecord/impl/SignPatientRecordServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/signpatientrecord/impl/SignPatientRecordServiceImpl.java @@ -1,9 +1,11 @@ package com.xinelu.manage.service.signpatientrecord.impl; +import com.alibaba.fastjson2.JSONObject; import com.xinelu.common.annotation.DataScope; import com.xinelu.common.constant.SignRecordServiceStatusConstants; import com.xinelu.common.constant.TaskCreateTypeConstant; import com.xinelu.common.enums.NodeExecuteStatusEnum; +import com.xinelu.common.enums.RouteCheckStatusEnum; import com.xinelu.common.exception.ServiceException; import com.xinelu.common.utils.SecurityUtils; import com.xinelu.common.utils.StringUtils; @@ -20,9 +22,11 @@ import com.xinelu.manage.domain.specialdiseaseroute.SpecialDiseaseRoute; import com.xinelu.manage.dto.signpatientmanageroutenode.SignPatientManageRouteNodeDto; import com.xinelu.manage.dto.signpatientpackage.SignPatientPackageSaveDto; import com.xinelu.manage.dto.signpatientrecord.IntentionalSignDto; +import com.xinelu.manage.dto.signpatientrecord.RouteCheckDto; import com.xinelu.manage.dto.signpatientrecord.SignPatientAddDto; import com.xinelu.manage.dto.signpatientrecord.SignPatientListDto; import com.xinelu.manage.dto.signpatientrecord.SignPatientStatusDto; +import com.xinelu.manage.mapper.labelfieldcontent.LabelFieldContentMapper; import com.xinelu.manage.mapper.patientinfo.PatientInfoMapper; import com.xinelu.manage.mapper.patientnodeparamslog.PatientNodeParamsLogMapper; import com.xinelu.manage.mapper.signpatientinformed.SignPatientInformedMapper; @@ -35,13 +39,17 @@ import com.xinelu.manage.mapper.signroutetriggercondition.SignRouteTriggerCondit import com.xinelu.manage.mapper.specialdiseasenode.SpecialDiseaseNodeMapper; import com.xinelu.manage.mapper.specialdiseaseroute.SpecialDiseaseRouteMapper; import com.xinelu.manage.mapper.specialdiseasetriggercondition.SpecialDiseaseTriggerConditionMapper; +import com.xinelu.manage.service.signpatientmanageroutenode.ISignPatientManageRouteNodeService; import com.xinelu.manage.service.signpatientrecord.ISignPatientRecordService; +import com.xinelu.manage.vo.labelfieldcontent.LabelFieldInfoContentVo; +import com.xinelu.manage.vo.patientinfo.PatientPortaitVo; import com.xinelu.manage.vo.signpatientrecord.SignPatientInfoVo; import com.xinelu.manage.vo.signpatientrecord.SignPatientListVo; import com.xinelu.manage.vo.signpatientrecord.SignPatientRecordVo; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import javax.annotation.Resource; import org.apache.commons.lang3.ObjectUtils; @@ -85,6 +93,10 @@ public class SignPatientRecordServiceImpl implements ISignPatientRecordService { private SignRouteTriggerConditionMapper signRouteTriggerConditionMapper; @Resource private PatientNodeParamsLogMapper patientNodeParamsLogMapper; + @Resource + private ISignPatientManageRouteNodeService signPatientManageRouteNodeService; + @Resource + private LabelFieldContentMapper labelFieldContentMapper; @Override @DataScope(agencyAlias = "sign") @@ -301,4 +313,93 @@ public class SignPatientRecordServiceImpl implements ISignPatientRecordService { } return flag; } + + /** + * 任务审核页面左侧画像信息 + * @param patientId 患者主键 + */ + @Override + public void getPortaitInfo(Long patientId) { + // 查询患者诊断信息、手术信息 + PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(patientId); + if (ObjectUtils.isEmpty(patientInfo)) { + throw new ServiceException("数据有误,未找到该患者"); + } + List drugInfo = new ArrayList<>(); + List consultationInfo = new ArrayList<>(); + // 查询画像信息 + List labelFieldContentList = labelFieldContentMapper.selectByPatientId(patientId); + + if (!CollectionUtils.isEmpty(labelFieldContentList)) { + // 按照任务细分分组 + Map> groupByPartition = labelFieldContentList.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getTaskPartitionDictId)); + // 查询用药 + List drugList = labelFieldContentList.stream().filter(labelField->labelField.getFieldCode().equals("DRUGNAME")).collect(Collectors.toList()); + // 包含用药的标签列表 + List drugLabelList = new ArrayList<>(); + for (LabelFieldInfoContentVo drugName : drugList) { + drugLabelList.addAll(groupByPartition.get(drugName.getTaskPartitionDictId())); + } + // 按照sn分组,每个分组是一个用药 + if (!CollectionUtils.isEmpty(drugLabelList)) { + Map> patientDrugList = drugLabelList.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getPortraitSn)); + for (String sn : patientDrugList.keySet()) { + List propertyList = patientDrugList.get(sn); + JSONObject drug = new JSONObject(); + propertyList.forEach(property-> { + drug.fluentPut(property.getFieldCode(), property.getFieldValue()); + }); + drugInfo.add(drug); + } + } + + // 查询复诊日期 + List consultationList = labelFieldContentList.stream().filter(labelField->labelField.getFieldCode().equals("CONSULTATIONDATE")).collect(Collectors.toList()); + // 包含复诊的标签列表 + List consultationLabelList = new ArrayList<>(); + for (LabelFieldInfoContentVo consultation : consultationList) { + consultationLabelList.addAll(groupByPartition.get(consultation.getTaskPartitionDictId())); + } + // 按照sn分组,每个分组是一个复诊 + if (!CollectionUtils.isEmpty(consultationLabelList)) { + Map> patientConsultationList = drugLabelList.stream().collect(Collectors.groupingBy(LabelFieldInfoContentVo::getPortraitSn)); + for (String sn : patientConsultationList.keySet()) { + List propertyList = patientConsultationList.get(sn); + JSONObject consultation = new JSONObject(); + propertyList.forEach(property-> { + consultation.fluentPut(property.getFieldCode(), property.getFieldValue()); + }); + consultationInfo.add(consultation); + } + } + } + + PatientPortaitVo.builder().mainDiagnosis(patientInfo.getMainDiagnosis()) + .surgicalName(patientInfo.getSurgicalName()).drugInfo(drugInfo).consultationInfo(consultationInfo).build(); + } + + @Override public int updatePortaitCheckStatus(RouteCheckDto checkDto) { + return 0; + } + + @Override + @Transactional + public int updateRouteCheckStatus(RouteCheckDto routeCheckDto) { + SignPatientRecord signPatientRecord = signPatientRecordMapper.selectByPrimaryKey(routeCheckDto.getSignPatientRecordId()); + if (ObjectUtils.isEmpty(signPatientRecord)) { + throw new ServiceException("未找到该签约记录"); + } + signPatientRecord.setRouteCheckStatus(routeCheckDto.getRouteCheckStatus()); + signPatientRecord.setRouteCheckRemark(routeCheckDto.getRouteCheckRemark()); + signPatientRecord.setRouteCheckDate(LocalDateTime.now()); + signPatientRecord.setRouteCheckPerson(SecurityUtils.getLoginUser().getUser().getNickName()); + int flag = signPatientRecordMapper.updateByPrimaryKeySelective(signPatientRecord); + if (StringUtils.equals(RouteCheckStatusEnum.AGREE.getInfo(), signPatientRecord.getRouteCheckStatus()) && StringUtils.equals(RouteCheckStatusEnum.AGREE.getInfo(), signPatientRecord.getPortaitCheckStatus())) { + // 路径、画像都审核通过则生成主路径任务 + signPatientManageRouteNodeService.generateMainRouteTask(routeCheckDto.getSignPatientRecordId()); + // 替换手动生成的任务中的标签 + signPatientManageRouteNodeService.manualCreateTaskLabelReplace(routeCheckDto.getSignPatientRecordId()); + } + return flag; + } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfo/PatientPortaitVo.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfo/PatientPortaitVo.java new file mode 100644 index 00000000..dc479b94 --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfo/PatientPortaitVo.java @@ -0,0 +1,35 @@ +package com.xinelu.manage.vo.patientinfo; + +import com.alibaba.fastjson2.JSONObject; +import io.swagger.annotations.ApiModelProperty; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: 患者画像信息视图类 + * @author: haown + * @create: 2024-06-26 17:30 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class PatientPortaitVo { + /** + * 主要诊断 + */ + @ApiModelProperty(value = "主要诊断") + private String mainDiagnosis; + + @ApiModelProperty(value = "手术名称") + private String surgicalName; + + @ApiModelProperty(value = "用药信息") + private List drugInfo; + + @ApiModelProperty("复诊信息") + private List consultationInfo; +} diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/signpatientmanageroutenode/SignPatientManageNodeAuditVo.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/signpatientmanageroutenode/SignPatientManageNodeAuditVo.java index 0df0d9d2..d02da0ee 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/signpatientmanageroutenode/SignPatientManageNodeAuditVo.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/signpatientmanageroutenode/SignPatientManageNodeAuditVo.java @@ -43,4 +43,10 @@ public class SignPatientManageNodeAuditVo extends SignPatientManageRouteNode { @ApiModelProperty(value = "推送方式") private String pushMethod; + /** + * 节点名称-中文 + */ + @ApiModelProperty(value = "节点名称-中文") + private String routeNodeNameCN; + } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/signpatientrecord/SignPatientListVo.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/signpatientrecord/SignPatientListVo.java index 7de96cf9..b91313f4 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/signpatientrecord/SignPatientListVo.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/signpatientrecord/SignPatientListVo.java @@ -186,6 +186,12 @@ public class SignPatientListVo { @ApiModelProperty(value = "专病路径审核状态,同意:AGREE,不同意:DISAGREE") private String routeCheckStatus; + /** + * 画像审核状态,同意:AGREE,不同意:DISAGREE + */ + @ApiModelProperty(value = "画像审核状态,同意:AGREE,不同意:DISAGREE") + private String portaitCheckStatus; + /** 服务包表id */ @ApiModelProperty(value = "服务包表id") @Excel(name = "服务包表id") diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/specialdiseaseroute/SpecialDiseaseRouteAuditVo.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/specialdiseaseroute/SpecialDiseaseRouteAuditVo.java index 95749182..85e1d6e6 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/specialdiseaseroute/SpecialDiseaseRouteAuditVo.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/specialdiseaseroute/SpecialDiseaseRouteAuditVo.java @@ -31,6 +31,9 @@ public class SpecialDiseaseRouteAuditVo { @ApiModelProperty(value = "病种名称") private String diseaseTypeName; + @ApiModelProperty("路径审核状态") + private String routeCheckStatus; + /** * 主路径节点列表 */ diff --git a/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml index 3d903f25..feb8c47c 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml @@ -781,14 +781,23 @@ + + \ No newline at end of file diff --git a/postdischarge-manage/src/main/resources/mapper/manage/signpatientrecord/SignPatientRecordMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/signpatientrecord/SignPatientRecordMapper.xml index c5c9e8c2..a7fc8cff 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/signpatientrecord/SignPatientRecordMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/signpatientrecord/SignPatientRecordMapper.xml @@ -37,6 +37,9 @@ + + + @@ -58,6 +61,7 @@ service_status,sign_status,intentional_source, intentional_time,billing_doctor_id,billing_doctor_name, price,payment_status,health_manage_id,health_manage_name, + portait_check_status,portait_check_person,portait_check_date, route_check_status,route_check_person,route_check_date,route_check_remark, del_flag,create_by,create_time,update_by,update_time @@ -84,6 +88,7 @@ ,service_status,sign_status,intentional_source ,intentional_time,billing_doctor_id,billing_doctor_name ,price,payment_status,health_manage_id,health_manage_name + ,portait_check_status,portait_check_person,portait_check_date ,route_check_status,route_check_person,route_check_date,route_check_remark ,del_flag,create_by,create_time,update_by ,update_time) @@ -96,6 +101,7 @@ ,#{serviceStatus,jdbcType=VARCHAR},#{signStatus,jdbcType=VARCHAR},#{intentionalSource,jdbcType=VARCHAR} ,#{intentionalTime,jdbcType=TIMESTAMP},#{billingDoctorId,jdbcType=BIGINT},#{billingDoctorName,jdbcType=VARCHAR} ,#{price,jdbcType=DECIMAL},#{paymentStatus,jdbcType=VARCHAR},#{healthManageId,jdbcType=BIGINT},#{healthManageName,jdbcType=VARCHAR} + ,#{portaitCheckStatus,jdbcType=VARCHAR},#{portaitCheckPerson,jdbcType=VARCHAR},#{portaitCheckDate,jdbcType=TIMESTAMP} ,#{routeCheckStatus,jdbcType=VARCHAR},#{routeCheckPerson,jdbcType=VARCHAR},#{routeCheckDate,jdbcType=TIMESTAMP},#{routeCheckRemark,jdbcType=VARCHAR} ,#{delFlag,jdbcType=TINYINT},#{createBy,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateBy,jdbcType=VARCHAR} ,#{updateTime,jdbcType=TIMESTAMP}) @@ -135,6 +141,9 @@ payment_status, health_manage_id, health_manage_name, + portait_check_status, + portait_check_person, + portait_check_date, route_check_status, route_check_person, route_check_date, @@ -178,6 +187,9 @@ #{paymentStatus,jdbcType=VARCHAR}, #{healthManageId,jdbcType=BIGINT}, #{healthManageName,jdbcType=VARCHAR}, + #{portaitCheckStatus,jdbcType=VARCHAR}, + #{portaitCheckPerson,jdbcType=VARCHAR}, + #{portaitCheckDate,jdbcType=TIMESTAMP}, #{routeCheckStatus,jdbcType=VARCHAR}, #{routeCheckPerson,jdbcType=VARCHAR}, #{routeCheckDate,jdbcType=TIMESTAMP}, @@ -285,6 +297,15 @@ health_manage_name = #{healthManageName,jdbcType=VARCHAR}, + + portait_check_status = #{portaitCheckStatus,jdbcType=VARCHAR}, + + + portait_check_person = #{portaitCheckPerson,jdbcType=VARCHAR}, + + + portait_check_date = #{portaitCheckDate,jdbcType=TIMESTAMP}, + route_check_status = #{routeCheckStatus,jdbcType=VARCHAR}, @@ -349,6 +370,9 @@ payment_status = #{paymentStatus,jdbcType=VARCHAR}, health_manage_id = #{healthManageId,jdbcType=BIGINT}, health_manage_name = #{healthManageName,jdbcType=VARCHAR}, + portait_check_status = #{portaitCheckStatus,jdbcType=VARCHAR}, + portait_check_person = #{portaitCheckPerson,jdbcType=VARCHAR}, + portait_check_date = #{portaitCheckDate,jdbcType=TIMESTAMP}, route_check_status = #{routeCheckStatus,jdbcType=VARCHAR}, route_check_person = #{routeCheckPerson,jdbcType=VARCHAR}, route_check_date = #{routeCheckDate,jdbcType=TIMESTAMP}, @@ -372,7 +396,7 @@ sign.visit_serial_number,sign.visit_method,sign.in_hospital_number,sign.sign_diagnosis,sign.review_diagnosis, sign.service_status,sign.sign_status,sign.intentional_source, sign.intentional_time,sign.billing_doctor_name,sign.payment_status,sign.price,sign.health_manage_id, sign.health_manage_name, - sign.route_check_status, + sign.route_check_status,sign.portait_check_status, p.service_package_id, p.package_name, p.service_end_time, p.package_term, p.package_term_unit from patient_info patient left join sign_patient_record sign on patient.sign_patient_record_id = sign.id @@ -426,13 +450,13 @@ - and sign.route_check_status is null + and (sign.route_check_status is null or sign.portait_check_status is null) - and sign.route_check_status = #{routeCheckStatus} + and sign.route_check_status = #{routeCheckStatus} and sign.portait_check_status = #{routeCheckStatus} - and sign.route_check_status = #{routeCheckStatus} + and (sign.route_check_status = #{routeCheckStatus} or sign.portait_check_status = #{routeCheckStatus})