-
Notifications
You must be signed in to change notification settings - Fork 3
Allow MWL C-FIND filter by patient name #51
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f0635e4
Allow MWL C-FIND filter by patient name
carlosmartinez 671bd1a
Put test_mwl_storage_patient_name_search in integration directory
carlosmartinez 20284b7
Avoid wildcard search if unnecessary
carlosmartinez f814764
fix merge errors
carlosmartinez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| """ | ||
|
carlosmartinez marked this conversation as resolved.
|
||
| Integration-style tests for MWLStorage.find_worklist_items patient name filtering. | ||
|
|
||
| These tests use a real SQLite database to verify that wildcard conversion and case-insensitive | ||
| matching work correctly in practice. | ||
| """ | ||
|
|
||
| import pytest | ||
|
|
||
| from services.storage import MWLStorage, WorklistItem | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def storage(tmp_dir): | ||
| return MWLStorage(f"{tmp_dir}/worklist.db") | ||
|
|
||
|
|
||
| @pytest.fixture(autouse=True) | ||
| def items(storage): | ||
| """Insert a small set of worklist items with varied names.""" | ||
| names = [ | ||
| "SMITH^SARITA", | ||
| "SMITH^JANE", | ||
| "JONES^SARITA", | ||
| "MÜLLER^DILMA", | ||
| ] | ||
| for i, name in enumerate(names): | ||
| storage.store_worklist_item( | ||
| WorklistItem( | ||
| accession_number=f"ACC{i:03d}", | ||
| patient_id=f"999000000{i}", | ||
| patient_name=name, | ||
| patient_birth_date="19800101", | ||
| scheduled_date="20260101", | ||
| scheduled_time="090000", | ||
| modality="MG", | ||
| ) | ||
| ) | ||
| return names | ||
|
|
||
|
|
||
| class TestPatientNameSearch: | ||
| def test_trailing_wildcard(self, storage): | ||
| results = storage.find_worklist_items(patient_name="SMITH*") | ||
| assert {r.patient_name for r in results} == {"SMITH^SARITA", "SMITH^JANE"} | ||
|
|
||
| def test_wildcard_on_given_name(self, storage): | ||
| results = storage.find_worklist_items(patient_name="*SARITA") | ||
| assert {r.patient_name for r in results} == {"SMITH^SARITA", "JONES^SARITA"} | ||
|
|
||
| def test_single_character_wildcard(self, storage): | ||
| results = storage.find_worklist_items(patient_name="SMITH^J?NE") | ||
| assert {r.patient_name for r in results} == {"SMITH^JANE"} | ||
|
|
||
| def test_exact_match(self, storage): | ||
| results = storage.find_worklist_items(patient_name="JONES^SARITA") | ||
| assert len(results) == 1 | ||
| assert results[0].patient_name == "JONES^SARITA" | ||
|
|
||
| def test_no_match(self, storage): | ||
| results = storage.find_worklist_items(patient_name="BROWN*") | ||
| assert results == [] | ||
|
|
||
| def test_case_insensitive_match(self, storage): | ||
| results = storage.find_worklist_items(patient_name="smith*") | ||
| assert {r.patient_name for r in results} == {"SMITH^SARITA", "SMITH^JANE"} | ||
|
|
||
| @pytest.mark.xfail(reason="SQLite's UPPER() is ASCII-only; non-ASCII case folding requires ICU compilation") | ||
| def test_case_insensitive_non_ascii(self, storage): | ||
| results = storage.find_worklist_items(patient_name="müller*") | ||
| assert {r.patient_name for r in results} == {"MÜLLER^DILMA"} | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.