|
|
@@ -16,9 +16,11 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import thyyxxk.webserver.config.exception.BizException;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
+import thyyxxk.webserver.constants.BedStatusEnum;
|
|
|
import thyyxxk.webserver.constants.Message;
|
|
|
import thyyxxk.webserver.dao.his.medicaladvice.patientinfo.AdjustBedDao;
|
|
|
import thyyxxk.webserver.dao.his.medicaladvice.patientinfo.ZyBedPreMsgDao;
|
|
|
+import thyyxxk.webserver.dao.his.zygl.ZyBedMiDao;
|
|
|
import thyyxxk.webserver.entity.dictionary.CodeName;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
import thyyxxk.webserver.entity.inpatient.ZyActpatient;
|
|
|
@@ -30,19 +32,14 @@ import thyyxxk.webserver.entity.medicaladvice.medicamanage.patientinfo.ZyBedMiPa
|
|
|
import thyyxxk.webserver.entity.medicaladvice.medicamanage.weixin.WeiXinPreBedMsgParam;
|
|
|
import thyyxxk.webserver.http.websocket.SocketV2;
|
|
|
import thyyxxk.webserver.http.websocket.dto.WebSocketByListUserCode;
|
|
|
+import thyyxxk.webserver.service.autocreateemr.AutoCreateEmrParams;
|
|
|
+import thyyxxk.webserver.service.autocreateemr.AutoCreateEmrServer;
|
|
|
import thyyxxk.webserver.service.externalhttp.WxServer;
|
|
|
import thyyxxk.webserver.service.hutoolcache.DeptCache;
|
|
|
import thyyxxk.webserver.service.hutoolcache.UserCache;
|
|
|
-import thyyxxk.webserver.utils.AssertUtil;
|
|
|
-import thyyxxk.webserver.utils.CommonUtil;
|
|
|
-import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
-import thyyxxk.webserver.utils.SocketMsg;
|
|
|
+import thyyxxk.webserver.utils.*;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @Description:
|
|
|
@@ -59,6 +56,9 @@ public class AdjustBedService {
|
|
|
private final SocketV2 intergrationPlatformSocket;
|
|
|
private final UserCache userCache;
|
|
|
private final DeptCache deptCache;
|
|
|
+ private final AutoCreateEmrServer autoCreateEmrServer;
|
|
|
+ private final ZyBedMiDao zyBedMiDao;
|
|
|
+
|
|
|
|
|
|
public ResultVo<String> preAllocationBed(MzZyReq mzZyReq) {
|
|
|
mzZyReq.setVisitDateStr(DateUtil.formatDateTime(mzZyReq.getVisitDate()));
|
|
|
@@ -167,8 +167,27 @@ public class AdjustBedService {
|
|
|
return dao.getPreAdmPatients(ward);
|
|
|
}
|
|
|
|
|
|
- public void receivePatient(ZyActpatient actpatient) {
|
|
|
- dao.updateBedStatus(actpatient.getInpatientNo(), actpatient.getPhry());
|
|
|
+ public void receivePatient(ZyActpatient act) {
|
|
|
+ ZyBedMi zyBedMi = zyBedMiDao.selectZyBedMi(act.getWard(), act.getWard(), act.getBedNo());
|
|
|
+ if (StringUtil.notBlank(zyBedMi.getInpatientNo()) &&
|
|
|
+ !Objects.equals(zyBedMi.getInpatientNo(), act.getInpatientNo())) {
|
|
|
+ String freeBedNo = zyBedMiDao.selectMaxFreeBedNo(act.getWard(), act.getWard());
|
|
|
+ if (StringUtil.isBlank(freeBedNo)) {
|
|
|
+ throw new BizException(ExceptionEnum.LOGICAL_ERROR, "接收失败,没有空闲床位!");
|
|
|
+ }
|
|
|
+ zyBedMi.setBedNo(freeBedNo);
|
|
|
+ }
|
|
|
+ zyBedMi.setInpatientNo(act.getInpatientNo());
|
|
|
+ zyBedMi.setAdmissTimes(act.getAdmissTimes());
|
|
|
+ zyBedMi.setBedStatus(BedStatusEnum.ARRANGE.code);
|
|
|
+ zyBedMiDao.updateZyBedMi(zyBedMi);
|
|
|
+
|
|
|
+ AutoCreateEmrParams.Params params = new AutoCreateEmrParams.Params();
|
|
|
+ params.setPatNo(act.getInpatientNo());
|
|
|
+ params.setTimes(act.getAdmissTimes());
|
|
|
+ // 自动创建病程记录
|
|
|
+ autoCreateEmrServer.createEmrAsync(params);
|
|
|
+ dao.updateBedStatus(act.getInpatientNo(), act.getPhry());
|
|
|
}
|
|
|
|
|
|
public ResultVo<List<Map>> getIdleBedNoList(ZyBedPreMsg msg) {
|
|
|
@@ -229,8 +248,12 @@ public class AdjustBedService {
|
|
|
if (zyBedMi == null || StrUtil.isBlank(zyBedMi.getInpatientNo())) {
|
|
|
throw new BizException(ExceptionEnum.INTERNAL_SERVER_ERROR, "此床位不存在病人信息,不能添加");
|
|
|
}
|
|
|
- zyBedMi.setBedStatus("2");
|
|
|
- dao.updatePatientByBed(zyBedMi);
|
|
|
+ BeanUtil.trimStrFields(zyBedMi);
|
|
|
+ //占床
|
|
|
+ param.setBedStatus("2");
|
|
|
+ param.setInpatientNo(zyBedMi.getInpatientNo());
|
|
|
+ param.setAdmissTimes(zyBedMi.getAdmissTimes());
|
|
|
+ dao.updatePatientByBed(param);
|
|
|
String message = StrUtil.format("添加{}床信息成功", param.getBedNo());
|
|
|
return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE, message);
|
|
|
}
|