feature: Phase3 - Task templates + generation on send
This commit is contained in:
@@ -14,6 +14,7 @@ import { StaffWorkingHoursService } from '../staff/staff-working-hours.service';
|
||||
import { CreateAppointmentDto } from './dto/create-appointment.dto';
|
||||
import { ListAppointmentsDto } from './dto/list-appointments.dto';
|
||||
import { UpdateAppointmentDto } from './dto/update-appointment.dto';
|
||||
import { TreatmentCatalogService } from '../treatment-catalog/treatment-catalog.service';
|
||||
|
||||
const MS_PER_DAY = 86_400_000;
|
||||
|
||||
@@ -22,6 +23,7 @@ export class AppointmentsService {
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly staffWorkingHoursService: StaffWorkingHoursService,
|
||||
private readonly treatmentCatalog: TreatmentCatalogService,
|
||||
) {}
|
||||
|
||||
getOrganizationIdFromUser(user: { organizationId?: string }) {
|
||||
@@ -134,6 +136,7 @@ export class AppointmentsService {
|
||||
|
||||
await this.ensurePatientInOrg(dto.patientId, organizationId);
|
||||
await this.ensureProviderIsTreatmentEditor(dto.providerUserId, organizationId);
|
||||
this.treatmentCatalog.assertKnownTreatmentType(dto.purpose);
|
||||
await this.ensureAppointmentWithinProviderWorkingHours(
|
||||
dto.providerUserId,
|
||||
organizationId,
|
||||
@@ -195,6 +198,8 @@ export class AppointmentsService {
|
||||
const providerUserId = dto.providerUserId ?? existing.providerUserId;
|
||||
const purpose = dto.purpose ?? existing.purpose;
|
||||
|
||||
this.treatmentCatalog.assertKnownTreatmentType(purpose);
|
||||
|
||||
await this.ensurePatientInOrg(patientId, organizationId);
|
||||
await this.ensureProviderIsTreatmentEditor(providerUserId, organizationId);
|
||||
await this.ensureAppointmentWithinProviderWorkingHours(
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsDateString, IsIn, IsUUID } from 'class-validator';
|
||||
|
||||
const APPOINTMENT_PURPOSES = ['consultation', 'filling', 'endo', 'visit', 'hygiene'] as const;
|
||||
|
||||
export type AppointmentPurpose = (typeof APPOINTMENT_PURPOSES)[number];
|
||||
import { IsDateString, IsString, IsUUID, MaxLength } from 'class-validator';
|
||||
|
||||
export class CreateAppointmentDto {
|
||||
@ApiProperty()
|
||||
@@ -22,7 +18,11 @@ export class CreateAppointmentDto {
|
||||
@IsDateString()
|
||||
endAt: string;
|
||||
|
||||
@ApiProperty({ enum: APPOINTMENT_PURPOSES })
|
||||
@IsIn([...APPOINTMENT_PURPOSES])
|
||||
purpose: AppointmentPurpose;
|
||||
@ApiProperty({
|
||||
description: 'Treatment type code from the treatment catalog',
|
||||
example: 'consultation',
|
||||
})
|
||||
@IsString()
|
||||
@MaxLength(64)
|
||||
purpose: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user