Skip to content

Commit

Permalink
Export transformation of DHIS2 Program to FHIR Plan Definition.
Browse files Browse the repository at this point in the history
Tests are still missing.
  • Loading branch information
volsch committed Jul 24, 2019
1 parent 8fb32c8 commit 8af22e3
Show file tree
Hide file tree
Showing 109 changed files with 1,221 additions and 393 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ protected void expectProgramStageMetadataRequests() throws Exception
.andRespond( withSuccess( IOUtils.resourceToString( "/org/dhis2/fhir/adapter/dhis/test/single-org-unit-OU_1234.json", StandardCharsets.UTF_8 ), MediaType.APPLICATION_JSON ) );
systemDhis2Server.expect( ExpectedCount.between( 0, 1 ), method( HttpMethod.GET ) ).andExpect( header( "Authorization", testConfiguration.getDhis2SystemAuthorization() ) )
.andExpect( requestTo( dhis2BaseUrl + "/api/" + dhis2ApiVersion + "/programs/EPDyQuoRnXk.json?" +
"fields=id,name,code,selectIncidentDatesInFuture,selectEnrollmentDatesInFuture,displayIncidentDate,registration,withoutRegistration,captureCoordinates,trackedEntityType%5Bid%5D,programTrackedEntityAttributes%5Bid,name,valueType,mandatory," +
"allowFutureDate,trackedEntityAttribute%5Bid,name,code,valueType,generated%5D%5D,programStages%5Bid,name,repeatable,captureCoordinates,generatedByEnrollmentDate,minDaysFromStart,programStageDataElements%5Bid,compulsory," +
"fields=id,name,code,description,selectIncidentDatesInFuture,selectEnrollmentDatesInFuture,displayIncidentDate,registration,withoutRegistration,captureCoordinates,trackedEntityType%5Bid%5D,programTrackedEntityAttributes%5Bid,name,valueType," +
"mandatory,allowFutureDate,trackedEntityAttribute%5Bid,name,code,valueType,generated%5D%5D,programStages%5Bid,name,description,repeatable,captureCoordinates,generatedByEnrollmentDate,minDaysFromStart,programStageDataElements%5Bid,compulsory," +
"allowProvidedElsewhere,dataElement%5Bid,name,code,formName,valueType,optionSetValue,optionSet%5Bid,name,options%5Bcode,name%5D%5D%5D%5D%5D" ) )
.andRespond( withSuccess( IOUtils.resourceToString( "/org/dhis2/fhir/adapter/dhis/test/single-program.json", StandardCharsets.UTF_8 ), MediaType.APPLICATION_JSON ) );
systemDhis2Server.expect( ExpectedCount.between( 0, 1 ), method( HttpMethod.GET ) ).andExpect( header( "Authorization", testConfiguration.getDhis2SystemAuthorization() ) )
.andExpect( requestTo( dhis2BaseUrl + "/api/" + dhis2ApiVersion + "/programs.json?paging=false&fields=id,name,code,selectIncidentDatesInFuture,selectEnrollmentDatesInFuture,displayIncidentDate,registration," +
.andExpect( requestTo( dhis2BaseUrl + "/api/" + dhis2ApiVersion + "/programs.json?paging=false&fields=id,name,code,description,selectIncidentDatesInFuture,selectEnrollmentDatesInFuture,displayIncidentDate,registration," +
"withoutRegistration,captureCoordinates,trackedEntityType%5Bid%5D,programTrackedEntityAttributes%5Bid,name,valueType,mandatory,allowFutureDate,trackedEntityAttribute%5Bid,name,code,valueType,generated%5D%5D,programStages%5Bid,name," +
"description," +
"repeatable,captureCoordinates,generatedByEnrollmentDate,minDaysFromStart,programStageDataElements%5Bid,compulsory,allowProvidedElsewhere,dataElement%5Bid,name,code,formName,valueType,optionSetValue,optionSet%5Bid,name,options%5Bcode," +
"name%5D%5D%5D%5D%5D&filter=name:eq:Child%20Programme" ) )
.andRespond( withSuccess( IOUtils.resourceToString( "/org/dhis2/fhir/adapter/dhis/test/default-program.json", StandardCharsets.UTF_8 ), MediaType.APPLICATION_JSON ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

/**
* DSTU3 tests for rest interfaces that access
* DHIS 2 organization units.
* DHIS2 organization units.
*
* @author volsch
*/
Expand Down Expand Up @@ -87,7 +87,7 @@ public void getLocationWithInvalidAuthorization()
}

@Test( expected = ResourceNotFoundException.class )
public void getLocationNotExistsRepeated() throws Exception
public void getLocationNotExistsRepeated()
{
try
{
Expand All @@ -100,7 +100,7 @@ public void getLocationNotExistsRepeated() throws Exception
}
}

private void getLocationNotExists() throws Exception
private void getLocationNotExists()
{
systemDhis2Server.reset();
userDhis2Server.reset();
Expand All @@ -124,7 +124,7 @@ private void getLocationNotExists() throws Exception
}

@Test( expected = ResourceNotFoundException.class )
public void getLocationRuleNotFoundRepeated() throws Exception
public void getLocationRuleNotFoundRepeated()
{
try
{
Expand All @@ -137,7 +137,7 @@ public void getLocationRuleNotFoundRepeated() throws Exception
}
}

private void getLocationRuleNotFound() throws Exception
private void getLocationRuleNotFound()
{
systemDhis2Server.reset();
userDhis2Server.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

/**
* DSTU3 tests for rest interfaces that access
* DHIS 2 program stages. <b>Some methods are executed twice in order to
* DHIS2 program stages. <b>Some methods are executed twice in order to
* verify that no cached data is used without authentication.</b>
*
* @author volsch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

/**
* DSTU3 tests for rest interfaces that access
* DHIS 2 tracked entity instances. <b>Some methods are executed twice in order to
* DHIS2 tracked entity instances. <b>Some methods are executed twice in order to
* verify that no cached data is used without authentication.</b>
*
* @author volsch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

/**
* R4 tests for rest interfaces that access
* DHIS 2 organization units.
* DHIS2 organization units.
*
* @author volsch
*/
Expand Down Expand Up @@ -118,7 +118,7 @@ private void getLocation() throws Exception
}

@Test( expected = ResourceNotFoundException.class )
public void getLocationNotExistsRepeated() throws Exception
public void getLocationNotExistsRepeated()
{
try
{
Expand All @@ -131,7 +131,7 @@ public void getLocationNotExistsRepeated() throws Exception
}
}

private void getLocationNotExists() throws Exception
private void getLocationNotExists()
{
systemDhis2Server.reset();
userDhis2Server.reset();
Expand All @@ -155,7 +155,7 @@ private void getLocationNotExists() throws Exception
}

@Test( expected = ResourceNotFoundException.class )
public void getLocationRuleNotFoundRepeated() throws Exception
public void getLocationRuleNotFoundRepeated()
{
try
{
Expand All @@ -168,7 +168,7 @@ public void getLocationRuleNotFoundRepeated() throws Exception
}
}

private void getLocationRuleNotFound() throws Exception
private void getLocationRuleNotFound()
{
systemDhis2Server.reset();
userDhis2Server.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

/**
* R4 tests for rest interfaces that access
* DHIS 2 program stages. <b>Some methods are executed twice in order to
* DHIS2 program stages. <b>Some methods are executed twice in order to
* verify that no cached data is used without authentication.</b>
*
* @author volsch
Expand Down Expand Up @@ -129,7 +129,7 @@ private void getObservation( boolean skipCached ) throws Exception
Assert.assertEquals( 0, observation.getIdentifier().size() );
Assert.assertEquals( "Patient/JeR2Ul4mZfx", observation.getSubject().getReference() );
Assert.assertEquals( "Organization/ldXIdLNUNEp", observation.getPerformerFirstRep().getReference() );
Assert.assertEquals( "Encounter/ps-deR4kl4mnf7-9d342f13aec146299d654f03fd0e848c", observation.getEncounter().getReference() );
Assert.assertEquals( "Encounter/deR4kl4mnf7", observation.getEncounter().getReference() );

systemDhis2Server.verify();
userDhis2Server.verify();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

/**
* R4 tests for rest interfaces that access
* DHIS 2 tracked entity instances. <b>Some methods are executed twice in order to
* DHIS2 tracked entity instances. <b>Some methods are executed twice in order to
* verify that no cached data is used without authentication.</b>
*
* @author volsch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;

/**
* Tests the transformation of a FHIR CarePlan to a DHIS 2 Program Instance.
* Tests the transformation of a FHIR CarePlan to a DHIS2 Program Instance.
*
* @author volsch
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ public abstract class AbstractEnrollmentTransformationAppTest extends AbstractAp
protected void expectMetadataRequests() throws Exception
{
systemDhis2Server.expect( ExpectedCount.between( 0, 1 ), method( HttpMethod.GET ) ).andExpect( header( "Authorization", testConfiguration.getDhis2SystemAuthorization() ) )
.andExpect( requestTo( dhis2BaseUrl + "/api/" + dhis2ApiVersion + "/programs/EPDyQuoRnXk.json?fields=id,name,code,selectIncidentDatesInFuture,selectEnrollmentDatesInFuture,displayIncidentDate,registration," +
.andExpect( requestTo( dhis2BaseUrl + "/api/" + dhis2ApiVersion + "/programs/EPDyQuoRnXk.json?fields=id,name,code,description,selectIncidentDatesInFuture,selectEnrollmentDatesInFuture,displayIncidentDate,registration," +
"withoutRegistration,captureCoordinates,trackedEntityType%5Bid%5D,programTrackedEntityAttributes%5Bid,name,valueType,mandatory,allowFutureDate,trackedEntityAttribute%5Bid,name,code,valueType,generated%5D%5D,programStages%5Bid,name," +
"repeatable,captureCoordinates,generatedByEnrollmentDate,minDaysFromStart,programStageDataElements%5Bid,compulsory,allowProvidedElsewhere,dataElement%5Bid,name,code,formName,valueType,optionSetValue,optionSet%5Bid,name,options%5Bcode," +
"name%5D%5D%5D%5D%5D" ) )
"description,repeatable,captureCoordinates,generatedByEnrollmentDate,minDaysFromStart,programStageDataElements%5Bid,compulsory,allowProvidedElsewhere,dataElement%5Bid,name,code,formName,valueType,optionSetValue,optionSet%5Bid,name," +
"options%5Bcode,name%5D%5D%5D%5D%5D" ) )
.andRespond( withSuccess( IOUtils.resourceToString( "/org/dhis2/fhir/adapter/dhis/test/single-program.json", StandardCharsets.UTF_8 ), MediaType.APPLICATION_JSON ) );
systemDhis2Server.expect( ExpectedCount.between( 0, 1 ), method( HttpMethod.GET ) ).andExpect( header( "Authorization", testConfiguration.getDhis2SystemAuthorization() ) )
.andExpect( requestTo( dhis2BaseUrl + "/api/" + dhis2ApiVersion + "/programs.json?paging=false&fields=id,name,code,selectIncidentDatesInFuture,selectEnrollmentDatesInFuture,displayIncidentDate,registration,withoutRegistration,captureCoordinates," +
"trackedEntityType%5Bid%5D,programTrackedEntityAttributes%5Bid,name,valueType,mandatory,allowFutureDate,trackedEntityAttribute%5Bid,name,code,valueType,generated%5D%5D,programStages%5Bid,name,repeatable,captureCoordinates," +
"generatedByEnrollmentDate,minDaysFromStart,programStageDataElements%5Bid,compulsory,allowProvidedElsewhere,dataElement%5Bid,name,code,formName,valueType,optionSetValue,optionSet%5Bid,name,options%5Bcode," +
.andExpect( requestTo( dhis2BaseUrl + "/api/" + dhis2ApiVersion + "/programs.json?paging=false&fields=id,name,code,description,selectIncidentDatesInFuture,selectEnrollmentDatesInFuture,displayIncidentDate,registration,withoutRegistration," +
"captureCoordinates," +
"trackedEntityType%5Bid%5D,programTrackedEntityAttributes%5Bid,name,valueType,mandatory,allowFutureDate,trackedEntityAttribute%5Bid,name,code,valueType,generated%5D%5D,programStages%5Bid,name,description,repeatable,captureCoordinates," +
"generatedByEnrollmentDate,minDaysFromStart,programStageDataElements%5Bid,compulsory,allowProvidedElsewhere,dataElement%5Bid,name,code,description,formName,valueType,optionSetValue,optionSet%5Bid,name,options%5Bcode," +
"name%5D%5D%5D%5D%5D&filter=name:eq:Child%20Programme" ) )
.andRespond( withSuccess( IOUtils.resourceToString( "/org/dhis2/fhir/adapter/dhis/test/all-programs.json", StandardCharsets.UTF_8 ), MediaType.APPLICATION_JSON ) );
systemDhis2Server.expect( ExpectedCount.between( 0, 1 ), method( HttpMethod.GET ) ).andExpect( header( "Authorization", testConfiguration.getDhis2SystemAuthorization() ) )
Expand All @@ -73,9 +74,9 @@ protected void expectMetadataRequests() throws Exception
.andRespond( withSuccess( IOUtils.resourceToString( "/org/dhis2/fhir/adapter/dhis/test/default-tracked-entity-type.json", StandardCharsets.UTF_8 ), MediaType.APPLICATION_JSON ) );
systemDhis2Server.expect( ExpectedCount.between( 0, 1 ), method( HttpMethod.GET ) ).andExpect( header( "Authorization", testConfiguration.getDhis2SystemAuthorization() ) )
.andExpect( requestTo( dhis2BaseUrl + "/api/" + dhis2ApiVersion + "/programs.json?paging=false&" +
"fields=id,name,code,selectIncidentDatesInFuture,selectEnrollmentDatesInFuture,displayIncidentDate,registration,withoutRegistration,captureCoordinates,trackedEntityType%5Bid%5D,programTrackedEntityAttributes%5Bid,name,valueType," +
"mandatory,allowFutureDate,trackedEntityAttribute%5Bid,name,code,valueType,generated%5D%5D,programStages%5Bid,name,repeatable,captureCoordinates,generatedByEnrollmentDate,minDaysFromStart,programStageDataElements%5Bid,compulsory," +
"allowProvidedElsewhere,dataElement%5Bid,name,code,formName,valueType,optionSetValue,optionSet%5Bid,name,options%5Bcode,name%5D%5D%5D%5D%5D&filter=name:eq:Child%20Programme" ) )
"fields=id,name,code,description,selectIncidentDatesInFuture,selectEnrollmentDatesInFuture,displayIncidentDate,registration,withoutRegistration,captureCoordinates,trackedEntityType%5Bid%5D,programTrackedEntityAttributes%5Bid,name,valueType," +
"mandatory,allowFutureDate,trackedEntityAttribute%5Bid,name,code,valueType,generated%5D%5D,programStages%5Bid,name,description,repeatable,captureCoordinates,generatedByEnrollmentDate,minDaysFromStart,programStageDataElements%5Bid,compulsory," +
"allowProvidedElsewhere,dataElement%5Bid,name,code,description,formName,valueType,optionSetValue,optionSet%5Bid,name,options%5Bcode,name%5D%5D%5D%5D%5D&filter=name:eq:Child%20Programme" ) )
.andRespond( withSuccess( IOUtils.resourceToString( "/org/dhis2/fhir/adapter/dhis/test/single-program.json", StandardCharsets.UTF_8 ), MediaType.APPLICATION_JSON ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import javax.annotation.Nonnull;

/**
* Tests the transformation of a FHIR Care Plan to a DHIS 2 Program Instance.
* Tests the transformation of a FHIR Care Plan to a DHIS2 Program Instance.
*
* @author volsch
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;

/**
* Tests the transformation of a FHIR Observation to a DHIS 2 Program Stage Instance.
* Tests the transformation of a FHIR Observation to a DHIS2 Program Stage Instance.
*
* @author volsch
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ public abstract class AbstractProgramStageTransformationAppTest extends Abstract
protected void expectMetadataRequests() throws Exception
{
systemDhis2Server.expect( ExpectedCount.between( 0, 1 ), method( HttpMethod.GET ) ).andExpect( header( "Authorization", testConfiguration.getDhis2SystemAuthorization() ) )
.andExpect( requestTo( dhis2BaseUrl + "/api/" + dhis2ApiVersion + "/programs.json?paging=false&fields=id,name,code,selectIncidentDatesInFuture,selectEnrollmentDatesInFuture,displayIncidentDate,registration,withoutRegistration,captureCoordinates," +
"trackedEntityType%5Bid%5D,programTrackedEntityAttributes%5Bid,name,valueType,mandatory,allowFutureDate,trackedEntityAttribute%5Bid,name,code,valueType,generated%5D%5D,programStages%5Bid,name,repeatable,captureCoordinates," +
.andExpect( requestTo( dhis2BaseUrl + "/api/" + dhis2ApiVersion + "/programs.json?paging=false&fields=id,name,code,description,selectIncidentDatesInFuture,selectEnrollmentDatesInFuture,displayIncidentDate,registration,withoutRegistration," +
"captureCoordinates,trackedEntityType%5Bid%5D,programTrackedEntityAttributes%5Bid,name,valueType,mandatory,allowFutureDate,trackedEntityAttribute%5Bid,name,code,valueType,generated%5D%5D,programStages%5Bid,name,description,repeatable," +
"captureCoordinates," +
"generatedByEnrollmentDate,minDaysFromStart,programStageDataElements%5Bid,compulsory,allowProvidedElsewhere,dataElement%5Bid,name,code,formName,valueType,optionSetValue,optionSet%5Bid,name,options%5Bcode," +
"name%5D%5D%5D%5D%5D&filter=name:eq:Child%20Programme" ) )
.andRespond( withSuccess( IOUtils.resourceToString( "/org/dhis2/fhir/adapter/dhis/test/all-programs.json", StandardCharsets.UTF_8 ), MediaType.APPLICATION_JSON ) );
Expand All @@ -68,9 +69,9 @@ protected void expectMetadataRequests() throws Exception
.andRespond( withSuccess( IOUtils.resourceToString( "/org/dhis2/fhir/adapter/dhis/test/default-tracked-entity-type.json", StandardCharsets.UTF_8 ), MediaType.APPLICATION_JSON ) );
systemDhis2Server.expect( ExpectedCount.between( 0, 1 ), method( HttpMethod.GET ) ).andExpect( header( "Authorization", testConfiguration.getDhis2SystemAuthorization() ) )
.andExpect( requestTo( dhis2BaseUrl + "/api/" + dhis2ApiVersion + "/programs.json?paging=false&" +
"fields=id,name,code,selectIncidentDatesInFuture,selectEnrollmentDatesInFuture,displayIncidentDate,registration,withoutRegistration,captureCoordinates,trackedEntityType%5Bid%5D,programTrackedEntityAttributes%5Bid,name,valueType," +
"mandatory,allowFutureDate,trackedEntityAttribute%5Bid,name,code,valueType,generated%5D%5D,programStages%5Bid,name,repeatable,captureCoordinates,generatedByEnrollmentDate,minDaysFromStart,programStageDataElements%5Bid,compulsory," +
"allowProvidedElsewhere,dataElement%5Bid,name,code,formName,valueType,optionSetValue,optionSet%5Bid,name,options%5Bcode,name%5D%5D%5D%5D%5D&filter=name:eq:Child%20Programme" ) )
"fields=id,name,code,description,selectIncidentDatesInFuture,selectEnrollmentDatesInFuture,displayIncidentDate,registration,withoutRegistration,captureCoordinates,trackedEntityType%5Bid%5D,programTrackedEntityAttributes%5Bid,name,valueType," +
"mandatory,allowFutureDate,trackedEntityAttribute%5Bid,name,code,valueType,generated%5D%5D,programStages%5Bid,name,description,repeatable,captureCoordinates,generatedByEnrollmentDate,minDaysFromStart,programStageDataElements%5Bid,compulsory," +
"allowProvidedElsewhere,dataElement%5Bid,name,code,description,formName,valueType,optionSetValue,optionSet%5Bid,name,options%5Bcode,name%5D%5D%5D%5D%5D&filter=name:eq:Child%20Programme" ) )
.andRespond( withSuccess( IOUtils.resourceToString( "/org/dhis2/fhir/adapter/dhis/test/single-program.json", StandardCharsets.UTF_8 ), MediaType.APPLICATION_JSON ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;

/**
* Tests the transformation of a FHIR Questionnaire Response to a DHIS 2 Program Stage Instance.
* Tests the transformation of a FHIR Questionnaire Response to a DHIS2 Program Stage Instance.
*
* @author volsch
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import javax.annotation.Nonnull;

/**
* Tests the transformation of a FHIR Observation to a DHIS 2 Program Stage Instance.
* Tests the transformation of a FHIR Observation to a DHIS2 Program Stage Instance.
*
* @author volsch
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import javax.annotation.Nonnull;

/**
* Tests the transformation of a FHIR Observation to a DHIS 2 Program Stage Instance.
* Tests the transformation of a FHIR Observation to a DHIS2 Program Stage Instance.
*
* @author volsch
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import javax.annotation.Nonnull;

/**
* Tests the transformation of a FHIR Questionnaire Response to a DHIS 2 Program Stage Instance.
* Tests the transformation of a FHIR Questionnaire Response to a DHIS2 Program Stage Instance.
*
* @author volsch
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;

/**
* Tests the transformation of a FHIR patient to a DHIS 2 Tracked Entity.
* Tests the transformation of a FHIR patient to a DHIS2 Tracked Entity.
*
* @author volsch
*/
Expand Down
Loading

0 comments on commit 8af22e3

Please sign in to comment.