|
@@ -0,0 +1,110 @@
|
|
|
+package thyyxxk.webserver.service.medicalinsurance;
|
|
|
+
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
+import thyyxxk.webserver.constants.sidicts.Insutype;
|
|
|
+import thyyxxk.webserver.constants.sidicts.MedType;
|
|
|
+import thyyxxk.webserver.dao.his.medicalinsurance.SiAdmVerifyDao;
|
|
|
+import thyyxxk.webserver.entity.ResultVo;
|
|
|
+import thyyxxk.webserver.entity.medicalinsurance.inpatient.SiAdmissApply;
|
|
|
+import thyyxxk.webserver.entity.yibao.dismiss.ZyDisYbDiag;
|
|
|
+import thyyxxk.webserver.entity.yibao.dismiss.ZyDisYbSrgry;
|
|
|
+import thyyxxk.webserver.entity.yibao.patient.Patient;
|
|
|
+import thyyxxk.webserver.entity.yibao.patient.ZyInYbDiag;
|
|
|
+import thyyxxk.webserver.service.redislike.RedisLikeService;
|
|
|
+import thyyxxk.webserver.service.yibao.PatientService;
|
|
|
+import thyyxxk.webserver.utils.DecimalUtil;
|
|
|
+import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
+import thyyxxk.webserver.utils.StringUtil;
|
|
|
+import thyyxxk.webserver.utils.TokenUtil;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author dj
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class SiAdmVerifyService {
|
|
|
+ private final SiAdmVerifyDao dao;
|
|
|
+ private final RedisLikeService redis;
|
|
|
+ private final PatientService ptntSrvc;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public SiAdmVerifyService(SiAdmVerifyDao dao, RedisLikeService redis, PatientService ptntSrvc) {
|
|
|
+ this.dao = dao;
|
|
|
+ this.redis = redis;
|
|
|
+ this.ptntSrvc = ptntSrvc;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<SiAdmissApply> selectAdmissApply(Patient p) {
|
|
|
+ MedType medType = MedType.get(p.getMedType());
|
|
|
+ if (null == medType) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医疗类别不能为空!");
|
|
|
+ }
|
|
|
+ if (medType == MedType.GENERAL_HOSPITALIZATION ||
|
|
|
+ (medType == MedType.SINGLE_DISEASE_HOSPITALIZATION && p.getInpatientNo().startsWith("JT"))) {
|
|
|
+ SiAdmissApply apply = new SiAdmissApply();
|
|
|
+ apply.setStatus(1);
|
|
|
+ return ResultVoUtil.success(apply);
|
|
|
+ }
|
|
|
+ SiAdmissApply apply = dao.selectAdmissApply(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
|
|
|
+ if (null == apply) {
|
|
|
+ apply = new SiAdmissApply();
|
|
|
+ apply.setAdmissDatetime(p.getYbRegisterDate());
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success(apply);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String> submitAdmissApply(SiAdmissApply apply) {
|
|
|
+ if (StringUtil.isBlank(apply.getInputComment())) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "申请理由不能为空!");
|
|
|
+ }
|
|
|
+ apply.setStatus(0);
|
|
|
+ apply.setInputStaff(TokenUtil.getTokenUserId());
|
|
|
+ dao.deleteAdmissApply(apply.getPatNo(), apply.getTimes(), apply.getLedgerSn());
|
|
|
+ dao.insertAdmissApply(apply);
|
|
|
+ return ResultVoUtil.success("提交成功。");
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<List<SiAdmissApply>> selectUnhandledApplies() {
|
|
|
+ List<SiAdmissApply> list = dao.selectUnhandledApplies();
|
|
|
+ for (SiAdmissApply apply : list) {
|
|
|
+ apply.setInputName(redis.getEmployeeName(apply.getInputStaff()));
|
|
|
+ apply.setHandleStaffName(redis.getEmployeeName(apply.getHandleStaff()));
|
|
|
+ apply.setAdmdvsName(redis.getRegionName(apply.getAdmdvs()));
|
|
|
+ apply.setMedTypeName(MedType.getName(apply.getMedType()));
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<Map<String, Object>> selectPatientInfo(SiAdmissApply apply) {
|
|
|
+ ResultVo<Patient> ptntRsvo = ptntSrvc.getPatientInfo(apply.getPatNo());
|
|
|
+ if (ptntRsvo.getCode() != ExceptionEnum.SUCCESS.getCode()) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, ptntRsvo.getMessage());
|
|
|
+ }
|
|
|
+ Patient patient = ptntRsvo.getData();
|
|
|
+ List<ZyInYbDiag> inYbDiags = ptntSrvc.getZyInYbDiags(apply.getPatNo(), apply.getTimes()).getData();
|
|
|
+ for (ZyInYbDiag itm : inYbDiags) {
|
|
|
+ itm.setOperName(redis.getEmployeeName(itm.getOperId()));
|
|
|
+ }
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("apply", apply);
|
|
|
+ map.put("patient", patient);
|
|
|
+ map.put("indiags", inYbDiags);
|
|
|
+ return ResultVoUtil.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String> handleApply(SiAdmissApply apply) {
|
|
|
+ if (StringUtil.isBlank(apply.getHandleComment())) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "处理意见不能为空!");
|
|
|
+ }
|
|
|
+ apply.setHandleStaff(TokenUtil.getTokenUserId());
|
|
|
+ dao.handleApply(apply);
|
|
|
+ return ResultVoUtil.success("处理成功。");
|
|
|
+ }
|
|
|
+}
|