@@ -27,18 +27,18 @@ class DiseaseSymptomProvider(
2727 flow : Flow <T >,
2828 symptomsExtractor : (T ) -> List <String >,
2929 ): Flow <Pair <T , ImmutableList <Symptom >>> {
30- val symptomsFlow =
30+ val folderFlow =
3131 partyRepository.getLive(partyId).right()
3232 .map { it.settings.language }
3333 .distinctUntilChanged()
34- .flatMapLatest {
35- journal.findByFolder(
36- partyId,
37- translatorFactory.create(it).translate( Str .journal_folder_symptoms),
38- )
39- }
34+ .map { translatorFactory.create(it).translate( Str .journal_folder_symptoms) }
35+
36+ val symptomsFlow =
37+ folderFlow.flatMapLatest { folder ->
38+ journal.findByFolder(partyId, folder )
39+ }
4040
41- return combine(flow, symptomsFlow) { item, allSymptoms ->
41+ return combine(flow, symptomsFlow, folderFlow ) { item, allSymptoms, folder ->
4242 val symptoms = symptomsExtractor(item)
4343
4444 if (symptoms.isEmpty()) {
@@ -47,11 +47,11 @@ class DiseaseSymptomProvider(
4747
4848 val symptomsByName = allSymptoms.associateBy { comparableSymptomName(it.name) }
4949 item to
50- symptoms.map {
50+ symptoms.map { symptom ->
5151 Symptom (
52- it ,
53- symptomsByName[comparableSymptomName(it )]?.id,
54- ( JOURNAL_PATH + listOf (it)).joinToString( " ${JournalEntry .PARENT_SEPARATOR } " ) ,
52+ symptom ,
53+ symptomsByName[comparableSymptomName(symptom )]?.id,
54+ " $folder ${JournalEntry .PARENT_SEPARATOR } $symptom " ,
5555 partyId,
5656 )
5757 }.toImmutableList()
@@ -66,6 +66,5 @@ class DiseaseSymptomProvider(
6666
6767 companion object {
6868 private val SYMPTOM_SPECIFICATION_REGEX = Regex (" \\ ([a-zA-Z ]+\\ )" )
69- private val JOURNAL_PATH = listOf (" Rules" , " Disease and Infection" , " Symptoms" )
7069 }
7170}
0 commit comments