Skip to content

Commit 419c6bf

Browse files
committed
simple logic conversions
1 parent de82aea commit 419c6bf

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

delta_backend/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ This project is designed to convert FHIR-compliant JSON data (e.g., Immunization
1010
|------------------------|---------------|
1111
| **`converter.py`** | 🧠 The main brain — applies the schema, runs conversions, handles errors. |
1212
| **`FHIRParser.py`** | 🪜 Knows how to dig into nested FHIR structures and pull out values like dates, IDs, and patient names. |
13-
| **`SchemaParser.py`** | 📐 Reads your schema layout and tells the converter which FHIR fields to extract and how to rename/format them. |
14-
| **`ConversionLayout.py`** | ✍️ A plain Python list that defines which fields you want, and how they should be formatted (e.g. date format, renaming rules). |
13+
| **`SchemaParser.py`** | Reads your schema layout and tells the converter which FHIR fields to extract and how to rename/format them. |
14+
| **`ConversionLayout.py`** | A plain Python list that defines which fields you want, and how they should be formatted (e.g. date format, renaming rules). |
1515
| **`ConversionChecker.py`** | 🔧 Handles transformation logic — e.g. turning a FHIR datetime into `YYYY-MM-DD`, applying lookups, gender codes, defaults, etc. |
16-
| **`Extractor.py`** | 🎣 Specialized logic to pull practitioner names, site codes, addresses, and apply time-aware rules. |
17-
| **`ExceptionMessages.py`** | 🚨 Holds reusable error messages and codes for clean debugging and validation feedback. |
16+
| **`Extractor.py`** | Specialized logic to pull practitioner names, site codes, addresses, and apply time-aware rules. |
17+
| **`ExceptionMessages.py`** | Holds reusable error messages and codes for clean debugging and validation feedback. |
1818

1919
---
2020

@@ -28,7 +28,7 @@ This project is designed to convert FHIR-compliant JSON data (e.g., Immunization
2828

2929
---
3030

31-
## 📦 Example Use Case
31+
## Example Use Case
3232

3333
- Input: FHIR `Immunization` resource (with nested fields)
3434
- Output: Flat JSON object with 34 standardized key-value pairs
@@ -51,19 +51,19 @@ This script loads sample FHIR data, runs it through the converter, and automatic
5151
python check_conversion.py
5252
```
5353

54-
### 📁 Output Location
54+
### Output Location
5555
When the script runs, it will automatically:
5656
- Save a **flat JSON file** as `output.json`
5757
- Save a **CSV file** as `output.csv`
5858

59-
These will be located one level up from the `src/` folder:
59+
These will be located one level up from the `tests/` folder:
6060

6161
```
6262
/mnt/c/Users/USER/desktop/shn/immunisation-fhir-api/delta_backend/output.json
6363
/mnt/c/Users/USER/desktop/shn/immunisation-fhir-api/delta_backend/output.csv
6464
```
6565

66-
### 👀 Visualization
66+
### Visualization
6767
You can now:
6868
- Open `output.csv` in Excel or Google Sheets to view cleanly structured records
6969
- Inspect `output.json` to validate the flat key-value output programmatically

delta_backend/src/ConversionChecker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def _convertToDateTime(self, expressionRule, fieldName, fieldValue, summarise, r
148148

149149
return dt_utc.strftime(format_str)
150150

151-
# Not Empty Validate
151+
# Not Empty Validate - Returns exactly what is in the extracted fields no parsing or logic needed
152152
def _convertToNotEmpty(self, expressionRule, fieldName, fieldValue, summarise, report_unexpected_exception):
153153
try:
154154
if len(str(fieldValue)) > 0:
@@ -186,7 +186,7 @@ def _convertToGender(self, expressionRule, fieldName, fieldValue, summarise, rep
186186
message = ExceptionMessages.MESSAGES[ExceptionMessages.UNEXPECTED_EXCEPTION] % (e.__class__.__name__, e)
187187
return message
188188

189-
# Change to Validate
189+
# Code for converting Action Flag
190190
def _convertToChangeTo(self, expressionRule, fieldName, fieldValue, summarise, report_unexpected_exception):
191191
try:
192192
return expressionRule

delta_backend/tests/.coverage

68 KB
Binary file not shown.

delta_backend/tests/sample_data/fhir_sample.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@
2727
"given": ["Sarah"]
2828
}
2929
],
30-
"gender": "unknown",
30+
"gender": "other",
3131
"birthDate": "1965-02-28",
3232
"address": [
3333
{
34-
"postalCode": "EC1A 1BB"
34+
"use": "home",
35+
"line": ["123 High Street"],
36+
"city": "London",
37+
"postalCode": "SW1A 1AA"
3538
}
3639
]
3740
}

0 commit comments

Comments
 (0)