( medicines: Medicine[], todayStr: string, in30daysStr: string, expiringDays: number, )
| 245 | } |
| 246 | |
| 247 | function 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 | |
| 276 | export function buildInventoryAnswer( |
| 277 | medicines: Medicine[], |
no test coverage detected