|
|
@@ -6,12 +6,15 @@ import org.springframework.stereotype.Service;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.dao.his.inpatient.nursemodule.PrintInfusionCardDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
+import thyyxxk.webserver.entity.ca.CaReturn;
|
|
|
+import thyyxxk.webserver.entity.ca.CaSignClass;
|
|
|
import thyyxxk.webserver.entity.executeItem.YzActOcc;
|
|
|
import thyyxxk.webserver.entity.inpatient.nursemodule.request.CardType;
|
|
|
import thyyxxk.webserver.entity.inpatient.nursemodule.request.InfusionInsert;
|
|
|
import thyyxxk.webserver.entity.inpatient.nursemodule.request.UpdatePrintStatus;
|
|
|
import thyyxxk.webserver.entity.inpatient.nursemodule.response.*;
|
|
|
import thyyxxk.webserver.entity.inpatient.nursemodule.request.QueryInfusionCard;
|
|
|
+import thyyxxk.webserver.service.ca.CaServer;
|
|
|
import thyyxxk.webserver.utils.*;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
@@ -21,10 +24,12 @@ import java.util.*;
|
|
|
@Service
|
|
|
public class PrintInfusionCardService {
|
|
|
private final PrintInfusionCardDao dao;
|
|
|
+ private final CaServer caService;
|
|
|
|
|
|
@Autowired
|
|
|
- public PrintInfusionCardService(PrintInfusionCardDao dao) {
|
|
|
+ public PrintInfusionCardService(PrintInfusionCardDao dao, CaServer caService) {
|
|
|
this.dao = dao;
|
|
|
+ this.caService = caService;
|
|
|
}
|
|
|
|
|
|
public ResultVo<List<PatientBed>> getPatientBeds(String wardCode) {
|
|
|
@@ -248,8 +253,17 @@ public class PrintInfusionCardService {
|
|
|
}
|
|
|
|
|
|
List<YzActOcc> drugs = dao.getInfusionDrugsByScan(patNo, actOrderNo, occTime);
|
|
|
+ if (drugs.isEmpty()) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有找到医嘱用药内容!");
|
|
|
+ }
|
|
|
int checkedCount = 0;
|
|
|
- for (YzActOcc occ : drugs) {
|
|
|
+ StringBuilder caMsbBuilder = new StringBuilder();
|
|
|
+ caMsbBuilder
|
|
|
+ .append("为患者【")
|
|
|
+ .append(drugs.get(0).getInpatientName().trim())
|
|
|
+ .append("】执行输液:");
|
|
|
+ for (int i = 0; i < drugs.size(); i++) {
|
|
|
+ YzActOcc occ = drugs.get(i);
|
|
|
if (StringUtil.notBlank(occ.getExecuteStaff()) && null != occ.getExecuteTime()) {
|
|
|
String executeTime = DateUtil.formatDatetime(occ.getExecuteTime());
|
|
|
return ResultVoUtil.fail(ExceptionEnum.SLIGHTLY_ERROR,
|
|
|
@@ -262,12 +276,27 @@ public class PrintInfusionCardService {
|
|
|
if (mapQuan.compareTo(occ.getDrugQuan()) != 0) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.SLIGHTLY_ERROR, "用药与医嘱不匹配,请检查!");
|
|
|
}
|
|
|
+ caMsbBuilder.append(occ.getOccName().trim()).append(" x ").append(occ.getDrugQuan());
|
|
|
+ if (i == drugs.size() - 1) {
|
|
|
+ caMsbBuilder.append("。");
|
|
|
+ } else {
|
|
|
+ caMsbBuilder.append(";");
|
|
|
+ }
|
|
|
checkedCount++;
|
|
|
drugMap.remove(occ.getChargeCode());
|
|
|
}
|
|
|
if (checkedCount == drugs.size() && drugMap.isEmpty()) {
|
|
|
String staff = TokenUtil.getInstance().getTokenUserId();
|
|
|
- int updatedRows = dao.updateExecutor(patNo, actOrderNo, occTime, staff);
|
|
|
+
|
|
|
+ CaSignClass.Send caParams = new CaSignClass.Send();
|
|
|
+ caParams.setId(staff);
|
|
|
+ caParams.setMsg(caMsbBuilder.toString());
|
|
|
+ caParams.setDesc("执行输液医嘱。");
|
|
|
+ log.info("执行输液CA签名入参:{}", caParams);
|
|
|
+ CaReturn.CaSignReturn caRes = caService.sendByCode(caParams);
|
|
|
+ log.info("执行输液CA签名返回:{}", caRes);
|
|
|
+
|
|
|
+ int updatedRows = dao.updateExecutor(patNo, actOrderNo, occTime, staff, caRes.getId());
|
|
|
if (updatedRows > 0) {
|
|
|
return ResultVoUtil.success("核对执行成功。");
|
|
|
}
|