-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:ItaloRAmaral/cliniccontrol into 120…
…-criacao-de-endpoint-de-criacao-de-consultas
- Loading branch information
Showing
24 changed files
with
1,820 additions
and
1,366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,23 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [1.7.0-beta.1](https://github.com/ItaloRAmaral/cliniccontrol/compare/[email protected]@1.7.0-beta.1) (2024-02-04) | ||
|
||
### Features | ||
|
||
- add mapper for registry ([e0d1247](https://github.com/ItaloRAmaral/cliniccontrol/commit/e0d1247dae8996baefaeb5fc0cbb6146b3916885)) | ||
- **CC-118:** add controllers and service in api module ([452c503](https://github.com/ItaloRAmaral/cliniccontrol/commit/452c503e0f063855dc707c7d29d866eb2ecd438f)) | ||
- **CC-118:** add dto to appointment registry ([44dcdee](https://github.com/ItaloRAmaral/cliniccontrol/commit/44dcdeee5ff32e50e2eddec02b134f6cc4d4b000)) | ||
- **CC-118:** add methods in prisma registry repository ([b944e02](https://github.com/ItaloRAmaral/cliniccontrol/commit/b944e0229ac910ea7be8e4f26628c18640eb66fd)) | ||
- **CC-118:** add registry fake client ([1615baa](https://github.com/ItaloRAmaral/cliniccontrol/commit/1615baa02af1250c893fdc76a6d2f53c55db75d7)) | ||
- **CC-118:** add registry mapper ([3f69213](https://github.com/ItaloRAmaral/cliniccontrol/commit/3f69213347e77136a95477a2e80ea300ba266ff3)) | ||
- **CC-118:** add repository in repositories module ([8142178](https://github.com/ItaloRAmaral/cliniccontrol/commit/8142178c2331615f0caf54677431ba32bc5c34e1)) | ||
- **CC-118:** add test e2e to appointment registry ([f4a4d78](https://github.com/ItaloRAmaral/cliniccontrol/commit/f4a4d78886a762bbd6f2033d0b495a4c8fdbec05)) | ||
- **CC-118:** create controller to appointment registry ([f11b910](https://github.com/ItaloRAmaral/cliniccontrol/commit/f11b9105394f6e202ac5c7ad631e882b9e311f8a)) | ||
- **CC-118:** create fake client to registry ([a547515](https://github.com/ItaloRAmaral/cliniccontrol/commit/a547515207a3dfad0968eefb21b581f56b9c3d14)) | ||
- **CC-118:** create service to appointment registry ([0b39908](https://github.com/ItaloRAmaral/cliniccontrol/commit/0b399083a9bf7478fa8f8f64961749d098092720)) | ||
- create PostgresqlPrismaOrmRegistryRepository ([cdbc7de](https://github.com/ItaloRAmaral/cliniccontrol/commit/cdbc7de00a77efe081c2d3b9082ad8a3fce481cf)) | ||
|
||
## [1.7.0-beta.0](https://github.com/ItaloRAmaral/cliniccontrol/compare/[email protected]@1.7.0-beta.0) (2024-01-12) | ||
|
||
### Features | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,23 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [1.4.0-beta.1](https://github.com/ItaloRAmaral/cliniccontrol/compare/@cliniccontrol/[email protected]...@cliniccontrol/[email protected]) (2024-02-04) | ||
|
||
### Features | ||
|
||
- add mapper for registry ([e0d1247](https://github.com/ItaloRAmaral/cliniccontrol/commit/e0d1247dae8996baefaeb5fc0cbb6146b3916885)) | ||
- **CC-118:** add controllers and service in api module ([452c503](https://github.com/ItaloRAmaral/cliniccontrol/commit/452c503e0f063855dc707c7d29d866eb2ecd438f)) | ||
- **CC-118:** add dto to appointment registry ([44dcdee](https://github.com/ItaloRAmaral/cliniccontrol/commit/44dcdeee5ff32e50e2eddec02b134f6cc4d4b000)) | ||
- **CC-118:** add methods in prisma registry repository ([b944e02](https://github.com/ItaloRAmaral/cliniccontrol/commit/b944e0229ac910ea7be8e4f26628c18640eb66fd)) | ||
- **CC-118:** add registry fake client ([1615baa](https://github.com/ItaloRAmaral/cliniccontrol/commit/1615baa02af1250c893fdc76a6d2f53c55db75d7)) | ||
- **CC-118:** add registry mapper ([3f69213](https://github.com/ItaloRAmaral/cliniccontrol/commit/3f69213347e77136a95477a2e80ea300ba266ff3)) | ||
- **CC-118:** add repository in repositories module ([8142178](https://github.com/ItaloRAmaral/cliniccontrol/commit/8142178c2331615f0caf54677431ba32bc5c34e1)) | ||
- **CC-118:** add test e2e to appointment registry ([f4a4d78](https://github.com/ItaloRAmaral/cliniccontrol/commit/f4a4d78886a762bbd6f2033d0b495a4c8fdbec05)) | ||
- **CC-118:** create controller to appointment registry ([f11b910](https://github.com/ItaloRAmaral/cliniccontrol/commit/f11b9105394f6e202ac5c7ad631e882b9e311f8a)) | ||
- **CC-118:** create fake client to registry ([a547515](https://github.com/ItaloRAmaral/cliniccontrol/commit/a547515207a3dfad0968eefb21b581f56b9c3d14)) | ||
- **CC-118:** create service to appointment registry ([0b39908](https://github.com/ItaloRAmaral/cliniccontrol/commit/0b399083a9bf7478fa8f8f64961749d098092720)) | ||
- create PostgresqlPrismaOrmRegistryRepository ([cdbc7de](https://github.com/ItaloRAmaral/cliniccontrol/commit/cdbc7de00a77efe081c2d3b9082ad8a3fce481cf)) | ||
|
||
## [1.4.0-beta.0](https://github.com/ItaloRAmaral/cliniccontrol/compare/@cliniccontrol/[email protected]...@cliniccontrol/[email protected]) (2024-01-12) | ||
|
||
### Features | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@authToken = {{$dotenv AUTH_TOKEN}} | ||
@apiKey = {{$dotenv API_KEY}} | ||
|
||
### Create New Appointment Registry | ||
|
||
# @name create_patient_appointment_registry | ||
POST http://localhost:3333/core/appointment-registry/create HTTP/1.1 | ||
Content-Type: application/json | ||
Authorization: Bearer {{authToken}} | ||
|
||
{ | ||
"registry": { | ||
"observations": "well" | ||
}, | ||
"psychologistId": "{{$dotenv PSYCHOLOGIST_ID}}", | ||
"patientId": "{{$dotenv PATIENT_ID}}" | ||
} | ||
|
||
### Update Registry | ||
|
||
# @name update_patient_appointment_registry | ||
PATCH http://localhost:3333/core/appointment-registry/update HTTP/1.1 | ||
|
||
Content-Type: application/json | ||
Authorization: Bearer {{authToken}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...try/create-patient-appointment-registry/create-patient-appointment-registry.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Body, Controller, Post } from '@nestjs/common'; | ||
import { ApiTags } from '@nestjs/swagger'; | ||
import { CreatePatientAppointmentRegistryDto } from '../../../../../../core/domains/patient-appointment-registry/use-cases/create-appointment-registry/create-appointment-registry-dto'; | ||
import { GlobalAppHttpException } from '../../../../../../shared/errors/globalAppHttpException'; | ||
import { CreatePatientAppointmentRegistryOutputDto } from './dto'; | ||
import { NestjsCreatePatientAppointmentRegistryService } from './nestjs-create-patient-appointment-registry.service'; | ||
|
||
@ApiTags('Create Patient Appointment Registry') | ||
@Controller({ | ||
path: 'appointment-registry', | ||
}) | ||
export class CreatePatientAppointmentRegistryController { | ||
constructor( | ||
private createPatientAppointmentRegistryService: NestjsCreatePatientAppointmentRegistryService, | ||
) {} | ||
|
||
@Post('create') | ||
async execute( | ||
@Body() createPatientAppointmentRegistryDto: CreatePatientAppointmentRegistryDto, | ||
): Promise<CreatePatientAppointmentRegistryOutputDto> { | ||
try { | ||
await this.createPatientAppointmentRegistryService.execute( | ||
createPatientAppointmentRegistryDto, | ||
); | ||
|
||
return { message: 'Appointment registry created successfully' }; | ||
} catch (error: unknown) { | ||
throw new GlobalAppHttpException(error); | ||
} | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
...istry/create-patient-appointment-registry/create-patient-appointment-registry.e2e-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import request from 'supertest'; | ||
|
||
import { INestApplication } from '@nestjs/common'; | ||
|
||
import { setupE2ETest } from '../../../../../../../../tests/utils/e2e-tests-initial-setup'; | ||
import { Registry } from '../../../../../../core/domains/patient-appointment-registry/entities/registry/dto'; | ||
import { CreatePatientAppointmentRegistryDto } from '../../../../../../core/domains/patient-appointment-registry/use-cases/create-appointment-registry/create-appointment-registry-dto'; | ||
import { PatientEntity } from '../../../../../../core/domains/patient/entities/patient/entity'; | ||
import { PsychologistEntity } from '../../../../../../core/domains/psychologist/entities/psychologist/entity'; | ||
|
||
describe('[E2E] - Create Appointment Registry', () => { | ||
let app: INestApplication; | ||
|
||
let access_token: string; | ||
|
||
let patient: PatientEntity; | ||
let psychologist: PsychologistEntity; | ||
let registry: Registry; | ||
|
||
beforeAll(async () => { | ||
const setup = await setupE2ETest(); | ||
|
||
app = setup.app; | ||
|
||
access_token = setup.access_token; | ||
|
||
patient = setup.patient; | ||
psychologist = setup.psychologist; | ||
|
||
registry = { | ||
observations: 'Patient is doing well', | ||
}; | ||
}); | ||
|
||
it('[POST] - Should successfully create a new registry', async () => { | ||
const appointmentRegistry: CreatePatientAppointmentRegistryDto = { | ||
patientId: patient.id, | ||
psychologistId: psychologist.id, | ||
registry, | ||
}; | ||
|
||
const createdPatientAppointmentRegistry = await request(app.getHttpServer()) | ||
.post('/appointment-registry/create') | ||
.set('Authorization', `Bearer ${access_token}`) | ||
.send(appointmentRegistry); | ||
|
||
expect(createdPatientAppointmentRegistry.statusCode).toBe(201); | ||
expect(createdPatientAppointmentRegistry.body.message).toBe( | ||
'Appointment registry created successfully', | ||
); | ||
}); | ||
|
||
it('[POST] - Should return an error when trying to create a registry with an invalid patient id', async () => { | ||
const appointmentRegistry: CreatePatientAppointmentRegistryDto = { | ||
patientId: 'invalid_patient_id', | ||
psychologistId: psychologist.id, | ||
registry, | ||
}; | ||
|
||
const createdPatientAppointmentRegistry = await request(app.getHttpServer()) | ||
.post('/appointment-registry/create') | ||
.set('Authorization', `Bearer ${access_token}`) | ||
.send(appointmentRegistry); | ||
|
||
expect(createdPatientAppointmentRegistry.statusCode).toBe(409); | ||
expect(createdPatientAppointmentRegistry.body.message).toBe('patient not found'); | ||
}); | ||
|
||
it('[POST] - Should return an error when trying to create a registry with an invalid psychologist id', async () => { | ||
const appointmentRegistry: CreatePatientAppointmentRegistryDto = { | ||
patientId: patient.id, | ||
psychologistId: 'invalid_psychologist_id', | ||
registry, | ||
}; | ||
|
||
const createdPatientAppointmentRegistry = await request(app.getHttpServer()) | ||
.post('/appointment-registry/create') | ||
.set('Authorization', `Bearer ${access_token}`) | ||
.send(appointmentRegistry); | ||
|
||
expect(createdPatientAppointmentRegistry.statusCode).toBe(409); | ||
expect(createdPatientAppointmentRegistry.body.message).toBe('psychologist not found'); | ||
}); | ||
|
||
it('[POST] - Should return an error when trying to create a registry without token', async () => { | ||
const appointmentRegistry: CreatePatientAppointmentRegistryDto = { | ||
patientId: patient.id, | ||
psychologistId: psychologist.id, | ||
registry, | ||
}; | ||
|
||
const createdPatientAppointmentRegistry = await request(app.getHttpServer()) | ||
.post('/appointment-registry/create') | ||
.send(appointmentRegistry); | ||
|
||
expect(createdPatientAppointmentRegistry.statusCode).toBe(401); | ||
expect(createdPatientAppointmentRegistry.body.message).toBe('Invalid JWT token'); | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
...ers/api/use-cases/patient-appointment-registry/create-patient-appointment-registry/dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { IsString } from "class-validator"; | ||
|
||
export class CreatePatientAppointmentRegistryOutputDto { | ||
@IsString() | ||
message!: string; | ||
} |
21 changes: 21 additions & 0 deletions
21
...create-patient-appointment-registry/nestjs-create-patient-appointment-registry.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { PatientAppointmentRegistryDatabaseRepository } from '../../../../../../core/domains/patient-appointment-registry/repositories/database-repository'; | ||
import { CreatePatientAppointmentRegistryService } from '../../../../../../core/domains/patient-appointment-registry/use-cases/create-appointment-registry/create-appointment-registry.service'; | ||
import { PatientDatabaseRepository } from '../../../../../../core/domains/patient/repositories/database-repository'; | ||
import { PsychologistDatabaseRepository } from '../../../../../../core/domains/psychologist/repositories/database-repository'; | ||
|
||
@Injectable() | ||
export class NestjsCreatePatientAppointmentRegistryService extends CreatePatientAppointmentRegistryService { | ||
constructor( | ||
psychologistDatabaseRepository: PsychologistDatabaseRepository, | ||
patientDatabaseRepository: PatientDatabaseRepository, | ||
patientAppointmentRegistryDatabaseRepository: PatientAppointmentRegistryDatabaseRepository, | ||
) | ||
{ | ||
super( | ||
psychologistDatabaseRepository, | ||
patientDatabaseRepository, | ||
patientAppointmentRegistryDatabaseRepository | ||
); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...a/migrations/20240115120146_update_appointment_patient_registry_schema_name/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the `patient_appointments_registry` table. If the table is not empty, all the data it contains will be lost. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "patient_appointments_registry" DROP CONSTRAINT "patient_appointments_registry_patient_id_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "patient_appointments_registry" DROP CONSTRAINT "patient_appointments_registry_psychologist_id_fkey"; | ||
|
||
-- DropTable | ||
DROP TABLE "patient_appointments_registry"; | ||
|
||
-- CreateTable | ||
CREATE TABLE "patient_appointment_registry" ( | ||
"id" TEXT NOT NULL, | ||
"updated_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"registry" JSON NOT NULL, | ||
"patient_id" TEXT NOT NULL, | ||
"psychologist_id" TEXT NOT NULL, | ||
|
||
CONSTRAINT "patient_appointment_registry_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "patient_appointment_registry" ADD CONSTRAINT "patient_appointment_registry_patient_id_fkey" FOREIGN KEY ("patient_id") REFERENCES "patient"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "patient_appointment_registry" ADD CONSTRAINT "patient_appointment_registry_psychologist_id_fkey" FOREIGN KEY ("psychologist_id") REFERENCES "psychologist"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.