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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | 7x 7x 7x 7x 7x 7x 7x 41x 13x 12x 7x 7x 4x | import { Appointment, Doctor, Patient, User } from '@prisma/client';
export function parseUserPayload(user: User): IUser {
return {
id: user.id,
email: user.email,
phone: user.phone,
name: user.name,
verifiedEmail: user.verifiedEmail,
verifiedPhoneNumber: user.verifiedPhoneNumber,
userType: user.userType,
createdAt: user.createdAt,
updatedAt: user.updatedAt,
};
}
export function parseDoctor(doctor: Doctor & { user?: User }): IDoctor {
return {
id: doctor.id,
user: doctor.user && parseUserPayload(doctor.user),
status: doctor.status as DoctorStatus,
address: doctor.address,
mapPosition: doctor.mapPosition ? JSON.parse(doctor.mapPosition) : undefined,
specialty: doctor.specialty,
biography: doctor.biography ?? undefined,
pictureUrl: doctor.pictureUrl ?? undefined,
createdAt: doctor.createdAt,
updatedAt: doctor.updatedAt,
};
}
export function parseCoords(coords: { lat?: string; lng?: string }) {
return {
lat: parseFloat(coords.lat ?? '0'),
lng: parseFloat(coords.lng ?? '0'),
} as ICoordinates;
}
export function parsePublicPatient(patient: Patient & { user: User }): IPublicPatient {
return {
id: patient.id,
user: parseUserPayload(patient.user),
birthDate: patient.birthDate,
gender: patient.gender as Gender,
address: patient.address,
occupation: patient.occupation,
createdAt: patient.createdAt,
updatedAt: patient.updatedAt,
};
}
export function parsePrivatePatient(
patient: Patient & { user: User; doctors?: (Doctor & { user?: User })[] }
): IPrivatePatient {
const publicPatient = parsePublicPatient(patient);
return {
...publicPatient,
emergencyContactName: patient.emergencyContactName,
emergencyContactNumber: patient.emergencyContactNumber,
primaryPhysician: patient.primaryPhysician,
insuranceProvider: patient.insuranceProvider ?? undefined,
insurancePolicyNumber: patient.insurancePolicyNumber ?? undefined,
allergies: patient.allergies ?? undefined,
currentMedication: patient.currentMedication ?? undefined,
familyMedicalHistory: patient.familyMedicalHistory ?? undefined,
pastMedicalHistory: patient.pastMedicalHistory ?? undefined,
identificationType: patient.identificationType ?? undefined,
identificationNumber: patient.identificationNumber ?? undefined,
identificationUrl: patient.identificationUrl ?? undefined,
privacyConsent: patient.privacyConsent,
doctors: patient.doctors?.map(parseDoctor) ?? undefined,
};
}
export function parseAppointment(
appointment: Appointment & { doctor: Doctor & { user: User }; patient: Patient & { user: User } }
): IAppointment {
return {
id: appointment.id,
reason: appointment.reason,
cancellationReason: appointment.cancellationReason ?? undefined,
note: appointment.note ?? undefined,
doctor: parseDoctor(appointment.doctor),
patient: parsePublicPatient(appointment.patient),
status: appointment.status as AppointmentStatus,
schedule: appointment.schedule,
createdAt: appointment.createdAt,
updatedAt: appointment.updatedAt,
};
}
|