diff --git a/README.md b/README.md index 058caa60..41d6779f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # DHIS2 FHIR Adapter ## Overview This repository contains the source code of the DHIS2 FHIR Adapter. The current scope of the Adapter is to import data into DHIS2 Tracker by using FHIR Subscriptions. Event if the adapter may support more FHIR Resource types at the moment, the initial - official support is for FHIR Patient resources that are transformed to DHIS2 Tracked Entity instances. + official support is for FHIR Patient resources that are transformed to DHIS2 Tracked Entity instances. + +The import works on the basis of a domain specific business rule engine that decides about transformations of medical data to questionnaire-like structures (DHIS2 Tracker Programs and their Program Stages). ![DHIS2 FHIR Adapter High Level Architecture](docs/images/DHIS2_FHIR_Adapter_High_Level_Architecture.png "DHIS2 FHIR Adapter High Level Architecture") diff --git a/app/src/main/java/org/dhis2/fhir/adapter/AppConfig.java b/app/src/main/java/org/dhis2/fhir/adapter/AppConfig.java index 3d09025e..df9680e0 100644 --- a/app/src/main/java/org/dhis2/fhir/adapter/AppConfig.java +++ b/app/src/main/java/org/dhis2/fhir/adapter/AppConfig.java @@ -28,62 +28,31 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; -import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; -import org.dhis2.fhir.adapter.jackson.SecuredPropertyFilter; -import org.dhis2.fhir.adapter.jackson.ToManyPropertyFilter; -import org.dhis2.fhir.adapter.jackson.ToOnePropertyFilter; -import org.dhis2.fhir.adapter.jackson.ZonedDateTimeDeserializer; -import org.dhis2.fhir.adapter.jackson.ZonedDateTimeSerializer; -import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; +import org.dhis2.fhir.adapter.converter.ZonedDateTimeToDateConverter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.core.annotation.Order; +import org.springframework.format.FormatterRegistry; import org.springframework.http.HttpMethod; import org.springframework.validation.annotation.Validated; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import javax.annotation.Nonnull; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; +import java.time.ZonedDateTime; +import java.util.Date; /** + * Common application configuration. + * * @author volsch */ @Configuration @Validated public class AppConfig { - @Bean - @Order( 1 ) - public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() - { - return jacksonObjectMapperBuilder -> { - final ZoneId zoneId = ZoneId.systemDefault(); - jacksonObjectMapperBuilder - .serializers( - new ZonedDateTimeSerializer(), - new LocalDateSerializer( DateTimeFormatter.ISO_LOCAL_DATE ) ) - .deserializers( - new ZonedDateTimeDeserializer(), - new LocalDateDeserializer( DateTimeFormatter.ISO_LOCAL_DATE ) ); - jacksonObjectMapperBuilder.filters( new SimpleFilterProvider() - .addFilter( SecuredPropertyFilter.FILTER_NAME, new SecuredPropertyFilter() ) - .addFilter( ToManyPropertyFilter.FILTER_NAME, new SimpleBeanPropertyFilter() - { - } ) - .addFilter( ToOnePropertyFilter.FILTER_NAME, new SimpleBeanPropertyFilter() - { - } ) ); - }; - } - @Bean @Nonnull - public WebMvcConfigurer corsConfigurer() + public WebMvcConfigurer mvcConfigurer() { return new WebMvcConfigurer() { @@ -95,6 +64,12 @@ public void addCorsMappings( @Nonnull CorsRegistry registry ) .allowedMethods( HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PUT.name(), HttpMethod.PATCH.name(), HttpMethod.DELETE.name(), HttpMethod.HEAD.name(), HttpMethod.OPTIONS.name() ) .allowCredentials( true ); } + + @Override + public void addFormatters( @Nonnull FormatterRegistry registry ) + { + registry.addConverter( ZonedDateTime.class, Date.class, new ZonedDateTimeToDateConverter() ); + } }; } } diff --git a/app/src/main/resources/application.yml b/app/src/main/resources/application.yml index 1ee843c6..85961ac1 100644 --- a/app/src/main/resources/application.yml +++ b/app/src/main/resources/application.yml @@ -27,9 +27,6 @@ # spring: - jackson: - serialization: - write-dates-as-timestamps: false data: rest: basePath: /api @@ -39,6 +36,10 @@ spring: hibernate: ddl-auto: none open-in-view: false + properties: + hibernate: + jdbc: + time_zone: UTC application: name: DHIS2 FHIR Adapter diff --git a/app/src/main/resources/templates/setup.html b/app/src/main/resources/templates/setup.html index f47c9f79..ee6ee763 100644 --- a/app/src/main/resources/templates/setup.html +++ b/app/src/main/resources/templates/setup.html @@ -32,6 +32,10 @@