diff --git a/backend/pkg/constants.go b/backend/pkg/constants.go index db8a6d75..e09ca457 100644 --- a/backend/pkg/constants.go +++ b/backend/pkg/constants.go @@ -11,6 +11,7 @@ type InstallationVerificationStatus string type InstallationQuotaStatus string type IPSSections string +type IPSSectionGroups string const ( ResourceListPageSize int = 20 @@ -67,6 +68,10 @@ const ( IPSSectionsPlanOfCare IPSSections = "plan_of_care" IPSSectionsFunctionalStatus IPSSections = "functional_status" IPSSectionsAdvanceDirectives IPSSections = "advance_directives" + + IPSSectionGroupsRequired IPSSectionGroups = "required" + IPSSectionGroupsRecommended IPSSectionGroups = "recommended" + IPSSectionGroupsOptional IPSSectionGroups = "optional" ) var IPSSectionsList = []IPSSections{ @@ -85,3 +90,26 @@ var IPSSectionsList = []IPSSections{ IPSSectionsFunctionalStatus, IPSSectionsAdvanceDirectives, } + +var IPSSectionGroupsOrdered = map[IPSSectionGroups][]IPSSections{ + IPSSectionGroupsRequired: []IPSSections{ + IPSSectionsMedicationSummary, + IPSSectionsAllergiesIntolerances, + IPSSectionsProblemList, + }, + IPSSectionGroupsRecommended: []IPSSections{ + IPSSectionsImmunizations, + IPSSectionsHistoryOfProcedures, + IPSSectionsMedicalDevices, + IPSSectionsDiagnosticResults, + }, + IPSSectionGroupsOptional: []IPSSections{ + IPSSectionsVitalSigns, + IPSSectionsHistoryOfIllness, + IPSSectionsPregnancy, + IPSSectionsSocialHistory, + IPSSectionsPlanOfCare, + IPSSectionsFunctionalStatus, + IPSSectionsAdvanceDirectives, + }, +} diff --git a/backend/pkg/database/gorm_repository_summary.go b/backend/pkg/database/gorm_repository_summary.go index 39f49b77..7c599dce 100644 --- a/backend/pkg/database/gorm_repository_summary.go +++ b/backend/pkg/database/gorm_repository_summary.go @@ -68,13 +68,46 @@ func (gr *GormRepository) GetInternationalPatientSummaryExport(ctx context.Conte //Step 2. Create the Composition Section compositionSections := []fhir401.CompositionSection{} - for sectionType, sectionQueryResultsList := range summarySectionQueryResults { - compositionSection, err := generateIPSCompositionSection(narrativeEngine, sectionType, sectionQueryResultsList) - if err != nil { - return exportData, err + + //loop though the various section groups in order (required, recommended, optional) + for ndx, _ := range pkg.IPSSectionGroupsOrdered[pkg.IPSSectionGroupsRequired] { + section := pkg.IPSSectionGroupsOrdered[pkg.IPSSectionGroupsRequired][ndx] + if sectionQueryResultsList, ok := summarySectionQueryResults[section]; ok { + compositionSection, err := generateIPSCompositionSection(narrativeEngine, section, sectionQueryResultsList) + if err != nil { + return exportData, err + } + compositionSections = append(compositionSections, *compositionSection) + } + } + for ndx, _ := range pkg.IPSSectionGroupsOrdered[pkg.IPSSectionGroupsRecommended] { + section := pkg.IPSSectionGroupsOrdered[pkg.IPSSectionGroupsRecommended][ndx] + if sectionQueryResultsList, ok := summarySectionQueryResults[section]; ok { + compositionSection, err := generateIPSCompositionSection(narrativeEngine, section, sectionQueryResultsList) + if err != nil { + return exportData, err + } + compositionSections = append(compositionSections, *compositionSection) } - compositionSections = append(compositionSections, *compositionSection) } + for ndx, _ := range pkg.IPSSectionGroupsOrdered[pkg.IPSSectionGroupsOptional] { + section := pkg.IPSSectionGroupsOrdered[pkg.IPSSectionGroupsOptional][ndx] + if sectionQueryResultsList, ok := summarySectionQueryResults[section]; ok { + compositionSection, err := generateIPSCompositionSection(narrativeEngine, section, sectionQueryResultsList) + if err != nil { + return exportData, err + } + compositionSections = append(compositionSections, *compositionSection) + } + } + + //for sectionType, sectionQueryResultsList := range summarySectionQueryResults { + // compositionSection, err := generateIPSCompositionSection(narrativeEngine, sectionType, sectionQueryResultsList) + // if err != nil { + // return exportData, err + // } + // compositionSections = append(compositionSections, *compositionSection) + //} //TODO: Step 3. Query all the Patient Resources & merge them together