This commit is contained in:
lik
2026-06-01 22:10:41 +08:00
parent cebe7876f7
commit 43aa9ac844
5 changed files with 40 additions and 18 deletions

View File

@@ -3,20 +3,27 @@ import z from "zod";
import { DBModel } from "../../../../models/index.js";
const escortRecordSetTool = tool(
async ({ mobile, status, notes, payment }) => {
async ({ orderId, status, notes, payment }) => {
try {
if (!mobile) {
if (!orderId) {
return {
success: false,
error: "Mobile phone number is required as the lookup key",
error: "Order ID (_id or orderNo) is required as the lookup key",
};
}
const record = await DBModel.EscortRecord.findOne({ "patient.mobile": mobile });
const query = {
$or: [
{ _id: orderId },
{ orderNo: orderId }
]
};
const record = await DBModel.EscortRecord.findOne(query);
if (!record) {
return {
success: false,
error: `No escort record found for mobile: ${mobile}`,
error: `No escort record found for order ID: ${orderId}`,
};
}
@@ -72,11 +79,11 @@ const escortRecordSetTool = tool(
{
name: "escort_record_set",
description:
"Update escort record fields by patient mobile phone number. Supports updating status, notes (patientNote, escortNote, medicalSummary), and payment (totalFee, paidFee, status). Only provided fields will be updated.",
"Update escort record fields by order ID (_id or orderNo). Supports updating status, notes (patientNote, escortNote, medicalSummary), and payment (totalFee, paidFee, status). Only provided fields will be updated.",
schema: z.object({
mobile: z
orderId: z
.string()
.describe("Patient mobile phone number used as the lookup key"),
.describe("Order ID (_id or orderNo) used as the lookup key"),
status: z
.enum(["pending", "confirmed", "in_progress", "completed", "cancelled"])
.optional()

View File

@@ -21,5 +21,6 @@ export { getEnvTool } from './system/envs.js';
// db
export { escortRecordQueryTool } from './db/escort_record_query.js';
export { escortRecordSetTool } from './db/escort_record_set.js';