world-med-commons 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dtos/pagination.dto.d.ts +6 -0
- package/dist/dtos/pagination.dto.js +52 -0
- package/dist/dtos/pagination.dto.js.map +1 -0
- package/dist/dtos/update-user.dto.d.ts +20 -0
- package/dist/dtos/update-user.dto.js +79 -0
- package/dist/dtos/update-user.dto.js.map +1 -0
- package/dist/guards/jwt/jwt-auth.guard.d.ts +12 -0
- package/dist/guards/jwt/jwt-auth.guard.js +62 -0
- package/dist/guards/jwt/jwt-auth.guard.js.map +1 -0
- package/dist/guards/roles/roles.guard.d.ts +9 -0
- package/dist/guards/roles/roles.guard.js +60 -0
- package/dist/guards/roles/roles.guard.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/models/allergy.schema.d.ts +176 -0
- package/dist/models/allergy.schema.js +92 -0
- package/dist/models/allergy.schema.js.map +1 -0
- package/dist/models/business-inventory.schema.d.ts +145 -0
- package/dist/models/business-inventory.schema.js +101 -0
- package/dist/models/business-inventory.schema.js.map +1 -0
- package/dist/models/business.schema.d.ts +45 -2
- package/dist/models/business.schema.js +19 -5
- package/dist/models/business.schema.js.map +1 -1
- package/dist/models/drug-variant.d.ts +103 -0
- package/dist/models/drug-variant.js +58 -0
- package/dist/models/drug-variant.js.map +1 -0
- package/dist/models/drug-variant.schema.d.ts +115 -0
- package/dist/models/drug-variant.schema.js +64 -0
- package/dist/models/drug-variant.schema.js.map +1 -0
- package/dist/models/drug.schema.d.ts +84 -0
- package/dist/models/drug.schema.js +43 -0
- package/dist/models/drug.schema.js.map +1 -0
- package/dist/models/patient.schema.d.ts +84 -0
- package/dist/models/patient.schema.js +60 -0
- package/dist/models/patient.schema.js.map +1 -0
- package/dist/models/suppliers.schema.d.ts +85 -0
- package/dist/models/suppliers.schema.js +49 -0
- package/dist/models/suppliers.schema.js.map +1 -0
- package/dist/models/user.schema.d.ts +26 -16
- package/dist/models/user.schema.js +5 -0
- package/dist/models/user.schema.js.map +1 -1
- package/package.json +6 -2
- package/src/dtos/pagination.dto.ts +30 -0
- package/src/dtos/update-user.dto.ts +38 -0
- package/src/index.ts +8 -0
- package/src/models/allergy.schema.ts +72 -0
- package/src/models/business-inventory.schema.ts +65 -0
- package/src/models/business.schema.ts +17 -4
- package/src/models/drug-variant.schema.ts +48 -0
- package/src/models/drug.schema.ts +27 -0
- package/src/models/patient.schema.ts +46 -0
- package/src/models/suppliers.schema.ts +28 -0
- package/src/models/user.schema.ts +4 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PaginationQueryDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
const class_transformer_1 = require("class-transformer");
|
|
15
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
16
|
+
class PaginationQueryDto {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.page = 1;
|
|
19
|
+
this.limit = 10;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.PaginationQueryDto = PaginationQueryDto;
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, swagger_1.ApiProperty)(),
|
|
25
|
+
(0, class_validator_1.IsOptional)(),
|
|
26
|
+
(0, class_validator_1.IsInt)(),
|
|
27
|
+
(0, class_validator_1.Min)(1),
|
|
28
|
+
(0, class_transformer_1.Type)(() => Number),
|
|
29
|
+
__metadata("design:type", Number)
|
|
30
|
+
], PaginationQueryDto.prototype, "page", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, swagger_1.ApiProperty)(),
|
|
33
|
+
(0, class_validator_1.IsOptional)(),
|
|
34
|
+
(0, class_validator_1.IsInt)(),
|
|
35
|
+
(0, class_validator_1.Min)(1),
|
|
36
|
+
(0, class_validator_1.Max)(100),
|
|
37
|
+
(0, class_transformer_1.Type)(() => Number),
|
|
38
|
+
__metadata("design:type", Number)
|
|
39
|
+
], PaginationQueryDto.prototype, "limit", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, swagger_1.ApiProperty)(),
|
|
42
|
+
(0, class_validator_1.IsOptional)(),
|
|
43
|
+
(0, class_validator_1.IsString)(),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], PaginationQueryDto.prototype, "displayName", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, swagger_1.ApiProperty)(),
|
|
48
|
+
(0, class_validator_1.IsOptional)(),
|
|
49
|
+
(0, class_validator_1.IsEmail)(),
|
|
50
|
+
__metadata("design:type", String)
|
|
51
|
+
], PaginationQueryDto.prototype, "email", void 0);
|
|
52
|
+
//# sourceMappingURL=pagination.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.dto.js","sourceRoot":"","sources":["../../src/dtos/pagination.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAiF;AACjF,yDAAyC;AACzC,6CAA8C;AAE9C,MAAa,kBAAkB;IAA/B;QAME,SAAI,GAAY,CAAC,CAAC;QAQlB,UAAK,GAAY,EAAE,CAAC;IAWtB,CAAC;CAAA;AAzBD,gDAyBC;AAnBC;IALC,IAAA,qBAAW,GAAE;IACb,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAG,EAAC,CAAC,CAAC;IACN,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;;gDACD;AAQlB;IANC,IAAA,qBAAW,GAAE;IACb,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAG,EAAC,CAAC,CAAC;IACN,IAAA,qBAAG,EAAC,GAAG,CAAC;IACR,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;;iDACC;AAKpB;IAHC,IAAA,qBAAW,GAAE;IACb,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;uDACU;AAKrB;IAHC,IAAA,qBAAW,GAAE;IACb,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAO,GAAE;;iDACK"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare class AddressDto {
|
|
2
|
+
state?: string;
|
|
3
|
+
city?: string;
|
|
4
|
+
street?: string;
|
|
5
|
+
building?: string;
|
|
6
|
+
floor?: string;
|
|
7
|
+
apartment?: string;
|
|
8
|
+
zipCode?: string;
|
|
9
|
+
country?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class UpdateUserDto {
|
|
12
|
+
email?: string;
|
|
13
|
+
phoneNumber?: string;
|
|
14
|
+
emailVerified?: boolean;
|
|
15
|
+
displayName?: string;
|
|
16
|
+
photoURL?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
addresses?: AddressDto;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UpdateUserDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
class AddressDto {
|
|
15
|
+
}
|
|
16
|
+
__decorate([
|
|
17
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
18
|
+
__metadata("design:type", String)
|
|
19
|
+
], AddressDto.prototype, "state", void 0);
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], AddressDto.prototype, "city", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], AddressDto.prototype, "street", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], AddressDto.prototype, "building", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], AddressDto.prototype, "floor", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], AddressDto.prototype, "apartment", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], AddressDto.prototype, "zipCode", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], AddressDto.prototype, "country", void 0);
|
|
48
|
+
class UpdateUserDto {
|
|
49
|
+
}
|
|
50
|
+
exports.UpdateUserDto = UpdateUserDto;
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
|
+
], UpdateUserDto.prototype, "email", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], UpdateUserDto.prototype, "phoneNumber", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
61
|
+
__metadata("design:type", Boolean)
|
|
62
|
+
], UpdateUserDto.prototype, "emailVerified", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
65
|
+
__metadata("design:type", String)
|
|
66
|
+
], UpdateUserDto.prototype, "displayName", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
69
|
+
__metadata("design:type", String)
|
|
70
|
+
], UpdateUserDto.prototype, "photoURL", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
73
|
+
__metadata("design:type", Boolean)
|
|
74
|
+
], UpdateUserDto.prototype, "disabled", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
77
|
+
__metadata("design:type", AddressDto)
|
|
78
|
+
], UpdateUserDto.prototype, "addresses", void 0);
|
|
79
|
+
//# sourceMappingURL=update-user.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-user.dto.js","sourceRoot":"","sources":["../../src/dtos/update-user.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAE9C,MAAM,UAAU;CAiBf;AAfC;IADC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;yCAClB;AAEf;IADC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;wCACnB;AAEd;IADC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;0CACjB;AAEhB;IADC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;4CACf;AAElB;IADC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;yCAClB;AAEf;IADC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;6CACd;AAEnB;IADC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;2CAChB;AAEjB;IADC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;2CAChB;AAGnB,MAAa,aAAa;CAezB;AAfD,sCAeC;AAbC;IADC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;4CAClB;AAEf;IADC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;kDACZ;AAErB;IADC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;oDACT;AAExB;IADC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;kDACZ;AAErB;IADC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;+CACf;AAElB;IADC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;+CACd;AAEnB;IADC,IAAA,qBAAW,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;8BACrB,UAAU;gDAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
import { AuthService } from '../../services/auth.service';
|
|
4
|
+
import { UsersService } from '../../../users/services/users/users.service';
|
|
5
|
+
export declare class JwtAuthGuard implements CanActivate {
|
|
6
|
+
private readonly authService;
|
|
7
|
+
private readonly usersService;
|
|
8
|
+
private readonly reflector;
|
|
9
|
+
constructor(authService: AuthService, usersService: UsersService, reflector: Reflector);
|
|
10
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
11
|
+
private extractTokenFromHeader;
|
|
12
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var _a, _b;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.JwtAuthGuard = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const core_1 = require("@nestjs/core");
|
|
16
|
+
const auth_service_1 = require("../../services/auth.service");
|
|
17
|
+
const users_service_1 = require("../../../users/services/users/users.service");
|
|
18
|
+
const public_decorator_1 = require("../../decorators/public.decorator");
|
|
19
|
+
let JwtAuthGuard = class JwtAuthGuard {
|
|
20
|
+
constructor(authService, usersService, reflector) {
|
|
21
|
+
this.authService = authService;
|
|
22
|
+
this.usersService = usersService;
|
|
23
|
+
this.reflector = reflector;
|
|
24
|
+
}
|
|
25
|
+
async canActivate(context) {
|
|
26
|
+
const isPublic = this.reflector.getAllAndOverride(public_decorator_1.IS_PUBLIC_KEY, [
|
|
27
|
+
context.getHandler(),
|
|
28
|
+
context.getClass(),
|
|
29
|
+
]);
|
|
30
|
+
if (isPublic) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
const request = context.switchToHttp().getRequest();
|
|
34
|
+
const token = this.extractTokenFromHeader(request);
|
|
35
|
+
if (!token) {
|
|
36
|
+
throw new common_1.UnauthorizedException('Missing token');
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const decodedToken = await this.authService.validateUser(token);
|
|
40
|
+
const user = await this.usersService.findByUid(decodedToken.uid);
|
|
41
|
+
request.decodedUser = decodedToken;
|
|
42
|
+
if (!user && !request.url.includes('/users/register')) {
|
|
43
|
+
throw new common_1.UnauthorizedException('User not found in database');
|
|
44
|
+
}
|
|
45
|
+
request.user = user;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
throw new common_1.UnauthorizedException(error.message || 'Invalid token');
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
extractTokenFromHeader(request) {
|
|
53
|
+
const [type, token] = request.headers.authorization?.split(' ') ?? [];
|
|
54
|
+
return type === 'Bearer' ? token : undefined;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
exports.JwtAuthGuard = JwtAuthGuard;
|
|
58
|
+
exports.JwtAuthGuard = JwtAuthGuard = __decorate([
|
|
59
|
+
(0, common_1.Injectable)(),
|
|
60
|
+
__metadata("design:paramtypes", [typeof (_a = typeof auth_service_1.AuthService !== "undefined" && auth_service_1.AuthService) === "function" ? _a : Object, typeof (_b = typeof users_service_1.UsersService !== "undefined" && users_service_1.UsersService) === "function" ? _b : Object, core_1.Reflector])
|
|
61
|
+
], JwtAuthGuard);
|
|
62
|
+
//# sourceMappingURL=jwt-auth.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-auth.guard.js","sourceRoot":"","sources":["../../../src/guards/jwt/jwt-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAKwB;AACxB,uCAAyC;AACzC,8DAA0D;AAC1D,+EAA2E;AAC3E,wEAAkE;AAG3D,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YACmB,WAAwB,EACxB,YAA0B,EAC1B,SAAoB;QAFpB,gBAAW,GAAX,WAAW,CAAa;QACxB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,cAAS,GAAT,SAAS,CAAW;IACpC,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAU,gCAAa,EAAE;YACxE,OAAO,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,QAAQ,EAAE;SACnB,CAAC,CAAC;QAEH,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QAEnD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,8BAAqB,CAAC,eAAe,CAAC,CAAC;QACnD,CAAC;QAED,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YAChE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YAGjE,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC;YAEnC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBACtD,MAAM,IAAI,8BAAqB,CAAC,4BAA4B,CAAC,CAAC;YAChE,CAAC;YAGD,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QACtB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,8BAAqB,CAAC,KAAK,CAAC,OAAO,IAAI,eAAe,CAAC,CAAC;QACpE,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,sBAAsB,CAAC,OAAY;QACzC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QACtE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/C,CAAC;CACF,CAAA;AAhDY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;yDAGqB,0BAAW,oBAAX,0BAAW,oDACV,4BAAY,oBAAZ,4BAAY,gCACf,gBAAS;GAJ5B,YAAY,CAgDxB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
import { EmployeesService } from '../../../employees/services/employees/employees.service';
|
|
4
|
+
export declare class RolesGuard implements CanActivate {
|
|
5
|
+
private reflector;
|
|
6
|
+
private employeesService;
|
|
7
|
+
constructor(reflector: Reflector, employeesService: EmployeesService);
|
|
8
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var _a;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.RolesGuard = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const core_1 = require("@nestjs/core");
|
|
16
|
+
const roles_decorator_1 = require("../../decorators/roles.decorator");
|
|
17
|
+
const employees_service_1 = require("../../../employees/services/employees/employees.service");
|
|
18
|
+
const public_decorator_1 = require("../../decorators/public.decorator");
|
|
19
|
+
let RolesGuard = class RolesGuard {
|
|
20
|
+
constructor(reflector, employeesService) {
|
|
21
|
+
this.reflector = reflector;
|
|
22
|
+
this.employeesService = employeesService;
|
|
23
|
+
}
|
|
24
|
+
async canActivate(context) {
|
|
25
|
+
const isPublic = this.reflector.getAllAndOverride(public_decorator_1.IS_PUBLIC_KEY, [
|
|
26
|
+
context.getHandler(),
|
|
27
|
+
context.getClass(),
|
|
28
|
+
]);
|
|
29
|
+
if (isPublic) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
const requiredRoles = this.reflector.getAllAndOverride(roles_decorator_1.ROLES_KEY, [
|
|
33
|
+
context.getHandler(),
|
|
34
|
+
context.getClass(),
|
|
35
|
+
]);
|
|
36
|
+
if (!requiredRoles || requiredRoles.length === 0) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
const { user } = context.switchToHttp().getRequest();
|
|
40
|
+
if (!user) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
let employee;
|
|
44
|
+
try {
|
|
45
|
+
employee = await this.employeesService.findById(user._id);
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
employee = null;
|
|
49
|
+
}
|
|
50
|
+
const userRoles = [...user.roles, employee?.role];
|
|
51
|
+
const hasUserRole = userRoles?.some((role) => requiredRoles.includes(role));
|
|
52
|
+
return hasUserRole;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
exports.RolesGuard = RolesGuard;
|
|
56
|
+
exports.RolesGuard = RolesGuard = __decorate([
|
|
57
|
+
(0, common_1.Injectable)(),
|
|
58
|
+
__metadata("design:paramtypes", [core_1.Reflector, typeof (_a = typeof employees_service_1.EmployeesService !== "undefined" && employees_service_1.EmployeesService) === "function" ? _a : Object])
|
|
59
|
+
], RolesGuard);
|
|
60
|
+
//# sourceMappingURL=roles.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.guard.js","sourceRoot":"","sources":["../../../src/guards/roles/roles.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA2E;AAC3E,uCAAyC;AACzC,sEAA6D;AAC7D,+FAA2F;AAC3F,wEAAkE;AAG3D,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,YACU,SAAoB,EACpB,gBAAkC;QADlC,cAAS,GAAT,SAAS,CAAW;QACpB,qBAAgB,GAAhB,gBAAgB,CAAkB;IACzC,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAU,gCAAa,EAAE;YACxE,OAAO,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,QAAQ,EAAE;SACnB,CAAC,CAAC;QAEH,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAW,2BAAS,EAAE;YAC1E,OAAO,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,QAAQ,EAAE;SACnB,CAAC,CAAC;QAEH,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAErD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,QAAQ,CAAA;QAEZ,IAAI,CAAC;YACH,QAAQ,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5D,CAAC;QAAA,OAAO,CAAC,EAAE,CAAC;YACV,QAAQ,GAAC,IAAI,CAAA;QACf,CAAC;QAED,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QAElD,MAAM,WAAW,GAAG,SAAS,EAAE,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CACnD,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,CAC7B,CAAC;QACF,OAAO,WAAW,CAAC;IACrB,CAAC;CACF,CAAA;AA7CY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAGU,gBAAS,sBACF,oCAAgB,oBAAhB,oCAAgB;GAHjC,UAAU,CA6CtB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
export * from './models/business.schema';
|
|
2
2
|
export * from './models/user.schema';
|
|
3
3
|
export * from './models/employee.schema';
|
|
4
|
+
export * from './models/allergy.schema';
|
|
5
|
+
export * from './dtos/pagination.dto';
|
|
6
|
+
export * from './models/allergy.schema';
|
|
7
|
+
export * from './models/drug.schema';
|
|
8
|
+
export * from './models/drug-variant.schema';
|
|
9
|
+
export * from './models/business-inventory.schema';
|
|
10
|
+
export * from './models/patient.schema';
|
|
11
|
+
export * from './models/suppliers.schema';
|
package/dist/index.js
CHANGED
|
@@ -17,4 +17,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./models/business.schema"), exports);
|
|
18
18
|
__exportStar(require("./models/user.schema"), exports);
|
|
19
19
|
__exportStar(require("./models/employee.schema"), exports);
|
|
20
|
+
__exportStar(require("./models/allergy.schema"), exports);
|
|
21
|
+
__exportStar(require("./dtos/pagination.dto"), exports);
|
|
22
|
+
__exportStar(require("./models/allergy.schema"), exports);
|
|
23
|
+
__exportStar(require("./models/drug.schema"), exports);
|
|
24
|
+
__exportStar(require("./models/drug-variant.schema"), exports);
|
|
25
|
+
__exportStar(require("./models/business-inventory.schema"), exports);
|
|
26
|
+
__exportStar(require("./models/patient.schema"), exports);
|
|
27
|
+
__exportStar(require("./models/suppliers.schema"), exports);
|
|
20
28
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,uDAAqC;AACrC,2DAAyC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,uDAAqC;AACrC,2DAAyC;AACzC,0DAAwC;AACxC,wDAAsC;AACtC,0DAAwC;AACxC,uDAAqC;AACrC,+DAA6C;AAC7C,qEAAmD;AACnD,0DAAwC;AACxC,4DAAyC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { Document, Types } from 'mongoose';
|
|
2
|
+
export declare enum AllergySeverity {
|
|
3
|
+
MILD = "mild",
|
|
4
|
+
MODERATE = "moderate",
|
|
5
|
+
SEVERE = "severe",
|
|
6
|
+
LIFE_THREATENING = "life-threatening"
|
|
7
|
+
}
|
|
8
|
+
export declare enum AllergyCriticality {
|
|
9
|
+
LOW = "low",
|
|
10
|
+
HIGH = "high",
|
|
11
|
+
UNABLE_TO_ASSESS = "unable-to-assess"
|
|
12
|
+
}
|
|
13
|
+
export declare enum AllergyType {
|
|
14
|
+
ALLERGY = "allergy",
|
|
15
|
+
INTOLERANCE = "intolerance",
|
|
16
|
+
CONTRAINDICATION = "contraindication"
|
|
17
|
+
}
|
|
18
|
+
export declare class Allergy extends Document {
|
|
19
|
+
user: Types.ObjectId;
|
|
20
|
+
substance: string;
|
|
21
|
+
codedSubstance?: {
|
|
22
|
+
system: string;
|
|
23
|
+
code: string;
|
|
24
|
+
display: string;
|
|
25
|
+
};
|
|
26
|
+
type: AllergyType;
|
|
27
|
+
severity: AllergySeverity;
|
|
28
|
+
criticality?: AllergyCriticality;
|
|
29
|
+
reactions: string[];
|
|
30
|
+
recordedDate?: Date;
|
|
31
|
+
note?: string;
|
|
32
|
+
recordedBy?: Types.ObjectId;
|
|
33
|
+
active: boolean;
|
|
34
|
+
isRefuted: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare const AllergySchema: import("mongoose").Schema<Allergy, import("mongoose").Model<Allergy, any, any, any, (Document<unknown, any, Allergy, any, import("mongoose").DefaultSchemaOptions> & Allergy & Required<{
|
|
37
|
+
_id: Types.ObjectId;
|
|
38
|
+
}> & {
|
|
39
|
+
__v: number;
|
|
40
|
+
} & {
|
|
41
|
+
id: string;
|
|
42
|
+
}) | (Document<unknown, any, Allergy, any, import("mongoose").DefaultSchemaOptions> & Allergy & Required<{
|
|
43
|
+
_id: Types.ObjectId;
|
|
44
|
+
}> & {
|
|
45
|
+
__v: number;
|
|
46
|
+
}), any, Allergy>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Allergy, Document<unknown, {}, Allergy, {
|
|
47
|
+
id: string;
|
|
48
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<Allergy & Required<{
|
|
49
|
+
_id: Types.ObjectId;
|
|
50
|
+
}> & {
|
|
51
|
+
__v: number;
|
|
52
|
+
}, "id"> & {
|
|
53
|
+
id: string;
|
|
54
|
+
}, {
|
|
55
|
+
_id?: import("mongoose").SchemaDefinitionProperty<Types.ObjectId, Allergy, Document<unknown, {}, Allergy, {
|
|
56
|
+
id: string;
|
|
57
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<Allergy & Required<{
|
|
58
|
+
_id: Types.ObjectId;
|
|
59
|
+
}> & {
|
|
60
|
+
__v: number;
|
|
61
|
+
}, "id"> & {
|
|
62
|
+
id: string;
|
|
63
|
+
}>;
|
|
64
|
+
type?: import("mongoose").SchemaDefinitionProperty<AllergyType, Allergy, Document<unknown, {}, Allergy, {
|
|
65
|
+
id: string;
|
|
66
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<Allergy & Required<{
|
|
67
|
+
_id: Types.ObjectId;
|
|
68
|
+
}> & {
|
|
69
|
+
__v: number;
|
|
70
|
+
}, "id"> & {
|
|
71
|
+
id: string;
|
|
72
|
+
}>;
|
|
73
|
+
user?: import("mongoose").SchemaDefinitionProperty<Types.ObjectId, Allergy, Document<unknown, {}, Allergy, {
|
|
74
|
+
id: string;
|
|
75
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<Allergy & Required<{
|
|
76
|
+
_id: Types.ObjectId;
|
|
77
|
+
}> & {
|
|
78
|
+
__v: number;
|
|
79
|
+
}, "id"> & {
|
|
80
|
+
id: string;
|
|
81
|
+
}>;
|
|
82
|
+
substance?: import("mongoose").SchemaDefinitionProperty<string, Allergy, Document<unknown, {}, Allergy, {
|
|
83
|
+
id: string;
|
|
84
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<Allergy & Required<{
|
|
85
|
+
_id: Types.ObjectId;
|
|
86
|
+
}> & {
|
|
87
|
+
__v: number;
|
|
88
|
+
}, "id"> & {
|
|
89
|
+
id: string;
|
|
90
|
+
}>;
|
|
91
|
+
codedSubstance?: import("mongoose").SchemaDefinitionProperty<{
|
|
92
|
+
system: string;
|
|
93
|
+
code: string;
|
|
94
|
+
display: string;
|
|
95
|
+
}, Allergy, Document<unknown, {}, Allergy, {
|
|
96
|
+
id: string;
|
|
97
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<Allergy & Required<{
|
|
98
|
+
_id: Types.ObjectId;
|
|
99
|
+
}> & {
|
|
100
|
+
__v: number;
|
|
101
|
+
}, "id"> & {
|
|
102
|
+
id: string;
|
|
103
|
+
}>;
|
|
104
|
+
severity?: import("mongoose").SchemaDefinitionProperty<AllergySeverity, Allergy, Document<unknown, {}, Allergy, {
|
|
105
|
+
id: string;
|
|
106
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<Allergy & Required<{
|
|
107
|
+
_id: Types.ObjectId;
|
|
108
|
+
}> & {
|
|
109
|
+
__v: number;
|
|
110
|
+
}, "id"> & {
|
|
111
|
+
id: string;
|
|
112
|
+
}>;
|
|
113
|
+
criticality?: import("mongoose").SchemaDefinitionProperty<AllergyCriticality, Allergy, Document<unknown, {}, Allergy, {
|
|
114
|
+
id: string;
|
|
115
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<Allergy & Required<{
|
|
116
|
+
_id: Types.ObjectId;
|
|
117
|
+
}> & {
|
|
118
|
+
__v: number;
|
|
119
|
+
}, "id"> & {
|
|
120
|
+
id: string;
|
|
121
|
+
}>;
|
|
122
|
+
reactions?: import("mongoose").SchemaDefinitionProperty<string[], Allergy, Document<unknown, {}, Allergy, {
|
|
123
|
+
id: string;
|
|
124
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<Allergy & Required<{
|
|
125
|
+
_id: Types.ObjectId;
|
|
126
|
+
}> & {
|
|
127
|
+
__v: number;
|
|
128
|
+
}, "id"> & {
|
|
129
|
+
id: string;
|
|
130
|
+
}>;
|
|
131
|
+
recordedDate?: import("mongoose").SchemaDefinitionProperty<Date, Allergy, Document<unknown, {}, Allergy, {
|
|
132
|
+
id: string;
|
|
133
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<Allergy & Required<{
|
|
134
|
+
_id: Types.ObjectId;
|
|
135
|
+
}> & {
|
|
136
|
+
__v: number;
|
|
137
|
+
}, "id"> & {
|
|
138
|
+
id: string;
|
|
139
|
+
}>;
|
|
140
|
+
note?: import("mongoose").SchemaDefinitionProperty<string, Allergy, Document<unknown, {}, Allergy, {
|
|
141
|
+
id: string;
|
|
142
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<Allergy & Required<{
|
|
143
|
+
_id: Types.ObjectId;
|
|
144
|
+
}> & {
|
|
145
|
+
__v: number;
|
|
146
|
+
}, "id"> & {
|
|
147
|
+
id: string;
|
|
148
|
+
}>;
|
|
149
|
+
recordedBy?: import("mongoose").SchemaDefinitionProperty<Types.ObjectId, Allergy, Document<unknown, {}, Allergy, {
|
|
150
|
+
id: string;
|
|
151
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<Allergy & Required<{
|
|
152
|
+
_id: Types.ObjectId;
|
|
153
|
+
}> & {
|
|
154
|
+
__v: number;
|
|
155
|
+
}, "id"> & {
|
|
156
|
+
id: string;
|
|
157
|
+
}>;
|
|
158
|
+
active?: import("mongoose").SchemaDefinitionProperty<boolean, Allergy, Document<unknown, {}, Allergy, {
|
|
159
|
+
id: string;
|
|
160
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<Allergy & Required<{
|
|
161
|
+
_id: Types.ObjectId;
|
|
162
|
+
}> & {
|
|
163
|
+
__v: number;
|
|
164
|
+
}, "id"> & {
|
|
165
|
+
id: string;
|
|
166
|
+
}>;
|
|
167
|
+
isRefuted?: import("mongoose").SchemaDefinitionProperty<boolean, Allergy, Document<unknown, {}, Allergy, {
|
|
168
|
+
id: string;
|
|
169
|
+
}, import("mongoose").DefaultSchemaOptions> & Omit<Allergy & Required<{
|
|
170
|
+
_id: Types.ObjectId;
|
|
171
|
+
}> & {
|
|
172
|
+
__v: number;
|
|
173
|
+
}, "id"> & {
|
|
174
|
+
id: string;
|
|
175
|
+
}>;
|
|
176
|
+
}, Allergy>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AllergySchema = exports.Allergy = exports.AllergyType = exports.AllergyCriticality = exports.AllergySeverity = void 0;
|
|
13
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
14
|
+
const mongoose_2 = require("mongoose");
|
|
15
|
+
var AllergySeverity;
|
|
16
|
+
(function (AllergySeverity) {
|
|
17
|
+
AllergySeverity["MILD"] = "mild";
|
|
18
|
+
AllergySeverity["MODERATE"] = "moderate";
|
|
19
|
+
AllergySeverity["SEVERE"] = "severe";
|
|
20
|
+
AllergySeverity["LIFE_THREATENING"] = "life-threatening";
|
|
21
|
+
})(AllergySeverity || (exports.AllergySeverity = AllergySeverity = {}));
|
|
22
|
+
var AllergyCriticality;
|
|
23
|
+
(function (AllergyCriticality) {
|
|
24
|
+
AllergyCriticality["LOW"] = "low";
|
|
25
|
+
AllergyCriticality["HIGH"] = "high";
|
|
26
|
+
AllergyCriticality["UNABLE_TO_ASSESS"] = "unable-to-assess";
|
|
27
|
+
})(AllergyCriticality || (exports.AllergyCriticality = AllergyCriticality = {}));
|
|
28
|
+
var AllergyType;
|
|
29
|
+
(function (AllergyType) {
|
|
30
|
+
AllergyType["ALLERGY"] = "allergy";
|
|
31
|
+
AllergyType["INTOLERANCE"] = "intolerance";
|
|
32
|
+
AllergyType["CONTRAINDICATION"] = "contraindication";
|
|
33
|
+
})(AllergyType || (exports.AllergyType = AllergyType = {}));
|
|
34
|
+
let Allergy = class Allergy extends mongoose_2.Document {
|
|
35
|
+
};
|
|
36
|
+
exports.Allergy = Allergy;
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, mongoose_1.Prop)({ type: mongoose_2.Types.ObjectId, ref: 'User', required: true, index: true }),
|
|
39
|
+
__metadata("design:type", mongoose_2.Types.ObjectId)
|
|
40
|
+
], Allergy.prototype, "user", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, mongoose_1.Prop)({ required: true }),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], Allergy.prototype, "substance", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, mongoose_1.Prop)({ type: { system: String, code: String, display: String } }),
|
|
47
|
+
__metadata("design:type", Object)
|
|
48
|
+
], Allergy.prototype, "codedSubstance", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, mongoose_1.Prop)({ type: String, enum: Object.values(AllergyType), default: AllergyType.ALLERGY }),
|
|
51
|
+
__metadata("design:type", String)
|
|
52
|
+
], Allergy.prototype, "type", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, mongoose_1.Prop)({ type: String, enum: Object.values(AllergySeverity), default: AllergySeverity.MODERATE }),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], Allergy.prototype, "severity", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, mongoose_1.Prop)({ type: String, enum: Object.values(AllergyCriticality), default: AllergyCriticality.HIGH }),
|
|
59
|
+
__metadata("design:type", String)
|
|
60
|
+
], Allergy.prototype, "criticality", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, mongoose_1.Prop)({ type: [String], default: [] }),
|
|
63
|
+
__metadata("design:type", Array)
|
|
64
|
+
], Allergy.prototype, "reactions", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, mongoose_1.Prop)(),
|
|
67
|
+
__metadata("design:type", Date)
|
|
68
|
+
], Allergy.prototype, "recordedDate", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, mongoose_1.Prop)(),
|
|
71
|
+
__metadata("design:type", String)
|
|
72
|
+
], Allergy.prototype, "note", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, mongoose_1.Prop)({ type: mongoose_2.Types.ObjectId, ref: 'User' }),
|
|
75
|
+
__metadata("design:type", mongoose_2.Types.ObjectId)
|
|
76
|
+
], Allergy.prototype, "recordedBy", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
(0, mongoose_1.Prop)({ default: true }),
|
|
79
|
+
__metadata("design:type", Boolean)
|
|
80
|
+
], Allergy.prototype, "active", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, mongoose_1.Prop)({ default: false }),
|
|
83
|
+
__metadata("design:type", Boolean)
|
|
84
|
+
], Allergy.prototype, "isRefuted", void 0);
|
|
85
|
+
exports.Allergy = Allergy = __decorate([
|
|
86
|
+
(0, mongoose_1.Schema)({ timestamps: true })
|
|
87
|
+
], Allergy);
|
|
88
|
+
exports.AllergySchema = mongoose_1.SchemaFactory.createForClass(Allergy);
|
|
89
|
+
exports.AllergySchema.index({ user: 1, active: 1 });
|
|
90
|
+
exports.AllergySchema.index({ user: 1, substance: 1 });
|
|
91
|
+
exports.AllergySchema.index({ substance: 1 });
|
|
92
|
+
//# sourceMappingURL=allergy.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allergy.schema.js","sourceRoot":"","sources":["../../src/models/allergy.schema.ts"],"names":[],"mappings":"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"}
|