• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ULL-ESIT-INF-DSI-2526 / grp02-medcore-api-groupd / 25628398609

10 May 2026 12:08PM UTC coverage: 87.197% (-0.5%) from 87.738%
25628398609

push

github

eduzu
Merge branch 'main' of github.com:ULL-ESIT-INF-DSI-2526/grp02-medcore-api-groupd
Medication controllers and basic testing

99 of 109 branches covered (90.83%)

Branch coverage included in aggregate %.

279 of 320 new or added lines in 31 files covered. (87.19%)

1 existing line in 1 file now uncovered.

405 of 469 relevant lines covered (86.35%)

7.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.75
/src/controller/record/readRecord.controller.ts
1
import { Request, Response } from 'express';
2
import { RecordFilter } from '../../models/records/types/recordFilter.js';
3
import { readRecord } from '../../services/record/readRecord.js';
4
import mongoose from 'mongoose';
5

6
/**
7
 * Controlador para leer registros médicos.
8
 * @param req - Request
9
 * @param res - Response
10
 * @returns Retorna una lista de registros que coinciden con los filtros aplicados.
11
 */
12
export async function readRecordController(req: Request, res: Response) {
13
  try {
8✔
14
    const {patient, doctor} = req.query;
8✔
15
    const filter = {} as RecordFilter;
8✔
16
    if (typeof patient === 'string' && mongoose.isValidObjectId(patient)) filter.patient = patient;
8✔
17
    if (typeof doctor === 'string' && mongoose.isValidObjectId(doctor)) filter.doctor = doctor;
8✔
18

19
    const result = await readRecord(filter);
8✔
20
    return res.status(200).json(result);
6✔
21
  } catch (error : unknown) {
22
    if (error instanceof mongoose.Error.ValidationError) {
2✔
NEW
23
      return res.status(400).json({ error: error.message });
×
24
    }
25
    if (error instanceof Error) {
2✔
26
      return res.status(500).json({ error: error.message });
1✔
27
    }
28
    return res.status(500).json({ error: 'Error reading records' });
1✔
29
  }
30
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc