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

Filter procedures to ngtube and chest x-ray #207

Merged
merged 7 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cli/src/pixl_cli/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@ def _check_and_parse_parquet(private_dir: Path, public_dir: Path) -> pd.DataFram
accessions = pd.read_parquet(private_dir / "PROCEDURE_OCCURRENCE_LINKS.parquet")
# study_date is in procedure.procedure_date
procedure = pd.read_parquet(public_dir / "PROCEDURE_OCCURRENCE.parquet")
# TODO: move from hardcoded ng tube and chest x-rays to being configurable # noqa: FIX002
# https://github.com/UCLH-Foundry/PIXL/issues/212
imaging_procedures = procedure.loc[procedure.procedure_concept_id.isin([4163872, 42538241])]
# joining data together
people_procedures = people.merge(procedure, on="person_id")
people_procedures = people.merge(imaging_procedures, on="person_id")
return people_procedures.merge(accessions, on="procedure_occurrence_id")


Expand Down
Binary file not shown.
Binary file modified cli/tests/resources/omop/public/PROCEDURE_OCCURRENCE.parquet
Binary file not shown.
34 changes: 9 additions & 25 deletions cli/tests/test_messages_from_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

def test_messages_from_parquet(resources: Path) -> None:
"""
Given a valid OMOP ES extract directory that has had the logfile parsed
Given a valid OMOP ES extract with 4 procedures, two of which are x-rays.
When the messages are generated from the directory and the output of logfile parsing
Then the messages should match expected values
Then two messages should be generated
"""
# Arrange
omop_parquet_dir = resources / "omop"
Expand All @@ -39,35 +39,19 @@ def test_messages_from_parquet(resources: Path) -> None:
assert all(isinstance(msg, Message) for msg in messages)

expected_messages = [
Message(
mrn="12345678",
accession_number="12345678",
study_date=datetime.date.fromisoformat("2021-07-01"),
procedure_occurrence_id=1,
project_name="test-extract-uclh-omop-cdm",
omop_es_timestamp=datetime.datetime.fromisoformat("2023-12-07T14:08:58"),
),
Message(
mrn="12345678",
accession_number="ABC1234567",
study_date=datetime.date.fromisoformat("2021-07-01"),
procedure_occurrence_id=2,
project_name="test-extract-uclh-omop-cdm",
omop_es_timestamp=datetime.datetime.fromisoformat("2023-12-07T14:08:58"),
),
Message(
mrn="987654321",
accession_number="ABC1234560",
study_date=datetime.date.fromisoformat("2020-05-01"),
procedure_occurrence_id=3,
accession_number="AA12345601",
study_date=datetime.date.fromisoformat("2020-05-23"),
procedure_occurrence_id=4,
project_name="test-extract-uclh-omop-cdm",
omop_es_timestamp=datetime.datetime.fromisoformat("2023-12-07T14:08:58"),
),
Message(
mrn="5020765",
accession_number="MIG0234560",
study_date=datetime.date.fromisoformat("2015-05-01"),
procedure_occurrence_id=4,
mrn="987654321",
accession_number="AA12345605",
study_date=datetime.date.fromisoformat("2020-05-23"),
procedure_occurrence_id=5,
project_name="test-extract-uclh-omop-cdm",
omop_es_timestamp=datetime.datetime.fromisoformat("2023-12-07T14:08:58"),
),
Expand Down
2 changes: 1 addition & 1 deletion test/scripts/check_entry_in_pixl_anon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ set -euxo pipefail
_sql_command="select * from emap_data.ehr_anon"
_result=$(docker exec system-test-postgres-1 /bin/bash -c \
"PGPASSWORD=pixl_db_password psql -U pixl_db_username -d pixl -c \"$_sql_command\"")
echo "$_result" | grep -q "6 row"
echo "$_result" | grep -q "2 row"