Bläddra i källkod

修复485数据问题

wuyunfeng 1 år sedan
förälder
incheckning
730dd413d8

+ 5 - 0
ncs-ms-feign/src/main/java/com/wdklian/ncs/ms/feignclient/open/PatientFeignClient.java

@@ -4,6 +4,7 @@ import com.wdklian.ncs.ms.common.entity.open.dos.PatientDO;
 import com.wdklian.ncs.ms.common.entity.open.vos.PatientDataVO;
 import com.wdklian.ncs.ms.common.entity.system.dos.CustomerDO;
 import com.wdklian.ncs.ms.framework.mvc.CommonResult;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.stereotype.Component;
 import org.springframework.validation.annotation.Validated;
@@ -32,6 +33,10 @@ public interface PatientFeignClient {
     @GetMapping("/his-outed")
     CommonResult<List<PatientDO>> listHisOutedPatients();
 
+
+    @PostMapping("/patient-out/batch")
+    CommonResult<List<PatientDO>> patientBatchOut(@RequestBody @NotNull(message = "患者数据不能为null") @Validated List<String> patientKeys);
+
     @GetMapping("/his-hospitalized")
     CommonResult<List<PatientDO>> listHospitaledPatient();
 

+ 7 - 0
ncs-open-service/src/main/java/com/wdklian/ncs/ms/open/controller/PatientController.java

@@ -70,6 +70,13 @@ public class PatientController {
     }
 
 
+    @PostMapping("/patient-out/batch")
+    @ApiOperation(value = "批量患者主键出院")
+    public CommonResult<List<PatientDO>> patientBatchOut(@RequestBody @NotNull(message = "患者数据不能为null") @Validated List<String> patientKeys) {
+        return CommonResult.success(patientService.patientBatchOut(patientKeys));
+    }
+
+
     @GetMapping("/{patient_key}")
     @ApiOperation(value = "根据主键查询患者信息", response = SinglePatientResponse.class)
     public CommonResult<PatientDO> getPatient(@PathVariable("patient_key") @NotEmpty(message = "患者主键不能为空") String patientKey) {

+ 25 - 10
ncs-open-service/src/main/java/com/wdklian/ncs/ms/open/service/impl/PatientServiceImpl.java

@@ -42,12 +42,13 @@ public class PatientServiceImpl extends OpenPlateformCRUDServiceImpl<PatientDO>
         String sql = "select * from " + PatientDO.class.getAnnotation(Table.class).name() + " where keyval=?";
         return this.daoSupport.queryForObject(sql, PatientDO.class, key);
     }
+
     @Override
     public List<PatientDO> listPatients(List<String> patientKeys) {
-        if(patientKeys.isEmpty()){
+        if (patientKeys.isEmpty()) {
             return new ArrayList<>();
         }
-        String sql = "select * from "+PatientDO.class.getAnnotation(Table.class).name()+" where find_in_set(keyval,?)";
+        String sql = "select * from " + PatientDO.class.getAnnotation(Table.class).name() + " where find_in_set(keyval,?)";
         return this.daoSupport.queryForList(sql, PatientDO.class, patientKeys.stream().collect(Collectors.joining(",")));
     }
 
@@ -89,10 +90,10 @@ public class PatientServiceImpl extends OpenPlateformCRUDServiceImpl<PatientDO>
     public List<PatientDO> savePatient(List<PatientDO> patients) {
         if (patients != null && !patients.isEmpty()) {
 //            String sqlTemplate= "replace into "+ PatientDO.class.getAnnotation(Table.class).name()+"(keyval,part_keyval,card_no,bed_no,name,sex,age,age_unit,birthday,id_no,address,mobile,indate,baby_name,baby_sex,baby_birthday,doctor_keyval,nurse_keyval,`status`,outdate,illness_description) values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')";
-            List<PatientDO> changedPatient= new ArrayList<>();
+            List<PatientDO> changedPatient = new ArrayList<>();
             for (PatientDO patient : patients) {
                 int i = this.daoSupport.insertOrUpdate(PatientDO.class.getAnnotation(Table.class).name(), patient);
-                if(i>0){
+                if (i > 0) {
                     changedPatient.add(patient);
                 }
 
@@ -140,7 +141,7 @@ public class PatientServiceImpl extends OpenPlateformCRUDServiceImpl<PatientDO>
             throw new ServiceException("不存在的患者!");
         } else {
             patient.setStatus("1");
-            if(StrUtil.isEmpty(patient.getOutdate())){
+            if (StrUtil.isEmpty(patient.getOutdate())) {
                 patient.setOutdate(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
             }
             this.daoSupport.insertOrUpdate(PatientDO.class.getAnnotation(Table.class).name(), patient);
@@ -157,6 +158,7 @@ public class PatientServiceImpl extends OpenPlateformCRUDServiceImpl<PatientDO>
             return patient;
         }
     }
+
     //仅对视图对接方式
     @Override
     public List<PatientDO> listOutedPatient() {
@@ -164,6 +166,7 @@ public class PatientServiceImpl extends OpenPlateformCRUDServiceImpl<PatientDO>
         String sql = "select * from " + PatientDO.class.getAnnotation(Table.class).name() + " where `sync_state`=0 and `status`=0";
         return this.daoSupport.queryForList(sql, PatientDO.class);
     }
+
     //仅对视图对接方式
     @Override
     public List<PatientDO> listHospitaledPatient() {
@@ -174,7 +177,7 @@ public class PatientServiceImpl extends OpenPlateformCRUDServiceImpl<PatientDO>
 
     //查询接口接入的在住院患者列表
     @Override
-    public List<PatientDO> listHospitaledPatientTP(){
+    public List<PatientDO> listHospitaledPatientTP() {
         String sql = "select * from " + PatientDO.class.getAnnotation(Table.class).name() + " where `status`=0 and (outdate is null or outdate='') and (bed_no is not null and bed_no<>'')";
         return this.daoSupport.queryForList(sql, PatientDO.class);
     }
@@ -195,8 +198,20 @@ public class PatientServiceImpl extends OpenPlateformCRUDServiceImpl<PatientDO>
     }
 
 
-
-
-
-
+    @Override
+    @Transactional(value = "openPlateformTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public List<PatientDO> patientBatchOut(List<String> patientKeys) {
+        if (patientKeys != null && patientKeys.size() > 0) {
+            List<PatientDO> patients = this.listPatients(patientKeys);
+            for (PatientDO patient : patients) {
+                patient.setStatus("1");
+                if (StrUtil.isEmpty(patient.getOutdate())) {
+                    patient.setOutdate(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
+                }
+                this.daoSupport.insertOrUpdate(PatientDO.class.getAnnotation(Table.class).name(), patient);
+            }
+            return patients;
+        }
+        return null;
+    }
 }

+ 2 - 0
ncs-open-service/src/main/java/com/wdklian/ncs/ms/open/service/iservice/PatientService.java

@@ -48,4 +48,6 @@ public interface PatientService extends CRUDBaseManager<PatientDO> {
 
     //todo 解藕模块
     void updatePatientPartId(List<CustomerDO> customerAllChange);
+
+    List<PatientDO> patientBatchOut(List<String> patientKeys);
 }

+ 5 - 0
ncs-system-service/src/main/java/com/wdklian/ncs/ms/system/service/impl/CustomerServiceImpl.java

@@ -116,6 +116,8 @@ public class CustomerServiceImpl extends SystemCRUDManagerImpl<CustomerDO> imple
                     customerDO.setStatus(HospitaliseStatusEnum.DISCHARGED.value());
                     customerDO.setOutDate(DateUtil.getDateline());
                     this.edit(customerDO, customerDO.getId());
+                    //485要设置设备member_id 为0
+                    this.deviceService.updateMemberId(customerDO.getFrameId(), new int[]{DeviceTypeEnum.DIGIT_BED_DEVICE.value(),DeviceTypeEnum.RS485_DOOR_DEVICE.value(),DeviceTypeEnum.SIMULATE_BED_DEVICE.value()}, 0);
                     handled.add(customerDO);
                 }
             }
@@ -320,6 +322,7 @@ public class CustomerServiceImpl extends SystemCRUDManagerImpl<CustomerDO> imple
             if (StrUtil.isEmpty(inbedCustomer.getHisKeyval())) {//非his同步的病人,可能是测试数据。出院
                 inbedCustomer.setStatus(HospitaliseStatusEnum.DISCHARGED.value());
                 this.edit(inbedCustomer, inbedCustomer.getId());
+
             } else if (StrUtil.isNotEmpty(inbedCustomer.getHisPartKeyval())
                     && inbedCustomer.getHisPartKeyval().trim().equalsIgnoreCase(part.getHisCode())
             ) { //当前入住的患者是主科室的患者,又传进来一个同床位患者。
@@ -615,6 +618,8 @@ public class CustomerServiceImpl extends SystemCRUDManagerImpl<CustomerDO> imple
 
         List<PatientDO> patientOuted = this.patientFeignClient.listHisOutedPatients().getData();
         List<CustomerDO> customerOut = this.handPatientOut(patientOuted);
+        List<String> patientKeys = patientOuted.stream().map(p -> p.getKeyval()).collect(Collectors.toList());
+        this.patientFeignClient.patientBatchOut(patientKeys);
         List<PatientDO> patientHospital = this.patientFeignClient.listHospitaledPatient().getData();
         List<CustomerDO> customerHospital = this.syncPatient(patientHospital, false);
         List<CustomerDO> sum = ListUtils.sum(customerOut, customerHospital);

+ 27 - 1
third-part-zldata/src/main/java/com/wdklian/ncs/ms/zldata/service/ZLDataHandle.java

@@ -201,7 +201,7 @@ public class ZLDataHandle {
         String doctorName = StrUtil.emptyToDefault(pv1Info.getString("pat_atdpscn_name"), null);//住院医生姓名
         String nurseId = StrUtil.emptyToDefault(pv1Info.getString("inp_pnurs_id"), null);//责任护士id
         String nurseName = StrUtil.emptyToDefault(pv1Info.getString("inp_pnurs"), null);//责任护士姓名
-        String bedNo = StrUtil.emptyToDefault(pv1Info.getString("inp_bed_no"), null);//责任护士姓名
+        String bedNo = StrUtil.emptyToDefault(pv1Info.getString("inp_bed_no"), null);//入住床位
         String deptId = StrUtil.emptyToDefault(pv1Info.getString("inp_dept_id"), null);//入住科室Id
         String wardId = StrUtil.emptyToDefault(pv1Info.getString("inp_ward_id"), deptId);//入住病区Id
         String visitSno = StrUtil.emptyToDefault(pv1Info.getString("visit_sno"), null);//就诊流水号,用来作为护理级别的key
@@ -210,6 +210,32 @@ public class ZLDataHandle {
         String adtaTime = StrUtil.emptyToDefault(pv1Info.getString("adta_time"), "");//入院时间
         String indeptTime = StrUtil.emptyToDefault(pv1Info.getString("indept_time"), adtaTime);//入科时间
         String dsctplanName = StrUtil.emptyToDefault(pv1Info.getString("dsctplan_name"), adtaTime);//费别
+
+        Object updInfo = data.getByPath("$.input.upd_info");
+        if(updInfo!=null){
+            JSONObject updateInfo = JSONObject.from(updInfo);
+            String upd_type = updateInfo.getString("upd_type");
+            switch (upd_type){
+                case "3": //转科
+                case "15"://转区
+                    deptId = StrUtil.emptyToDefault(updateInfo.getString("into_dept_id"), null);
+                    wardId = StrUtil.emptyToDefault(updateInfo.getString("into_ward_id"), deptId);
+                    bedNo = StrUtil.emptyToDefault(updateInfo.getString("into_bed"), null);
+                    break;
+                case "6": //护理等级变动
+                    nursingGrade = StrUtil.emptyToDefault(updateInfo.getString("nursing_grade"), "");
+                    break;
+                case "13"://病情
+                    patConditon = StrUtil.emptyToDefault(updateInfo.getString("pat_conditon"), "");
+                    break;
+                case "4":
+                    bedNo = StrUtil.emptyToDefault(updateInfo.getString("into_bed"), null);
+                    break;
+
+            }
+        }
+
+
         PatientDO patientDO = new PatientDO();
         patientDO.setKeyval(patientId);
         patientDO.setPartKeyval(wardId);