Conversation
| { | ||
| final Map<String, Object> variables = new HashMap<>( scriptVariables ); | ||
|
|
||
| final DataValueSet dataValueSet = getResource( fhirClientResource, context, ruleInfo, scriptVariables ).orElse( null ); |
There was a problem hiding this comment.
Block could be moved to version independent abstract class.
| } | ||
|
|
||
| //------------------------------ | ||
| if ( ruleInfo.getRule().getDataSetIdLookupScript() == null ) |
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
Will most likely be overridden by server.
|
|
||
| dataValueSet.setId( createArtificialDataValueSetId( mr ) ); | ||
| dataValueSet.setLastUpdated( lastUpdated ); | ||
| dataValueSet.setPeriod( PeriodUtils.getDHIS2PeriodString( mr.getPeriod().getStart(), mr.getPeriod().getEnd() ) ); |
There was a problem hiding this comment.
IllegalArgumentException that may be thrown by the period utils must be converted into a TransformerDataException.
| dataSetId.ifPresent( dataValueSet::setDataSetId ); | ||
| } | ||
|
|
||
| if ( dataValueSet.getDataSetId() == null ) |
There was a problem hiding this comment.
If no data set ID could be determined, a TransformerDataException should be thrown.
| organizationUnit.ifPresent( ou -> dataValueSet.setOrgUnitId( ou.getId() ) ); | ||
| } | ||
|
|
||
| if ( !organizationUnit.isPresent() ) |
There was a problem hiding this comment.
TransformerDataException should be thrown.
|
|
||
| dataValueSet.setId( createArtificialDataValueSetId( mr ) ); | ||
| dataValueSet.setLastUpdated( lastUpdated ); | ||
| dataValueSet.setPeriod( PeriodUtils.getDHIS2PeriodString( mr.getPeriod().getStart(), mr.getPeriod().getEnd() ) ); |
There was a problem hiding this comment.
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 ) |
There was a problem hiding this comment.
Switch could be used instead of if/else.
|
|
||
| try | ||
| { | ||
| if ( Objects.isNull( mr.getPeriod() ) || Objects.isNull( mr.getPeriod().getStart() ) || Objects.isNull( mr.getPeriod().getEnd() ) ) |
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
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++ ) |
There was a problem hiding this comment.
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???
D2INT-36