-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #533 from anantmittal/registry-mark-review
Registry Support for "Mark Reviewed" of "New" Patient Entries
- Loading branch information
Showing
22 changed files
with
857 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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,73 @@ | ||
from typing import List, Optional | ||
|
||
import pymongo.collection | ||
import scope.database.collection_utils | ||
|
||
DOCUMENT_TYPE = "reviewMark" | ||
SEMANTIC_SET_ID = "reviewMarkId" | ||
|
||
|
||
def get_review_marks( | ||
*, | ||
collection: pymongo.collection.Collection, | ||
) -> Optional[List[dict]]: | ||
""" | ||
Get list of "reviewMark" documents. | ||
""" | ||
|
||
return scope.database.collection_utils.get_set( | ||
collection=collection, | ||
document_type=DOCUMENT_TYPE, | ||
) | ||
|
||
|
||
def get_review_mark( | ||
*, | ||
collection: pymongo.collection.Collection, | ||
set_id: str, | ||
) -> Optional[dict]: | ||
""" | ||
Get "reviewMark" document. | ||
""" | ||
|
||
return scope.database.collection_utils.get_set_element( | ||
collection=collection, | ||
document_type=DOCUMENT_TYPE, | ||
set_id=set_id, | ||
) | ||
|
||
|
||
def post_review_mark( | ||
*, | ||
collection: pymongo.collection.Collection, | ||
review_mark: dict, | ||
) -> scope.database.collection_utils.SetPostResult: | ||
""" | ||
Post "reviewMark" document. | ||
""" | ||
|
||
return scope.database.collection_utils.post_set_element( | ||
collection=collection, | ||
document_type=DOCUMENT_TYPE, | ||
semantic_set_id=SEMANTIC_SET_ID, | ||
document=review_mark, | ||
) | ||
|
||
|
||
def put_review_mark( | ||
*, | ||
collection: pymongo.collection.Collection, | ||
review_mark: dict, | ||
set_id: str, | ||
) -> scope.database.collection_utils.SetPutResult: | ||
""" | ||
Put "reviewMark" document. | ||
""" | ||
|
||
return scope.database.collection_utils.put_set_element( | ||
collection=collection, | ||
document_type=DOCUMENT_TYPE, | ||
semantic_set_id=SEMANTIC_SET_ID, | ||
set_id=set_id, | ||
document=review_mark, | ||
) |
This file contains 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 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 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 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,35 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://uwscope.org/schemas/documents/review-mark", | ||
"title": "IReviewMark", | ||
"description": "IReviewMark Type", | ||
"type": "object", | ||
"properties": { | ||
"_id": { | ||
"type": "string" | ||
}, | ||
"_type": { | ||
"const": "reviewMark" | ||
}, | ||
"_set_id": { | ||
"type": "string" | ||
}, | ||
"_rev": { | ||
"type": "number" | ||
}, | ||
"reviewMarkId": { | ||
"type": "string" | ||
}, | ||
"editedDateTime": { | ||
"$ref": "/schemas/utils/datetime#/properties/datetime" | ||
}, | ||
"effectiveDateTime": { | ||
"$ref": "/schemas/utils/datetime#/properties/datetime" | ||
}, | ||
"providerId": { | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": ["_type", "editedDateTime", "providerId"] | ||
} |
This file contains 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,9 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://uwscope.org/schemas/documents/review-marks", | ||
"title": "IReviewMark[]", | ||
"type": "array", | ||
"items": { | ||
"$ref": "/schemas/documents/review-mark" | ||
} | ||
} |
This file contains 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
74 changes: 74 additions & 0 deletions
74
scope_shared/scope/testing/fake_data/fixtures_fake_review_mark.py
This file contains 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,74 @@ | ||
import datetime | ||
import faker | ||
import pytest | ||
import pytz | ||
from typing import Callable | ||
|
||
import scope.database.date_utils as date_utils | ||
import scope.database.patient.review_marks | ||
import scope.enums | ||
import scope.schema | ||
import scope.schema_utils | ||
|
||
|
||
def fake_review_mark_factory( | ||
*, | ||
faker_factory: faker.Faker, | ||
) -> Callable[[], dict]: | ||
""" | ||
Obtain a factory that will generate fake recent entry review documents. | ||
""" | ||
|
||
def factory() -> dict: | ||
fake_review_mark = { | ||
"_type": scope.database.patient.review_marks.DOCUMENT_TYPE, | ||
"editedDateTime": date_utils.format_datetime( | ||
pytz.utc.localize( | ||
faker_factory.date_time_between_dates( | ||
datetime_start=datetime.datetime.now() | ||
- datetime.timedelta(weeks=1), | ||
datetime_end=datetime.datetime.now(), | ||
) | ||
) | ||
), | ||
"effectiveDateTime": date_utils.format_datetime( | ||
pytz.utc.localize( | ||
faker_factory.date_time_between_dates( | ||
datetime_start=datetime.datetime.now() | ||
- datetime.timedelta(weeks=2), | ||
datetime_end=datetime.datetime.now(), | ||
) | ||
) | ||
), | ||
# TODO: this should be a providerId | ||
"providerId": faker_factory.name(), | ||
} | ||
|
||
return fake_review_mark | ||
|
||
return factory | ||
|
||
|
||
@pytest.fixture(name="data_fake_review_mark_factory") | ||
def fixture_data_fake_review_mark_factory( | ||
faker: faker.Faker, | ||
) -> Callable[[], dict]: | ||
""" | ||
Fixture for data_fake_review_mark_factory. | ||
""" | ||
|
||
unvalidated_factory = fake_review_mark_factory( | ||
faker_factory=faker, | ||
) | ||
|
||
def factory() -> dict: | ||
fake_review_mark = unvalidated_factory() | ||
|
||
scope.schema_utils.xfail_for_invalid_schema( | ||
schema=scope.schema.review_mark_schema, | ||
data=fake_review_mark, | ||
) | ||
|
||
return fake_review_mark | ||
|
||
return factory |
49 changes: 49 additions & 0 deletions
49
scope_shared/scope/testing/fake_data/fixtures_fake_review_marks.py
This file contains 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,49 @@ | ||
import pytest | ||
import random | ||
from typing import Callable, List | ||
|
||
import scope.schema | ||
import scope.schema_utils | ||
|
||
|
||
def fake_review_marks_factory( | ||
*, | ||
fake_review_mark_factory: Callable[[], dict], | ||
) -> Callable[[], List[dict]]: | ||
""" | ||
Obtain a factory that will generate a list of fake recent entry review documents. | ||
""" | ||
|
||
def factory() -> List[dict]: | ||
fake_review_marks = [ | ||
fake_review_mark_factory() for _ in range(random.randint(1, 5)) | ||
] | ||
|
||
return fake_review_marks | ||
|
||
return factory | ||
|
||
|
||
@pytest.fixture(name="data_fake_review_marks_factory") | ||
def fixture_data_fake_review_marks_factory( | ||
data_fake_review_mark_factory: Callable[[], dict], | ||
) -> Callable[[], List[dict]]: | ||
""" | ||
Fixture for data_fake_review_marks_factory. | ||
""" | ||
|
||
unvalidated_factory = fake_review_marks_factory( | ||
fake_review_mark_factory=data_fake_review_mark_factory, | ||
) | ||
|
||
def factory() -> List[dict]: | ||
fake_review_marks = unvalidated_factory() | ||
|
||
scope.schema_utils.xfail_for_invalid_schema( | ||
schema=scope.schema.review_marks_schema, | ||
data=fake_review_marks, | ||
) | ||
|
||
return fake_review_marks | ||
|
||
return factory |
This file contains 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 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 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.