diff --git a/hlw/automation/config.js b/hlw/automation/config.js index 67c1a78..5adda0b 100644 --- a/hlw/automation/config.js +++ b/hlw/automation/config.js @@ -8,6 +8,8 @@ const DEFAULT_AUTOMATION_CONFIG = { autoAcceptOrder: false, autoOpenRx: false, autoPassRx: false, + // Preserve the existing behaviour for institutions with no saved value. + enableRationalDrug: true, autoAcceptDelayMinSeconds: 2, autoAcceptDelayMaxSeconds: 5, autoOpenRxDelayMinSeconds: 20, @@ -73,6 +75,7 @@ function normalizeAutomationConfig(config = {}) { result.autoAcceptOrder = config.autoAcceptOrder === true; result.autoOpenRx = config.autoOpenRx === true; result.autoPassRx = config.autoPassRx === true; + result.enableRationalDrug = config.enableRationalDrug !== false; return result; } diff --git a/hlw/automation/config.test.js b/hlw/automation/config.test.js index ce6bdaa..ff5aca7 100644 --- a/hlw/automation/config.test.js +++ b/hlw/automation/config.test.js @@ -12,6 +12,7 @@ describe("automation config", () => { autoAcceptOrder: false, autoOpenRx: false, autoPassRx: false, + enableRationalDrug: true, autoAcceptDelayMinSeconds: 2, autoAcceptDelayMaxSeconds: 5, autoOpenRxDelayMinSeconds: 20, diff --git a/hlw/diagnostic-record/index.js b/hlw/diagnostic-record/index.js index d27cbd7..bb9f693 100644 --- a/hlw/diagnostic-record/index.js +++ b/hlw/diagnostic-record/index.js @@ -2146,10 +2146,27 @@ async function getRxMedicineOrderStatus(ctx, db) { async function getYbReviewResult(ctx, db) { const params = ctx && ctx.params && typeof ctx.params === "object" ? ctx.params : {}; + const corpId = typeof ctx.corpId === "string" ? ctx.corpId.trim() : ""; + + try { + // The switch is deliberately checked here so every caller (manual and + // automated prescribing) has one consistent rational-drug-review policy. + if (corpId) { + const config = await db.collection("hlw-config").findOne( + { corpId }, + { projection: { enableRationalDrug: 1 } } + ); + if (config && config.enableRationalDrug === false) { + return { success: true, message: "未开启合理用药,已跳过合理用药" }; + } + } + } catch (e) { + return { success: false, message: `查询合理用药配置失败: ${e.message}` }; + } + const orderId = typeof params.orderId === "string" ? params.orderId.trim() : ""; const drugs = Array.isArray(params.drugs) ? params.drugs : []; const diagnosisList = Array.isArray(params.diagnosisList) ? params.diagnosisList : []; - const corpId = typeof ctx.corpId === "string" ? ctx.corpId.trim() : ""; if (!orderId) { return { success: false, message: "订单号不能为空" }; diff --git a/hlw/hlw-config/index.js b/hlw/hlw-config/index.js index f72fc3e..968102a 100644 --- a/hlw/hlw-config/index.js +++ b/hlw/hlw-config/index.js @@ -43,6 +43,7 @@ async function getHlwOrderConfig({ corpId }) { autoAcceptOrder: 1, autoOpenRx: 1, autoPassRx: 1, + enableRationalDrug: 1, autoAcceptDelayMinSeconds: 1, autoAcceptDelayMaxSeconds: 1, autoOpenRxDelayMinSeconds: 1, @@ -79,6 +80,7 @@ async function updateHlwOrderConfig(ctx) { autoAcceptOrder, autoOpenRx, autoPassRx, + enableRationalDrug, } = ctx; const data = {} if (typeof payDuration == 'number') { @@ -121,6 +123,9 @@ async function updateHlwOrderConfig(ctx) { if (typeof autoPassRx === 'boolean') { data.autoPassRx = autoPassRx; } + if (typeof enableRationalDrug === 'boolean') { + data.enableRationalDrug = enableRationalDrug; + } if (AUTOMATION_DELAY_KEYS.some((key) => key in ctx)) { const current = await db.collection("hlw-config").findOne(