diff --git a/src/interfaces/patient.interface.ts b/src/interfaces/patient.interface.ts index b61442d..00642a7 100644 --- a/src/interfaces/patient.interface.ts +++ b/src/interfaces/patient.interface.ts @@ -1,6 +1,20 @@ import { Document } from 'mongoose'; import IObraSocial from './obraSocial.interface'; +export interface IPatientSub { + dni?: string; + lastName: string; + firstName: string; + fechaNac?: Date | null; + sex: string; + nombreAutopercibido?: string; + idMPI?: string; + obraSocial?: { + nombre?: string; + numeroAfiliado?: string; + } | IObraSocial; +} + export default interface IPatient extends Document { dni?: string; lastName: string; diff --git a/src/models/certificate.model.ts b/src/models/certificate.model.ts index 4b0b865..a98387a 100644 --- a/src/models/certificate.model.ts +++ b/src/models/certificate.model.ts @@ -1,10 +1,10 @@ import { Schema, Model, model } from "mongoose"; -import { patientSchema } from "./patient.model"; +import { patientSubSchema } from "./patient.model"; import ICertificate from "../interfaces/certificate.interface"; const certificateSchema = new Schema({ - patient: patientSchema, + patient: patientSubSchema, professional: { userId: Schema.Types.ObjectId, businessName: { type: String, required: true }, diff --git a/src/models/patient.model.ts b/src/models/patient.model.ts index 3f0a3f1..e031aa4 100644 --- a/src/models/patient.model.ts +++ b/src/models/patient.model.ts @@ -4,6 +4,43 @@ import needle from 'needle'; import { obraSocialSchema } from './obraSocial.model'; import axios from 'axios'; + +export const patientSubSchema = new Schema({ + firstName: { + type: String, + required: '{PATH} is required' + }, + lastName: { + type: String, + required: '{PATH} is required' + }, + nombreAutopercibido: { + type: String, + default: '' + }, + dni: { + type: String, + default: '' + }, + fechaNac: { + type: Date, + default: null + }, + sex: { + type: String, + enum: ['Femenino', 'Masculino', 'Otro'], + required: '{PATH} is required' + }, + obraSocial: { + nombre: { type: String, default: '' }, + numeroAfiliado: { type: String, default: '' } + }, + idMPI: { + type: String, + default: '' + } +}, { _id: false }); + // Schema export const patientSchema = new Schema({ dni: { diff --git a/src/models/practice.model.ts b/src/models/practice.model.ts index 9ce44dc..2a9951d 100644 --- a/src/models/practice.model.ts +++ b/src/models/practice.model.ts @@ -1,13 +1,13 @@ import { Schema, Model, model } from 'mongoose'; import IPractice from '../interfaces/practice.interface'; -import { patientSchema } from './patient.model'; +import { patientSubSchema } from './patient.model'; const practiceSchema: Schema = new Schema({ date: { type: Date, required: true }, - patient: patientSchema, + patient: patientSubSchema, professional: { userId: { type: String, diff --git a/src/models/prescription.model.ts b/src/models/prescription.model.ts index 70e0d63..c00b455 100644 --- a/src/models/prescription.model.ts +++ b/src/models/prescription.model.ts @@ -1,7 +1,7 @@ import { Schema, Model, model } from 'mongoose'; import IPrescription from '../interfaces/prescription.interface'; import { supplySchema } from '../models/supply.model'; -import { patientSchema } from '../models/patient.model'; +import { patientSubSchema } from '../models/patient.model'; // Schema const prescriptionSchema = new Schema({ @@ -10,7 +10,7 @@ const prescriptionSchema = new Schema({ unique: true, sparse: true }, - patient: patientSchema, + patient: patientSubSchema, professional: { userId: Schema.Types.ObjectId, businessName: { type: String, required: true },