|
|
@@ -0,0 +1,87 @@
|
|
|
+package com.coffee.bus.hospital.config;
|
|
|
+
|
|
|
+import cn.hutool.core.text.CharSequenceUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.coffee.bus.entity.BusDeviceRunningEntity;
|
|
|
+import com.coffee.bus.hospital.config.bean.FunctionFinishMonitorConfig;
|
|
|
+import com.coffee.bus.hospital.config.bean.FunctionPatientCodeConfig;
|
|
|
+import com.coffee.bus.hospital.enums.ConfigHandlerEnums;
|
|
|
+import com.coffee.bus.registry.device.DeviceRegistry;
|
|
|
+import com.coffee.bus.service.LocalBusInfusionHistoryService;
|
|
|
+import com.coffee.bus.utils.WsPublishUtils;
|
|
|
+import com.coffee.common.cache.ConfigStorage;
|
|
|
+import com.coffee.common.util.RedissonUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author lifang
|
|
|
+ * @version 1.0.0
|
|
|
+ * @ClassName HospitalPatientCodeHandler.java
|
|
|
+ * @Description TODO
|
|
|
+ * @createTime 2022年06月25日 14:38:00
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+public class HospitalPatientCodeHandler extends AbstractHospitalConfigHandler<FunctionPatientCodeConfig, BusDeviceRunningEntity> {
|
|
|
+
|
|
|
+ public HospitalPatientCodeHandler(ConfigStorage configStorage, String hospitalId, RedissonUtil redissonUtil, LocalBusInfusionHistoryService infusionHistoryService, DeviceRegistry deviceRegistry, WsPublishUtils wsPublishUtils) {
|
|
|
+ super(configStorage, hospitalId, redissonUtil, infusionHistoryService, deviceRegistry, wsPublishUtils);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ConfigHandlerEnums getId() {
|
|
|
+ return ConfigHandlerEnums.patientCode;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getDescription() {
|
|
|
+ return "病号格式化处理";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void handler(BusDeviceRunningEntity source) {
|
|
|
+ FunctionPatientCodeConfig config = this.getConfig().as(FunctionPatientCodeConfig.class);
|
|
|
+ if(config==null||!Boolean.TRUE.equals(config.getEnable())|| Objects.isNull(config.getFillChar())){
|
|
|
+ log.warn("id:{},配置名称:{},不存在",hospitalId,getId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ source.setPatientCode(formatPatientCode(config,source.getPatientCode(),source.getTenantId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 描述: 病号格式化处理
|
|
|
+ * @author lifang
|
|
|
+ * @date 2022/6/25 14:40
|
|
|
+ * @param config
|
|
|
+ * @param code
|
|
|
+ * @return String
|
|
|
+ */
|
|
|
+ private String formatPatientCode(FunctionPatientCodeConfig config,String code,String tenantId){
|
|
|
+ String fillChar = config.getFillChar();
|
|
|
+ Boolean fillLeft = config.getFillLeft();
|
|
|
+ Integer length = config.getLength();
|
|
|
+ if(Objects.isNull(fillChar)
|
|
|
+ ||Objects.isNull(fillLeft)
|
|
|
+ ||Objects.isNull(length)){
|
|
|
+ log.warn("医院【{}】,病号转换配置【{}】有误",tenantId, JSONUtil.toJsonStr(config));
|
|
|
+ return code;
|
|
|
+ }
|
|
|
+ String appendChars="";
|
|
|
+ if(CharSequenceUtil.length(code)<length){
|
|
|
+ StringBuffer append=new StringBuffer();
|
|
|
+ int subSize=length-CharSequenceUtil.length(code);
|
|
|
+ while (CharSequenceUtil.length(append)<subSize){
|
|
|
+ append.append(fillChar);
|
|
|
+ }
|
|
|
+ appendChars=append.substring(0,subSize-1);
|
|
|
+ }
|
|
|
+ if(Boolean.TRUE.equals(fillLeft)){
|
|
|
+ code=appendChars+code;
|
|
|
+ }else {
|
|
|
+ code=code+appendChars;
|
|
|
+ }
|
|
|
+ return code;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|