-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Refactors codebase in order to implement requirements for #26 - Restructures some of the dependencies to maintain project structure around domain driven design independent of the framework.
- Loading branch information
Showing
14 changed files
with
300 additions
and
122 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
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
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 was deleted.
Oops, something went wrong.
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,32 @@ | ||
from typing import Protocol, TypeVar, List | ||
import abc | ||
|
||
from xcov19.domain.models.patient import Patient | ||
from xcov19.domain.models.provider import Provider | ||
|
||
PatientT = TypeVar("PatientT", bound=Patient) | ||
ProviderT = TypeVar("ProviderT", bound=Patient) | ||
|
||
|
||
class IPatientStore[PatientT: Patient](Protocol): | ||
@classmethod | ||
@abc.abstractmethod | ||
def enqueue_diagnosis_query(cls, patient: PatientT): | ||
raise NotImplementedError | ||
|
||
@classmethod | ||
@abc.abstractmethod | ||
def enqueue_geolocation_query(cls, patient: PatientT): | ||
raise NotImplementedError | ||
|
||
|
||
class IProviderRepository[ProviderT: Provider](Protocol): | ||
@abc.abstractmethod | ||
def fetch_by_providers(self, **address: dict[str, str]) -> List[ProviderT]: | ||
raise NotImplementedError | ||
|
||
@abc.abstractmethod | ||
def fetch_by_query( | ||
self, query_id: str, filtered_providers: List[ProviderT] | ||
) -> List[ProviderT]: | ||
raise NotImplementedError |
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
Empty file.
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,68 @@ | ||
from __future__ import annotations | ||
|
||
import abc | ||
from typing import TypeVar, Protocol, Callable, List | ||
|
||
from xcov19.dto import LocationQueryJSON, Address, FacilitiesResult | ||
from xcov19.utils.mixins import InterfaceProtocolCheckMixin | ||
|
||
T = TypeVar("T", bound=LocationQueryJSON) | ||
|
||
|
||
# Application services | ||
|
||
|
||
class LocationQueryServiceInterface[T: LocationQueryJSON](Protocol): | ||
"""Location aware service for listing faciltiies. | ||
1. Searches and fetches existing processed results by query_id for a cust_id | ||
2. Resolves coordinates from a given geolocation. | ||
3. Fetches all facilities from a given set of records for a | ||
given radius from geolocation. | ||
Radius is default for now. | ||
# TODO: Filter to be added | ||
""" | ||
|
||
@classmethod | ||
@abc.abstractmethod | ||
async def resolve_coordinates( | ||
cls, reverse_geo_lookup_svc: Callable[[T], dict], query: T | ||
) -> Address: | ||
raise NotImplementedError | ||
|
||
@classmethod | ||
@abc.abstractmethod | ||
async def fetch_facilities( | ||
cls, | ||
reverse_geo_lookup_svc: Callable[[T], dict], | ||
query: T, | ||
patient_query_lookup_svc: Callable[[Address, T], List[FacilitiesResult]], | ||
) -> List[FacilitiesResult] | None: | ||
raise NotImplementedError | ||
|
||
|
||
class GeolocationQueryService( | ||
LocationQueryServiceInterface[LocationQueryJSON], InterfaceProtocolCheckMixin | ||
): | ||
@classmethod | ||
async def resolve_coordinates( | ||
cls, | ||
reverse_geo_lookup_svc: Callable[[LocationQueryJSON], dict], | ||
query: LocationQueryJSON, | ||
) -> Address: | ||
"""Resolves to address by geo reverse lookup.""" | ||
return Address(**reverse_geo_lookup_svc(query)) | ||
|
||
@classmethod | ||
async def fetch_facilities( | ||
cls, | ||
reverse_geo_lookup_svc: Callable[[LocationQueryJSON], dict], | ||
query: LocationQueryJSON, | ||
patient_query_lookup_svc: Callable[ | ||
[Address, LocationQueryJSON], | ||
List[FacilitiesResult], | ||
], | ||
) -> List[FacilitiesResult] | None: | ||
"""Fetches facilities for a query location for a query id for a customer.""" | ||
patient_address = await cls.resolve_coordinates(reverse_geo_lookup_svc, query) | ||
return patient_query_lookup_svc(patient_address, query) or None |
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.