Skip to content

Commit

Permalink
feat(): add schemas for specialties and suppliers
Browse files Browse the repository at this point in the history
  • Loading branch information
juandav committed Feb 10, 2020
1 parent c997bb2 commit 173a101
Show file tree
Hide file tree
Showing 12 changed files with 344 additions and 239 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"dependencies": {
"@nestjs/common": "^6.10.14",
"@nestjs/core": "^6.10.14",
"@nestjs/mongoose": "^6.3.1",
"@nestjs/platform-express": "^6.10.14",
"mongoose": "^5.8.11",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.0",
"rxjs": "^6.5.4"
Expand Down
3 changes: 2 additions & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { MongooseModule } from '@nestjs/mongoose';

@Module({
imports: [],
imports: [MongooseModule.forRoot('mongodb://juandav:juandav1@ds155634.mlab.com:55634/evercheck-test-9')],
controllers: [AppController],
providers: [AppService],
})
Expand Down
10 changes: 10 additions & 0 deletions src/providers/providers.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import { Controller, Get } from '@nestjs/common';

@Controller('providers')
export class ProvidersController {
@Get()
findAll(): string {
return 'This action returns all providers';
}
}
24 changes: 24 additions & 0 deletions src/providers/providers.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { ProvidersController } from './providers.controller';
import { ProvidersService } from './providers.serrvice';
import { ProvidersSchema } from './providers.schema';

@Module({
imports: [
MongooseModule.forFeatureAsync([
{
name: 'Providers',
useFactory: () => {
const schema = ProvidersSchema;
schema.pre('save', () => console.log('Hello from pre save'));
return schema;
},
},
]),
],
controllers: [ProvidersController],
providers: [ProvidersService],
})
export class ProvidersModule {}
100 changes: 100 additions & 0 deletions src/providers/providers.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import * as mongoose from 'mongoose';

export const ProvidersSchema = new mongoose.Schema({
email: {
type: String,
lowercase: true,
required: true,
unique: true,
},
firstName: {
type: String,
required: false,
},
lastName: {
type: String,
required: false,
},
specialty: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Specialty'
},
projectedStartDate: {
type: Date,
default: new Date()
},
providerType: {
type: String,
enum: [
'APRN',
'ARNP',
'CNS',
'CRNA',
'DC',
'DDS',
'DMD',
'DO',
'DPM',
'LCMFT',
'LCMHC',
'LCP',
'LCPC',
'MD',
'NP',
'PA'
]
},
staffStatus: {
type: String,
enum: [
'ACTIVE',
'AFFILIATE',
'ASSOCIATE',
'COMMUNITY',
'CONSULTING',
'COURTESY',
'FACULTY',
'HONORARY',
'HOSPITALIST',
'HAUSE_STAFF',
'LOCUM_TENENS',
'PROVISIONAL',
'RESIDENT',
'TEACHING'
]
},
status: {
type: String,
enum: [
'AWAITING_CREDENTIALS',
'READY_FOR_REVIEW',
'UNDER_REVIEW',
'AWAITING_DECISION',
'APPROVED',
'DENIED'
],
default: 'AWAITING_CREDENTIALS'
},
employerId: {
type: Number,
required: true
},
assignedTo: {
type: Number,
required: true
},
createdBy: {
type: Number,
required: true
},
updatedBy: {
type: Number,
required: true
}
}, {
collection: 'providers',
timestamps: {
createdAt: 'created_at',
updatedAt: 'updated_at',
}
});
14 changes: 14 additions & 0 deletions src/providers/providers.serrvice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Injectable } from '@nestjs/common';

@Injectable()
export class ProvidersService {
private readonly data: any[] = [];

create(data: any) {
this.data.push(data);
}

findAll(): any[] {
return this.data;
}
}
4 changes: 4 additions & 0 deletions src/specialties/interfaces/data.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface Data {
name: string;
age: number;
}
10 changes: 10 additions & 0 deletions src/specialties/specialties.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import { Controller, Get } from '@nestjs/common';

@Controller('specialties')
export class SpecialtiesController {
@Get()
findAll(): string {
return 'This action returns all specialties';
}
}
10 changes: 10 additions & 0 deletions src/specialties/specialties.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import { Module } from '@nestjs/common';
import { SpecialtiesController } from './specialties.controller';
import { SpecialtiesService } from './specialties.service';

@Module({
controllers: [SpecialtiesController],
providers: [SpecialtiesService],
})
export class SpecialtiesModule {}
23 changes: 23 additions & 0 deletions src/specialties/specialties.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as mongoose from 'mongoose';

export const SpecialtiesSchema = new mongoose.Schema({
name: {
type: String,
lowercase: true,
required: true,
},
createdBy: {
type: Number,
required: false,
},
updatedBy: {
type: Number,
required: false,
}
}, {
collection: 'specialties',
timestamps: {
createdAt: 'created_at',
updatedAt: 'updated_at',
}
});
15 changes: 15 additions & 0 deletions src/specialties/specialties.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Injectable } from '@nestjs/common';
import { Data } from './interfaces/data.interface';

@Injectable()
export class SpecialtiesService {
private readonly data: Data[] = [];

create(data: Data) {
this.data.push(data);
}

findAll(): Data[] {
return this.data;
}
}
Loading

0 comments on commit 173a101

Please sign in to comment.