Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 26x 26x 26x 15x 13x 13x 12x | import { randomUUID } from 'node:crypto';
import { BabyRepository } from '../baby/baby-repository';
import { BabyGuardianRepository } from '../baby/baby-guardian-repository';
import { ensureBabyAccess } from '../baby/ensure-baby-access';
import { BabyVaccineRecord, VaccineRecordSource } from '../../domain/vaccine/baby-vaccine-record';
import { BabyVaccineRecordRepository } from './baby-vaccine-record-repository';
export interface RegisterAdhocVaccineInput {
babyId: string;
requestingUserId: string;
source: Exclude<VaccineRecordSource, 'CATALOG'>;
customName: string;
customDose?: string | null;
applicationDate: Date;
notes?: string | null;
batchNumber?: string | null;
location?: string | null;
professional?: string | null;
photoUrl?: string | null;
}
export class RegisterAdhocVaccineUseCase {
constructor(
private readonly babyRepository: BabyRepository,
private readonly babyGuardianRepository: BabyGuardianRepository,
private readonly babyVaccineRecordRepository: BabyVaccineRecordRepository,
) {}
async execute(input: RegisterAdhocVaccineInput): Promise<BabyVaccineRecord> {
await ensureBabyAccess(this.babyRepository, this.babyGuardianRepository, input.babyId, input.requestingUserId);
const record = BabyVaccineRecord.registerAdhoc({
id: randomUUID(),
babyId: input.babyId,
source: input.source,
customName: input.customName,
customDose: input.customDose,
applicationDate: input.applicationDate,
notes: input.notes,
batchNumber: input.batchNumber,
location: input.location,
professional: input.professional,
photoUrl: input.photoUrl,
});
await this.babyVaccineRecordRepository.create(record);
return record;
}
}
|