Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/interfaces/patient.interface.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/models/certificate.model.ts
Original file line number Diff line number Diff line change
@@ -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 },
Expand Down
37 changes: 37 additions & 0 deletions src/models/patient.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions src/models/practice.model.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/models/prescription.model.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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 },
Expand Down