Created
December 10, 2018 14:16
-
-
Save ivange94/dd9022f6a733cf94612f0b4f3948e673 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Second part of the report: obs summary row | |
{ | |
DataSetRow row = dataSet.getDataSets().get("Obs Summary").iterator().next(); | |
assertThat(row, is(notNullValue())); | |
Map<String, Object> reportDataMap = row.getColumnValuesByKey(); | |
Set<String> colNames = new HashSet<>(reportDataMap.keySet()); | |
colNames.remove(OutpatientConsultationReportManager.col12); | |
{ | |
List<Integer> _25To50yFemalesForAllDiagnosis = (List<Integer>) row | |
.getColumnValue(OutpatientConsultationReportManager.col12); | |
assertThat(_25To50yFemalesForAllDiagnosis, is(notNullValue())); | |
assertThat(_25To50yFemalesForAllDiagnosis.size(), is(2)); | |
assertThat(_25To50yFemalesForAllDiagnosis.contains(77), is(true)); | |
assertThat(_25To50yFemalesForAllDiagnosis.contains(8), is(true)); | |
} | |
colNames.remove(OutpatientConsultationReportManager.col7); | |
{ | |
List<Integer> _5To15yMalesForAllDiagnosis = (List<Integer>) row | |
.getColumnValue(OutpatientConsultationReportManager.col7); | |
assertThat(_5To15yMalesForAllDiagnosis, is(notNullValue())); | |
assertThat(_5To15yMalesForAllDiagnosis.size(), is(5)); | |
Set<Integer> _5To15yMalesForAllDiagnosisWithoutDuplicates = new HashSet<>(_5To15yMalesForAllDiagnosis); | |
assertThat(_5To15yMalesForAllDiagnosisWithoutDuplicates.size(), is(2)); | |
assertThat(_5To15yMalesForAllDiagnosisWithoutDuplicates.contains(2), is(true)); | |
assertThat(_5To15yMalesForAllDiagnosisWithoutDuplicates.contains(6), is(true)); | |
} | |
colNames.remove(OutpatientConsultationReportManager.col23); | |
{ | |
List<Integer> totalDiagnosisRecordsForAllGenders = (List<Integer>) row | |
.getColumnValue(OutpatientConsultationReportManager.col23); | |
assertThat(totalDiagnosisRecordsForAllGenders, is(notNullValue())); | |
assertThat(totalDiagnosisRecordsForAllGenders.size(), is(7)); | |
Set<Integer> totalDiagnosisRecordsForAllGendersWithoutDuplicates = new HashSet<>( | |
totalDiagnosisRecordsForAllGenders); | |
assertThat(totalDiagnosisRecordsForAllGendersWithoutDuplicates.size(), is(4)); | |
assertThat(totalDiagnosisRecordsForAllGendersWithoutDuplicates.contains(6), is(true)); | |
assertThat(totalDiagnosisRecordsForAllGendersWithoutDuplicates.contains(2), is(true)); | |
assertThat(totalDiagnosisRecordsForAllGendersWithoutDuplicates.contains(77), is(true)); | |
assertThat(totalDiagnosisRecordsForAllGendersWithoutDuplicates.contains(8), is(true)); | |
} | |
colNames.remove(OutpatientConsultationReportManager.col20); | |
{ | |
List<Integer> referredToFemales = (List<Integer>) row | |
.getColumnValue(OutpatientConsultationReportManager.col20); | |
assertThat(referredToFemales, is(notNullValue())); | |
assertThat(referredToFemales.size(), is(1)); | |
assertThat(referredToFemales.contains(77), is(true)); | |
} | |
Map<String, List<Integer>> emptyListMap = colNames.stream() | |
.filter(reportDataMap::containsKey) | |
.collect(Collectors.toMap(Function.identity(), colName -> (List<Integer>) reportDataMap.get(colName))); | |
emptyListMap.entrySet().forEach(e -> { | |
List<Integer> result = e.getValue(); | |
assertNotNull(result); | |
assertThat(result, is(0)); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment