|
@@ -0,0 +1,84 @@
|
|
|
+package thyyxxk.webserver.scheduled;
|
|
|
+
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
+import thyyxxk.webserver.constants.YesOrNo;
|
|
|
+import thyyxxk.webserver.constants.sidicts.MedChrgitmType;
|
|
|
+import thyyxxk.webserver.dao.his.medicalinsurance.SiSetlinfoDao;
|
|
|
+import thyyxxk.webserver.entity.ResultVo;
|
|
|
+import thyyxxk.webserver.entity.medicalinsurance.query.SiSetlFeeDetl;
|
|
|
+import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
|
|
|
+import thyyxxk.webserver.service.medicalinsurance.SiQueryService;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class AnalyzeSiInpatientCharges {
|
|
|
+ @Value("${execute-scheduled}")
|
|
|
+ private Boolean executeScheduled;
|
|
|
+ private final SiQueryService service;
|
|
|
+ private final SiSetlinfoDao dao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public AnalyzeSiInpatientCharges(SiQueryService service, SiSetlinfoDao dao) {
|
|
|
+ this.service = service;
|
|
|
+ this.dao = dao;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 0 3 * * ?")
|
|
|
+ public void notifyDailyCount() {
|
|
|
+ if (executeScheduled) {
|
|
|
+ startAnalyze();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void startAnalyze() {
|
|
|
+ List<SiSetlinfo> unAnalyzedData = dao.selectUnAnalyzedData();
|
|
|
+ for (int i = 0; i < unAnalyzedData.size(); i++) {
|
|
|
+ SiSetlinfo setlinfo = unAnalyzedData.get(i);
|
|
|
+ ResultVo<List<SiSetlFeeDetl>> chargeList = service.getChrgitems(setlinfo.getPsnNo(), setlinfo.getSetlId(),
|
|
|
+ setlinfo.getMdtrtId(), setlinfo.getInsuplcAdmdvs());
|
|
|
+ if (chargeList.getCode() == ExceptionEnum.SUCCESS.getCode()) {
|
|
|
+ analyzeChargeItems(setlinfo, chargeList.getData());
|
|
|
+ }
|
|
|
+ setlinfo.setChargesAnalyzed(YesOrNo.YES.getCode());
|
|
|
+ dao.fillAnalyzedData(setlinfo);
|
|
|
+ log.info("【序号:{}】结算ID为【{}】的医保患者结算收费类别已分析完成。", i+1, setlinfo.getSetlId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void analyzeChargeItems(SiSetlinfo setlinfo, List<SiSetlFeeDetl> chargeItems) {
|
|
|
+ Map<String, BigDecimal> map = new HashMap<>();
|
|
|
+ chargeItems.forEach(itm -> {
|
|
|
+ BigDecimal itmfeeSum = new BigDecimal(itm.getDetItemFeeSumamt());
|
|
|
+ String typeKey = itm.getMedChrgitmType();
|
|
|
+ if (map.containsKey(typeKey)) {
|
|
|
+ map.replace(typeKey, map.get(typeKey).add(itmfeeSum));
|
|
|
+ } else {
|
|
|
+ map.put(typeKey, itmfeeSum);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ setlinfo.setChargeWesternMedicine(map.get(MedChrgitmType.WEST_MED.getCode()));
|
|
|
+ setlinfo.setChargePatentMedicine(map.get(MedChrgitmType.CHN_PTNT.getCode()));
|
|
|
+ setlinfo.setChargeHerbal(map.get(MedChrgitmType.HERBAL.getCode()));
|
|
|
+ setlinfo.setChargeExamination(map.get(MedChrgitmType.CLINIC.getCode()));
|
|
|
+ setlinfo.setChargeTreatment(map.get(MedChrgitmType.TREAT.getCode()));
|
|
|
+ setlinfo.setChargeOperation(map.get(MedChrgitmType.SURGERY.getCode()));
|
|
|
+ setlinfo.setChargeNursing(map.get(MedChrgitmType.NURSING.getCode()));
|
|
|
+ setlinfo.setChargeSanitaryMaterial(map.get(MedChrgitmType.MATERIAL.getCode()));
|
|
|
+ setlinfo.setChargeAssay(map.get(MedChrgitmType.EXAM.getCode()));
|
|
|
+ setlinfo.setChargeGeneralDiagnosis(map.get(MedChrgitmType.HEAL.getCode()));
|
|
|
+ setlinfo.setChargeInspection(map.get(MedChrgitmType.INSPECTION.getCode()));
|
|
|
+ setlinfo.setChargeRegistration(map.get(MedChrgitmType.REG.getCode()));
|
|
|
+ setlinfo.setChargeBed(map.get(MedChrgitmType.BED.getCode()));
|
|
|
+ setlinfo.setChargeOthers(map.get(MedChrgitmType.OTH.getCode()));
|
|
|
+ }
|
|
|
+}
|