|
@@ -1757,4 +1757,110 @@ public class MzPharmacyController {
|
|
|
|
|
|
return resultMap;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据关联字段查询发药记录
|
|
|
+ *
|
|
|
+ * 功能说明:通过关联字段查询具体的发药记录,用于医保接口关联发药信息
|
|
|
+ *
|
|
|
+ * 关联字段说明:
|
|
|
+ * - patientId: 患者ID,来自 mz_charge_detail.patient_id 表
|
|
|
+ * - times: 就诊次数,来自 mz_charge_detail.times 表
|
|
|
+ * - receiptNo: 发票分票号,来自 mz_charge_detail.receipt_no 表
|
|
|
+ * - orderNo: 处方号,来自 mz_charge_detail.order_no 表
|
|
|
+ * - chargeItemCode: 收费项目编码,来自 mz_charge_detail.charge_item_code 表
|
|
|
+ * - realNo: 流水号,来自 mz_charge_detail.real_no 表
|
|
|
+ *
|
|
|
+ * 查询的数据表:
|
|
|
+ * 1. yp_mz_fytj: 发药统计表
|
|
|
+ * - 记录发药数量、金额、确认时间等统计信息
|
|
|
+ * - 通过关联字段查询具体的发药统计记录
|
|
|
+ *
|
|
|
+ * 2. mz_drug_trac_codg: 药品追溯码表
|
|
|
+ * - 记录药品追溯码信息
|
|
|
+ * - 通过关联字段查询具体的追溯码记录
|
|
|
+ *
|
|
|
+ * 调用场景:
|
|
|
+ * 1. 医保接口调用后,需要查询具体的发药记录进行审计
|
|
|
+ * 2. 系统管理员需要查看特定发药记录的详细信息
|
|
|
+ * 3. 财务对账时,需要核对发药记录与医保记录的一致性
|
|
|
+ *
|
|
|
+ * 返回数据:
|
|
|
+ * - fytjRecords: 发药统计记录列表
|
|
|
+ * - tracCodgRecords: 追溯码记录列表
|
|
|
+ * - associationKey: 关联键字符串,用于日志记录和后续查询
|
|
|
+ *
|
|
|
+ * @param request 包含关联字段的请求参数
|
|
|
+ * @param httpServletRequest HTTP请求对象
|
|
|
+ * @return Map<String, Object> 查询结果,包含发药记录和追溯码信息
|
|
|
+ */
|
|
|
+ @UserLoginToken
|
|
|
+ @RequestMapping(value = "/getDispensingRecordByAssociation", method = {RequestMethod.POST})
|
|
|
+ public Map<String, Object> getDispensingRecordByAssociation(@RequestBody Map<String, Object> request, HttpServletRequest httpServletRequest) {
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ try {
|
|
|
+ // 从请求参数中提取关联字段
|
|
|
+ String patientId = (String) request.get("patientId");
|
|
|
+ Integer times = (Integer) request.get("times");
|
|
|
+ Integer receiptNo = (Integer) request.get("receiptNo");
|
|
|
+ Integer orderNo = (Integer) request.get("orderNo");
|
|
|
+ String chargeItemCode = (String) request.get("chargeItemCode");
|
|
|
+ Integer realNo = (Integer) request.get("realNo");
|
|
|
+
|
|
|
+ // 参数验证:确保所有必要的关联字段都不为空
|
|
|
+ if (StringUtils.isBlank(patientId) || times == null || receiptNo == null ||
|
|
|
+ orderNo == null || StringUtils.isBlank(chargeItemCode)) {
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "关联字段不能为空");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 记录查询日志,便于问题排查和审计
|
|
|
+ log.info("查询发药记录 - 关联字段: patientId={}, times={}, receiptNo={}, orderNo={}, chargeItemCode={}, realNo={}",
|
|
|
+ patientId, times, receiptNo, orderNo, chargeItemCode, realNo);
|
|
|
+
|
|
|
+ // 1. 查询发药统计记录(yp_mz_fytj 表)
|
|
|
+ // 该表记录发药的数量、金额、确认时间等统计信息
|
|
|
+ Map<String, Object> fytjQuery = new HashMap<>();
|
|
|
+ fytjQuery.put("patientId", patientId);
|
|
|
+ fytjQuery.put("times", times);
|
|
|
+ fytjQuery.put("receiptNo", receiptNo);
|
|
|
+ fytjQuery.put("orderNo", orderNo);
|
|
|
+ fytjQuery.put("chargeItemCode", chargeItemCode);
|
|
|
+ fytjQuery.put("realNo", realNo);
|
|
|
+
|
|
|
+ List<Map<String, Object>> fytjRecords = mzPharmacyService.queryDispensingRecordsByAssociation(fytjQuery);
|
|
|
+
|
|
|
+ // 2. 查询追溯码记录(mz_drug_trac_codg 表)
|
|
|
+ // 该表记录药品追溯码信息,用于药品追溯和监管
|
|
|
+ Map<String, Object> tracCodgQuery = new HashMap<>();
|
|
|
+ tracCodgQuery.put("patientId", patientId);
|
|
|
+ tracCodgQuery.put("times", times);
|
|
|
+ tracCodgQuery.put("receiptNo", receiptNo);
|
|
|
+ tracCodgQuery.put("orderNo", orderNo);
|
|
|
+ tracCodgQuery.put("chargeItemCode", chargeItemCode);
|
|
|
+ tracCodgQuery.put("realNo", realNo);
|
|
|
+
|
|
|
+ List<Map<String, Object>> tracCodgRecords = mzPharmacyService.queryTracCodgRecordsByAssociation(tracCodgQuery);
|
|
|
+
|
|
|
+ // 3. 构建返回数据
|
|
|
+ // 包含发药统计记录、追溯码记录和关联键信息
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
+ data.put("fytjRecords", fytjRecords);
|
|
|
+ data.put("tracCodgRecords", tracCodgRecords);
|
|
|
+ data.put("associationKey", String.format("patientId=%s×=%s&receiptNo=%s&orderNo=%s&chargeItemCode=%s&realNo=%s",
|
|
|
+ patientId, times, receiptNo, orderNo, chargeItemCode, realNo));
|
|
|
+
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "查询发药记录成功");
|
|
|
+ resultMap.put("data", data);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询发药记录失败", e);
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "查询发药记录失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
}
|