Skip to content

Commit 157ca05

Browse files
chore: create health professional dto for azure digital twin
1 parent dcbf720 commit 157ca05

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2023. Smart Operating Block
3+
*
4+
* Use of this source code is governed by an MIT-style
5+
* license that can be found in the LICENSE file or at
6+
* https://opensource.org/licenses/MIT.
7+
*/
8+
9+
package infrastructure.digitaltwins.adtpresenter
10+
11+
import com.azure.digitaltwins.core.BasicDigitalTwin
12+
import com.azure.digitaltwins.core.BasicDigitalTwinMetadata
13+
import entity.healthprofessional.HealthProfessionalData.HealthProfessional
14+
15+
/**
16+
* Module with the data of Azure Digital Twin of Health Professional.
17+
*/
18+
object HealthProfessionalAdt {
19+
20+
private const val HEALTH_PROFESSIONAL_MODEL = "dtmi:io:github:smartoperatingblock:HealthProfessional;1"
21+
private const val NAME_PROPERTY = "name"
22+
private const val SURNAME_PROPERTY = "surname"
23+
private const val ROLE_PROPERTY = "role"
24+
25+
/**
26+
* Extension function to create a digital twin from the health professional.
27+
*/
28+
fun HealthProfessional.toDigitalTwin(): BasicDigitalTwin =
29+
BasicDigitalTwin(this.healthProfessionalId)
30+
.setMetadata(BasicDigitalTwinMetadata().setModelId(HEALTH_PROFESSIONAL_MODEL))
31+
.addToContents(NAME_PROPERTY, HealthProfessional::name)
32+
.addToContents(SURNAME_PROPERTY, HealthProfessional::surname)
33+
.addToContents(ROLE_PROPERTY, HealthProfessional::role.name)
34+
}

0 commit comments

Comments
 (0)