Skip to content

Commit

Permalink
chore: adding schema to request fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mateus3009 committed Jul 25, 2024
1 parent 92bfb59 commit 86a3da6
Show file tree
Hide file tree
Showing 41 changed files with 351 additions and 181 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Verify
run: mvn verify
- name: Verify
run: mvn verify
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
- "8082:8082"
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -sf http://localhost:8082/actuator/health | grep -q \"UP\" || exit 1"]
test: [ "CMD-SHELL", "curl -sf http://localhost:8082/actuator/health | grep -q \"UP\" || exit 1" ]
interval: 10s
timeout: 5s
retries: 5
Expand Down
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
Expand All @@ -26,7 +26,8 @@
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
<sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/target/site/jacoco/jacoco.xml
</sonar.coverage.jacoco.xmlReportPaths>
<sonar.language>kotlin</sonar.language>
<sonar.verbose>true</sonar.verbose>
<sonar.exclusions>
Expand Down
16 changes: 8 additions & 8 deletions src/main/kotlin/com/fiap/healthmed/HealthMedApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import org.springframework.boot.runApplication
@SpringBootApplication
@OpenAPIDefinition(
info =
Info(
title = "HealthMed App",
version = "1.0.0",
description = "MVP telemedicine app",
contact = Contact(
name = "Grupo 15",
url = "http://fiap-3soat-g15.s3-website-us-east-1.amazonaws.com",
),
Info(
title = "HealthMed App",
version = "1.0.0",
description = "MVP telemedicine app",
contact = Contact(
name = "Grupo 15",
url = "http://fiap-3soat-g15.s3-website-us-east-1.amazonaws.com",
),
),
servers = [
Server(url = "/"),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class DoctorController(
) : DoctorApi {

private val service = DoctorService(doctorGateway)
private val createDoctorUseCase : CreateDoctorUseCase = service
private val updateDoctorUseCase : UpdateDoctorUseCase = service
private val updateAvailableTimeDoctorUseCase : UpdateAvailableTimeDoctorUseCase = service
private val searchDoctorUseCase : SearchDoctorUseCase = service
private val createDoctorUseCase: CreateDoctorUseCase = service
private val updateDoctorUseCase: UpdateDoctorUseCase = service
private val updateAvailableTimeDoctorUseCase: UpdateAvailableTimeDoctorUseCase = service
private val searchDoctorUseCase: SearchDoctorUseCase = service


override fun create(request: DoctorRequest): ResponseEntity<Doctor> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package com.fiap.healthmed.adapter.controller
import com.fiap.healthmed.adapter.gateway.MedicalAppointmentGateway
import com.fiap.healthmed.domain.MedicalAppointment
import com.fiap.healthmed.driver.web.MedicalAppointmentByDoctorApi
import com.fiap.healthmed.usecases.*
import com.fiap.healthmed.usecases.AcceptAppointmentUseCase
import com.fiap.healthmed.usecases.ListMedicalAppointmentByDoctorUseCase
import com.fiap.healthmed.usecases.RejectAppointmentUseCase
import com.fiap.healthmed.usecases.service.MedicalAppointmentService
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.RestController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class PatientController(
) : PatientApi {

private val service: PatientService = PatientService(patientGateway)
private val createPatientUseCase : CreatePatientUseCase = service
private val updatePatientUseCase : UpdatePatientUseCase = service
private val createPatientUseCase: CreatePatientUseCase = service
private val updatePatientUseCase: UpdatePatientUseCase = service

override fun create(request: PatientRequest): ResponseEntity<Patient> {
return ResponseEntity.ok(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ControllerExceptionHandler {
ApiError(domainException.errorType.name, domainException.message),
HttpStatus.NOT_FOUND,
)

else ->
ApiErrorResponseEntity(
ApiError(ErrorType.UNEXPECTED_ERROR.name, domainException.localizedMessage),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package com.fiap.healthmed.adapter.gateway.impl
import com.fiap.healthmed.adapter.gateway.MedicalRecordGateway
import com.fiap.healthmed.driver.database.persistence.jpa.MedicalRecordJpaRepository

class MedicalRecordGatewayImpl(private val medicalRecordJpaRepository: MedicalRecordJpaRepository) : MedicalRecordGateway {
class MedicalRecordGatewayImpl(private val medicalRecordJpaRepository: MedicalRecordJpaRepository) :
MedicalRecordGateway {
}
3 changes: 2 additions & 1 deletion src/main/kotlin/com/fiap/healthmed/domain/AvailableTimes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ data class AvailableTimes(val slots: Map<DayOfWeek, List<AvailablePeriods>>) {
init {
if (start.isAfter(end)
|| Duration.between(start, end) < Duration.ofMinutes(50)
|| Duration.between(start, end) > Duration.ofDays(1)) {
|| Duration.between(start, end) > Duration.ofDays(1)
) {
throw IllegalArgumentException("start must be after the end")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ enum class ErrorType {
DOCTOR_NOT_FOUND,
DOCKER_ALREADY_EXISTS,

UNEXPECTED_ERROR
,
UNEXPECTED_ERROR,
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.math.BigDecimal

@Entity
@Table(name = "doctor")
class DoctorEntity (
class DoctorEntity(
@Id
@Column(name = "doctor_crm")
val crm: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import java.time.LocalDateTime

@Entity
@Table(name = "medical_appointment")
class MedicalAppointmentEntity (
class MedicalAppointmentEntity(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "medical_appointment_number")
Expand Down
12 changes: 7 additions & 5 deletions src/main/kotlin/com/fiap/healthmed/driver/web/DoctorApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface DoctorApi {
],
)
@PostMapping("/create")
fun create(@RequestBody request: DoctorRequest) : ResponseEntity<Doctor>
fun create(@RequestBody request: DoctorRequest): ResponseEntity<Doctor>

@Operation(summary = "Atualizar um cadastro de um médico")
@ApiResponses(
Expand All @@ -30,7 +30,8 @@ interface DoctorApi {
@PutMapping("/update/{crm}")
fun update(
@PathVariable crm: String,
@RequestBody request: DoctorRequest) : ResponseEntity<Doctor>
@RequestBody request: DoctorRequest
): ResponseEntity<Doctor>

@Operation(summary = "Atualizar os horarios disponiveis do medico")
@ApiResponses(
Expand All @@ -41,12 +42,13 @@ interface DoctorApi {
@PatchMapping("/update/available/{crm}")
fun updateAvailableTimes(
@PathVariable crm: String,
@RequestBody request: AvailableTimesRequest) : ResponseEntity<Doctor>
@RequestBody request: AvailableTimesRequest
): ResponseEntity<Doctor>


@GetMapping("/search")
fun search(@RequestParam query: Map<String, String>) : ResponseEntity<List<Doctor>>
fun search(@RequestParam query: Map<String, String>): ResponseEntity<List<Doctor>>

@GetMapping("/{crm}")
fun get(@PathVariable crm: String) : ResponseEntity<Doctor>
fun get(@PathVariable crm: String): ResponseEntity<Doctor>
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping
interface MedicalAppointmentByDoctorApi {

@GetMapping
fun getAllMyAppointments(@PathVariable crm: String) : ResponseEntity<List<MedicalAppointment>>
fun getAllMyAppointments(@PathVariable crm: String): ResponseEntity<List<MedicalAppointment>>

@PostMapping("/reject/{appointmentNumber}")
fun rejectAppointment(
Expand All @@ -24,4 +24,4 @@ interface MedicalAppointmentByDoctorApi {
@PathVariable crm: String,
@PathVariable appointmentNumber: String,
): ResponseEntity<MedicalAppointment>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ interface MedicalAppointmentByPatientApi {
): ResponseEntity<MedicalAppointment>

@GetMapping
fun getAllMyAppointments(@PathVariable document: String) : ResponseEntity<List<MedicalAppointment>>
fun getAllMyAppointments(@PathVariable document: String): ResponseEntity<List<MedicalAppointment>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ interface MedicalRecordApi {
@PostMapping("/append")
fun appendAnnotations(
@RequestBody request: MedicalRecordContentRequest,
@PathVariable appointmentNumber: String) : ResponseEntity<MedicalAppointment>
}
@PathVariable appointmentNumber: String
): ResponseEntity<MedicalAppointment>
}
6 changes: 3 additions & 3 deletions src/main/kotlin/com/fiap/healthmed/driver/web/PatientApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface PatientApi {
],
)
@PostMapping("/create")
fun create(@RequestBody request: PatientRequest) : ResponseEntity<Patient>
fun create(@RequestBody request: PatientRequest): ResponseEntity<Patient>

@Operation(summary = "Atualizar um cadastro de um paciente")
@ApiResponses(
Expand All @@ -30,5 +30,5 @@ interface PatientApi {
fun update(
@PathVariable document: String,
@RequestBody request: PatientRequest
) : ResponseEntity<Patient>
}
): ResponseEntity<Patient>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,31 @@ package com.fiap.healthmed.driver.web.request

import com.fiap.healthmed.domain.AvailableTimes
import com.fiap.healthmed.driver.web.request.AvailableTimesRequest.AvailablePeriodsRequest
import io.swagger.v3.oas.annotations.media.Schema
import java.time.DayOfWeek
import java.time.LocalDateTime

data class AvailableTimesRequest(val slots: Map<DayOfWeek, List<AvailablePeriodsRequest>>) {

data class AvailablePeriodsRequest(val start: LocalDateTime, val end: LocalDateTime)
data class AvailableTimesRequest(
@Schema(
description = "Available slots", example = """
{
"MONDAY": [
{
"start": "2022-12-31T00:00:00",
"end": "2022-12-31T23:59:59"
}
]
}
"""
)
val slots: Map<DayOfWeek, List<AvailablePeriodsRequest>>
) {
data class AvailablePeriodsRequest(
@Schema(description = "Start time", example = "2022-12-31T23:00:00")
val start: LocalDateTime,
@Schema(description = "End time", example = "2022-12-31T23:59:59")
val end: LocalDateTime
)
}

fun AvailablePeriodsRequest.toDomain() = AvailableTimes.AvailablePeriods(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
package com.fiap.healthmed.driver.web.request

import com.fiap.healthmed.domain.Doctor
import io.swagger.v3.oas.annotations.media.Schema
import java.math.BigDecimal

data class DoctorRequest(
@Schema(description = "CRM", example = "123456")
val crm: String,
@Schema(description = "CPF", example = "28685216907")
val document: String,
@Schema(description = "Specialty", example = "Cardiologist")
val specialty: String,
@Schema(description = "Name", example = "John Doe")
val name: String,
@Schema(description = "Email", example = "[email protected]")
val email: String,
@Schema(description = "Phone number", example = "+5511999999999")
val phoneNumber: String,
@Schema(description = "Service ZIP code", example = "12345678")
val serviceZipCode: String,
@Schema(description = "Service address", example = "123, Main St.")
val serviceAddress: String,
@Schema(description = "Available times")
val availableTimes: AvailableTimesRequest,
@Schema(description = "Appointment price", example = "100.00")
val appointmentPrice: BigDecimal,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
package com.fiap.healthmed.driver.web.request

data class JustificationCancellationRequest(val text: String)
import io.swagger.v3.oas.annotations.media.Schema

data class JustificationCancellationRequest(
@Schema(description = "Justification text", example = "I'm not feeling well")
val text: String
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
package com.fiap.healthmed.driver.web.request

data class MedicalRecordContentRequest(val content: String)
import io.swagger.v3.oas.annotations.media.Schema

data class MedicalRecordContentRequest(
@Schema(description = "Medical record content", example = "Patient has a fever")
val content: String
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package com.fiap.healthmed.driver.web.request

import com.fiap.healthmed.domain.Patient
import io.swagger.v3.oas.annotations.media.Schema

data class PatientRequest(
@Schema(description = "CPF", example = "12345678900")
val document: String,
@Schema(description = "Name", example = "Foo Bar")
val name: String,
@Schema(description = "Email", example = "[email protected]")
val email: String,
@Schema(description = "Phone number", example = "+5511999999999")
val phoneNumber: String,
@Schema(description = "ZIP code", example = "12345678")
val zipCode: String,
@Schema(description = "Address", example = "123, Main St.")
val address: String
)

Expand All @@ -16,6 +23,6 @@ fun PatientRequest.toDomain(): Patient = Patient(
name = name,
email = email,
phoneNumber = phoneNumber,
zipCode = zipCode,
zipCode = zipCode,
address = address
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.fiap.healthmed.driver.web.request

import io.swagger.v3.oas.annotations.media.Schema
import java.time.LocalDateTime

data class TimeAndDateToScheduleRequest(
@Schema(description = "scheduleAt", example = "2022-12-31T23:59:59")
val scheduleAt: LocalDateTime,
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package com.fiap.healthmed.usecases
import com.fiap.healthmed.domain.MedicalAppointment

interface AcceptAppointmentUseCase {
fun accept(crm: String, appointmentNumber: String) : MedicalAppointment
fun accept(crm: String, appointmentNumber: String): MedicalAppointment
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package com.fiap.healthmed.usecases
import com.fiap.healthmed.domain.MedicalRecord

interface AppendInMedicalRecordUseCase {
fun append(content: String, appointmentNumber: String) : MedicalRecord
fun append(content: String, appointmentNumber: String): MedicalRecord
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import com.fiap.healthmed.domain.MedicalAppointment
interface CancelAppointmentUseCase {

fun cancel(
documentPatient: String, appointmentNumber: String, justification: String) : MedicalAppointment
documentPatient: String, appointmentNumber: String, justification: String
): MedicalAppointment
}
Loading

0 comments on commit 86a3da6

Please sign in to comment.