|
|
@@ -7,7 +7,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.constants.Capacity;
|
|
|
-import thyyxxk.webserver.constants.HrgAddr;
|
|
|
+import thyyxxk.webserver.constants.ExternalAddr;
|
|
|
import thyyxxk.webserver.constants.ResponceType;
|
|
|
import thyyxxk.webserver.dao.his.markmtfees.MarkMtFeesDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
@@ -116,137 +116,139 @@ public class MarkMtFeesService {
|
|
|
return ResultVoUtil.success();
|
|
|
}
|
|
|
|
|
|
- public ResultVo<Map<String, Object>> getMtReceipts(String patientId, Integer times) {
|
|
|
- Map<String, Object> map = new HashMap<>(Capacity.FOUR);
|
|
|
- List<MzPatient> mzPatients = dao.selectMzPatient(patientId, times);
|
|
|
+ public ResultVo<List<Map<String, Object>>> getMtReceipts(String patientId) {
|
|
|
+ List<MzPatient> mzPatients = dao.selectMzPatient(patientId);
|
|
|
if (null == mzPatients || mzPatients.isEmpty()) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【门诊号:" + patientId + ",就诊次数:" +
|
|
|
- times + "】未找到此患者的本次就诊信息,请核实。");
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【门诊号:" + patientId + "】未找到此患者的个人基本信息,请核实。");
|
|
|
}
|
|
|
- MzVisit mzVisit = dao.selectMzVisit(patientId, times);
|
|
|
- if (null == mzVisit) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【门诊号:" + patientId + ",就诊次数:" +
|
|
|
- times + "】未找到此患者的本次就诊信息,请核实。");
|
|
|
- }
|
|
|
- map.put("mzPatient", mzPatients.get(0));
|
|
|
- map.put("mzVisit", mzVisit);
|
|
|
JSONObject queryMzChargeList = new JSONObject();
|
|
|
queryMzChargeList.put("patCardType", 21);
|
|
|
queryMzChargeList.put("patCardNo", patientId);
|
|
|
queryMzChargeList.put("hisOrdNum", "");
|
|
|
RestTemplate template = new RestTemplate();
|
|
|
- Map<String, Object> mzChargeListMap = template.postForObject(HrgAddr.GET_MZ_CHARGE_DETAIL_FOR_UN_PAID, queryMzChargeList, Map.class);
|
|
|
+ Map<String, Object> mzChargeListMap = template.postForObject(ExternalAddr.GET_MZ_CHARGE_DETAIL_FOR_UN_PAID, queryMzChargeList, Map.class);
|
|
|
if (null == mzChargeListMap) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
|
|
|
}
|
|
|
if (0 != (int) mzChargeListMap.get("resultCode")) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, mzChargeListMap.get("resultMessage").toString());
|
|
|
}
|
|
|
+
|
|
|
+ List<Map<String, Object>> finalResult = new ArrayList<>();
|
|
|
List<Map<String, String>> mzChargeList = FilterUtil.cast(mzChargeListMap.get("data"));
|
|
|
- List<Map<String, Object>> mzChargeDetailList = new ArrayList<>();
|
|
|
- mzChargeList.forEach(item -> {
|
|
|
+
|
|
|
+ for (Map<String, String> item : mzChargeList) {
|
|
|
String hisOrdNum = item.get("hisOrdNum");
|
|
|
if (null != hisOrdNum) {
|
|
|
String[] hisOrdNumParts = hisOrdNum.split("_");
|
|
|
- if (Integer.parseInt(hisOrdNumParts[1]) == times) {
|
|
|
- JSONObject queryMzChargeDetail = new JSONObject();
|
|
|
- queryMzChargeDetail.put("patientId", patientId);
|
|
|
- queryMzChargeDetail.put("times", times);
|
|
|
- queryMzChargeDetail.put("receiptNo", hisOrdNumParts[2]);
|
|
|
- Map<String, Object> mzChargeDetailMap = template.postForObject(HrgAddr.UN_PAID_TO_FULL_CHARGE_DETAIL,
|
|
|
- queryMzChargeDetail, Map.class);
|
|
|
- if (null != mzChargeDetailMap && 0 == (int) mzChargeDetailMap.get("resultCode")) {
|
|
|
- List<Map<String, Object>> detail = FilterUtil.cast(mzChargeDetailMap.get("data"));
|
|
|
- mzChargeDetailList.addAll(detail);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- mzChargeDetailList.removeIf(item -> "TC".equals(item.get("billItemCode")) ||
|
|
|
- !"5".equals(item.get("payMark")) || "BILL99".equals(item.get("chargeItemCode")) ||
|
|
|
- "四舍五入".equals(item.get("tcName")));
|
|
|
- if (mzChargeDetailList.isEmpty()) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "未查询到此患者的待缴费处方。");
|
|
|
- }
|
|
|
- Map<Integer, List<MzReceipt>> orderReceiptsMap = new HashMap<>(Capacity.DEFAULT);
|
|
|
- String doctorName = dao.selectDoctorName(mzChargeDetailList.get(0).get("doctorCode").toString());
|
|
|
- mzChargeDetailList.forEach(item -> {
|
|
|
- MzReceipt receipt = new MzReceipt();
|
|
|
- receipt.setChecked(!item.get("tcName").toString().contains("外送艾迪康"));
|
|
|
- receipt.setPatientId(patientId);
|
|
|
- receipt.setTimes(times);
|
|
|
- receipt.setReceiptNo((int) item.get("receiptNo"));
|
|
|
- receipt.setOrderNo((int) item.get("orderNo"));
|
|
|
- receipt.setItemNo((int) item.get("itemNo"));
|
|
|
- receipt.setDrugName(item.get("tcName").toString());
|
|
|
- receipt.setChargeItemCode(item.get("chargeItemCode").toString());
|
|
|
- receipt.setPriceTime(DateUtil.formatPriceTime(item.get("priceTime").toString()));
|
|
|
- receipt.setUnitPrice(new BigDecimal(item.get("unitPrice").toString()).setScale(4, BigDecimal.ROUND_HALF_UP));
|
|
|
- receipt.setQuantity((double) item.get("quantity"));
|
|
|
- receipt.setDrugWin((int) item.get("drugWin"));
|
|
|
- receipt.setDoctorCode(item.get("doctorCode").toString());
|
|
|
- receipt.setDoctorName(doctorName);
|
|
|
- receipt.setSerialNo(item.get("serialNo").toString());
|
|
|
- receipt.setGroupNo(item.get("groupNo").toString());
|
|
|
- receipt.setBillItemCode(item.get("billItemCode").toString());
|
|
|
- receipt.setChargeBillCode(item.get("chargeBillCode").toString());
|
|
|
- if (null != item.get("instructionText")) {
|
|
|
- receipt.setInstructionText(item.get("instructionText").toString());
|
|
|
- }
|
|
|
- if (null != item.get("specification")) {
|
|
|
- receipt.setSpecification(item.get("specification").toString());
|
|
|
- }
|
|
|
- if (null != item.get("frequency")) {
|
|
|
- receipt.setFrequency(item.get("frequency").toString());
|
|
|
- }
|
|
|
- if (null != item.get("drugQuan")) {
|
|
|
- receipt.setDrugQuan((Double) item.get("drugQuan"));
|
|
|
- }
|
|
|
- if (null != item.get("orderDays")) {
|
|
|
- receipt.setOrderDays((Integer) item.get("orderDays"));
|
|
|
- }
|
|
|
- // groupNo:00-项目;其他-药品
|
|
|
- if ("00".equals(receipt.getGroupNo())) {
|
|
|
- receipt.setDrugUnit(dao.selectXmChargeUnit(receipt.getChargeItemCode()));
|
|
|
- } else {
|
|
|
- if (null != item.get("serial")) {
|
|
|
- receipt.setSerial(item.get("serial").toString());
|
|
|
- receipt.setSpecification(dao.selectSpecification(receipt.getChargeItemCode(), receipt.getSerial()));
|
|
|
+ int times = Integer.parseInt(hisOrdNumParts[1]);
|
|
|
+ MzVisit mzVisit = dao.selectMzVisit(patientId, times);
|
|
|
+ if (null == mzVisit) {
|
|
|
+ continue;
|
|
|
}
|
|
|
- if (null != item.get("supplyCode")) {
|
|
|
- receipt.setSupplyCode(dao.selectSupplyName(item.get("supplyCode").toString()));
|
|
|
- }
|
|
|
- if (null != item.get("drugUnit")) {
|
|
|
- receipt.setDrugUnit(dao.selectDrugUnit(item.get("drugUnit").toString()));
|
|
|
+ Map<String, Object> childResult = new HashMap<>(Capacity.FIVE);
|
|
|
+ childResult.put("times", times);
|
|
|
+ childResult.put("mzPatient", mzPatients.get(0));
|
|
|
+ childResult.put("mzVisit", mzVisit);
|
|
|
+ JSONObject queryMzChargeDetail = new JSONObject();
|
|
|
+ queryMzChargeDetail.put("patientId", patientId);
|
|
|
+ queryMzChargeDetail.put("times", times);
|
|
|
+ queryMzChargeDetail.put("receiptNo", hisOrdNumParts[2]);
|
|
|
+ mzVisit.setReceiptNo(Integer.parseInt(hisOrdNumParts[2]));
|
|
|
+ Map<String, Object> mzChargeDetailMap = template.postForObject(ExternalAddr.UN_PAID_TO_FULL_CHARGE_DETAIL,
|
|
|
+ queryMzChargeDetail, Map.class);
|
|
|
+ if (null != mzChargeDetailMap && 0 == (int) mzChargeDetailMap.get("resultCode")) {
|
|
|
+ List<Map<String, Object>> mzChargeDetailList = FilterUtil.cast(mzChargeDetailMap.get("data"));
|
|
|
+
|
|
|
+ mzChargeDetailList.removeIf(detail -> "TC".equals(detail.get("billItemCode")) ||
|
|
|
+ !"5".equals(detail.get("payMark")) || "BILL99".equals(detail.get("chargeItemCode")) ||
|
|
|
+ "四舍五入".equals(detail.get("tcName")));
|
|
|
+ if (mzChargeDetailList.isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<Integer, List<MzReceipt>> orderReceiptsMap = new HashMap<>(Capacity.DEFAULT);
|
|
|
+ String doctorName = dao.selectDoctorName(mzChargeDetailList.get(0).get("doctorCode").toString());
|
|
|
+ mzChargeDetailList.forEach(detail -> {
|
|
|
+ MzReceipt receipt = new MzReceipt();
|
|
|
+ receipt.setChecked(!detail.get("tcName").toString().contains("外送艾迪康"));
|
|
|
+ receipt.setPatientId(patientId);
|
|
|
+ receipt.setTimes(times);
|
|
|
+ receipt.setReceiptNo((int) detail.get("receiptNo"));
|
|
|
+ receipt.setOrderNo((int) detail.get("orderNo"));
|
|
|
+ receipt.setItemNo((int) detail.get("itemNo"));
|
|
|
+ receipt.setDrugName(detail.get("tcName").toString());
|
|
|
+ receipt.setChargeItemCode(detail.get("chargeItemCode").toString());
|
|
|
+ receipt.setPriceTime(DateUtil.formatPriceTime(detail.get("priceTime").toString()));
|
|
|
+ receipt.setUnitPrice(new BigDecimal(detail.get("unitPrice").toString()).setScale(4, BigDecimal.ROUND_HALF_UP));
|
|
|
+ receipt.setQuantity((double) detail.get("quantity"));
|
|
|
+ receipt.setDrugWin((int) detail.get("drugWin"));
|
|
|
+ receipt.setDoctorCode(detail.get("doctorCode").toString());
|
|
|
+ receipt.setDoctorName(doctorName);
|
|
|
+ receipt.setSerialNo(detail.get("serialNo").toString());
|
|
|
+ receipt.setGroupNo(detail.get("groupNo").toString());
|
|
|
+ receipt.setBillItemCode(detail.get("billItemCode").toString());
|
|
|
+ receipt.setChargeBillCode(detail.get("chargeBillCode").toString());
|
|
|
+ if (null != detail.get("instructionText")) {
|
|
|
+ receipt.setInstructionText(detail.get("instructionText").toString());
|
|
|
+ }
|
|
|
+ if (null != detail.get("specification")) {
|
|
|
+ receipt.setSpecification(detail.get("specification").toString());
|
|
|
+ }
|
|
|
+ if (null != detail.get("frequency")) {
|
|
|
+ receipt.setFrequency(detail.get("frequency").toString());
|
|
|
+ }
|
|
|
+ if (null != detail.get("drugQuan")) {
|
|
|
+ receipt.setDrugQuan((Double) detail.get("drugQuan"));
|
|
|
+ }
|
|
|
+ if (null != detail.get("orderDays")) {
|
|
|
+ receipt.setOrderDays((Integer) detail.get("orderDays"));
|
|
|
+ }
|
|
|
+ // groupNo:00-项目;其他-药品
|
|
|
+ if ("00".equals(receipt.getGroupNo())) {
|
|
|
+ receipt.setDrugUnit(dao.selectXmChargeUnit(receipt.getChargeItemCode()));
|
|
|
+ } else {
|
|
|
+ if (null != detail.get("serial")) {
|
|
|
+ receipt.setSerial(detail.get("serial").toString());
|
|
|
+ receipt.setSpecification(dao.selectSpecification(receipt.getChargeItemCode(), receipt.getSerial()));
|
|
|
+ }
|
|
|
+ if (null != detail.get("supplyCode")) {
|
|
|
+ receipt.setSupplyCode(dao.selectSupplyName(detail.get("supplyCode").toString()));
|
|
|
+ }
|
|
|
+ if (null != detail.get("drugUnit")) {
|
|
|
+ receipt.setDrugUnit(dao.selectDrugUnit(detail.get("drugUnit").toString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!orderReceiptsMap.containsKey(receipt.getOrderNo())) {
|
|
|
+ List<MzReceipt> list = new ArrayList<>();
|
|
|
+ list.add(receipt);
|
|
|
+ orderReceiptsMap.put(receipt.getOrderNo(), list);
|
|
|
+ } else {
|
|
|
+ orderReceiptsMap.get(receipt.getOrderNo()).add(receipt);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ List<OrderNo> orderNos = new ArrayList<>();
|
|
|
+ for (Map.Entry<Integer, List<MzReceipt>> entry : orderReceiptsMap.entrySet()) {
|
|
|
+ OrderNo orderNo = new OrderNo();
|
|
|
+ orderNo.setPatientId(patientId);
|
|
|
+ orderNo.setTimes(times);
|
|
|
+ orderNo.setReceiptNo(entry.getValue().get(0).getReceiptNo());
|
|
|
+ orderNo.setOrderNo(entry.getKey());
|
|
|
+ BigDecimal total = new BigDecimal("0.00");
|
|
|
+ for (MzReceipt receipt : entry.getValue()) {
|
|
|
+ total = total.add(receipt.getChargeFee());
|
|
|
+ }
|
|
|
+ orderNo.setTotalFee(total);
|
|
|
+ int count = dao.selectFeeCount(patientId, times, mzVisit.getReceiptNo(), entry.getKey());
|
|
|
+ orderNo.setStatus(count > 0);
|
|
|
+ orderNos.add(orderNo);
|
|
|
+ }
|
|
|
+ childResult.put("orderNos", orderNos);
|
|
|
+ childResult.put("mzReceipts", orderReceiptsMap);
|
|
|
+ finalResult.add(childResult);
|
|
|
}
|
|
|
}
|
|
|
- if (!orderReceiptsMap.containsKey(receipt.getOrderNo())) {
|
|
|
- List<MzReceipt> list = new ArrayList<>();
|
|
|
- list.add(receipt);
|
|
|
- orderReceiptsMap.put(receipt.getOrderNo(), list);
|
|
|
- } else {
|
|
|
- orderReceiptsMap.get(receipt.getOrderNo()).add(receipt);
|
|
|
- }
|
|
|
- });
|
|
|
- List<OrderNo> orderNos = new ArrayList<>();
|
|
|
- for (Map.Entry<Integer, List<MzReceipt>> entry : orderReceiptsMap.entrySet()) {
|
|
|
- OrderNo orderNo = new OrderNo();
|
|
|
- orderNo.setPatientId(patientId);
|
|
|
- orderNo.setTimes(times);
|
|
|
- orderNo.setReceiptNo(entry.getValue().get(0).getReceiptNo());
|
|
|
- orderNo.setOrderNo(entry.getKey());
|
|
|
- BigDecimal total = new BigDecimal("0.00");
|
|
|
- for (MzReceipt item : entry.getValue()) {
|
|
|
- total = total.add(item.getChargeFee());
|
|
|
- }
|
|
|
- orderNo.setTotalFee(total);
|
|
|
- int count = dao.selectFeeCount(patientId, times, mzVisit.getReceiptNo(), entry.getKey());
|
|
|
- orderNo.setStatus(count > 0);
|
|
|
- orderNos.add(orderNo);
|
|
|
}
|
|
|
- map.put("orderNos", orderNos);
|
|
|
- map.put("mzReceipts", orderReceiptsMap);
|
|
|
- return ResultVoUtil.success(map);
|
|
|
+ return ResultVoUtil.success(finalResult);
|
|
|
}
|
|
|
|
|
|
public ResultVo<String> insertMtFees(MarkMtFeeParam param) {
|