generated from SmartOperatingBlock/kotlin-template-project
-
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.
chore: create health professional dto for azure digital twin
- Loading branch information
1 parent
dcbf720
commit 157ca05
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/main/kotlin/infrastructure/digitaltwins/adtpresenter/HealthProfessionalAdt.kt
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,34 @@ | ||
/* | ||
* 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 infrastructure.digitaltwins.adtpresenter | ||
|
||
import com.azure.digitaltwins.core.BasicDigitalTwin | ||
import com.azure.digitaltwins.core.BasicDigitalTwinMetadata | ||
import entity.healthprofessional.HealthProfessionalData.HealthProfessional | ||
|
||
/** | ||
* Module with the data of Azure Digital Twin of Health Professional. | ||
*/ | ||
object HealthProfessionalAdt { | ||
|
||
private const val HEALTH_PROFESSIONAL_MODEL = "dtmi:io:github:smartoperatingblock:HealthProfessional;1" | ||
private const val NAME_PROPERTY = "name" | ||
private const val SURNAME_PROPERTY = "surname" | ||
private const val ROLE_PROPERTY = "role" | ||
|
||
/** | ||
* Extension function to create a digital twin from the health professional. | ||
*/ | ||
fun HealthProfessional.toDigitalTwin(): BasicDigitalTwin = | ||
BasicDigitalTwin(this.healthProfessionalId) | ||
.setMetadata(BasicDigitalTwinMetadata().setModelId(HEALTH_PROFESSIONAL_MODEL)) | ||
.addToContents(NAME_PROPERTY, HealthProfessional::name) | ||
.addToContents(SURNAME_PROPERTY, HealthProfessional::surname) | ||
.addToContents(ROLE_PROPERTY, HealthProfessional::role.name) | ||
} |