fix: 合理用药开关
This commit is contained in:
parent
0adca17bbe
commit
785d067477
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ describe("automation config", () => {
|
||||
autoAcceptOrder: false,
|
||||
autoOpenRx: false,
|
||||
autoPassRx: false,
|
||||
enableRationalDrug: true,
|
||||
autoAcceptDelayMinSeconds: 2,
|
||||
autoAcceptDelayMaxSeconds: 5,
|
||||
autoOpenRxDelayMinSeconds: 20,
|
||||
|
||||
@ -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: "订单号不能为空" };
|
||||
|
||||
@ -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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user