EHR queries - #103
Open
jeremyestein wants to merge 88 commits into
Open
EHR queries#103jeremyestein wants to merge 88 commits into
jeremyestein wants to merge 88 commits into
Conversation
Introduces new queries for airway and sputum/secretions data, and refactors the flow sheet query to consolidate multiple values into a wider format. A new README documents the overall data extraction goal and the current set of scripts.
Transforms specific lab test results (e.g., CRP, WCC) from a long format into distinct columns using `MAX() FILTER`. This enables direct consumption of lab data in a wider format, simplifying downstream analysis. Additionally, the query is updated to use parameters for `hospital_visit_id` and to include date range filtering, improving its flexibility.
…Claude Sonnet 5.0
jeremyestein
had a problem deploying
to
hasher
September 16, 2026 16:01 — with
GitHub Actions
Failure
jeremyestein
had a problem deploying
to
hasher
September 16, 2026 18:03 — with
GitHub Actions
Failure
jeremyestein
had a problem deploying
to
hasher
September 16, 2026 21:01 — with
GitHub Actions
Failure
test and would require mocking inside the container
way of testing this.
need a fixup Merge branch 'st/get_ehr' into ehr_queries_clean
I can test the rest of the pipeline
skeating
approved these changes
Sep 25, 2026
| ON r.lab_order_id = o.lab_order_id | ||
|
|
||
| WHERE | ||
| r.result_status LIKE 'FINAL' |
Collaborator
There was a problem hiding this comment.
Actually no you could just use =
| "LabCRP", | ||
| "LabWCC", | ||
| ] | ||
|
|
Collaborator
There was a problem hiding this comment.
I had envisioned only recording one column of dateTime - but this is probably something we need feedback on
| ("TubeType", pa.string()), | ||
| ("TubeSize", pa.string()), | ||
| # ("Repositioned", ), | ||
| # ("Position frequency", ), |
Collaborator
There was a problem hiding this comment.
Should these be commented out
Comment on lines
+38
to
+43
| --- | ||
|
|
||
| ## Unfinished scripts | ||
|
|
||
| | script | arguments | record | location of script in repo | database | | ||
| |- | --- | --- |- | --- | |
|
|
||
| | script | arguments | record | location of script in repo | database | | ||
| |- | --- | --- |- | --- | | ||
| | airway.sql | csn/today/yesterday | part of the table above | waveform-private-queries/src/sql | caboodle | |
Collaborator
There was a problem hiding this comment.
This one is no longer unfinished
| ) -> pd.DataFrame: | ||
| """Retrieve airflow data from database.""" | ||
|
|
||
| airway_query = get_sql_query_text("private/airway.sql") |
Collaborator
There was a problem hiding this comment.
Does that address the issue of differences between mssql and postgres time zones? If it does then it seems the most sensible thing to do, if not do you have plans to do that
| None, | ||
| "mL", | ||
| ), | ||
| # Temperature (why no units?) |
Collaborator
There was a problem hiding this comment.
epic doesn't record a unit for temperature !!
This branch was successfully deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is now deployed and apparently working on the GAE, along with the branch for PR 1 in the private queries repo.
(vs the original PR: I have linearised the previous branches somewhat and removed all merges from dev (or janitoring), then done a big merge at the end. This took us up to the equivalent of commit 061dca7 in the other branch. Then I made some further fixes.)