Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

WIP: PeriodUtils and not complete MeasureReport implementation for R4 #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

huzvak
Copy link

@huzvak huzvak commented Aug 12, 2019

D2INT-36

@huzvak huzvak requested a review from volsch August 12, 2019 08:53
{
final Map<String, Object> variables = new HashMap<>( scriptVariables );

final DataValueSet dataValueSet = getResource( fhirClientResource, context, ruleInfo, scriptVariables ).orElse( null );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Block could be moved to version independent abstract class.

}

//------------------------------
if ( ruleInfo.getRule().getDataSetIdLookupScript() == null )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be handled directly in Java code. No data set ID lookup script is required.

// String version = mr.getMeta().getVersionId();

dataValueSet.setId( createArtificialDataValueSetId( mr ) );
dataValueSet.setLastUpdated( lastUpdated );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will most likely be overridden by server.


dataValueSet.setId( createArtificialDataValueSetId( mr ) );
dataValueSet.setLastUpdated( lastUpdated );
dataValueSet.setPeriod( PeriodUtils.getDHIS2PeriodString( mr.getPeriod().getStart(), mr.getPeriod().getEnd() ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IllegalArgumentException that may be thrown by the period utils must be converted into a TransformerDataException.

dataSetId.ifPresent( dataValueSet::setDataSetId );
}

if ( dataValueSet.getDataSetId() == null )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no data set ID could be determined, a TransformerDataException should be thrown.

organizationUnit.ifPresent( ou -> dataValueSet.setOrgUnitId( ou.getId() ) );
}

if ( !organizationUnit.isPresent() )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TransformerDataException should be thrown.


dataValueSet.setId( createArtificialDataValueSetId( mr ) );
dataValueSet.setLastUpdated( lastUpdated );
dataValueSet.setPeriod( PeriodUtils.getDHIS2PeriodString( mr.getPeriod().getStart(), mr.getPeriod().getEnd() ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Period start and end are optional in FHIR. OpenLMIS profile will not be validated by the Adapter (in General profile checking could be added, but this has other advantages/disadavantages).

String periodString = String.valueOf( startDate.getYear() );

//Period is year
if ( totalMonths == 12 )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch could be used instead of if/else.


try
{
if ( Objects.isNull( mr.getPeriod() ) || Objects.isNull( mr.getPeriod().getStart() ) || Objects.isNull( mr.getPeriod().getEnd() ) )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getPeriod() should never be null (contract of HAPI FHIR API, objects and lists and created always, isEmpty() can be used for null check).

{
try
{
String measureUuid = measureReport.getMeasure().substring( 8 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Measure is canonical with a possible complex syntax. Eiteher the URI utils should be used or the utilities that are also able to retrieve the remote measure (see previous private chat).

try
{
String measureUuid = measureReport.getMeasure().substring( 8 );
String locationId = measureReport.getReporter().getReference().substring( 9 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Location ID should be looked up by getOrgUnitId(). See also new transformers for FHIR CarePlan and QuestionnaireResponse (to DHIS2 transformers).


private void transformDataValues( MeasureReport measureReport, DataValueSet dataValueSet, ZonedDateTime lastUpdated )
{
for ( int i = 1; i < measureReport.getGroup().size(); i++ )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make any sense to use this kind of loop instead of the loop over an iterable? And why to skip the first group item???

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants