diff --git a/README.md b/README.md index 78921c5..f6ac611 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,7 @@ the data from the RADAR-base kafka service.[]\ Data dashboard applications can use the APIs as follows. -`GET */subject/{subjectId}/variables/observations` - -Get all configured users for a particular source-type use `GET */users?source-type={source-type}` +`GET */subject/{subjectId}/topic/{topicId}/observations` ## Installation diff --git a/data-dashboard-backend/dev/dashboard.yml b/data-dashboard-backend/dev/dashboard.yml index 14e86c6..c2e0cc5 100644 --- a/data-dashboard-backend/dev/dashboard.yml +++ b/data-dashboard-backend/dev/dashboard.yml @@ -5,13 +5,13 @@ service: auth: managementPortal: - url: http://localhost:8080/managementportal + url: http://127.0.0.1:8080/managementportal clientId: data_dashboard_api clientSecret: data_dashboard_api_secret jwtResourceName: res_DataDashboardAPI database: - url: jdbc:postgresql://localhost:5432/data + url: jdbc:postgresql://127.0.0.1:5432/data user: radarbase password: radarbase dialect: org.hibernate.dialect.PostgreSQLDialect diff --git a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/api/ObservationDto.kt b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/api/ObservationDto.kt index 3317c15..73ddc03 100644 --- a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/api/ObservationDto.kt +++ b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/api/ObservationDto.kt @@ -23,6 +23,15 @@ data class ObservationDto( /** Unique observation ID. */ val id: Long?, + /** Unique identifier of study subject. */ + val subject: String?, + + /** Unique identifier of the kafka topic. */ + val topic: String?, + + /** Category of the observation (optional). */ + val category: String?, + /** Date or date-time of the observation. */ val date: String?, diff --git a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/api/VariableListDto.kt b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/api/ObservationListDto.kt similarity index 90% rename from data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/api/VariableListDto.kt rename to data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/api/ObservationListDto.kt index 761a397..85eb17b 100644 --- a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/api/VariableListDto.kt +++ b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/api/ObservationListDto.kt @@ -19,6 +19,6 @@ package org.radarbase.datadashboard.api.api /** List of variables. */ -data class VariableListDto( - val variables: List, +data class ObservationListDto( + val observations: List, ) diff --git a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/api/VariableDto.kt b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/api/VariableDto.kt deleted file mode 100644 index 7997a5f..0000000 --- a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/api/VariableDto.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2024 The Hyve - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * - */ - -package org.radarbase.datadashboard.api.api - -import org.radarbase.datadashboard.api.domain.model.Variable - -/** A variable, describing a type of observations. */ -data class VariableDto( - /** Unique ID. */ - val id: Long?, - /** Canonical name of the variable. */ - val name: String, - /** Data type of observations for this variable. */ - val type: String?, - /** Category to group variables with. */ - val category: String?, - /** Observations that are selected for this variable. */ - val observations: List?, - /** Date type of observations. */ - val dateType: Variable.DateType? = Variable.DateType.LOCAL_DATE, -) diff --git a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/domain/ObservationRepository.kt b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/domain/ObservationRepository.kt index ec57ecf..5db3759 100644 --- a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/domain/ObservationRepository.kt +++ b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/domain/ObservationRepository.kt @@ -29,15 +29,16 @@ class ObservationRepository( @Context em: Provider, ) : HibernateRepository(em) { - fun getObservations(subjectId: String): List { - logger.debug("Get observations of {}", subjectId) + fun getObservations(topicId: String, subjectId: String): List { + logger.debug("Get observations in topic {} of subject {}", topicId, subjectId) return transact { createQuery( - "SELECT o FROM Observation o WHERE o.subjectId = :subjectId ORDER BY o.date DESC", + "SELECT o FROM Observation o WHERE o.subject = :subjectId AND o.topic = :topicId ORDER BY o.date DESC", Observation::class.java, ).apply { setParameter("subjectId", subjectId) + setParameter("topicId", topicId) }.resultList } } diff --git a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/domain/mapper/Extensions.kt b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/domain/mapper/Extensions.kt index 5086efd..dc31d71 100644 --- a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/domain/mapper/Extensions.kt +++ b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/domain/mapper/Extensions.kt @@ -19,13 +19,14 @@ package org.radarbase.datadashboard.api.domain.mapper import org.radarbase.datadashboard.api.api.ObservationDto -import org.radarbase.datadashboard.api.api.VariableDto import org.radarbase.datadashboard.api.domain.model.Observation -import org.radarbase.datadashboard.api.domain.model.Variable import java.time.Duration fun Observation.toDto(): ObservationDto = ObservationDto( id = id, + subject = subject, + topic = topic, + category = category, date = date?.toString(), period = if (date != null && endDate != null) { Duration.between(date, endDate).toString() @@ -35,22 +36,3 @@ fun Observation.toDto(): ObservationDto = ObservationDto( value = valueNumeric ?: valueTextual, ) -fun Map.Entry>.toDto(): VariableDto { - val (variable, observations) = this - return variable.toDto( - observations - .sortedBy { it.date } - .map { it.toDto() }, - ) -} - -fun Variable.toDtoWithoutObservations(): VariableDto = toDto(null) - -fun Variable.toDto(observations: List?): VariableDto = VariableDto( - id = id, - name = name, - type = type, - category = category, - observations = observations, - dateType = dateType, -) diff --git a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/domain/model/Observation.kt b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/domain/model/Observation.kt index 2120053..f464445 100644 --- a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/domain/model/Observation.kt +++ b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/domain/model/Observation.kt @@ -24,48 +24,55 @@ import java.util.* @Entity @Table(name = "observation") -class Observation( +data class Observation( @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(updatable = false, nullable = false) @Id - val id: Long?, - @Column(name = "subject_id") - val subjectId: String, - @ManyToOne - @JoinColumn(name = "variable_id") - val variable: Variable, - val date: ZonedDateTime?, + val id: Long, + + @Column(nullable = false) + @Id + val subject: String, + + @Column(nullable = false) + @Id + val topic: String, + + @Id + val category: String, + + @Column(nullable = false) + @Id + val variable: String, + + @Column(nullable = false) + @Id + val date: ZonedDateTime, + @Column(name = "end_date") val endDate: ZonedDateTime?, + @Column(name = "value_textual") val valueTextual: String?, + @Column(name = "value_numeric") val valueNumeric: Double?, + ) { override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false other as Observation - if (id != null && other.id != null) { - return id == other.id - } - - return subjectId == other.subjectId && + return subject == other.subject && + topic == other.topic && + category == other.category && variable == other.variable && date == other.date && endDate == other.endDate } - override fun hashCode(): Int = Objects.hash(subjectId, variable, date) - - override fun toString(): String = "Observation(" + - "id=$id, " + - "variable=$variable, " + - "date=$date, " + - "endDate=$endDate, " + - "valueTextual=${valueTextual.toPrintString()}, " + - "valueNumeric=$valueNumeric)" + override fun hashCode(): Int = Objects.hash(subject, variable, date) companion object { internal fun String?.toPrintString() = if (this != null) "'$this'" else "null" diff --git a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/domain/model/Variable.kt b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/domain/model/Variable.kt deleted file mode 100644 index 104bcf8..0000000 --- a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/domain/model/Variable.kt +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * * Copyright 2024 The Hyve - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * - */ - -package org.radarbase.datadashboard.api.domain.model - -import org.radarbase.datadashboard.api.domain.model.Observation.Companion.toPrintString -import jakarta.persistence.* - -@Entity -@Table(name = "variable") -class Variable( - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Id - val id: Long?, - val name: String, - val type: String?, - val category: String?, - @OneToMany(mappedBy = "variable", fetch = FetchType.LAZY) - val observations: List, - @Enumerated(EnumType.STRING) - @Column(name = "date_type") - val dateType: DateType? = DateType.LOCAL_DATE, -) { - enum class DateType { - LOCAL_DATE, ZONED_DATE, LOCAL_DATE_TIME, ZONED_DATE_TIME, - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (javaClass != other?.javaClass) return false - - other as Variable - - if (id != null && other.id != null) { - return id == other.id - } - - return name == other.name && - type == other.type && - category == other.category && - dateType == other.dateType - } - - override fun hashCode(): Int = name.hashCode() - - override fun toString(): String = "Variable(" + - "id=$id, " + - "name='$name', " + - "type=${type.toPrintString()}, " + - "category=${category.toPrintString()}, " + - "dateType=$dateType)" -} diff --git a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/enhancer/DashBoardApiEnhancerFactory.kt b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/enhancer/DashBoardApiEnhancerFactory.kt index af24ae3..7dec3d3 100644 --- a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/enhancer/DashBoardApiEnhancerFactory.kt +++ b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/enhancer/DashBoardApiEnhancerFactory.kt @@ -20,7 +20,6 @@ package org.radarbase.datadashboard.api.enhancer import org.radarbase.datadashboard.api.config.DashboardApiConfig import org.radarbase.datadashboard.api.domain.model.Observation -import org.radarbase.datadashboard.api.domain.model.Variable import org.radarbase.jersey.enhancer.EnhancerFactory import org.radarbase.jersey.enhancer.Enhancers import org.radarbase.jersey.enhancer.JerseyResourceEnhancer @@ -40,8 +39,7 @@ class DashBoardApiEnhancerFactory( HibernateResourceEnhancer( config.database.copy( managedClasses = listOf( - Observation::class.jvmName, - Variable::class.jvmName + Observation::class.jvmName ), ), ), diff --git a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/resource/ObservationResource.kt b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/resource/ObservationResource.kt index 21bb68e..34616fc 100644 --- a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/resource/ObservationResource.kt +++ b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/resource/ObservationResource.kt @@ -20,27 +20,36 @@ package org.radarbase.datadashboard.api.resource import jakarta.annotation.Resource import jakarta.ws.rs.* +import jakarta.ws.rs.container.ContainerRequestContext import jakarta.ws.rs.core.Context -import org.radarbase.datadashboard.api.api.VariableListDto +import jakarta.ws.rs.core.Response import org.radarbase.datadashboard.api.service.ObservationService import org.radarbase.auth.authorization.Permission +import org.radarbase.datadashboard.api.api.ObservationDto +import org.radarbase.datadashboard.api.api.ObservationListDto import org.radarbase.jersey.auth.Authenticated import org.radarbase.jersey.auth.NeedsPermission -@Path("subject/{subjectId}/variables") +@Path("subject/{subjectId}/topic/{topicId}") @Resource @Produces("application/json") @Consumes("application/json") @Authenticated class ObservationResource( - @Context private val observationService: ObservationService, + @Context private val observationService: ObservationService ) { @GET @Path("observations") @NeedsPermission(Permission.MEASUREMENT_READ) fun getObservations( - @PathParam("subjectId") subjectId: String - ): VariableListDto { - return observationService.getObservations(subjectId) + @PathParam("subjectId") subjectId: String, + @PathParam("topicId") topicId: String + ): ObservationListDto { +// if (request.securityContext != null && request.securityContext is RadarSecurityContext) { +// val userName = (request.securityContext as RadarSecurityContext).userPrincipal +// if (!subjectId.equals(userName)) throw NotFoundException("Subjects can only access their own data.") + return observationService.getObservations(topicId, subjectId) +// } +// return emptyList() } } diff --git a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/service/ObservationService.kt b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/service/ObservationService.kt index dffc77b..5086be2 100644 --- a/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/service/ObservationService.kt +++ b/data-dashboard-backend/src/main/java/org/radarbase/datadashboard/api/service/ObservationService.kt @@ -19,19 +19,17 @@ package org.radarbase.datadashboard.api.service import jakarta.ws.rs.core.Context -import org.radarbase.datadashboard.api.api.VariableListDto +import org.radarbase.datadashboard.api.api.ObservationListDto import org.radarbase.datadashboard.api.domain.ObservationRepository import org.radarbase.datadashboard.api.domain.mapper.toDto class ObservationService( @Context private val observationRepository: ObservationRepository ) { - fun getObservations(subjectId: String): VariableListDto { - val result = this.observationRepository.getObservations(subjectId) - return VariableListDto( - result - .groupBy { it.variable } - .map { it.toDto() }, + fun getObservations(topicId: String, subjectId: String): ObservationListDto { + val result = this.observationRepository.getObservations(topicId, subjectId) + return ObservationListDto( + result.map { it.toDto() }, ) } } diff --git a/data-dashboard-backend/src/main/resources/db/changelog/changes/20220309-create-database.xml b/data-dashboard-backend/src/main/resources/db/changelog/changes/20220309-create-database.xml index dc613bd..61c14aa 100644 --- a/data-dashboard-backend/src/main/resources/db/changelog/changes/20220309-create-database.xml +++ b/data-dashboard-backend/src/main/resources/db/changelog/changes/20220309-create-database.xml @@ -23,41 +23,33 @@ https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.6.xsd"> - - Create variable and observation tables - + + - - + + + + + + - - - - - + - - + + - - - - - - - - - + + + + diff --git a/data-dashboard-backend/src/main/resources/db/changelog/changes/20220321-insert-mock-data.xml b/data-dashboard-backend/src/main/resources/db/changelog/changes/20220321-insert-mock-data.xml index bc245ef..4a4c0f5 100644 --- a/data-dashboard-backend/src/main/resources/db/changelog/changes/20220321-insert-mock-data.xml +++ b/data-dashboard-backend/src/main/resources/db/changelog/changes/20220321-insert-mock-data.xml @@ -22,19 +22,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.9.xsd"> - - - - + usePreparedStatements="true"> + + + diff --git a/data-dashboard-backend/src/main/resources/db/changelog/changes/20220321-observations.csv b/data-dashboard-backend/src/main/resources/db/changelog/changes/20220321-observations.csv index 44127f7..c7f744e 100644 --- a/data-dashboard-backend/src/main/resources/db/changelog/changes/20220321-observations.csv +++ b/data-dashboard-backend/src/main/resources/db/changelog/changes/20220321-observations.csv @@ -1,370 +1,9 @@ -variable_id;value_numeric;value_textual;date;subject_id;end_date -1;1;NULL;2021-02-20 00:00:00;sub-1;NULL -2;1969;NULL;2021-02-20 00:00:00;sub-1;NULL -3;1;NULL;2021-02-20 00:00:00;sub-1;NULL -4;176;NULL;2021-02-20 00:00:00;sub-1;NULL -5;82;NULL;2021-02-20 00:00:00;sub-1;NULL -6;6;NULL;2021-02-20 00:00:00;sub-1;NULL -7;2;NULL;2021-02-20 00:00:00;sub-1;NULL -8;10997;NULL;2021-02-20 00:00:00;sub-1;NULL -9;2;NULL;2021-02-20 00:00:00;sub-1;NULL -10;2015;NULL;2021-02-20 00:00:00;sub-1;NULL -11;3;NULL;2021-02-20 00:00:00;sub-1;NULL -12;3;NULL;2021-02-20 00:00:00;sub-1;NULL -13;3;NULL;2021-02-20 00:00:00;sub-1;NULL -14;1;NULL;2021-02-20 00:00:00;sub-1;NULL -15;0;NULL;2021-02-20 00:00:00;sub-1;NULL -16;0;NULL;2021-02-20 00:00:00;sub-1;NULL -17;0;NULL;2021-02-20 00:00:00;sub-1;NULL -18;0;NULL;2021-02-20 00:00:00;sub-1;NULL -19;0;NULL;2021-02-20 00:00:00;sub-1;NULL -20;0;NULL;2021-02-20 00:00:00;sub-1;NULL -21;0;NULL;2021-02-20 00:00:00;sub-1;NULL -22;0;NULL;2021-02-20 00:00:00;sub-1;NULL -23;0;NULL;2021-02-20 00:00:00;sub-1;NULL -24;1;NULL;2021-02-20 00:00:00;sub-1;NULL -25;1;NULL;2021-02-20 00:00:00;sub-1;NULL -26;0;NULL;2021-02-20 00:00:00;sub-1;NULL -27;0;NULL;2021-02-20 00:00:00;sub-1;NULL -28;0;NULL;2021-02-20 00:00:00;sub-1;NULL -29;0;NULL;2021-02-20 00:00:00;sub-1;NULL -30;0;NULL;2021-02-20 00:00:00;sub-1;NULL -32;1;NULL;2021-02-20 00:00:00;sub-1;NULL -33;0;NULL;2021-02-20 00:00:00;sub-1;NULL -34;0;NULL;2021-02-20 00:00:00;sub-1;NULL -35;0;NULL;2021-02-20 00:00:00;sub-1;NULL -36;0;NULL;2021-02-20 00:00:00;sub-1;NULL -37;0;NULL;2021-02-20 00:00:00;sub-1;NULL -38;0;NULL;2021-02-20 00:00:00;sub-1;NULL -39;0;NULL;2021-02-20 00:00:00;sub-1;NULL -40;3;NULL;2021-02-20 00:00:00;sub-1;NULL -41;0;NULL;2021-02-20 00:00:00;sub-1;NULL -42;0;NULL;2021-02-20 00:00:00;sub-1;NULL -43;0;NULL;2021-02-20 00:00:00;sub-1;NULL -44;0;NULL;2021-02-20 00:00:00;sub-1;NULL -45;0;NULL;2021-02-20 00:00:00;sub-1;NULL -46;0;NULL;2021-02-20 00:00:00;sub-1;NULL -47;0;NULL;2021-02-20 00:00:00;sub-1;NULL -48;1;NULL;2021-02-20 00:00:00;sub-1;NULL -49;1;NULL;2021-02-20 00:00:00;sub-1;NULL -50;1;NULL;2021-02-20 00:00:00;sub-1;NULL -51;0;NULL;2021-02-20 00:00:00;sub-1;NULL -52;0;NULL;2021-02-20 00:00:00;sub-1;NULL -53;0;NULL;2021-02-20 00:00:00;sub-1;NULL -54;3;NULL;2021-02-20 00:00:00;sub-1;NULL -55;5;NULL;2021-02-20 00:00:00;sub-1;NULL -56;2;NULL;2021-02-20 00:00:00;sub-1;NULL -57;0;NULL;2021-02-20 00:00:00;sub-1;NULL -58;3;NULL;2021-02-20 00:00:00;sub-1;NULL -59;2;NULL;2021-02-20 00:00:00;sub-1;NULL -61;3;NULL;2021-02-20 00:00:00;sub-1;NULL -62;3;NULL;2021-02-20 00:00:00;sub-1;NULL -63;3;NULL;2021-02-20 00:00:00;sub-1;NULL -64;3;NULL;2021-02-20 00:00:00;sub-1;NULL -67;3;NULL;2021-02-20 00:00:00;sub-1;NULL -68;4;NULL;2021-02-20 00:00:00;sub-1;NULL -69;3;NULL;2021-02-20 00:00:00;sub-1;NULL -70;4;NULL;2021-02-20 00:00:00;sub-1;NULL -73;1;NULL;2021-02-20 00:00:00;sub-1;NULL -74;1;NULL;2021-02-20 00:00:00;sub-1;NULL -77;3;NULL;2021-02-20 00:00:00;sub-1;NULL -78;4;NULL;2021-02-20 00:00:00;sub-1;NULL -79;4;NULL;2021-02-20 00:00:00;sub-1;NULL -80;2;NULL;2021-02-20 00:00:00;sub-1;NULL -83;1;NULL;2021-02-20 00:00:00;sub-1;NULL -84;1;NULL;2021-02-20 00:00:00;sub-1;NULL -87;2;NULL;2021-02-20 00:00:00;sub-1;NULL -88;2;NULL;2021-02-20 00:00:00;sub-1;NULL -89;2;NULL;2021-02-20 00:00:00;sub-1;NULL -90;2;NULL;2021-02-20 00:00:00;sub-1;NULL -93;3;NULL;2021-02-20 00:00:00;sub-1;NULL -94;3;NULL;2021-02-20 00:00:00;sub-1;NULL -95;3;NULL;2021-02-20 00:00:00;sub-1;NULL -96;1;NULL;2021-02-20 00:00:00;sub-1;NULL -99;2;NULL;2021-02-20 00:00:00;sub-1;NULL -100;2;NULL;2021-02-20 00:00:00;sub-1;NULL -103;3;NULL;2021-02-20 00:00:00;sub-1;NULL -104;2;NULL;2021-02-20 00:00:00;sub-1;NULL -105;3;NULL;2021-02-20 00:00:00;sub-1;NULL -106;2;NULL;2021-02-20 00:00:00;sub-1;NULL -107;1;NULL;2021-02-20 00:00:00;sub-1;NULL -108;1;NULL;2021-02-20 00:00:00;sub-1;NULL -109;2;NULL;2021-02-20 00:00:00;sub-1;NULL -110;3;NULL;2021-02-20 00:00:00;sub-1;NULL -111;2;NULL;2021-02-20 00:00:00;sub-1;NULL -112;2;NULL;2021-02-20 00:00:00;sub-1;NULL -113;3;NULL;2021-02-20 00:00:00;sub-1;NULL -114;0;NULL;2021-02-20 00:00:00;sub-1;NULL -115;1;NULL;2021-02-20 00:00:00;sub-1;NULL -116;1;NULL;2021-02-20 00:00:00;sub-1;NULL -117;1;NULL;2021-02-20 00:00:00;sub-1;NULL -118;1;NULL;2021-02-20 00:00:00;sub-1;NULL -119;1;NULL;2021-02-20 00:00:00;sub-1;NULL -120;3;NULL;2021-02-20 00:00:00;sub-1;NULL -121;3;NULL;2021-02-20 00:00:00;sub-1;NULL -122;1;NULL;2021-02-20 00:00:00;sub-1;NULL -123;1;NULL;2021-02-20 00:00:00;sub-1;NULL -61;3;NULL;2021-06-20 00:00:00;sub-1;NULL -62;3;NULL;2021-06-20 00:00:00;sub-1;NULL -63;3;NULL;2021-06-20 00:00:00;sub-1;NULL -64;3;NULL;2021-06-20 00:00:00;sub-1;NULL -67;3;NULL;2021-06-20 00:00:00;sub-1;NULL -68;3;NULL;2021-06-20 00:00:00;sub-1;NULL -69;4;NULL;2021-06-20 00:00:00;sub-1;NULL -70;3;NULL;2021-06-20 00:00:00;sub-1;NULL -73;4;NULL;2021-06-20 00:00:00;sub-1;NULL -74;1;NULL;2021-06-20 00:00:00;sub-1;NULL -77;1;NULL;2021-06-20 00:00:00;sub-1;NULL -78;3;NULL;2021-06-20 00:00:00;sub-1;NULL -79;4;NULL;2021-06-20 00:00:00;sub-1;NULL -80;4;NULL;2021-06-20 00:00:00;sub-1;NULL -83;2;NULL;2021-06-20 00:00:00;sub-1;NULL -84;1;NULL;2021-06-20 00:00:00;sub-1;NULL -87;1;NULL;2021-06-20 00:00:00;sub-1;NULL -88;2;NULL;2021-06-20 00:00:00;sub-1;NULL -89;2;NULL;2021-06-20 00:00:00;sub-1;NULL -90;2;NULL;2021-06-20 00:00:00;sub-1;NULL -93;2;NULL;2021-06-20 00:00:00;sub-1;NULL -94;3;NULL;2021-06-20 00:00:00;sub-1;NULL -95;3;NULL;2021-06-20 00:00:00;sub-1;NULL -96;3;NULL;2021-06-20 00:00:00;sub-1;NULL -99;1;NULL;2021-06-20 00:00:00;sub-1;NULL -100;2;NULL;2021-06-20 00:00:00;sub-1;NULL -103;2;NULL;2021-06-20 00:00:00;sub-1;NULL -104;3;NULL;2021-06-20 00:00:00;sub-1;NULL -105;2;NULL;2021-06-20 00:00:00;sub-1;NULL -106;3;NULL;2021-06-20 00:00:00;sub-1;NULL -107;2;NULL;2021-06-20 00:00:00;sub-1;NULL -108;1;NULL;2021-06-20 00:00:00;sub-1;NULL -109;1;NULL;2021-06-20 00:00:00;sub-1;NULL -110;2;NULL;2021-06-20 00:00:00;sub-1;NULL -111;3;NULL;2021-06-20 00:00:00;sub-1;NULL -112;2;NULL;2021-06-20 00:00:00;sub-1;NULL -113;2;NULL;2021-06-20 00:00:00;sub-1;NULL -114;3;NULL;2021-06-20 00:00:00;sub-1;NULL -115;0;NULL;2021-06-20 00:00:00;sub-1;NULL -116;1;NULL;2021-06-20 00:00:00;sub-1;NULL -117;1;NULL;2021-06-20 00:00:00;sub-1;NULL -118;1;NULL;2021-06-20 00:00:00;sub-1;NULL -119;1;NULL;2021-06-20 00:00:00;sub-1;NULL -120;1;NULL;2021-06-20 00:00:00;sub-1;NULL -121;3;NULL;2021-06-20 00:00:00;sub-1;NULL -122;3;NULL;2021-06-20 00:00:00;sub-1;NULL -123;0;NULL;2021-06-20 00:00:00;sub-1;NULL -19;0;NULL;2021-09-20 00:00:00;sub-1;NULL -20;0;NULL;2021-09-20 00:00:00;sub-1;NULL -24;1;NULL;2021-09-20 00:00:00;sub-1;NULL -25;1;NULL;2021-09-20 00:00:00;sub-1;NULL -26;0;NULL;2021-09-20 00:00:00;sub-1;NULL -27;0;NULL;2021-09-20 00:00:00;sub-1;NULL -28;0;NULL;2021-09-20 00:00:00;sub-1;NULL -29;0;NULL;2021-09-20 00:00:00;sub-1;NULL -30;0;NULL;2021-09-20 00:00:00;sub-1;NULL -32;1;NULL;2021-09-20 00:00:00;sub-1;NULL -33;0;NULL;2021-09-20 00:00:00;sub-1;NULL -34;0;NULL;2021-09-20 00:00:00;sub-1;NULL -35;0;NULL;2021-09-20 00:00:00;sub-1;NULL -36;0;NULL;2021-09-20 00:00:00;sub-1;NULL -37;0;NULL;2021-09-20 00:00:00;sub-1;NULL -38;0;NULL;2021-09-20 00:00:00;sub-1;NULL -39;0;NULL;2021-09-20 00:00:00;sub-1;NULL -40;3;NULL;2021-09-20 00:00:00;sub-1;NULL -41;0;NULL;2021-09-20 00:00:00;sub-1;NULL -42;0;NULL;2021-09-20 00:00:00;sub-1;NULL -43;0;NULL;2021-09-20 00:00:00;sub-1;NULL -44;0;NULL;2021-09-20 00:00:00;sub-1;NULL -45;0;NULL;2021-09-20 00:00:00;sub-1;NULL -46;0;NULL;2021-09-20 00:00:00;sub-1;NULL -47;0;NULL;2021-09-20 00:00:00;sub-1;NULL -50;1;NULL;2021-09-20 00:00:00;sub-1;NULL -51;0;NULL;2021-09-20 00:00:00;sub-1;NULL -52;0;NULL;2021-09-20 00:00:00;sub-1;NULL -53;0;NULL;2021-09-20 00:00:00;sub-1;NULL -54;3;NULL;2021-09-20 00:00:00;sub-1;NULL -58;3;NULL;2021-09-20 00:00:00;sub-1;NULL -59;2;NULL;2021-09-20 00:00:00;sub-1;NULL -61;3;NULL;2021-09-20 00:00:00;sub-1;NULL -62;3;NULL;2021-09-20 00:00:00;sub-1;NULL -63;2;NULL;2021-09-20 00:00:00;sub-1;NULL -64;3;NULL;2021-09-20 00:00:00;sub-1;NULL -67;4;NULL;2021-09-20 00:00:00;sub-1;NULL -68;3;NULL;2021-09-20 00:00:00;sub-1;NULL -69;4;NULL;2021-09-20 00:00:00;sub-1;NULL -70;3;NULL;2021-09-20 00:00:00;sub-1;NULL -73;4;NULL;2021-09-20 00:00:00;sub-1;NULL -74;1;NULL;2021-09-20 00:00:00;sub-1;NULL -77;1;NULL;2021-09-20 00:00:00;sub-1;NULL -78;3;NULL;2021-09-20 00:00:00;sub-1;NULL -79;4;NULL;2021-09-20 00:00:00;sub-1;NULL -80;4;NULL;2021-09-20 00:00:00;sub-1;NULL -83;2;NULL;2021-09-20 00:00:00;sub-1;NULL -84;1;NULL;2021-09-20 00:00:00;sub-1;NULL -87;1;NULL;2021-09-20 00:00:00;sub-1;NULL -88;2;NULL;2021-09-20 00:00:00;sub-1;NULL -89;2;NULL;2021-09-20 00:00:00;sub-1;NULL -90;2;NULL;2021-09-20 00:00:00;sub-1;NULL -93;2;NULL;2021-09-20 00:00:00;sub-1;NULL -94;3;NULL;2021-09-20 00:00:00;sub-1;NULL -95;3;NULL;2021-09-20 00:00:00;sub-1;NULL -96;3;NULL;2021-09-20 00:00:00;sub-1;NULL -99;1;NULL;2021-09-20 00:00:00;sub-1;NULL -100;2;NULL;2021-09-20 00:00:00;sub-1;NULL -103;2;NULL;2021-09-20 00:00:00;sub-1;NULL -104;3;NULL;2021-09-20 00:00:00;sub-1;NULL -105;2;NULL;2021-09-20 00:00:00;sub-1;NULL -106;2;NULL;2021-09-20 00:00:00;sub-1;NULL -107;1;NULL;2021-09-20 00:00:00;sub-1;NULL -108;4;NULL;2021-09-20 00:00:00;sub-1;NULL -109;2;NULL;2021-09-20 00:00:00;sub-1;NULL -110;1;NULL;2021-09-20 00:00:00;sub-1;NULL -111;3;NULL;2021-09-20 00:00:00;sub-1;NULL -112;2;NULL;2021-09-20 00:00:00;sub-1;NULL -113;2;NULL;2021-09-20 00:00:00;sub-1;NULL -114;3;NULL;2021-09-20 00:00:00;sub-1;NULL -115;0;NULL;2021-09-20 00:00:00;sub-1;NULL -116;1;NULL;2021-09-20 00:00:00;sub-1;NULL -117;1;NULL;2021-09-20 00:00:00;sub-1;NULL -118;1;NULL;2021-09-20 00:00:00;sub-1;NULL -119;3;NULL;2021-09-20 00:00:00;sub-1;NULL -120;2;NULL;2021-09-20 00:00:00;sub-1;NULL -121;3;NULL;2021-09-20 00:00:00;sub-1;NULL -122;3;NULL;2021-09-20 00:00:00;sub-1;NULL -123;0;NULL;2021-09-20 00:00:00;sub-1;NULL -61;2;NULL;2021-12-20 00:00:00;sub-1;NULL -62;2;NULL;2021-12-20 00:00:00;sub-1;NULL -63;1;NULL;2021-12-20 00:00:00;sub-1;NULL -64;1;NULL;2021-12-20 00:00:00;sub-1;NULL -67;2;NULL;2021-12-20 00:00:00;sub-1;NULL -68;5;NULL;2021-12-20 00:00:00;sub-1;NULL -69;5;NULL;2021-12-20 00:00:00;sub-1;NULL -70;4;NULL;2021-12-20 00:00:00;sub-1;NULL -73;5;NULL;2021-12-20 00:00:00;sub-1;NULL -74;2;NULL;2021-12-20 00:00:00;sub-1;NULL -77;2;NULL;2021-12-20 00:00:00;sub-1;NULL -78;3;NULL;2021-12-20 00:00:00;sub-1;NULL -79;4;NULL;2021-12-20 00:00:00;sub-1;NULL -80;4;NULL;2021-12-20 00:00:00;sub-1;NULL -83;2;NULL;2021-12-20 00:00:00;sub-1;NULL -84;5;NULL;2021-12-20 00:00:00;sub-1;NULL -87;4;NULL;2021-12-20 00:00:00;sub-1;NULL -88;1;NULL;2021-12-20 00:00:00;sub-1;NULL -89;1;NULL;2021-12-20 00:00:00;sub-1;NULL -90;1;NULL;2021-12-20 00:00:00;sub-1;NULL -93;1;NULL;2021-12-20 00:00:00;sub-1;NULL -94;3;NULL;2021-12-20 00:00:00;sub-1;NULL -95;3;NULL;2021-12-20 00:00:00;sub-1;NULL -96;3;NULL;2021-12-20 00:00:00;sub-1;NULL -99;1;NULL;2021-12-20 00:00:00;sub-1;NULL -100;4;NULL;2021-12-20 00:00:00;sub-1;NULL -103;4;NULL;2021-12-20 00:00:00;sub-1;NULL -104;7;NULL;2021-12-20 00:00:00;sub-1;NULL -105;2;NULL;2021-12-20 00:00:00;sub-1;NULL -106;2;NULL;2021-12-20 00:00:00;sub-1;NULL -107;1;NULL;2021-12-20 00:00:00;sub-1;NULL -108;1;NULL;2021-12-20 00:00:00;sub-1;NULL -109;2;NULL;2021-12-20 00:00:00;sub-1;NULL -110;1;NULL;2021-12-20 00:00:00;sub-1;NULL -111;4;NULL;2021-12-20 00:00:00;sub-1;NULL -112;4;NULL;2021-12-20 00:00:00;sub-1;NULL -113;4;NULL;2021-12-20 00:00:00;sub-1;NULL -114;3;NULL;2021-12-20 00:00:00;sub-1;NULL -115;0;NULL;2021-12-20 00:00:00;sub-1;NULL -116;4;NULL;2021-12-20 00:00:00;sub-1;NULL -117;4;NULL;2021-12-20 00:00:00;sub-1;NULL -118;1;NULL;2021-12-20 00:00:00;sub-1;NULL -119;4;NULL;2021-12-20 00:00:00;sub-1;NULL -120;3;NULL;2021-12-20 00:00:00;sub-1;NULL -121;4;NULL;2021-12-20 00:00:00;sub-1;NULL -122;4;NULL;2021-12-20 00:00:00;sub-1;NULL -123;1;NULL;2021-12-20 00:00:00;sub-1;NULL -4;176;NULL;2022-02-20 00:00:00;sub-1;NULL -5;82;NULL;2022-02-20 00:00:00;sub-1;NULL -7;1;NULL;2022-02-20 00:00:00;sub-1;NULL -8;10990;NULL;2022-02-20 00:00:00;sub-1;NULL -9;2;NULL;2022-02-20 00:00:00;sub-1;NULL -12;1;NULL;2022-02-20 00:00:00;sub-1;NULL -13;3;NULL;2022-02-20 00:00:00;sub-1;NULL -19;0;NULL;2022-02-20 00:00:00;sub-1;NULL -20;0;NULL;2022-02-20 00:00:00;sub-1;NULL -24;1;NULL;2022-02-20 00:00:00;sub-1;NULL -25;1;NULL;2022-02-20 00:00:00;sub-1;NULL -26;0;NULL;2022-02-20 00:00:00;sub-1;NULL -27;0;NULL;2022-02-20 00:00:00;sub-1;NULL -28;0;NULL;2022-02-20 00:00:00;sub-1;NULL -29;0;NULL;2022-02-20 00:00:00;sub-1;NULL -30;0;NULL;2022-02-20 00:00:00;sub-1;NULL -32;1;NULL;2022-02-20 00:00:00;sub-1;NULL -33;0;NULL;2022-02-20 00:00:00;sub-1;NULL -34;0;NULL;2022-02-20 00:00:00;sub-1;NULL -35;0;NULL;2022-02-20 00:00:00;sub-1;NULL -36;0;NULL;2022-02-20 00:00:00;sub-1;NULL -37;0;NULL;2022-02-20 00:00:00;sub-1;NULL -38;0;NULL;2022-02-20 00:00:00;sub-1;NULL -39;0;NULL;2022-02-20 00:00:00;sub-1;NULL -40;3;NULL;2022-02-20 00:00:00;sub-1;NULL -41;0;NULL;2022-02-20 00:00:00;sub-1;NULL -42;0;NULL;2022-02-20 00:00:00;sub-1;NULL -43;0;NULL;2022-02-20 00:00:00;sub-1;NULL -44;0;NULL;2022-02-20 00:00:00;sub-1;NULL -45;0;NULL;2022-02-20 00:00:00;sub-1;NULL -46;0;NULL;2022-02-20 00:00:00;sub-1;NULL -47;0;NULL;2022-02-20 00:00:00;sub-1;NULL -48;1;NULL;2022-02-20 00:00:00;sub-1;NULL -49;1;NULL;2022-02-20 00:00:00;sub-1;NULL -50;2;NULL;2022-02-20 00:00:00;sub-1;NULL -51;1;NULL;2022-02-20 00:00:00;sub-1;NULL -52;0;NULL;2022-02-20 00:00:00;sub-1;NULL -53;0;NULL;2022-02-20 00:00:00;sub-1;NULL -54;2;NULL;2022-02-20 00:00:00;sub-1;NULL -55;2;NULL;2022-02-20 00:00:00;sub-1;NULL -56;2;NULL;2022-02-20 00:00:00;sub-1;NULL -57;0;NULL;2022-02-20 00:00:00;sub-1;NULL -58;2;NULL;2022-02-20 00:00:00;sub-1;NULL -59;2;NULL;2022-02-20 00:00:00;sub-1;NULL -61;4;NULL;2022-02-20 00:00:00;sub-1;NULL -62;4;NULL;2022-02-20 00:00:00;sub-1;NULL -63;3;NULL;2022-02-20 00:00:00;sub-1;NULL -64;4;NULL;2022-02-20 00:00:00;sub-1;NULL -67;5;NULL;2022-02-20 00:00:00;sub-1;NULL -68;3;NULL;2022-02-20 00:00:00;sub-1;NULL -69;3;NULL;2022-02-20 00:00:00;sub-1;NULL -70;3;NULL;2022-02-20 00:00:00;sub-1;NULL -73;3;NULL;2022-02-20 00:00:00;sub-1;NULL -74;4;NULL;2022-02-20 00:00:00;sub-1;NULL -77;4;NULL;2022-02-20 00:00:00;sub-1;NULL -78;2;NULL;2022-02-20 00:00:00;sub-1;NULL -79;2;NULL;2022-02-20 00:00:00;sub-1;NULL -80;2;NULL;2022-02-20 00:00:00;sub-1;NULL -83;2;NULL;2022-02-20 00:00:00;sub-1;NULL -84;2;NULL;2022-02-20 00:00:00;sub-1;NULL -87;1;NULL;2022-02-20 00:00:00;sub-1;NULL -88;4;NULL;2022-02-20 00:00:00;sub-1;NULL -89;2;NULL;2022-02-20 00:00:00;sub-1;NULL -90;3;NULL;2022-02-20 00:00:00;sub-1;NULL -93;4;NULL;2022-02-20 00:00:00;sub-1;NULL -94;3;NULL;2022-02-20 00:00:00;sub-1;NULL -95;3;NULL;2022-02-20 00:00:00;sub-1;NULL -96;3;NULL;2022-02-20 00:00:00;sub-1;NULL -99;1;NULL;2022-02-20 00:00:00;sub-1;NULL -100;3;NULL;2022-02-20 00:00:00;sub-1;NULL -103;3;NULL;2022-02-20 00:00:00;sub-1;NULL -104;5;NULL;2022-02-20 00:00:00;sub-1;NULL -105;2;NULL;2022-02-20 00:00:00;sub-1;NULL -106;2;NULL;2022-02-20 00:00:00;sub-1;NULL -107;2;NULL;2022-02-20 00:00:00;sub-1;NULL -108;1;NULL;2022-02-20 00:00:00;sub-1;NULL -109;1;NULL;2022-02-20 00:00:00;sub-1;NULL -110;1;NULL;2022-02-20 00:00:00;sub-1;NULL -111;5;NULL;2022-02-20 00:00:00;sub-1;NULL -112;3;NULL;2022-02-20 00:00:00;sub-1;NULL -113;2;NULL;2022-02-20 00:00:00;sub-1;NULL -114;4;NULL;2022-02-20 00:00:00;sub-1;NULL -115;0;NULL;2022-02-20 00:00:00;sub-1;NULL -116;5;NULL;2022-02-20 00:00:00;sub-1;NULL -117;5;NULL;2022-02-20 00:00:00;sub-1;NULL -118;4;NULL;2022-02-20 00:00:00;sub-1;NULL -119;5;NULL;2022-02-20 00:00:00;sub-1;NULL -120;4;NULL;2022-02-20 00:00:00;sub-1;NULL -121;5;NULL;2022-02-20 00:00:00;sub-1;NULL -122;4;NULL;2022-02-20 00:00:00;sub-1;NULL -123;0;NULL;2022-02-20 00:00:00;sub-1;NULL +subject;topic;category;variable;value_numeric;value_textual;date;end_date +sub-1;questionnaire_answer;baseline_questions;Perceived_Pain_Score;5;NULL;2021-02-20 00:00:00;NULL +sub-1;questionnaire_answer;followup_questions;Name_Of_Physician;NULL;Dr.J.Adams;2021-02-20 00:00:00;NULL +sub-2;questionnaire_answer;baseline_questions;Perceived_Pain_Score;2;NULL;2021-02-20 00:00:00;NULL +sub-2;questionnaire_answer;followup_questions;Name_Of_Physician;NULL;Dr.G.Washington;2022-05-20 00:00:00;NULL +sub-1;phone_battery_level;NULL;batteryLevel;5;NULL;2021-02-20 00:00:00;NULL +sub-1;phone_battery_level;NULL;status;NULL;CHARGING;2021-02-20 00:00:00;NULL +sub-2;phone_battery_level;NULL;batteryLevel;10;NULL;2021-02-20 00:00:00;NULL +sub-2;phone_battery_level;NULL;status;NULL;FULL;2021-02-20 00:00:00;NULL diff --git a/data-dashboard-backend/src/main/resources/db/changelog/changes/20220321-variables.csv b/data-dashboard-backend/src/main/resources/db/changelog/changes/20220321-variables.csv deleted file mode 100644 index 5d6a8f4..0000000 --- a/data-dashboard-backend/src/main/resources/db/changelog/changes/20220321-variables.csv +++ /dev/null @@ -1,124 +0,0 @@ -id;category;name;type;date_type -1;Registration;PATCONSENT1;boolean;LOCAL_DATE -2;Sociodemographics;YearOfBirth;year;LOCAL_DATE -3;Sociodemographics;SEX;number;LOCAL_DATE -4;Sociodemographics;HEIGHTPAT;number;LOCAL_DATE -5;Sociodemographics;WEIGHTPAT;number;LOCAL_DATE -6;Sociodemographics;EducationLevel;number;LOCAL_DATE -7;Sociodemographics;LivingArrangements;number;LOCAL_DATE -8;Sociodemographics;ZIPCODE;number;LOCAL_DATE -9;Medical History;DIABTYPEPAT;number;LOCAL_DATE -10;Medical History;YODIAG;year;LOCAL_DATE -11;Medical History;DMFAM;number;LOCAL_DATE -12;Medical History;CARDIOACUTE;number;LOCAL_DATE -13;Medical History;STROKEACUTE;number;LOCAL_DATE -14;Medical History;CHDPAT;number;LOCAL_DATE -15;Medical History;HFPAT;number;LOCAL_DATE -16;Medical History;CKD;number;LOCAL_DATE -17;Medical History;DMRETINO;number;LOCAL_DATE -18;Medical History;DMMACU;number;LOCAL_DATE -19;Medical History;LULLCPAT;number;LOCAL_DATE -20;Medical History;LLAMPPAT;number;LOCAL_DATE -21;Medical History;EDPAT;number;LOCAL_DATE -22;Medical History;PERIODONPAT;number;LOCAL_DATE -23;Medical History;NODIABCOM;number;LOCAL_DATE -24;Treatment;TRDIETEXC;number;LOCAL_DATE -25;Treatment;TRTAB;number;LOCAL_DATE -26;Treatment;TRGLP1;number;LOCAL_DATE -27;Treatment;TRLONGINS;number;LOCAL_DATE -28;Treatment;TRSHORTINS;number;LOCAL_DATE -29;Treatment;TRPUMP;number;LOCAL_DATE -30;Treatment;TROTHER;number;LOCAL_DATE -31;Treatment;TRNO;number;LOCAL_DATE -32;Treatment;TRMET;number;LOCAL_DATE -33;Treatment;TRSGLT2;number;LOCAL_DATE -34;Treatment;TRDPP4;number;LOCAL_DATE -35;Treatment;TRSULF;number;LOCAL_DATE -36;Treatment;TRGLINIDE;number;LOCAL_DATE -37;Treatment;TRGLITAZONE;number;LOCAL_DATE -38;Treatment;TRGLYCOSIDASE;number;LOCAL_DATE -39;Treatment;TRDONTKNOW;number;LOCAL_DATE -40;Treatment;GLCMEASURE;number;LOCAL_DATE -41;Treatment;BPLTHEREPAT;number;LOCAL_DATE -42;Treatment;LIPTHERAPAT;number;LOCAL_DATE -43;Treatment;CARDINT;number;LOCAL_DATE -44;Treatment;CARDSURG;number;LOCAL_DATE -45;Treatment;LASER;number;LOCAL_DATE -46;Treatment;DIALYSISPAT;number;LOCAL_DATE -47;Treatment;NOFURTHERTR;number;LOCAL_DATE -48;Examinations;EYEEXAM;number;LOCAL_DATE -49;Examinations;FOOTEXAM;number;LOCAL_DATE -50;Examinations;HYPOSUP;number;LOCAL_DATE -51;Examinations;HYPONOSUP;number;LOCAL_DATE -52;Examinations;DKAHHSPAT;number;LOCAL_DATE -53;Examinations;HYPOANX;number;LOCAL_DATE -54;Health Behavior;SmokingStatus;number;LOCAL_DATE -55;Health Behavior;ALCFREQ1;number;LOCAL_DATE -56;Health Behavior;HEALTYDIET;number;LOCAL_DATE -57;Health Behavior;BINGE;number;LOCAL_DATE -58;Health Behavior;PHYSACTSEN;number;LOCAL_DATE -59;Functional Health Status - Psychosocial;Global01;number;LOCAL_DATE -60;Functional Health Status - Psychosocial;TRANS3MON;number;LOCAL_DATE -61;Functional Health Status - Psychosocial;PFA11;number;LOCAL_DATE -62;Functional Health Status - Psychosocial;PFA21;number;LOCAL_DATE -63;Functional Health Status - Psychosocial;PFA23;number;LOCAL_DATE -64;Functional Health Status - Psychosocial;PFA53;number;LOCAL_DATE -65;Functional Health Status - Psychosocial;PFTHETA;number;LOCAL_DATE -66;Functional Health Status - Psychosocial;PFSE;number;LOCAL_DATE -67;Functional Health Status - Psychosocial;HI7;number;LOCAL_DATE -68;Functional Health Status - Psychosocial;AN3;number;LOCAL_DATE -69;Functional Health Status - Psychosocial;FATEXP41;number;LOCAL_DATE -70;Functional Health Status - Psychosocial;FATEXP40;number;LOCAL_DATE -71;Functional Health Status - Psychosocial;FATTHETA;number;LOCAL_DATE -72;Functional Health Status - Psychosocial;FATSE;number;LOCAL_DATE -73;Functional Health Status - Psychosocial;PC8r;number;LOCAL_DATE -74;Functional Health Status - Psychosocial;PC13r;number;LOCAL_DATE -75;Functional Health Status - Psychosocial;COGTHETA;number;LOCAL_DATE -76;Functional Health Status - Psychosocial;COGSE;number;LOCAL_DATE -77;Functional Health Status - Psychosocial;EDDEP04;number;LOCAL_DATE -78;Functional Health Status - Psychosocial;EDDEP06;number;LOCAL_DATE -79;Functional Health Status - Psychosocial;EDDEP29;number;LOCAL_DATE -80;Functional Health Status - Psychosocial;EDDEP41;number;LOCAL_DATE -81;Functional Health Status - Psychosocial;DEPTHETA;number;LOCAL_DATE -82;Functional Health Status - Psychosocial;DEPSE;number;LOCAL_DATE -83;Functional Health Status - Psychosocial;EDANX01;number;LOCAL_DATE -84;Functional Health Status - Psychosocial;EDANX53;number;LOCAL_DATE -85;Functional Health Status - Psychosocial;ANXTHETA;number;LOCAL_DATE -86;Functional Health Status - Psychosocial;ANXSE;number;LOCAL_DATE -87;Functional Health Status - Psychosocial;SRPPER11_CaPS;number;LOCAL_DATE -88;Functional Health Status - Psychosocial;SRPPER18_CaPS;number;LOCAL_DATE -89;Functional Health Status - Psychosocial;SRPPER23_CaPS;number;LOCAL_DATE -90;Functional Health Status - Psychosocial;SRPPER46_CaPS;number;LOCAL_DATE -91;Functional Health Status - Psychosocial;SFTHETA;number;LOCAL_DATE -92;Functional Health Status - Psychosocial;SFSE;number;LOCAL_DATE -93;Functional Health Status - Psychosocial;Sleep116;number;LOCAL_DATE -94;Functional Health Status - Psychosocial;Sleep20;number;LOCAL_DATE -95;Functional Health Status - Psychosocial;Sleep44;number;LOCAL_DATE -96;Functional Health Status - Psychosocial;Sleep109;number;LOCAL_DATE -97;Functional Health Status - Psychosocial;SLEEPTHETA;number;LOCAL_DATE -98;Functional Health Status - Psychosocial;SLEEPSE;number;LOCAL_DATE -99;Functional Health Status - Psychosocial;PAININ22;number;LOCAL_DATE -100;Functional Health Status - Psychosocial;PAININ31;number;LOCAL_DATE -101;Functional Health Status - Psychosocial;PAINTHETA;number;LOCAL_DATE -102;Functional Health Status - Psychosocial;PAINSE;number;LOCAL_DATE -103;Functional Health Status - Psychosocial;Global07;number;LOCAL_DATE -104;Functional Health Status - Psychosocial;NEUROPAT;number;LOCAL_DATE -105;Functional Health Status - Psychosocial;GISYMP;number;LOCAL_DATE -106;Functional Health Status - Psychosocial;UISYMP;number;LOCAL_DATE -107;Functional Health Status - Psychosocial;ERRECTIL;number;LOCAL_DATE -108;Functional Health Status - Psychosocial;VISIMP;number;LOCAL_DATE -109;Functional Health Status - Psychosocial;EATBEH;number;LOCAL_DATE -110;Functional Health Status - Psychosocial;GLCREG;number;LOCAL_DATE -111;Functional Health Status - Psychosocial;DISSSTRESS;number;LOCAL_DATE -112;Functional Health Status - Psychosocial;GLCSTA;number;LOCAL_DATE -113;Functional Health Status - Psychosocial;THREATSAT;number;LOCAL_DATE -114;Functional Health Status - Psychosocial;GOALACH;number;LOCAL_DATE -115;Functional Health Status - Psychosocial;THERKNOW1;number;LOCAL_DATE -116;Functional Health Status - Psychosocial;THERKNOW2;number;LOCAL_DATE -117;Functional Health Status - Psychosocial;THERKNOW3;number;LOCAL_DATE -118;Functional Health Status - Psychosocial;THERKNOW4;number;LOCAL_DATE -119;Functional Health Status - Psychosocial;THERKNOW5;number;LOCAL_DATE -120;Functional Health Status - Psychosocial;THERAD;number;LOCAL_DATE -121;Functional Health Status - Psychosocial;HCACCESS;number;LOCAL_DATE -122;Functional Health Status - Psychosocial;DISCUTHREAT;number;LOCAL_DATE -123;Functional Health Status - Psychosocial;SUPPTHREAT;number;LOCAL_DATE diff --git a/data-dashboard-backend/src/test/java/org/radarbase/datadashboard/api/DashboardIntegrationTest.kt b/data-dashboard-backend/src/test/java/org/radarbase/datadashboard/api/DashboardIntegrationTest.kt index 40d4501..07ea8a5 100644 --- a/data-dashboard-backend/src/test/java/org/radarbase/datadashboard/api/DashboardIntegrationTest.kt +++ b/data-dashboard-backend/src/test/java/org/radarbase/datadashboard/api/DashboardIntegrationTest.kt @@ -30,6 +30,7 @@ import org.glassfish.jersey.test.spi.TestContainerFactory import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.radarbase.datadashboard.api.config.DashboardApiConfig +import org.radarbase.datadashboard.api.resource.ObservationResource import org.radarbase.jersey.auth.AuthValidator import org.radarbase.jersey.auth.disabled.DisabledAuthValidator import org.radarbase.jersey.config.ConfigLoader @@ -48,6 +49,7 @@ class DashboardIntegrationTest: JerseyTest() { bind(disabledAuthValidator).to(AuthValidator::class.java).ranked(1) } }) + resourceConfig.register(ObservationResource::class.java) return resourceConfig } @@ -69,13 +71,13 @@ class DashboardIntegrationTest: JerseyTest() { @Test fun testGetObservationsNoToken() { - val response = target("subject/sub-1/variables/observations").request().get() + val response = target("subject/sub-1/topic/phone_battery_level/observations").request().get() Assertions.assertEquals(401, response.status) } @Test fun testGetObservationsWithToken() { - val response = target("subject/sub-1/variables/observations") + val response = target("subject/sub-1/topic/phone_battery_level/observations") .request() .header(HttpHeaders.AUTHORIZATION, "Bearer " + "... encoded token ...") .get() diff --git a/data-dashboard-backend/src/test/java/org/radarbase/datadashboard/api/resource/ObservationResourceTest.kt b/data-dashboard-backend/src/test/java/org/radarbase/datadashboard/api/resource/ObservationResourceTest.kt index ad97988..fdcd68c 100644 --- a/data-dashboard-backend/src/test/java/org/radarbase/datadashboard/api/resource/ObservationResourceTest.kt +++ b/data-dashboard-backend/src/test/java/org/radarbase/datadashboard/api/resource/ObservationResourceTest.kt @@ -28,11 +28,11 @@ import org.junit.jupiter.api.Test import org.mockito.Mock import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations -import org.radarbase.datadashboard.api.api.VariableListDto +import org.radarbase.datadashboard.api.api.ObservationListDto import org.radarbase.datadashboard.api.domain.mapper.toDto import org.radarbase.datadashboard.api.domain.model.Observation -import org.radarbase.datadashboard.api.domain.model.Variable import org.radarbase.datadashboard.api.service.ObservationService +import java.time.ZonedDateTime class ObservationResourceTest: JerseyTest() { @@ -40,8 +40,9 @@ class ObservationResourceTest: JerseyTest() { @Mock lateinit var observationService: ObservationService - private lateinit var variableListDto: VariableListDto + private lateinit var observationListDto: ObservationListDto private val subjectId = "sub-1" + private val topicId = "topic-1" override fun configure(): Application { // Initialize all defined Mockito mocks (with @Mock annotation). @@ -60,61 +61,38 @@ class ObservationResourceTest: JerseyTest() { @BeforeEach fun init() { // Create some fake observations that are returned by the service. - // Each observation is linked to a Variable. - val var1 = createVariable(id = 1L, name = "name1") - val var2 = createVariable(id = 2L, name = "name2") - val obs1 = createObservation(id = 1L, variable = var1) - val obs2 = createObservation(id = 2L, variable = var1) - val obs3 = createObservation(id = 1L, variable = var2) - val obs4 = createObservation(id = 2L, variable = var2) + val obs1 = Observation(id = 1L, subject = subjectId, topic = "topic-1", category = "category-1", variable = "variable-1", date = ZonedDateTime.now(), valueTextual = "value1", valueNumeric = null, endDate = null) + val obs2 = Observation(id = 2L, subject = subjectId, topic = "topic-1", category = "category-1", variable = "variable-1", date = ZonedDateTime.now(), valueTextual = "value1", valueNumeric = null, endDate = null) + val obs3 = Observation(id = 3L, subject = subjectId, topic = "topic-1", category = "category-1", variable = "variable-1", date = ZonedDateTime.now(), valueTextual = "value1", valueNumeric = null, endDate = null) + val obs4 = Observation(id = 4L, subject = subjectId, topic = "topic-1", category = "category-1", variable = "variable-1", date = ZonedDateTime.now(), valueTextual = "value1", valueNumeric = null, endDate = null) val observations: List = listOf(obs1, obs2, obs3, obs4) // Create Dto that should be returned by the ObservationService. - variableListDto = VariableListDto( - observations - .groupBy { it.variable } - .map { it.toDto() }, + observationListDto = ObservationListDto( + observations.map { it.toDto() }, ) } @Test fun testGetObservations() { // Instruct the mock to return the fake observations when called. - `when`(observationService.getObservations(subjectId)).thenReturn(variableListDto) + `when`(observationService.getObservations(subjectId = subjectId, topicId = topicId)).thenReturn(observationListDto) // Make the call to the REST endpoint. - val response = target("subject/sub-1/variables/observations").request().get() + val response = target("subject/sub-1/topic/topic-1/observations").request().get() // Expect the http response to be OK and the same as the expected DTO. assertEquals(200, response.status) - assertEquals(variableListDto, response.readEntity(VariableListDto::class.java)) + assertEquals(observationListDto, response.readEntity(ObservationListDto::class.java)) } @Test fun testGetObservations_failNoSubjectId() { - // Make the call to the REST endpoint. - val response = target("subject//variables/observations").request().get() - // Expect the http response to be OK and the same as the expected DTO. + val response = target("subject//topic/topic-1/observations").request().get() assertEquals(404, response.status) } - private fun createVariable(id: Long, name: String): Variable { - return Variable( - id = id, - name = name, - type = "type1", - category = null, - observations = emptyList() - ) - } - - private fun createObservation(id: Long, variable: Variable): Observation { - return Observation( - id = id, - subjectId = "sub-1", - variable = variable, - date = null, - valueTextual = "value1", - valueNumeric = 1.0, - endDate = null - ) + @Test + fun testGetObservations_failNoTopicId() { + val response = target("subject/sub-1/topic//observations").request().get() + assertEquals(404, response.status) } } \ No newline at end of file diff --git a/data-dashboard-backend/src/test/java/org/radarbase/datadashboard/api/service/ObservationServiceTest.kt b/data-dashboard-backend/src/test/java/org/radarbase/datadashboard/api/service/ObservationServiceTest.kt index 6fd99f1..5fb1e1d 100644 --- a/data-dashboard-backend/src/test/java/org/radarbase/datadashboard/api/service/ObservationServiceTest.kt +++ b/data-dashboard-backend/src/test/java/org/radarbase/datadashboard/api/service/ObservationServiceTest.kt @@ -23,14 +23,16 @@ import org.junit.jupiter.api.Test import org.mockito.Mock import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations -import org.radarbase.datadashboard.api.api.VariableListDto +import org.radarbase.datadashboard.api.api.ObservationListDto import org.radarbase.datadashboard.api.domain.ObservationRepository import org.radarbase.datadashboard.api.domain.mapper.toDto import org.radarbase.datadashboard.api.domain.model.Observation -import org.radarbase.datadashboard.api.domain.model.Variable +import java.time.ZonedDateTime class ObservationServiceTest { + val subjectId = "sub-1" + // Create a Mockito mock of the ObservationRepository. This is instantiated in the init block. @Mock private lateinit var observationRepository: ObservationRepository @@ -43,53 +45,31 @@ class ObservationServiceTest { observationService = ObservationService(observationRepository) } + /** This test does not test much (only whether the service calls the repository). + * I made it mainly to document how to write a test with mocking. + * */ @Test fun test_getObservations1() { // Create some fake observations that are returned by the repository. // Each observation is linked to a Variable. - val subjectId = "sub-1" - val var1 = createVariable(id = 1L, name = "name1") - val var2 = createVariable(id = 2L, name = "name2") - val obs1 = createObservation(id = 1L, variable = var1) - val obs2 = createObservation(id = 2L, variable = var1) - val obs3 = createObservation(id = 1L, variable = var2) - val obs4 = createObservation(id = 2L, variable = var2) + val obs1 = Observation(id = 1L, subject = subjectId, topic = "topic-1", category = "category-1", variable = "variable-1", date = ZonedDateTime.now(), valueTextual = "value1", valueNumeric = null, endDate = null) + val obs2 = Observation(id = 2L, subject = subjectId, topic = "topic-1", category = "category-1", variable = "variable-1", date = ZonedDateTime.now(), valueTextual = "value1", valueNumeric = null, endDate = null) + val obs3 = Observation(id = 3L, subject = subjectId, topic = "topic-1", category = "category-1", variable = "variable-1", date = ZonedDateTime.now(), valueTextual = "value1", valueNumeric = null, endDate = null) + val obs4 = Observation(id = 4L, subject = subjectId, topic = "topic-1", category = "category-1", variable = "variable-1", date = ZonedDateTime.now(), valueTextual = "value1", valueNumeric = null, endDate = null) val observations = listOf(obs1, obs2, obs3, obs4) // Mock the repository to return the fake observations. - `when`(observationRepository.getObservations(subjectId)).thenReturn(observations) + `when`(observationRepository.getObservations(subjectId = subjectId, topicId = "topic-1")).thenReturn(observations) // Call the ObservationService (class under test) to get the observations. - val result = observationService.getObservations(subjectId) + val result = observationService.getObservations(subjectId = subjectId, topicId = "topic-1") - // Check if the result is as expected (observations keyed by the Variable). - val expectedDto = VariableListDto( - observations.groupBy { it.variable }.map { it.toDto() } + // Check if the result is as expected (observations transformed to ObservationListDto). + val expectedDto = ObservationListDto( + observations.map { it.toDto() } ) assertEquals(expectedDto, result) } - private fun createVariable(id: Long, name: String): Variable { - return Variable( - id = id, - name = name, - type = "type1", - category = null, - observations = emptyList() - ) - } - - private fun createObservation(id: Long, variable: Variable): Observation { - return Observation( - id = id, - subjectId = "sub-1", - variable = variable, - date = null, - valueTextual = "value1", - valueNumeric = 1.0, - endDate = null - ) - } - } \ No newline at end of file