Skip to content

Commit

Permalink
make sure the patient summary is exported in a specific order.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Mar 20, 2024
1 parent ea88871 commit 7ceaec0
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 5 deletions.
28 changes: 28 additions & 0 deletions backend/pkg/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type InstallationVerificationStatus string
type InstallationQuotaStatus string

type IPSSections string
type IPSSectionGroups string

const (
ResourceListPageSize int = 20
Expand Down Expand Up @@ -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{
Expand All @@ -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,
},
}
43 changes: 38 additions & 5 deletions backend/pkg/database/gorm_repository_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7ceaec0

Please sign in to comment.