Skip to content

Commit bb046be

Browse files
authored
Merge pull request #6 from DHEPLab/feat/enhance-api
feat(api): fix backend API logic and add docs
2 parents c8338a9 + 5ebaa60 commit bb046be

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,22 @@ Clone the repository if you haven't done so already, then follow these steps to
5959

6060
To run the application locally, follow these steps:
6161

62+
> Note: Ensure you have activated your pipenv shell by running `pipenv shell`.
63+
6264
1. Ensure all dependencies are installed using Pipenv.
65+
```bash
66+
pipenv install
67+
```
6368
2. Start your Docker containers if the application requires any external services like databases.
64-
3. Use the following command to run the application under the ``src``:
69+
3. Use the following command to run the application under the ``src`` directory:
6570
```shell
6671
flask run
6772
```
6873
Adjust the command based on your application's entry point if different.
74+
4. Alternatively, run the following command to start the application, at the root path of the project if there is any port conflict on your machine:
75+
```shell
76+
flask run --host=127.0.0.1 --port=5001
77+
```
6978

7079
> **NOTE:** If your frontend is also running, ensure it is configured to communicate with this backend API. You may need to set the API URL in your frontend configuration.
7180
> Also, you might need to use CORS (Cross-Origin Resource Sharing) if your frontend and backend are served from different origins. You can use the `flask-cors` package to handle this:

src/cases/service/case_service.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ def get_page_configuration(self):
270270

271271
def get_case_review(self, case_config_id): # pragma: no cover
272272
"""
273+
A function that implements the business logic for the /case-reviews/{id} API endpoint.
274+
Steps:
273275
1) Load saved DisplayConfig for this case_config_id + user_email.
274276
2) Build full unpruned case_details tree.
275277
3) Prune under “BACKGROUND” according to CSV path_config.
@@ -279,6 +281,9 @@ def get_case_review(self, case_config_id): # pragma: no cover
279281
b) Then, any "Adjusted CRC Risk" row (renaming it)
280282
c) If neither found, emit "N/A"
281283
6) If CSV had no RISK ASSESSMENT entries at all, do not emit any CRC score node.
284+
7) Return Case object with pruned case_details and important_infos.
285+
286+
This function relies on the Tree data structure, which is built by utils/csv_parser.py.
282287
"""
283288
# --- 1) Load configuration & verify access ---
284289
configuration = self.configuration_repository.get_configuration_by_id(case_config_id)
@@ -406,7 +411,6 @@ def get_case_review(self, case_config_id): # pragma: no cover
406411

407412
# 6) If neither csv_crc_score_leaf nor old_crc_toggle, we do not append any CRC score node.
408413

409-
# --- 7) Return the assembled Case object ---
410414
return Case(
411415
self.person.person_source_value,
412416
str(configuration.case_id),

0 commit comments

Comments
 (0)