From 44646058582b482c0c7e0d32cfbecdec6cb5ee97 Mon Sep 17 00:00:00 2001 From: Volker Schmidt Date: Sun, 27 Jan 2019 22:27:18 +0100 Subject: [PATCH] Adjusted minimal event update to DHIS 2.31 handling (may cause conflict otherwise). --- .../program/impl/EventServiceImpl.java | 2 +- .../tracker/program/impl/MinimalEvent.java | 90 ++++++++++++++++++- 2 files changed, 87 insertions(+), 5 deletions(-) diff --git a/dhis/src/main/java/org/dhis2/fhir/adapter/dhis/tracker/program/impl/EventServiceImpl.java b/dhis/src/main/java/org/dhis2/fhir/adapter/dhis/tracker/program/impl/EventServiceImpl.java index 828b2a0a..c7fb1197 100644 --- a/dhis/src/main/java/org/dhis2/fhir/adapter/dhis/tracker/program/impl/EventServiceImpl.java +++ b/dhis/src/main/java/org/dhis2/fhir/adapter/dhis/tracker/program/impl/EventServiceImpl.java @@ -249,7 +249,7 @@ protected Event minimalUpdate( @Nonnull Event event ) return update( event ); } event.getDataValues().stream().filter( DataValue::isModified ).forEach( dv -> - update( new MinimalEvent( event.getId(), dv ) ) ); + update( new MinimalEvent( event, dv ) ) ); return event; } } diff --git a/dhis/src/main/java/org/dhis2/fhir/adapter/dhis/tracker/program/impl/MinimalEvent.java b/dhis/src/main/java/org/dhis2/fhir/adapter/dhis/tracker/program/impl/MinimalEvent.java index ab3ed3a3..9d295fb3 100644 --- a/dhis/src/main/java/org/dhis2/fhir/adapter/dhis/tracker/program/impl/MinimalEvent.java +++ b/dhis/src/main/java/org/dhis2/fhir/adapter/dhis/tracker/program/impl/MinimalEvent.java @@ -1,7 +1,7 @@ package org.dhis2.fhir.adapter.dhis.tracker.program.impl; /* - * Copyright (c) 2004-2018, University of Oslo + * Copyright (c) 2004-2019, University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,7 +29,11 @@ */ import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; import org.dhis2.fhir.adapter.dhis.model.DataValue; +import org.dhis2.fhir.adapter.dhis.tracker.program.Event; +import org.dhis2.fhir.adapter.dhis.tracker.program.EventStatus; import javax.annotation.Nonnull; import java.io.Serializable; @@ -45,13 +49,36 @@ public class MinimalEvent implements Serializable { private static final long serialVersionUID = 1560261589980305347L; - private final String id; + @JsonProperty( "event" ) + @JsonInclude( JsonInclude.Include.NON_NULL ) + private String id; + + @JsonProperty( "orgUnit" ) + private String orgUnitId; + + @JsonProperty( "program" ) + private String programId; + + @JsonProperty( "trackedEntityInstance" ) + @JsonInclude( JsonInclude.Include.NON_NULL ) + private String trackedEntityInstanceId; + + @JsonProperty( "programStage" ) + @JsonInclude( JsonInclude.Include.NON_NULL ) + private String programStageId; + + private EventStatus status; private final List dataValues; - public MinimalEvent( @Nonnull String id, @Nonnull DataValue dataValue ) + public MinimalEvent( @Nonnull Event event, @Nonnull DataValue dataValue ) { - this.id = id; + this.id = event.getId(); + this.orgUnitId = event.getOrgUnitId(); + this.programId = event.getProgramId(); + this.trackedEntityInstanceId = event.getTrackedEntityInstanceId(); + this.programStageId = event.getProgramStageId(); + this.status = event.getStatus(); this.dataValues = Collections.singletonList( dataValue ); } @@ -60,6 +87,61 @@ public String getId() return id; } + public void setId( String id ) + { + this.id = id; + } + + public String getOrgUnitId() + { + return orgUnitId; + } + + public void setOrgUnitId( String orgUnitId ) + { + this.orgUnitId = orgUnitId; + } + + public String getProgramId() + { + return programId; + } + + public void setProgramId( String programId ) + { + this.programId = programId; + } + + public String getTrackedEntityInstanceId() + { + return trackedEntityInstanceId; + } + + public void setTrackedEntityInstanceId( String trackedEntityInstanceId ) + { + this.trackedEntityInstanceId = trackedEntityInstanceId; + } + + public String getProgramStageId() + { + return programStageId; + } + + public void setProgramStageId( String programStageId ) + { + this.programStageId = programStageId; + } + + public EventStatus getStatus() + { + return status; + } + + public void setStatus( EventStatus status ) + { + this.status = status; + } + public List getDataValues() { return dataValues;