Skip to content

Commit

Permalink
feat: add medical devices application services
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-acampora committed Mar 28, 2023
1 parent e11cf91 commit c8840d5
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/main/kotlin/application/service/MedicalDeviceServices.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2023. Smart Operating Block
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/

package application.service

import entity.medicaldevice.MedicalDeviceData
import entity.process.ProcessData
import entity.process.SurgicalProcess
import usecase.repository.MedicalDeviceRepository
import java.time.Instant

/**
* Module that wraps all the application services of medical devices.
*/
object MedicalDeviceServices {

/**
* The [ApplicationService] to add the usage of a medical device.
*/
class AddMedicalDeviceUsage(
private val medicalDeviceId: MedicalDeviceData.ImplantableMedicalDeviceId,
private val processId: ProcessData.ProcessId,
private val medicalDeviceRepository: MedicalDeviceRepository
) : ApplicationService<Boolean> {
override fun execute(): Boolean = this.medicalDeviceRepository.addMedicalDeviceUsage(medicalDeviceId, processId)
}

/**
* The [ApplicationService] to add the usage of a medical technology.
*/
class AddMedicalTechnologyUsage(
private val medicalTechnologyId: MedicalDeviceData.MedicalTechnologyId,
private val processId: ProcessData.ProcessId,
private val dateTime: Instant,
private val inUse: Boolean,
private val medicalDeviceRepository: MedicalDeviceRepository
) : ApplicationService<Boolean> {
override fun execute(): Boolean = this.medicalDeviceRepository.addMedicalTechnologyUsage(
medicalTechnologyId,
processId,
dateTime,
inUse
)
}

/**
* The [ApplicationService] to find a surgical process by a medical technology.
*/
class FindProcessByMedicalTechnology(
private val medicalTechnologyId: MedicalDeviceData.MedicalTechnologyId,
private val medicalDeviceRepository: MedicalDeviceRepository
) : ApplicationService<SurgicalProcess?> {

override fun execute(): SurgicalProcess? =
this.medicalDeviceRepository.findSurgicalProcessByMedicalTechnology(medicalTechnologyId)
}
}

0 comments on commit c8840d5

Please sign in to comment.