MCPcopy Create free account
hub / github.com/MonoYan/open-medkit / buildQueryNotes

Function buildQueryNotes

backend/src/ai/query.ts:247–274  ·  view source on GitHub ↗
(
  medicines: Medicine[],
  todayStr: string,
  in30daysStr: string,
  expiringDays: number,
)

Source from the content-addressed store, hash-verified

245}
246
247function buildQueryNotes(
248 medicines: Medicine[],
249 todayStr: string,
250 in30daysStr: string,
251 expiringDays: number,
252) {
253 const expired = medicines.filter(
254 (medicine) => getMedicineExpiryState(medicine, todayStr, in30daysStr) === 'expired',
255 );
256 const expiring = medicines.filter(
257 (medicine) => getMedicineExpiryState(medicine, todayStr, in30daysStr) === 'expiring',
258 );
259 const lines: string[] = [];
260
261 if (expired.length > 0 || expiring.length > 0) {
262 lines.push('### 注意事项');
263 }
264
265 if (expired.length > 0) {
266 lines.push(`- **已过期**:${expired.map(formatMedicineDisplayName).join('、')},请勿继续使用`);
267 }
268
269 if (expiring.length > 0) {
270 lines.push(`- **${expiringDays} 天内到期**:${expiring.map(formatMedicineDisplayName).join('、')}`);
271 }
272
273 return lines;
274}
275
276export function buildInventoryAnswer(
277 medicines: Medicine[],

Callers 2

buildInventoryAnswerFunction · 0.85
buildMatchedAnswerFunction · 0.85

Calls 1

getMedicineExpiryStateFunction · 0.90

Tested by

no test coverage detected