-
Notifications
You must be signed in to change notification settings - Fork 3
/
IPatient.ts
40 lines (34 loc) · 1.17 KB
/
IPatient.ts
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
import { Gender } from "./Gender";
import Joi from "@hapi/joi";
export interface IPatient {
[key: string]: unknown;
id?: string;
firstName?: string;
lastName: string;
fullName?: string;
gender: Gender;
dateOfBirth: string;
postCode: string;
insuranceNumber?: string;
preferredContactNumber?: string;
lastUpdated?: Date;
}
const maxLengthNameField = 64;
const maxLengthFullNameField = 128;
const postcodeLength = 4;
const dateRegexString = /^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1]))?)?$/;
export const PatientSchema = Joi.object<IPatient>({
id: Joi.string().guid().optional(),
firstName: Joi.string().max(maxLengthNameField).required(),
lastName: Joi.string().max(maxLengthNameField),
fullName: Joi.string().max(maxLengthFullNameField),
gender: Joi.string()
.allow(Gender.Male, Gender.Female, Gender.Other, Gender.Unknown)
.only()
.required(),
dateOfBirth: Joi.string().pattern(dateRegexString, "date").required(),
postCode: Joi.string().length(postcodeLength).required(),
insuranceNumber: Joi.string(),
preferredContactNumber: Joi.string(),
lastUpdated: Joi.date().optional(),
});