@@ -13,8 +13,10 @@ import application.presenter.api.report.medicaldevice.ImplantableMedicalDeviceAp
1313import application.presenter.api.report.medicaldevice.MedicalTechnologyApiDto
1414import application.presenter.api.report.medicaldevice.MedicalTechnologyApiDtoType
1515import entity.surgeryreport.medicaldevice.ImplantableMedicalDevice
16+ import entity.surgeryreport.medicaldevice.ImplantableMedicalDeviceID
1617import entity.surgeryreport.medicaldevice.ImplantableMedicalDeviceType
1718import entity.surgeryreport.medicaldevice.MedicalTechnology
19+ import entity.surgeryreport.medicaldevice.MedicalTechnologyID
1820import entity.surgeryreport.medicaldevice.MedicalTechnologyType
1921
2022/* *
@@ -29,11 +31,26 @@ object MedicalDeviceSerializer {
2931 type = this .type.toApiDtoType(),
3032 )
3133
34+ /* *
35+ * Extension method to obtain the an implantable medical device from dto.
36+ */
37+ fun ImplantableMedicalDeviceApiDto.toImplantableMedicalDevice (): ImplantableMedicalDevice =
38+ ImplantableMedicalDevice (
39+ id = ImplantableMedicalDeviceID (this .id),
40+ type = this .type.toImplantableMedicalDevice(),
41+ )
42+
3243 private fun ImplantableMedicalDeviceType.toApiDtoType (): ImplantableMedicalDeviceApiDtoType = when (this ) {
3344 ImplantableMedicalDeviceType .CATHETER -> ImplantableMedicalDeviceApiDtoType .CATHETER
3445 ImplantableMedicalDeviceType .PACEMAKER -> ImplantableMedicalDeviceApiDtoType .PACEMAKER
3546 }
3647
48+ private fun ImplantableMedicalDeviceApiDtoType.toImplantableMedicalDevice (): ImplantableMedicalDeviceType =
49+ when (this ) {
50+ ImplantableMedicalDeviceApiDtoType .CATHETER -> ImplantableMedicalDeviceType .CATHETER
51+ ImplantableMedicalDeviceApiDtoType .PACEMAKER -> ImplantableMedicalDeviceType .PACEMAKER
52+ }
53+
3754 /* *
3855 * Extension method to obtain the api dto of a medical technology.
3956 */
@@ -45,8 +62,24 @@ object MedicalDeviceSerializer {
4562 inUse = this .inUse,
4663 )
4764
65+ /* *
66+ * Extension method to obtain a medical technology from dto.
67+ */
68+ fun MedicalTechnologyApiDto.toMedicalTechnology (): MedicalTechnology = MedicalTechnology (
69+ id = MedicalTechnologyID (this .id),
70+ name = this .name,
71+ description = this .description,
72+ type = this .type.toMedicalTechnologyType(),
73+ inUse = this .inUse,
74+ )
75+
4876 private fun MedicalTechnologyType.toApiDtoType (): MedicalTechnologyApiDtoType = when (this ) {
4977 MedicalTechnologyType .ENDOSCOPE -> MedicalTechnologyApiDtoType .ENDOSCOPE
5078 MedicalTechnologyType .XRAY -> MedicalTechnologyApiDtoType .XRAY
5179 }
80+
81+ private fun MedicalTechnologyApiDtoType.toMedicalTechnologyType (): MedicalTechnologyType = when (this ) {
82+ MedicalTechnologyApiDtoType .ENDOSCOPE -> MedicalTechnologyType .ENDOSCOPE
83+ MedicalTechnologyApiDtoType .XRAY -> MedicalTechnologyType .XRAY
84+ }
5285}
0 commit comments