|
@@ -162,14 +162,14 @@ public class CustomerServiceImpl extends SystemCRUDManagerImpl<CustomerDO> imple
|
|
// List<CustomerDO> patientWasIn = this.listCustomerByHisKeys(patientDOS.stream().map(p -> p.getKeyval()).collect(Collectors.toList()));
|
|
// List<CustomerDO> patientWasIn = this.listCustomerByHisKeys(patientDOS.stream().map(p -> p.getKeyval()).collect(Collectors.toList()));
|
|
//在住院患者
|
|
//在住院患者
|
|
List<CustomerDO> patientIn = this.getCustomersByHospitaliseStatus(HospitaliseStatusEnum.HOSPITALIZED);
|
|
List<CustomerDO> patientIn = this.getCustomersByHospitaliseStatus(HospitaliseStatusEnum.HOSPITALIZED);
|
|
- //传入患者已经有入住过的记录
|
|
|
|
- List<CustomerDO> patientWasIn = this.listCustomerByHisKeys(patientDOS.stream().map(p -> p.getKeyval()).collect(Collectors.toList()));
|
|
|
|
|
|
+ //传入患者已经有入住过但已出院的记录
|
|
|
|
+ List<CustomerDO> patientWasIn = this.listCustomerByHisKeys(patientDOS.stream().map(p -> p.getKeyval()).collect(Collectors.toList())).stream().filter(p->p.getStatus().equals(HospitaliseStatusEnum.DISCHARGED.value())).collect(Collectors.toList());
|
|
patientWasIn.addAll(patientIn);
|
|
patientWasIn.addAll(patientIn);
|
|
List<MemberDO> patientMemberWasIn = new ArrayList<>();
|
|
List<MemberDO> patientMemberWasIn = new ArrayList<>();
|
|
List<CustomerCareMappingVO> patientWasInCareMapping = new ArrayList<>();
|
|
List<CustomerCareMappingVO> patientWasInCareMapping = new ArrayList<>();
|
|
if (patientWasIn != null && patientWasIn.size() > 0) {
|
|
if (patientWasIn != null && patientWasIn.size() > 0) {
|
|
patientMemberWasIn = this.memberService.listMemberByIds(patientWasIn.stream().mapToInt(p -> p.getMemberId()).boxed().collect(Collectors.toList()));
|
|
patientMemberWasIn = this.memberService.listMemberByIds(patientWasIn.stream().mapToInt(p -> p.getMemberId()).boxed().collect(Collectors.toList()));
|
|
- patientWasInCareMapping = this.customerMappingService.listCustomerCareChargeByCustomerIds(patientWasIn.stream().mapToInt(p -> p.getMemberId()).boxed().collect(Collectors.toList()));
|
|
|
|
|
|
+ patientWasInCareMapping = this.customerMappingService.listCustomerCareChargeByCustomerIds(patientWasIn.stream().mapToInt(p -> p.getId()).boxed().collect(Collectors.toList()));
|
|
}
|
|
}
|
|
//所有角色列表
|
|
//所有角色列表
|
|
List<RoleDO> roles = this.roleService.listRole();
|
|
List<RoleDO> roles = this.roleService.listRole();
|
|
@@ -209,14 +209,22 @@ public class CustomerServiceImpl extends SystemCRUDManagerImpl<CustomerDO> imple
|
|
MemberDO member = null;
|
|
MemberDO member = null;
|
|
List<CustomerCareMappingVO> customerCareMappingVOS = new ArrayList<>();
|
|
List<CustomerCareMappingVO> customerCareMappingVOS = new ArrayList<>();
|
|
if (customerDO != null) {
|
|
if (customerDO != null) {
|
|
|
|
+
|
|
member = patientMemberWasIn.stream().filter(p -> p.getMemberId().equals(customerDO.getMemberId())).findFirst().orElse(null);
|
|
member = patientMemberWasIn.stream().filter(p -> p.getMemberId().equals(customerDO.getMemberId())).findFirst().orElse(null);
|
|
customerCareMappingVOS = patientWasInCareMapping.stream().filter(p -> p.getCustomerId().equals(customerDO.getId())).collect(Collectors.toList());
|
|
customerCareMappingVOS = patientWasInCareMapping.stream().filter(p -> p.getCustomerId().equals(customerDO.getId())).collect(Collectors.toList());
|
|
//患者已经在库中,需要判定此患者是否住院状态,如果是住院状态,要处理患者是否转床、转科室
|
|
//患者已经在库中,需要判定此患者是否住院状态,如果是住院状态,要处理患者是否转床、转科室
|
|
- if (customerDO.getStatus().equals(HospitaliseStatusEnum.HOSPITALIZED.value()) && bed != null && !customerDO.getFrameId().equals(bed.getId())) {
|
|
|
|
|
|
+ if (customerDO.getStatus().equals(HospitaliseStatusEnum.HOSPITALIZED.value()) && (bed != null && !customerDO.getFrameId().equals(bed.getId()))
|
|
|
|
+ || bed==null //这个人还在住院,但是床位变了,可能转到了新的床位,或者转到了一个呼叫系统中不存在的床位
|
|
|
|
+ ) {
|
|
//住院状态,且床位信息发生了变化,拷贝custoerDO,放入syncCustomers中,返回后可以获取到旧的customer信息,通知旧床位更新设备信息
|
|
//住院状态,且床位信息发生了变化,拷贝custoerDO,放入syncCustomers中,返回后可以获取到旧的customer信息,通知旧床位更新设备信息
|
|
CustomerDO customerBak = new CustomerDO();
|
|
CustomerDO customerBak = new CustomerDO();
|
|
BeanUtil.copyProperties(customerDO, customerBak);
|
|
BeanUtil.copyProperties(customerDO, customerBak);
|
|
syncCustomers.add(customerBak);
|
|
syncCustomers.add(customerBak);
|
|
|
|
+ //旧床位设备设置memberId为0,否则485依然显示旧床位患者数据
|
|
|
|
+ FrameDO oldFrameDO = allBeds.stream().filter(p -> p.getId().equals(customerDO.getFrameId())).findFirst().orElse(null);
|
|
|
|
+ if(!patientWasIn.stream().anyMatch(p->p.getFrameId().equals(oldFrameDO.getId())&&p.getStatus().equals(HospitaliseStatusEnum.HOSPITALIZED.value())&&!p.getId().equals(customerDO.getId()))) { //没有人入住旧床位了
|
|
|
|
+ this.deviceService.updateMemberId(customerDO.getFrameId(), new int[]{DeviceTypeEnum.DIGIT_BED_DEVICE.value(), DeviceTypeEnum.RS485_DOOR_DEVICE.value(), DeviceTypeEnum.SIMULATE_BED_DEVICE.value()}, 0);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -224,7 +232,9 @@ public class CustomerServiceImpl extends SystemCRUDManagerImpl<CustomerDO> imple
|
|
CustomerDO customer = handleSinglePatient(patientInfo, part, bed, customerDO, member, roles, customerCareMappingVOS, patientWasIn);
|
|
CustomerDO customer = handleSinglePatient(patientInfo, part, bed, customerDO, member, roles, customerCareMappingVOS, patientWasIn);
|
|
if (customer != null) {
|
|
if (customer != null) {
|
|
//重要-- 把同步成功的患者加入到已入住列表中,防止同一批次患者有相同床位的,不加入无法判断出上一次已经入住了床位
|
|
//重要-- 把同步成功的患者加入到已入住列表中,防止同一批次患者有相同床位的,不加入无法判断出上一次已经入住了床位
|
|
- patientWasIn.add(customer);
|
|
|
|
|
|
+ if(!patientWasIn.stream().anyMatch(p->p.getId().equals(customer.getId()))) {
|
|
|
|
+ patientWasIn.add(customer);
|
|
|
|
+ }
|
|
//把同步成功的患者加入返回列表
|
|
//把同步成功的患者加入返回列表
|
|
syncCustomers.add(customer);
|
|
syncCustomers.add(customer);
|
|
}
|
|
}
|
|
@@ -290,8 +300,6 @@ public class CustomerServiceImpl extends SystemCRUDManagerImpl<CustomerDO> imple
|
|
customer = updateCustomer(patient, part, bed, customer);
|
|
customer = updateCustomer(patient, part, bed, customer);
|
|
//提交更新
|
|
//提交更新
|
|
this.edit(customer, customer.getId());
|
|
this.edit(customer, customer.getId());
|
|
- } else {
|
|
|
|
- return null;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return customer;
|
|
return customer;
|
|
@@ -322,13 +330,14 @@ public class CustomerServiceImpl extends SystemCRUDManagerImpl<CustomerDO> imple
|
|
if (StrUtil.isEmpty(inbedCustomer.getHisKeyval())) {//非his同步的病人,可能是测试数据。出院
|
|
if (StrUtil.isEmpty(inbedCustomer.getHisKeyval())) {//非his同步的病人,可能是测试数据。出院
|
|
inbedCustomer.setStatus(HospitaliseStatusEnum.DISCHARGED.value());
|
|
inbedCustomer.setStatus(HospitaliseStatusEnum.DISCHARGED.value());
|
|
this.edit(inbedCustomer, inbedCustomer.getId());
|
|
this.edit(inbedCustomer, inbedCustomer.getId());
|
|
-
|
|
|
|
|
|
+ // this.customerMappingService.clearCustomerMapping(inbedCustomer.getId());
|
|
} else if (StrUtil.isNotEmpty(inbedCustomer.getHisPartKeyval())
|
|
} else if (StrUtil.isNotEmpty(inbedCustomer.getHisPartKeyval())
|
|
&& inbedCustomer.getHisPartKeyval().trim().equalsIgnoreCase(part.getHisCode())
|
|
&& inbedCustomer.getHisPartKeyval().trim().equalsIgnoreCase(part.getHisCode())
|
|
) { //当前入住的患者是主科室的患者,又传进来一个同床位患者。
|
|
) { //当前入住的患者是主科室的患者,又传进来一个同床位患者。
|
|
if (!inbedCustomer.getHisKeyval().equals(patient.getKeyval())) { //现在住的和要住的不是同一个人,把现在住的出院。这里如果传过来同一个床位如果有两个人以上,我方显示的人可能会切换显示
|
|
if (!inbedCustomer.getHisKeyval().equals(patient.getKeyval())) { //现在住的和要住的不是同一个人,把现在住的出院。这里如果传过来同一个床位如果有两个人以上,我方显示的人可能会切换显示
|
|
inbedCustomer.setStatus(HospitaliseStatusEnum.DISCHARGED.value());
|
|
inbedCustomer.setStatus(HospitaliseStatusEnum.DISCHARGED.value());
|
|
this.edit(inbedCustomer, inbedCustomer.getId());
|
|
this.edit(inbedCustomer, inbedCustomer.getId());
|
|
|
|
+ // this.customerMappingService.clearCustomerMapping(inbedCustomer.getId());
|
|
}
|
|
}
|
|
} else if (StrUtil.isNotEmpty(part.getAttachHisCodes())
|
|
} else if (StrUtil.isNotEmpty(part.getAttachHisCodes())
|
|
&& part.getAttachHisCodes().contains(inbedCustomer.getHisPartKeyval())
|
|
&& part.getAttachHisCodes().contains(inbedCustomer.getHisPartKeyval())
|
|
@@ -337,15 +346,23 @@ public class CustomerServiceImpl extends SystemCRUDManagerImpl<CustomerDO> imple
|
|
if (patient.getPartKeyval().trim().equalsIgnoreCase(part.getHisCode())) { //现在要住主科室的患者,其他科室的出院
|
|
if (patient.getPartKeyval().trim().equalsIgnoreCase(part.getHisCode())) { //现在要住主科室的患者,其他科室的出院
|
|
inbedCustomer.setStatus(HospitaliseStatusEnum.DISCHARGED.value());
|
|
inbedCustomer.setStatus(HospitaliseStatusEnum.DISCHARGED.value());
|
|
this.edit(inbedCustomer, inbedCustomer.getId());
|
|
this.edit(inbedCustomer, inbedCustomer.getId());
|
|
|
|
+ // this.customerMappingService.clearCustomerMapping(inbedCustomer.getId());
|
|
} else { //现在要住的也不是主科室的患者
|
|
} else { //现在要住的也不是主科室的患者
|
|
- if (!inbedCustomer.getHisKeyval().equalsIgnoreCase(patient.getKeyval())) { //在住的和要住的还不是同一个人,不处理
|
|
|
|
- return false;
|
|
|
|
|
|
+ if(inbedCustomer.getHisPartKeyval().equalsIgnoreCase(patient.getPartKeyval())&&!inbedCustomer.getHisKeyval().equalsIgnoreCase(patient.getKeyval())){ //当前入住的和要住的是同一个科室的患者,把当前住的患者出院
|
|
|
|
+ inbedCustomer.setStatus(HospitaliseStatusEnum.DISCHARGED.value());
|
|
|
|
+ this.edit(inbedCustomer, inbedCustomer.getId());
|
|
|
|
+ //this.customerMappingService.clearCustomerMapping(inbedCustomer.getId());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// if (!inbedCustomer.getHisKeyval().equalsIgnoreCase(patient.getKeyval())) { //在住的和要住的还不是同一个人,不处理
|
|
|
|
+// return false;
|
|
|
|
+// }
|
|
}
|
|
}
|
|
|
|
|
|
}else{ //科室对接更换了hiscode,当前入住的患者已经不属于这个科室
|
|
}else{ //科室对接更换了hiscode,当前入住的患者已经不属于这个科室
|
|
inbedCustomer.setStatus(HospitaliseStatusEnum.DISCHARGED.value());
|
|
inbedCustomer.setStatus(HospitaliseStatusEnum.DISCHARGED.value());
|
|
this.edit(inbedCustomer, inbedCustomer.getId());
|
|
this.edit(inbedCustomer, inbedCustomer.getId());
|
|
|
|
+ this.customerMappingService.clearCustomerMapping(inbedCustomer.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -393,14 +410,31 @@ public class CustomerServiceImpl extends SystemCRUDManagerImpl<CustomerDO> imple
|
|
@Transactional(value = "systemTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
@Transactional(value = "systemTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
public CustomerDO handleSinglePatient(PatientDO patient, ShopDO part, FrameDO bed, CustomerDO customer, MemberDO member, List<RoleDO> roles, List<CustomerCareMappingVO> customerCareMapping, List<CustomerDO> hospitalized) {
|
|
public CustomerDO handleSinglePatient(PatientDO patient, ShopDO part, FrameDO bed, CustomerDO customer, MemberDO member, List<RoleDO> roles, List<CustomerCareMappingVO> customerCareMapping, List<CustomerDO> hospitalized) {
|
|
|
|
|
|
- //出院状态
|
|
|
|
- if (StrUtil.isNotEmpty(patient.getStatus()) && Integer.parseInt(patient.getStatus()) == (HospitaliseStatusEnum.DISCHARGED.value()) && customer != null) {
|
|
|
|
- customer.setStatus(HospitaliseStatusEnum.DISCHARGED.value());
|
|
|
|
- this.edit(customer, customer.getId());
|
|
|
|
- this.deviceService.updateMemberId(customer.getFrameId(), new int[]{DeviceTypeEnum.DIGIT_BED_DEVICE.value(),DeviceTypeEnum.RS485_DOOR_DEVICE.value(),DeviceTypeEnum.SIMULATE_BED_DEVICE.value()}, 0);
|
|
|
|
- return customer;
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(customer != null) {
|
|
|
|
+ //出院状态
|
|
|
|
+ if ((StrUtil.isNotEmpty(patient.getStatus()) && Integer.parseInt(patient.getStatus()) == (HospitaliseStatusEnum.DISCHARGED.value()))||
|
|
|
|
+ bed==null //患者转到了一个无法识别的床位
|
|
|
|
+ ) {
|
|
|
|
+ if(customer.getFrameId().equals(784)){
|
|
|
|
+ int i=0;
|
|
|
|
+ }
|
|
|
|
+ customer.setStatus(HospitaliseStatusEnum.DISCHARGED.value());
|
|
|
|
+ this.edit(customer, customer.getId());
|
|
|
|
+ this.customerMappingService.clearCustomerMapping(customer.getId());
|
|
|
|
+ if(bed!=null) { //如果患者转到了不存在的床位,不能更新设备的memberId,不然可能有新入住的患者在485上无法显示.只有患者明确出院了才能设置memberId为0
|
|
|
|
+ if(bed.getId().equals(784)){
|
|
|
|
+ int i=0;
|
|
|
|
+ }
|
|
|
|
+ this.deviceService.updateMemberId(customer.getFrameId(), new int[]{DeviceTypeEnum.DIGIT_BED_DEVICE.value(), DeviceTypeEnum.RS485_DOOR_DEVICE.value(), DeviceTypeEnum.SIMULATE_BED_DEVICE.value()}, 0);
|
|
|
|
+ }
|
|
|
|
+ return customer;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
CustomerDO inBed = hospitalized.stream().filter(p -> p.getFrameId() != null && bed != null && p.getFrameId().equals(bed.getId()) &&
|
|
CustomerDO inBed = hospitalized.stream().filter(p -> p.getFrameId() != null && bed != null && p.getFrameId().equals(bed.getId()) &&
|
|
p.getStatus().equals(0)).findFirst().orElse(null);
|
|
p.getStatus().equals(0)).findFirst().orElse(null);
|
|
//入住
|
|
//入住
|
|
@@ -410,7 +444,7 @@ public class CustomerServiceImpl extends SystemCRUDManagerImpl<CustomerDO> imple
|
|
//2、用户入住
|
|
//2、用户入住
|
|
CustomerDO customerDO = patient2Customer(patient, part, bed, customer, member);
|
|
CustomerDO customerDO = patient2Customer(patient, part, bed, customer, member);
|
|
|
|
|
|
- if (customerDO != null || customer != null) {
|
|
|
|
|
|
+ if (customerDO != null ) {
|
|
|
|
|
|
//3、入住成功,更新医护人员
|
|
//3、入住成功,更新医护人员
|
|
//准备医护人员,这里必须每次查询,因为可能有新增,如果一次性查出来,数据可能不对
|
|
//准备医护人员,这里必须每次查询,因为可能有新增,如果一次性查出来,数据可能不对
|
|
@@ -420,9 +454,13 @@ public class CustomerServiceImpl extends SystemCRUDManagerImpl<CustomerDO> imple
|
|
Boolean changed = updateCustomerCareCharge(ObjectUtil.defaultIfNull(customerDO, customer), clerkDOS, customerCareMapping);
|
|
Boolean changed = updateCustomerCareCharge(ObjectUtil.defaultIfNull(customerDO, customer), clerkDOS, customerCareMapping);
|
|
if (changed) {
|
|
if (changed) {
|
|
customerDO = ObjectUtil.defaultIfNull(customerDO, customer);
|
|
customerDO = ObjectUtil.defaultIfNull(customerDO, customer);
|
|
- this.deviceService.updateMemberId(customerDO.getFrameId(), new int[]{DeviceTypeEnum.DIGIT_BED_DEVICE.value(),DeviceTypeEnum.RS485_DOOR_DEVICE.value(),DeviceTypeEnum.SIMULATE_BED_DEVICE.value()}, customerDO.getMemberId());
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if(customerDO!=null){
|
|
|
|
+ this.deviceService.updateMemberId(customerDO.getFrameId(), new int[]{DeviceTypeEnum.DIGIT_BED_DEVICE.value(),DeviceTypeEnum.RS485_DOOR_DEVICE.value(),DeviceTypeEnum.SIMULATE_BED_DEVICE.value()}, customerDO.getMemberId());
|
|
}
|
|
}
|
|
|
|
+
|
|
return customerDO;
|
|
return customerDO;
|
|
|
|
|
|
} else {
|
|
} else {
|
|
@@ -451,6 +489,7 @@ public class CustomerServiceImpl extends SystemCRUDManagerImpl<CustomerDO> imple
|
|
//要删除的医护人员id
|
|
//要删除的医护人员id
|
|
List<Integer> removes = ListUtils.removeAll(oldClerkIds, newClerkIds);
|
|
List<Integer> removes = ListUtils.removeAll(oldClerkIds, newClerkIds);
|
|
Boolean change = false;
|
|
Boolean change = false;
|
|
|
|
+
|
|
if (adds != null && adds.size() > 0) { //要新加的医护人员
|
|
if (adds != null && adds.size() > 0) { //要新加的医护人员
|
|
for (Integer add : adds) {
|
|
for (Integer add : adds) {
|
|
ClerkDO clerk = clerks.stream().filter(p -> p.getClerkId().equals(add)).findFirst().orElse(null);
|
|
ClerkDO clerk = clerks.stream().filter(p -> p.getClerkId().equals(add)).findFirst().orElse(null);
|
|
@@ -484,7 +523,7 @@ public class CustomerServiceImpl extends SystemCRUDManagerImpl<CustomerDO> imple
|
|
}
|
|
}
|
|
|
|
|
|
private CustomerDO updateCustomer(PatientDO patient, ShopDO shop, FrameDO bed, CustomerDO customerDO) {
|
|
private CustomerDO updateCustomer(PatientDO patient, ShopDO shop, FrameDO bed, CustomerDO customerDO) {
|
|
- String age = patient.getAge().toString();
|
|
|
|
|
|
+ String age = patient.getAge();
|
|
Integer patientAge = StringHelper.fetchAge(age);
|
|
Integer patientAge = StringHelper.fetchAge(age);
|
|
customerDO.setAge(patientAge);
|
|
customerDO.setAge(patientAge);
|
|
if (StrUtil.isEmpty(patient.getAgeUnit())) { //没有传入年龄单位,尝试从年龄中获取
|
|
if (StrUtil.isEmpty(patient.getAgeUnit())) { //没有传入年龄单位,尝试从年龄中获取
|