liusheng
18 小时以前 3d1344ca6f0613bf3726d2c40d35f3928f82a910
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java
@@ -13,6 +13,7 @@
import cn.lihu.jh.module.ecg.dal.mysql.appointment.AppointmentMapper;
import cn.lihu.jh.module.ecg.enums.AppointmentTypeEnum;
import cn.lihu.jh.module.ecg.enums.HisCheckCodeEnum;
import cn.lihu.jh.module.ecg.enums.HisCheckNameEnum;
import cn.lihu.jh.module.ecg.feign.RemoteDataService;
import cn.lihu.jh.module.ecg.service.config.EcgConfigService;
import cn.lihu.jh.module.ecg.service.devrent.ApplicationTemplate;
@@ -20,6 +21,7 @@
import cn.lihu.jh.module.ecg.service.queuesequence.QueueSequenceService;
import cn.lihu.jh.module.ecg.webservice.WebServiceClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
@@ -378,7 +380,7 @@
            // 医生开单时间
            Optional.ofNullable(dataMap.get("controlActProcess")).map(controlActProcess -> (Map<String, Object>) controlActProcess).map(controlActProcess -> (Map<String, Object>) controlActProcess.get("subject")).map(subject -> (Map<String, Object>) subject.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("author")).map(author -> (Map<String, Object>) author.get("time")).map(time -> (String) time.get("value")).map(str -> {
                try {
                    return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(str);
                    return new SimpleDateFormat("yyyyMMddHHmmss").parse(str);
                } catch (Exception e) {
                    e.printStackTrace();
                    return null;
@@ -465,8 +467,17 @@
            //设置检查类型
//            String checkType = Optional.ofNullable(dataMap.get("controlActProcess")).map(controlActProcess -> (Map<String, Object>) controlActProcess).map(controlActProcess -> (Map<String, Object>) controlActProcess.get("component2")).map(component2 -> (Map<String, Object>) component2.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("code")).map(code -> (String) code.get("code")).orElseThrow(() -> exception(APPOINTMENT_CREATE_FAIL));
            String checkType = Optional.ofNullable(dataMap.get("controlActProcess")).map(controlActProcess -> (Map<String, Object>) controlActProcess).map(controlActProcess -> (Map<String, Object>) controlActProcess.get("subject")).map(subject -> (Map<String, Object>) subject.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("component2")).map(component2 -> (Map<String, Object>) component2.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("code")).map(code -> (String) code.get("code")).orElseThrow(() -> exception(APPOINTMENT_CREATE_FAIL));
            if (checkType != null || checkType != "")
                appointment.setBookCheckType(Integer.valueOf(HisCheckCodeEnum.getByCode(checkType.substring(1))));
            String checkName = Optional.ofNullable(dataMap.get("controlActProcess")).map(controlActProcess -> (Map<String, Object>) controlActProcess).map(controlActProcess -> (Map<String, Object>) controlActProcess.get("subject")).map(subject -> (Map<String, Object>) subject.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("component2")).map(component2 -> (Map<String, Object>) component2.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("code")).map(code -> (Map<String, Object>) code.get("displayName")).map(displayName -> (String) displayName.get("value")).orElseThrow(() -> exception(APPOINTMENT_CREATE_FAIL));
            if (appointment.getPatSrc() != null && appointment.getPatSrc() != 4) {
                if (checkType != null || checkType != "")
                    appointment.setBookCheckType(Integer.valueOf(HisCheckCodeEnum.getByCode(checkType.substring(1))));
            } else if (appointment.getPatSrc() != null && appointment.getPatSrc() == 4) {
                if (StringUtils.isNotEmpty(checkName)) {
                    checkName = checkName.replaceAll("\\s+", "");
                    appointment.setBookCheckType(Integer.valueOf(HisCheckNameEnum.getByName(checkName)));
                }
            }
            // 将AppointmentDO转换为AppointmentSaveReqVO并保存
            AppointmentSaveReqVO saveReqVO = BeanUtils.toBean(appointment, AppointmentSaveReqVO.class);
@@ -617,7 +628,12 @@
     * 从dataMap中提取encounter数据
     */
    private Map<String, Object> extractEncounter(Map<String, Object> dataMap) {
        return Optional.ofNullable(dataMap.get("controlActProcess")).map(controlActProcess -> (Map<String, Object>) controlActProcess).map(controlActProcess -> (Map<String, Object>) controlActProcess.get("subject")).map(subject -> (Map<String, Object>) subject.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("componentOf1")).map(componentOf1 -> (Map<String, Object>) componentOf1.get("encounter")).orElse(null);
        return Optional.ofNullable(dataMap.get("controlActProcess"))
                .map(controlActProcess -> (Map<String, Object>) controlActProcess)
                .map(controlActProcess -> (Map<String, Object>) controlActProcess.get("subject"))
                .map(subject -> (Map<String, Object>) subject.get("observationRequest"))
                .map(observationRequest -> (Map<String, Object>) observationRequest.get("componentOf1"))
                .map(componentOf1 -> (Map<String, Object>) componentOf1.get("encounter")).orElse(null);
    }
    @Override
@@ -686,6 +702,37 @@
        appointmentMapper.updateById(appointment);
    }
    @Override
    public void handleAppointmentStatusUpdate(Map<String, Object> dataMap) {
        if (dataMap == null) {
            throw exception(APPOINTMENT_STATUS_REGISTER_UPDATE_FAIL);
        }
        //获取applyNo
        Map<String, Object> controlActProcess = (Map<String, Object>) dataMap.get("controlActProcess");
        Map<String, Object> subject = (Map<String, Object>) controlActProcess.get("subject");
        Map<String, Object> placerGroup = (Map<String, Object>) subject.get("placerGroup");
        Map<String, Object> component2 = (Map<String, Object>) placerGroup.get("component2");
        Map<String, Object> observationRequest = (Map<String, Object>) component2.get("observationRequest");
        Map<String, Object> id = (Map<String, Object>) observationRequest.get("id");
        Map<String, Object> item = (Map<String, Object>) id.get("item");
        String applyNo = (String) item.get("extension");
        //获取status
        Map<String, Object> component1 = (Map<String, Object>) observationRequest.get("component1");
        Map<String, Object> processStep = (Map<String, Object>) component1.get("processStep");
        Map<String, Object> codeMap = (Map<String, Object>) processStep.get("code");
        String status = String.valueOf(codeMap.get("code"));
        Date date = null;
        if (status.equals("3")) {
            //记录登记时间
            date = new Date();
        }
        //状态更新
        Integer i = appointmentMapper.updateStatusByApplyNo(applyNo, status, date);
        log.info("申请单登记applyNo:{},状态status:{},更新结果:{}", applyNo, status, i);
    }
    public AppointmentDO getByApplyNo(String applyNo) {
        return appointmentMapper.getByApplyNo(applyNo);
    }