Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/FilterSurgeries #59

Merged
merged 12 commits into from
Mar 7, 2024
Merged

Feature/FilterSurgeries #59

merged 12 commits into from
Mar 7, 2024

Conversation

nriedman
Copy link
Contributor

@nriedman nriedman commented Mar 7, 2024

Load robust Surgery data from FHIR Resource and filter procedures using manual filters and LLM reasoning

♻️ Current situation & Problem

At first pass, the SurgeryItem had the following footprint:

struct SurgeryItem: Identifiable {
    var id = UUID()
    var surgeryName: String = ""
    var date: String?
}

To load the surgery from FHIR data into this struct, we had a shallow query that only took the display name and date from the FHIRResource datatype instead of loading the robust data from the Procedures datatype specifically. This looked something like this:

func getProcedures() {
    let procedures = fhirstore.procedures

    for pro in procedures {
        var newEntry = SurgeryItem(surgeryName: pro.displayName)
        
        if let date = pro.date?.formatted() {
            newEntry.date = date
        }
        data.surgeries.append(newEntry)
    }
}

Furthermore, there was no filtering done on the procedures, meaning that the datapoints we displayed included items such as "Medication Reconciliation". Technically, these count as procedures, but we want to filter them out and only keep relevant surgeries.

⚙️ Release Notes

Now, we load data from the Procedure itself, and have access to richer information: notes, complications, status, location, and body sites, as well as more specific date information that allows for operations that span more than one day. See the Documentation section for more information about the specific changes to the SurgeryItem footprint and the new loading function.

Additionally, the function that loads in the surgeries now filters them using a manual filter and LLM reasoning. First, the manual filter excludes all procedures whose display name includes words in a manually curated stopWords list (see inline documentation). Then, the remaining display names are passed to an LLM, which removes extraneous labels such as "(procedure)" and selects which surgeries seem most relevant. This is done with few-shot prompting, and works reasonably well (see in-line documentation). More work is required to fine tune this process for better results.

📚 Documentation

The SurgeryItem now includes more robust information:

struct SurgeryItem: Identifiable {
    var id = UUID()
    var surgeryName: String = ""
    var startDate: String = ""
    var endDate: String = ""
    var status: String = ""
    var location: String = ""
    var notes: [String] = []
    var bodySites: [String] = []
    var complications: [String] = []
}

Note that there will only ever be an endDate if there is also a startDate. Both are optional.
See inline documentation for details about the loading function and filtering.

✅ Testing

This section will be thoroughly tested along with the rest of the code.

📝 Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

@nriedman nriedman changed the title Optimization/LoadSurgeries Feature/FilterSurgeries Mar 7, 2024
Needed to change parameter to be consistent with other files to pass merge tests, once merged with main I will create another PR to fix this.
Copy link

codecov bot commented Mar 7, 2024

Codecov Report

Attention: Patch coverage is 0.89686% with 221 lines in your changes are missing coverage. Please review.

Project coverage is 13.08%. Comparing base (897bd71) to head (451eefb).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #59      +/-   ##
==========================================
- Coverage   13.86%   13.08%   -0.77%     
==========================================
  Files          55       55              
  Lines        2671     2845     +174     
==========================================
+ Hits          370      372       +2     
- Misses       2301     2473     +172     
Files Coverage Δ
Intake/Home.swift 90.59% <100.00%> (+0.12%) ⬆️
Intake/Intake.swift 100.00% <100.00%> (ø)
Intake/Surgery/SurgeryView.swift 0.00% <0.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 897bd71...451eefb. Read the comment docs.

@nriedman nriedman enabled auto-merge (squash) March 7, 2024 23:29
Copy link
Contributor

@zoyagarg zoyagarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIYA

@nriedman nriedman merged commit 52b4aa6 into main Mar 7, 2024
7 checks passed
@nriedman nriedman deleted the feature/filter_surgeries branch March 7, 2024 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants