Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/converter-generate-nomenclatures.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Converter Generate Nomenclatures

on:
pull_request:
branches:
- '**'
workflow_dispatch:

permissions:
contents: write

jobs:
generate:
runs-on: ubuntu-latest
defaults:
run:
working-directory: converter

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref_name }}

- name: Check for changes requiring nomenclatures generation
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
nomenclatures:
- 'converter/resources/export_mapping_nomenclatures.csv'
- 'converter/scripts/generate_nomenclatures_maps.py'

- name: Set up Python
if: steps.filter.outputs.nomenclatures == 'true'
uses: actions/setup-python@v4
with:
python-version: '3.14'

- name: Install uv
if: steps.filter.outputs.nomenclatures == 'true'
uses: astral-sh/setup-uv@v3

- name: Install dependencies
if: steps.filter.outputs.nomenclatures == 'true'
run: uv sync

- name: Generate nomenclatures maps
if: steps.filter.outputs.nomenclatures == 'true'
run: uv run scripts/generate_nomenclatures_maps.py

- name: Commit and push changes
if: steps.filter.outputs.nomenclatures == 'true'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: '鈿欙笍 Auto-g茅n茅ration du CSV et des maps de nomenclatures'
file_pattern: 'converter/resources/export_mapping_nomenclatures.csv converter/converter/nomenclatures/**/*.py'
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ class CreateCaseCISUConstants:
QUALIFICATION_VICTIM_COUNT_PATH = f"{QUALIFICATION_VICTIMS_PATH}.count"
QUALIFICATION_DETAILS_PRIORITY_PATH = f"{QUALIFICATION_PATH}.details.priority"
QUALIFICATION_WHATS_HAPPEN_PATH = f"{QUALIFICATION_PATH}.whatsHappen"
QUALIFICATION_HEALTH_MOTIVE_PATH = f"{QUALIFICATION_PATH}.healthMotive"
QUALIFICATION_RISK_THREAT_PATH = f"{QUALIFICATION_PATH}.riskThreat"
QUALIFICATION_LOCATION_KIND_PATH = f"{QUALIFICATION_PATH}.locationKind"

MEDICAL_NOTE_PATH = "$.medicalNote"

Expand Down
78 changes: 78 additions & 0 deletions converter/converter/cisu/create_case/create_case_cisu_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,34 @@
set_value,
)
from converter.cisu.base_cisu_converter import BaseCISUConverter
from converter.nomenclatures.utils import (
apply_nomenclature_mapping,
apply_nomenclature_mapping_to_list,
)
from converter.nomenclatures.from_cisu_to_rs.whats_happen import (
MAP as CISU_TO_RS_WHATS_HAPPEN_MAP,
)
from converter.nomenclatures.from_cisu_to_rs.health_motive import (
MAP as CISU_TO_RS_HEALTH_MOTIVE_MAP,
)
from converter.nomenclatures.from_cisu_to_rs.risk_threat import (
MAP as CISU_TO_RS_RISK_THREAT_MAP,
)
from converter.nomenclatures.from_cisu_to_rs.location_kind import (
MAP as CISU_TO_RS_LOCATION_KIND_MAP,
)
from converter.nomenclatures.from_rs_to_cisu.whats_happen import (
MAP as RS_TO_CISU_WHATS_HAPPEN_MAP,
)
from converter.nomenclatures.from_rs_to_cisu.health_motive import (
MAP as RS_TO_CISU_HEALTH_MOTIVE_MAP,
)
from converter.nomenclatures.from_rs_to_cisu.risk_threat import (
MAP as RS_TO_CISU_RISK_THREAT_MAP,
)
from converter.nomenclatures.from_rs_to_cisu.location_kind import (
MAP as RS_TO_CISU_LOCATION_KIND_MAP,
)
import logging

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -283,6 +311,29 @@ def add_call_taker_org_to_custom_map(json_data: Dict[str, Any]):

return json_data

def apply_qualification_nomenclature_mappings(json_data: Dict[str, Any]):
logger.debug("Applying qualification nomenclature mappings")
apply_nomenclature_mapping(
json_data,
CreateCaseCISUConstants.QUALIFICATION_WHATS_HAPPEN_PATH,
CISU_TO_RS_WHATS_HAPPEN_MAP,
)
apply_nomenclature_mapping(
json_data,
CreateCaseCISUConstants.QUALIFICATION_HEALTH_MOTIVE_PATH,
CISU_TO_RS_HEALTH_MOTIVE_MAP,
)
apply_nomenclature_mapping_to_list(
json_data,
CreateCaseCISUConstants.QUALIFICATION_RISK_THREAT_PATH,
CISU_TO_RS_RISK_THREAT_MAP,
)
apply_nomenclature_mapping(
json_data,
CreateCaseCISUConstants.QUALIFICATION_LOCATION_KIND_PATH,
CISU_TO_RS_LOCATION_KIND_MAP,
)

# Create independent envelope copy without usecase for output
output_json = cls.copy_cisu_input_content(input_json)

Expand All @@ -300,6 +351,8 @@ def add_call_taker_org_to_custom_map(json_data: Dict[str, Any]):
set_default_location_freetext(output_use_case_json)
add_location_detail(output_use_case_json)

apply_qualification_nomenclature_mappings(output_use_case_json)

add_case_priority(output_use_case_json)
add_to_initial_alert_notes(
output_use_case_json,
Expand Down Expand Up @@ -388,6 +441,29 @@ def add_default_external_info_type(json_data: Dict[str, Any]):
CreateCaseCISUConstants.DEFAULT_LOCATION_EXTERNAL_INFO_TYPE,
)

def apply_qualification_nomenclature_mappings(json_data: Dict[str, Any]):
logger.debug("Applying qualification nomenclature mappings")
apply_nomenclature_mapping(
json_data,
CreateCaseCISUConstants.QUALIFICATION_WHATS_HAPPEN_PATH,
RS_TO_CISU_WHATS_HAPPEN_MAP,
)
apply_nomenclature_mapping(
json_data,
CreateCaseCISUConstants.QUALIFICATION_HEALTH_MOTIVE_PATH,
RS_TO_CISU_HEALTH_MOTIVE_MAP,
)
apply_nomenclature_mapping_to_list(
json_data,
CreateCaseCISUConstants.QUALIFICATION_RISK_THREAT_PATH,
RS_TO_CISU_RISK_THREAT_MAP,
)
apply_nomenclature_mapping(
json_data,
CreateCaseCISUConstants.QUALIFICATION_LOCATION_KIND_PATH,
RS_TO_CISU_LOCATION_KIND_MAP,
)

# Create independent envelope copy without usecase for output
output_json = cls.copy_rs_input_content(input_json)

Expand Down Expand Up @@ -420,6 +496,8 @@ def add_default_external_info_type(json_data: Dict[str, Any]):
CreateCaseCISUConstants.DEFAULT_LOCATION_COUNTRY,
)

apply_qualification_nomenclature_mappings(output_usecase_json)

if not is_field_completed(
output_usecase_json, CreateCaseCISUConstants.QUALIFICATION_WHATS_HAPPEN_PATH
):
Expand Down
1 change: 1 addition & 0 deletions converter/converter/nomenclatures/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Empty file to mark directory as Python package
Loading
Loading