Xcov19 / project-healthcare

Healthcare Infrastructure as a Service: backend api for UI services to integrate location-aware consultation and diagnostics facilities for patient centric services
https://health.xcov19.dev
GNU Lesser General Public License v2.1
3 stars 6 forks source link

[C4GT Community]: Implement a repository pattern using sqlite storage for GeolocationQueryService #26

Open codecakes opened 1 month ago

codecakes commented 1 month ago

Ticket Contents

Description

Issue #12 covers a high complexity objective to implement /geo api endpoint. In order to list facilities, implement a repository to be consumed from GeolocationQueryService.

Background:

The project has 3 primary levels:

  1. IO layer: all infrastructural/mutating transactions. --> We want to implement repository storage here.
  2. application services: services that consume the domain layer and are consumed by the IO layer.
  3. domain: the ƒat business logic. --> We want to define interface signatures here.

The project src directory contains the following:


xcov19
├── app: Contains web framework, application services, routes, dto related modules.
│   ├── auth.py
│   ├── binders.py
│   ├── controllers
│   │   ├── diagnose.py
│   │   └── geolocation.py
│   ├── docs
│   │   └── binders.py
│   ├── dto.py
│   ├── errors.py
│   ├── main.py
│   ├── middleware.py
│   ├── services.py
│   └── settings.py: configuration and settings to run server with.
├── dev.py: runs server in developer mode
├── domain: contains the entities, values and aggregates for business domain context
│   ├── common.py
│   ├── models
│   │   ├── patient.py
│   │   └── provider.py
│   └── repository.py: Repository that abstracts away storage implementation and manages application logic between domain aggregate and data store for a specific context.
└── utils
    └── mixins.py

The GeolocationQueryService is an application service consumed by the web api route geo. See here.

The service needs to query the storage layer via a storage repository. This repository is called by the patient query look up service which is a callable and it calls the repository passing relevant parameters available in the set of: [Address, LocationQueryJSON, List[FacilitiesResult]] which are defined in dto.py.

In the repository pattern, extend IProviderStore interface in domain/models/provider.py and implement a provider store with implementation in sqlite to allow GeolocationQueryService to fetch healthcare providers in a storage -agnostic manner.

See You Wanted Banana and API First design for motivation

Goals

Goals

Expected Outcome

Acceptance Criteria

Implementation Details

The repository’s role is to handle the persistence of aggregates.

Refer to dto.py and provider.py in order to understand the flow as described here.

The Repository receives aggregate as input parameters so first think and map the necessary DTOs to aggregate. The caller service transforms DTO to aggregates. The repository takes in and preprocesses query_id, cust_id in addition to geo location coordinates in order to call sqlite db and return a list of records, the return schema for which is defined in #12 ; The repository takes in the aggregate Provider in provider.py and performs a geo-query to filter all records that are within 50 kms of the patient's coordinates.

Query against the following tentative table attributes from the repository:

columns name type
query_id alphanumeric string
cust_id alphanumeric string
lat float
lng float
specialty array[text]

Expected return value For each query_id and cust_id, filter down the coordinates lat and lng and return the data. Ignore the missing attributes from the attribute column that you cannot find. Let the missing return parameters be optional while maintaining strong consistency with the JSON Type format per attribute.

Mockups/Wireframes

UML sequence for xcov19

Product Name

project-healthcare

Organisation Name

XCoV19

Domain

Healthcare

Tech Skills Needed

Database, Debugging, Flask, Python, SQL, Test, Testing Library

Mentor(s)

@codecakes

Complexity

High

Category

Backend, Database, Refactoring, Testing

RISHIKESHk07 commented 2 weeks ago

@codecakes is this open and requier's issue #12 to be solved first ? , i would like to contribute to the issue , any deadlines or other info i need to know

codecakes commented 2 weeks ago

42

@RISHIKESHk07 Short answer: No. All issues are independent. Go ahead with the PR.

Refer to PR #42 to understand what files you would be leveraging upon in order to do this. Ask for any doubts.

RISHIKESHk07 commented 2 weeks ago

@codecakes did try running poetry install --no-root --with=dev but got the error group dev not found , i see the line commented out image

RISHIKESHk07 commented 2 weeks ago

@codecakes do i install without --with=dev flag

codecakes commented 2 weeks ago

@codecakes did try running poetry install --no-root --with=dev but got the error group dev not found , i see the line commented out image

@RISHIKESHk07 The setup has been simplified. See Contributing; Let me know if this worked for you.

Brownie point if you raise a PR that fixes this setup instruction in the README.md. It should simply point to the CONTRIBUTING page.