Skip to content

Commit

Permalink
chore: create health professional dto for azure digital twin
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-acampora committed Feb 26, 2023
1 parent dcbf720 commit 157ca05
Showing 1 changed file with 34 additions and 0 deletions.
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)
}

0 comments on commit 157ca05

Please sign in to comment.