diff --git a/.github/workflows/generate-model.yaml b/.github/workflows/generate-model.yaml index d2778d649b..ecd2ca5504 100644 --- a/.github/workflows/generate-model.yaml +++ b/.github/workflows/generate-model.yaml @@ -33,10 +33,14 @@ jobs: - 'nomenclature_parser/**' - 'csv_parser/json_schema2xsd/**' - 'src/main/resources/sample/examples/**' + - 'automatic-schema-generator/templates/**' + - 'automatic-schema-generator/automatic-generator.sh' + - 'generator/templates/**' + - 'generator/config/manual/**' test_case_parsing_required: - 'csv_parser/test_case_generator.py' - 'csv_parser/workflow.py' - - 'csv_parser/test-cases-sources/**' + - 'csv_parser/test-case-sources/**' - name: Install Graphviz if: steps.filter.outputs.parsing_required == 'true' diff --git a/automatic-schema-generator/templates/ContentMessage.java.tmpl b/automatic-schema-generator/templates/ContentMessage.java.tmpl index da7f351f3c..6c75e7c3eb 100644 --- a/automatic-schema-generator/templates/ContentMessage.java.tmpl +++ b/automatic-schema-generator/templates/ContentMessage.java.tmpl @@ -4,6 +4,7 @@ package com.hubsante.model.edxl; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; @@ -15,6 +16,7 @@ import com.hubsante.model.{{ .package }}.{{ .rootElement | title }}Wrapper;{{ en import com.hubsante.model.report.ErrorWrapper; import com.hubsante.model.custom.CustomMessage; import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -42,6 +44,16 @@ public class ContentMessage { return 0; } + @JsonIgnore + public String getUseCaseName() { + return "unknown"; + } + + @JsonIgnore + public Optional getCaseId() { + return Optional.empty(); + } + public static class UseCaseHelper { public static final Map useCases = Stream.of(new String[][] { {{ range $i, $e := (datasource "config").schemas }}{{if eq .automaticGeneration "Y"}} diff --git a/automatic-schema-generator/templates/schema.wrapper.generator-config.json.tmpl b/automatic-schema-generator/templates/schema.wrapper.generator-config.json.tmpl index eba9c36357..b6fc160f6e 100644 --- a/automatic-schema-generator/templates/schema.wrapper.generator-config.json.tmpl +++ b/automatic-schema-generator/templates/schema.wrapper.generator-config.json.tmpl @@ -18,7 +18,8 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true{{ if .customExtendPackage}}, + "enablePostProcessFile": true, + "useCaseName": "{{ .rootElement }}"{{ if .customExtendPackage }}, "customExtend": { "package": "{{ .customExtendPackage }}", "className": "{{ .customExtendClass }}" diff --git a/csv_parser/csv_parser.py b/csv_parser/csv_parser.py index a96735c1f8..957439d21e 100644 --- a/csv_parser/csv_parser.py +++ b/csv_parser/csv_parser.py @@ -771,6 +771,9 @@ def json_schema_to_openapi_schema(json_schema): root_definition = {key: json_schema[key] for key in json_schema if key not in [ '$schema', 'definitions', 'version', 'id' ]} + # Allows retrieving the caseId from any ContentMessage (cf. ContentMessage#getCaseId) + if 'caseId' in root_definition.get('properties', {}): + root_definition['x-implements'] = ['com.hubsante.model.edxl.UseCaseWithCaseId'] definitions = { **{MODEL_TYPE: root_definition}, **definitions diff --git a/generator/config/generated/GEO-POS/GEO-POS.wrapper.generator-config.json b/generator/config/generated/GEO-POS/GEO-POS.wrapper.generator-config.json index a3a4638ff4..658eb02b9b 100644 --- a/generator/config/generated/GEO-POS/GEO-POS.wrapper.generator-config.json +++ b/generator/config/generated/GEO-POS/GEO-POS.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "geoPositionsUpdate" } } diff --git a/generator/config/generated/GEO-REQ/GEO-REQ.wrapper.generator-config.json b/generator/config/generated/GEO-REQ/GEO-REQ.wrapper.generator-config.json index 441724c0af..d472f18e92 100644 --- a/generator/config/generated/GEO-REQ/GEO-REQ.wrapper.generator-config.json +++ b/generator/config/generated/GEO-REQ/GEO-REQ.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "geoResourcesRequest" } } diff --git a/generator/config/generated/GEO-RES/GEO-RES.wrapper.generator-config.json b/generator/config/generated/GEO-RES/GEO-RES.wrapper.generator-config.json index 479ce83ef4..faacd90a02 100644 --- a/generator/config/generated/GEO-RES/GEO-RES.wrapper.generator-config.json +++ b/generator/config/generated/GEO-RES/GEO-RES.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "geoResourcesDetails" } } diff --git a/generator/config/generated/RC-DE/RC-DE.wrapper.generator-config.json b/generator/config/generated/RC-DE/RC-DE.wrapper.generator-config.json index d41fcca5d5..46aa71d3c0 100644 --- a/generator/config/generated/RC-DE/RC-DE.wrapper.generator-config.json +++ b/generator/config/generated/RC-DE/RC-DE.wrapper.generator-config.json @@ -19,6 +19,7 @@ "supportUrlQuery": false, "xmlns": "eda:1.9", "enablePostProcessFile": true, + "useCaseName": "distributionElement", "customExtend": { "package": "com.hubsante.model.edxl", "className": "ContentMessage" diff --git a/generator/config/generated/RC-EDA/RC-EDA.wrapper.generator-config.json b/generator/config/generated/RC-EDA/RC-EDA.wrapper.generator-config.json index 0ca3c1ba1e..312fae1d2d 100644 --- a/generator/config/generated/RC-EDA/RC-EDA.wrapper.generator-config.json +++ b/generator/config/generated/RC-EDA/RC-EDA.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "createCase" } } diff --git a/generator/config/generated/RC-REF/RC-REF.wrapper.generator-config.json b/generator/config/generated/RC-REF/RC-REF.wrapper.generator-config.json index 1e291ab9dd..08fbc6543f 100644 --- a/generator/config/generated/RC-REF/RC-REF.wrapper.generator-config.json +++ b/generator/config/generated/RC-REF/RC-REF.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "reference" } } diff --git a/generator/config/generated/RC-RI/RC-RI.wrapper.generator-config.json b/generator/config/generated/RC-RI/RC-RI.wrapper.generator-config.json index 91864b66dd..de2f45c08c 100644 --- a/generator/config/generated/RC-RI/RC-RI.wrapper.generator-config.json +++ b/generator/config/generated/RC-RI/RC-RI.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "resourcesInfoCisu" } } diff --git a/generator/config/generated/RS-BPV/RS-BPV.wrapper.generator-config.json b/generator/config/generated/RS-BPV/RS-BPV.wrapper.generator-config.json index df804606ed..a4bf94071d 100644 --- a/generator/config/generated/RS-BPV/RS-BPV.wrapper.generator-config.json +++ b/generator/config/generated/RS-BPV/RS-BPV.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "interventionReport" } } diff --git a/generator/config/generated/RS-DR/RS-DR.wrapper.generator-config.json b/generator/config/generated/RS-DR/RS-DR.wrapper.generator-config.json index 15e44f7c36..55dde01b41 100644 --- a/generator/config/generated/RS-DR/RS-DR.wrapper.generator-config.json +++ b/generator/config/generated/RS-DR/RS-DR.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "resourcesRequest" } } diff --git a/generator/config/generated/RS-EDA-MAJ/RS-EDA-MAJ.wrapper.generator-config.json b/generator/config/generated/RS-EDA-MAJ/RS-EDA-MAJ.wrapper.generator-config.json index d7a5eecac9..13b750660b 100644 --- a/generator/config/generated/RS-EDA-MAJ/RS-EDA-MAJ.wrapper.generator-config.json +++ b/generator/config/generated/RS-EDA-MAJ/RS-EDA-MAJ.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "createCaseHealthUpdate" } } diff --git a/generator/config/generated/RS-EDA/RS-EDA.wrapper.generator-config.json b/generator/config/generated/RS-EDA/RS-EDA.wrapper.generator-config.json index cfb46d1268..38846857e2 100644 --- a/generator/config/generated/RS-EDA/RS-EDA.wrapper.generator-config.json +++ b/generator/config/generated/RS-EDA/RS-EDA.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "createCaseHealth" } } diff --git a/generator/config/generated/RS-ER/RS-ER.wrapper.generator-config.json b/generator/config/generated/RS-ER/RS-ER.wrapper.generator-config.json index 95ed705d96..267247bb9d 100644 --- a/generator/config/generated/RS-ER/RS-ER.wrapper.generator-config.json +++ b/generator/config/generated/RS-ER/RS-ER.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "resourcesEngagement" } } diff --git a/generator/config/generated/RS-RI/RS-RI.wrapper.generator-config.json b/generator/config/generated/RS-RI/RS-RI.wrapper.generator-config.json index 16239aa10f..0d24c4b915 100644 --- a/generator/config/generated/RS-RI/RS-RI.wrapper.generator-config.json +++ b/generator/config/generated/RS-RI/RS-RI.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "resourcesInfo" } } diff --git a/generator/config/generated/RS-RPIS/RS-RPIS.wrapper.generator-config.json b/generator/config/generated/RS-RPIS/RS-RPIS.wrapper.generator-config.json index 71541397f7..5fbe6367d0 100644 --- a/generator/config/generated/RS-RPIS/RS-RPIS.wrapper.generator-config.json +++ b/generator/config/generated/RS-RPIS/RS-RPIS.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "rpis" } } diff --git a/generator/config/generated/RS-RR/RS-RR.wrapper.generator-config.json b/generator/config/generated/RS-RR/RS-RR.wrapper.generator-config.json index c711528aeb..cb706bede7 100644 --- a/generator/config/generated/RS-RR/RS-RR.wrapper.generator-config.json +++ b/generator/config/generated/RS-RR/RS-RR.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "resourcesResponse" } } diff --git a/generator/config/generated/RS-SAS-RDV/RS-SAS-RDV.wrapper.generator-config.json b/generator/config/generated/RS-SAS-RDV/RS-SAS-RDV.wrapper.generator-config.json index 934781bc49..2f9f1f7862 100644 --- a/generator/config/generated/RS-SAS-RDV/RS-SAS-RDV.wrapper.generator-config.json +++ b/generator/config/generated/RS-SAS-RDV/RS-SAS-RDV.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "appointment" } } diff --git a/generator/config/generated/RS-SR/RS-SR.wrapper.generator-config.json b/generator/config/generated/RS-SR/RS-SR.wrapper.generator-config.json index 2816709b06..3f8959f6e1 100644 --- a/generator/config/generated/RS-SR/RS-SR.wrapper.generator-config.json +++ b/generator/config/generated/RS-SR/RS-SR.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "resourcesStatus" } } diff --git a/generator/config/generated/RS-URL/RS-URL.wrapper.generator-config.json b/generator/config/generated/RS-URL/RS-URL.wrapper.generator-config.json index 9adb6f9407..8d0a2380fe 100644 --- a/generator/config/generated/RS-URL/RS-URL.wrapper.generator-config.json +++ b/generator/config/generated/RS-URL/RS-URL.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "documentLink" } } diff --git a/generator/config/generated/TECHNICAL/TECHNICAL.wrapper.generator-config.json b/generator/config/generated/TECHNICAL/TECHNICAL.wrapper.generator-config.json index 31e47cd538..9547110c42 100644 --- a/generator/config/generated/TECHNICAL/TECHNICAL.wrapper.generator-config.json +++ b/generator/config/generated/TECHNICAL/TECHNICAL.wrapper.generator-config.json @@ -18,6 +18,7 @@ "openApiNullable": true, "supportUrlQuery": false, "xmlns": "eda:1.9", - "enablePostProcessFile": true + "enablePostProcessFile": true, + "useCaseName": "technical" } } diff --git a/generator/config/generated/TECHNICAL_NOREQ/TECHNICAL_NOREQ.wrapper.generator-config.json b/generator/config/generated/TECHNICAL_NOREQ/TECHNICAL_NOREQ.wrapper.generator-config.json index a5e0b2d7f1..eabbf8fdba 100644 --- a/generator/config/generated/TECHNICAL_NOREQ/TECHNICAL_NOREQ.wrapper.generator-config.json +++ b/generator/config/generated/TECHNICAL_NOREQ/TECHNICAL_NOREQ.wrapper.generator-config.json @@ -19,6 +19,7 @@ "supportUrlQuery": false, "xmlns": "eda:1.9", "enablePostProcessFile": true, + "useCaseName": "technicalNoreq", "customExtend": { "package": "com.hubsante.model.edxl", "className": "ContentMessage" diff --git a/generator/config/manual/RS-ERROR/RS-ERROR.wrapper.generator-config.json b/generator/config/manual/RS-ERROR/RS-ERROR.wrapper.generator-config.json index 0789106f83..773365e8cc 100644 --- a/generator/config/manual/RS-ERROR/RS-ERROR.wrapper.generator-config.json +++ b/generator/config/manual/RS-ERROR/RS-ERROR.wrapper.generator-config.json @@ -17,7 +17,9 @@ "serializationLibrary": "jackson", "openApiNullable": true, "supportUrlQuery": false, + "xmlns": "eda:1.9", "enablePostProcessFile": true, + "useCaseName": "error", "customExtend": { "package": "com.hubsante.model.edxl", "className": "ContentMessage" diff --git a/generator/input/RC-EDA.openapi.yaml b/generator/input/RC-EDA.openapi.yaml index 698d33bdf7..ac03575a65 100644 --- a/generator/input/RC-EDA.openapi.yaml +++ b/generator/input/RC-EDA.openapi.yaml @@ -106,6 +106,8 @@ components: additionalInformation: $ref: '#/components/schemas/additionalInformation' additionalProperties: false + x-implements: + - com.hubsante.model.edxl.UseCaseWithCaseId qualification: type: object title: Qualification diff --git a/generator/input/RC-RI.openapi.yaml b/generator/input/RC-RI.openapi.yaml index ebc590aa34..775378e9cd 100644 --- a/generator/input/RC-RI.openapi.yaml +++ b/generator/input/RC-RI.openapi.yaml @@ -42,6 +42,8 @@ components: $ref: '#/components/schemas/resource' minItems: 1 additionalProperties: false + x-implements: + - com.hubsante.model.edxl.UseCaseWithCaseId resource: type: object title: Ressource diff --git a/generator/input/RS-BPV.openapi.yaml b/generator/input/RS-BPV.openapi.yaml index ad1a09be24..91ecf9c7ea 100644 --- a/generator/input/RS-BPV.openapi.yaml +++ b/generator/input/RS-BPV.openapi.yaml @@ -66,6 +66,8 @@ components: evaluation: $ref: '#/components/schemas/evaluation' additionalProperties: false + x-implements: + - com.hubsante.model.edxl.UseCaseWithCaseId redactor: type: object title: "Professionnel de sant\xE9 qui r\xE9alise le bilan" diff --git a/generator/input/RS-DR.openapi.yaml b/generator/input/RS-DR.openapi.yaml index 81a9088453..9bc9f2291c 100644 --- a/generator/input/RS-DR.openapi.yaml +++ b/generator/input/RS-DR.openapi.yaml @@ -51,6 +51,8 @@ components: examples: - ANNULEE additionalProperties: false + x-implements: + - com.hubsante.model.edxl.UseCaseWithCaseId request: type: object title: Demande de ressource diff --git a/generator/input/RS-EDA-MAJ.openapi.yaml b/generator/input/RS-EDA-MAJ.openapi.yaml index 9d6a6cf8ba..e290dec0bc 100644 --- a/generator/input/RS-EDA-MAJ.openapi.yaml +++ b/generator/input/RS-EDA-MAJ.openapi.yaml @@ -105,6 +105,8 @@ components: additionalInformation: $ref: '#/components/schemas/additionalInformation' additionalProperties: false + x-implements: + - com.hubsante.model.edxl.UseCaseWithCaseId qualification: type: object title: Qualification diff --git a/generator/input/RS-EDA.openapi.yaml b/generator/input/RS-EDA.openapi.yaml index 6fd52f3d50..1f6138a7ef 100644 --- a/generator/input/RS-EDA.openapi.yaml +++ b/generator/input/RS-EDA.openapi.yaml @@ -131,6 +131,8 @@ components: additionalInformation: $ref: '#/components/schemas/additionalInformation' additionalProperties: false + x-implements: + - com.hubsante.model.edxl.UseCaseWithCaseId qualification: type: object title: Qualification diff --git a/generator/input/RS-ER.openapi.yaml b/generator/input/RS-ER.openapi.yaml index a6f84c4282..811bdff25e 100644 --- a/generator/input/RS-ER.openapi.yaml +++ b/generator/input/RS-ER.openapi.yaml @@ -42,6 +42,8 @@ components: $ref: '#/components/schemas/resource' minItems: 1 additionalProperties: false + x-implements: + - com.hubsante.model.edxl.UseCaseWithCaseId resource: type: object title: Ressource diff --git a/generator/input/RS-RI.openapi.yaml b/generator/input/RS-RI.openapi.yaml index 2502313cea..41a608f41a 100644 --- a/generator/input/RS-RI.openapi.yaml +++ b/generator/input/RS-RI.openapi.yaml @@ -42,6 +42,8 @@ components: $ref: '#/components/schemas/resource' minItems: 1 additionalProperties: false + x-implements: + - com.hubsante.model.edxl.UseCaseWithCaseId resource: type: object title: Ressource diff --git a/generator/input/RS-RR.openapi.yaml b/generator/input/RS-RR.openapi.yaml index 3ecd737854..8f2bacb03d 100644 --- a/generator/input/RS-RR.openapi.yaml +++ b/generator/input/RS-RR.openapi.yaml @@ -58,6 +58,8 @@ components: response: $ref: '#/components/schemas/response' additionalProperties: false + x-implements: + - com.hubsante.model.edxl.UseCaseWithCaseId response: type: object title: "R\xE9ponse \xE0 la demande de ressources" diff --git a/generator/input/RS-SR.openapi.yaml b/generator/input/RS-SR.openapi.yaml index 6edef13772..58da83f740 100644 --- a/generator/input/RS-SR.openapi.yaml +++ b/generator/input/RS-SR.openapi.yaml @@ -57,6 +57,8 @@ components: state: $ref: '#/components/schemas/state' additionalProperties: false + x-implements: + - com.hubsante.model.edxl.UseCaseWithCaseId state: type: object title: Etat vecteur diff --git a/generator/input/RS-URL.openapi.yaml b/generator/input/RS-URL.openapi.yaml index 397955cd6e..ee034e2299 100644 --- a/generator/input/RS-URL.openapi.yaml +++ b/generator/input/RS-URL.openapi.yaml @@ -66,6 +66,8 @@ components: $ref: '#/components/schemas/document' minItems: 1 additionalProperties: false + x-implements: + - com.hubsante.model.edxl.UseCaseWithCaseId document: type: object title: Documents diff --git a/generator/templates/wrapper/model.mustache b/generator/templates/wrapper/model.mustache index fa03289579..e8c0f1fb0c 100644 --- a/generator/templates/wrapper/model.mustache +++ b/generator/templates/wrapper/model.mustache @@ -8,6 +8,8 @@ package {{package}}; {{/useReflectionEqualsHashCode}} import java.util.Objects; import java.util.Arrays; +import java.util.Optional; +import com.hubsante.model.edxl.UseCaseWithCaseId; {{#imports}} import {{import}}; {{/imports}} diff --git a/generator/templates/wrapper/pojo.mustache b/generator/templates/wrapper/pojo.mustache index 3f428bc11d..0dae67fcc3 100644 --- a/generator/templates/wrapper/pojo.mustache +++ b/generator/templates/wrapper/pojo.mustache @@ -35,6 +35,19 @@ public class {{classname}}{{#vendorExtensions.x-implements}}{{#-first}}implement {{/serializableModel}} @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:{{xmlns}}"; + + @Override + public String getUseCaseName() { + return "{{useCaseName}}"; + } + + @Override + public Optional getCaseId() { + return {{#vars}}{{name}}{{/vars}} instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + {{#vars}} {{#isEnum}} {{^isContainer}} diff --git a/src/main/java/com/hubsante/model/cisu/CreateCase.java b/src/main/java/com/hubsante/model/cisu/CreateCase.java index 7d844a998a..0530e5cd73 100644 --- a/src/main/java/com/hubsante/model/cisu/CreateCase.java +++ b/src/main/java/com/hubsante/model/cisu/CreateCase.java @@ -59,7 +59,7 @@ @JsonTypeName("createCase") @JsonInclude(JsonInclude.Include.NON_EMPTY) -public class CreateCase { +public class CreateCase implements com.hubsante.model.edxl.UseCaseWithCaseId { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9:createCase"; public static final String JSON_PROPERTY_CASE_ID = "caseId"; diff --git a/src/main/java/com/hubsante/model/cisu/CreateCaseWrapper.java b/src/main/java/com/hubsante/model/cisu/CreateCaseWrapper.java index e4be2ccdba..c0cd02119f 100644 --- a/src/main/java/com/hubsante/model/cisu/CreateCaseWrapper.java +++ b/src/main/java/com/hubsante/model/cisu/CreateCaseWrapper.java @@ -35,10 +35,12 @@ import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; import com.hubsante.model.cisu.CreateCase; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.rcde.DistributionElement; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * CreateCaseWrapper @@ -56,6 +58,19 @@ public class CreateCaseWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "createCase"; + } + + @Override + public Optional getCaseId() { + return createCase instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_CREATE_CASE = "createCase"; private CreateCase createCase; diff --git a/src/main/java/com/hubsante/model/cisu/resources/info/ResourcesInfoCisu.java b/src/main/java/com/hubsante/model/cisu/resources/info/ResourcesInfoCisu.java index 441e1f1dd6..f5a1dfe6e7 100644 --- a/src/main/java/com/hubsante/model/cisu/resources/info/ResourcesInfoCisu.java +++ b/src/main/java/com/hubsante/model/cisu/resources/info/ResourcesInfoCisu.java @@ -49,7 +49,8 @@ @JsonTypeName("resourcesInfoCisu") @JsonInclude(JsonInclude.Include.NON_EMPTY) -public class ResourcesInfoCisu { +public class ResourcesInfoCisu + implements com.hubsante.model.edxl.UseCaseWithCaseId { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9:resourcesinfocisu"; public static final String JSON_PROPERTY_CASE_ID = "caseId"; diff --git a/src/main/java/com/hubsante/model/cisu/resources/info/ResourcesInfoCisuWrapper.java b/src/main/java/com/hubsante/model/cisu/resources/info/ResourcesInfoCisuWrapper.java index f390121f1c..b730f7fd4c 100644 --- a/src/main/java/com/hubsante/model/cisu/resources/info/ResourcesInfoCisuWrapper.java +++ b/src/main/java/com/hubsante/model/cisu/resources/info/ResourcesInfoCisuWrapper.java @@ -35,10 +35,12 @@ import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; import com.hubsante.model.cisu.resources.info.ResourcesInfoCisu; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.rcde.DistributionElement; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * ResourcesInfoCisuWrapper @@ -56,6 +58,19 @@ public class ResourcesInfoCisuWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "resourcesInfoCisu"; + } + + @Override + public Optional getCaseId() { + return resourcesInfoCisu instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_RESOURCES_INFO_CISU = "resourcesInfoCisu"; private ResourcesInfoCisu resourcesInfoCisu; diff --git a/src/main/java/com/hubsante/model/documentlink/DocumentLink.java b/src/main/java/com/hubsante/model/documentlink/DocumentLink.java index 435bbf7f46..1f245b9023 100644 --- a/src/main/java/com/hubsante/model/documentlink/DocumentLink.java +++ b/src/main/java/com/hubsante/model/documentlink/DocumentLink.java @@ -50,7 +50,7 @@ @JsonTypeName("documentLink") @JsonInclude(JsonInclude.Include.NON_EMPTY) -public class DocumentLink { +public class DocumentLink implements com.hubsante.model.edxl.UseCaseWithCaseId { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9:documentlink"; public static final String JSON_PROPERTY_CASE_ID = "caseId"; diff --git a/src/main/java/com/hubsante/model/documentlink/DocumentLinkWrapper.java b/src/main/java/com/hubsante/model/documentlink/DocumentLinkWrapper.java index 0892955d12..216ed2a5d3 100644 --- a/src/main/java/com/hubsante/model/documentlink/DocumentLinkWrapper.java +++ b/src/main/java/com/hubsante/model/documentlink/DocumentLinkWrapper.java @@ -35,10 +35,12 @@ import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; import com.hubsante.model.documentlink.DocumentLink; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.rcde.DistributionElement; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * DocumentLinkWrapper @@ -56,6 +58,19 @@ public class DocumentLinkWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "documentLink"; + } + + @Override + public Optional getCaseId() { + return documentLink instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_DOCUMENT_LINK = "documentLink"; private DocumentLink documentLink; diff --git a/src/main/java/com/hubsante/model/edxl/ContentMessage.java b/src/main/java/com/hubsante/model/edxl/ContentMessage.java index 707940b056..59d700aed3 100644 --- a/src/main/java/com/hubsante/model/edxl/ContentMessage.java +++ b/src/main/java/com/hubsante/model/edxl/ContentMessage.java @@ -19,6 +19,7 @@ package com.hubsante.model.edxl; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; @@ -66,6 +67,7 @@ import com.hubsante.model.report.ErrorWrapper; import com.hubsante.model.custom.CustomMessage; import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -111,6 +113,16 @@ public int hashCode() { return 0; } + @JsonIgnore + public String getUseCaseName() { + return "unknown"; + } + + @JsonIgnore + public Optional getCaseId() { + return Optional.empty(); + } + public static class UseCaseHelper { public static final Map useCases = Stream.of(new String[][] { diff --git a/src/main/java/com/hubsante/model/edxl/UseCaseWithCaseId.java b/src/main/java/com/hubsante/model/edxl/UseCaseWithCaseId.java new file mode 100644 index 0000000000..73ee5e7abe --- /dev/null +++ b/src/main/java/com/hubsante/model/edxl/UseCaseWithCaseId.java @@ -0,0 +1,24 @@ +/** + * Copyright © 2023-2026 Agence du Numerique en Sante (ANS) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.hubsante.model.edxl; + +/** + * Implemented by use case models carrying a caseId field, so that it can be retrieved + * from any ContentMessage without knowing its concrete type. + */ +public interface UseCaseWithCaseId { + String getCaseId(); +} diff --git a/src/main/java/com/hubsante/model/geolocation/GeoPositionsUpdateWrapper.java b/src/main/java/com/hubsante/model/geolocation/GeoPositionsUpdateWrapper.java index 947a62173e..4a5c724746 100644 --- a/src/main/java/com/hubsante/model/geolocation/GeoPositionsUpdateWrapper.java +++ b/src/main/java/com/hubsante/model/geolocation/GeoPositionsUpdateWrapper.java @@ -34,11 +34,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.geolocation.GeoPositionsUpdate; import com.hubsante.model.rcde.DistributionElement; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * GeoPositionsUpdateWrapper @@ -57,6 +59,19 @@ public class GeoPositionsUpdateWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "geoPositionsUpdate"; + } + + @Override + public Optional getCaseId() { + return geoPositionsUpdate instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_GEO_POSITIONS_UPDATE = "geoPositionsUpdate"; private GeoPositionsUpdate geoPositionsUpdate; diff --git a/src/main/java/com/hubsante/model/geolocation/GeoResourcesDetailsWrapper.java b/src/main/java/com/hubsante/model/geolocation/GeoResourcesDetailsWrapper.java index 5efc549e43..0621a18cde 100644 --- a/src/main/java/com/hubsante/model/geolocation/GeoResourcesDetailsWrapper.java +++ b/src/main/java/com/hubsante/model/geolocation/GeoResourcesDetailsWrapper.java @@ -34,11 +34,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.geolocation.GeoResourcesDetails; import com.hubsante.model.rcde.DistributionElement; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * GeoResourcesDetailsWrapper @@ -57,6 +59,19 @@ public class GeoResourcesDetailsWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "geoResourcesDetails"; + } + + @Override + public Optional getCaseId() { + return geoResourcesDetails instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_GEO_RESOURCES_DETAILS = "geoResourcesDetails"; private GeoResourcesDetails geoResourcesDetails; diff --git a/src/main/java/com/hubsante/model/geolocation/GeoResourcesRequestWrapper.java b/src/main/java/com/hubsante/model/geolocation/GeoResourcesRequestWrapper.java index 7cd54d4232..e89a5612f7 100644 --- a/src/main/java/com/hubsante/model/geolocation/GeoResourcesRequestWrapper.java +++ b/src/main/java/com/hubsante/model/geolocation/GeoResourcesRequestWrapper.java @@ -34,11 +34,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.geolocation.GeoResourcesRequest; import com.hubsante.model.rcde.DistributionElement; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * GeoResourcesRequestWrapper @@ -57,6 +59,19 @@ public class GeoResourcesRequestWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "geoResourcesRequest"; + } + + @Override + public Optional getCaseId() { + return geoResourcesRequest instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_GEO_RESOURCES_REQUEST = "geoResourcesRequest"; private GeoResourcesRequest geoResourcesRequest; diff --git a/src/main/java/com/hubsante/model/health/CreateCaseHealth.java b/src/main/java/com/hubsante/model/health/CreateCaseHealth.java index fff6572a8c..a51d285f1b 100644 --- a/src/main/java/com/hubsante/model/health/CreateCaseHealth.java +++ b/src/main/java/com/hubsante/model/health/CreateCaseHealth.java @@ -67,7 +67,8 @@ @JsonTypeName("createCaseHealth") @JsonInclude(JsonInclude.Include.NON_EMPTY) -public class CreateCaseHealth { +public class CreateCaseHealth + implements com.hubsante.model.edxl.UseCaseWithCaseId { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9:createCaseHealth"; public static final String JSON_PROPERTY_CASE_ID = "caseId"; diff --git a/src/main/java/com/hubsante/model/health/CreateCaseHealthUpdate.java b/src/main/java/com/hubsante/model/health/CreateCaseHealthUpdate.java index 549b36885f..f32342ff09 100644 --- a/src/main/java/com/hubsante/model/health/CreateCaseHealthUpdate.java +++ b/src/main/java/com/hubsante/model/health/CreateCaseHealthUpdate.java @@ -66,7 +66,8 @@ @JsonTypeName("createCaseHealthUpdate") @JsonInclude(JsonInclude.Include.NON_EMPTY) -public class CreateCaseHealthUpdate { +public class CreateCaseHealthUpdate + implements com.hubsante.model.edxl.UseCaseWithCaseId { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9:createCaseHealthUpdate"; public static final String JSON_PROPERTY_CASE_ID = "caseId"; diff --git a/src/main/java/com/hubsante/model/health/CreateCaseHealthUpdateWrapper.java b/src/main/java/com/hubsante/model/health/CreateCaseHealthUpdateWrapper.java index e3faef6bc0..d04e1fe344 100644 --- a/src/main/java/com/hubsante/model/health/CreateCaseHealthUpdateWrapper.java +++ b/src/main/java/com/hubsante/model/health/CreateCaseHealthUpdateWrapper.java @@ -34,11 +34,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.health.CreateCaseHealthUpdate; import com.hubsante.model.rcde.DistributionElement; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * CreateCaseHealthUpdateWrapper @@ -57,6 +59,19 @@ public class CreateCaseHealthUpdateWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "createCaseHealthUpdate"; + } + + @Override + public Optional getCaseId() { + return createCaseHealthUpdate instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_CREATE_CASE_HEALTH_UPDATE = "createCaseHealthUpdate"; private CreateCaseHealthUpdate createCaseHealthUpdate; diff --git a/src/main/java/com/hubsante/model/health/CreateCaseHealthWrapper.java b/src/main/java/com/hubsante/model/health/CreateCaseHealthWrapper.java index bead2b74bc..6218fc422a 100644 --- a/src/main/java/com/hubsante/model/health/CreateCaseHealthWrapper.java +++ b/src/main/java/com/hubsante/model/health/CreateCaseHealthWrapper.java @@ -34,11 +34,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.health.CreateCaseHealth; import com.hubsante.model.rcde.DistributionElement; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * CreateCaseHealthWrapper @@ -56,6 +58,19 @@ public class CreateCaseHealthWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "createCaseHealth"; + } + + @Override + public Optional getCaseId() { + return createCaseHealth instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_CREATE_CASE_HEALTH = "createCaseHealth"; private CreateCaseHealth createCaseHealth; diff --git a/src/main/java/com/hubsante/model/interventionreport/InterventionReport.java b/src/main/java/com/hubsante/model/interventionreport/InterventionReport.java index dec3edc34c..35ac34b844 100644 --- a/src/main/java/com/hubsante/model/interventionreport/InterventionReport.java +++ b/src/main/java/com/hubsante/model/interventionreport/InterventionReport.java @@ -54,7 +54,8 @@ @JsonTypeName("interventionReport") @JsonInclude(JsonInclude.Include.NON_EMPTY) -public class InterventionReport { +public class InterventionReport + implements com.hubsante.model.edxl.UseCaseWithCaseId { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9:interventionreport"; public static final String JSON_PROPERTY_CASE_ID = "caseId"; diff --git a/src/main/java/com/hubsante/model/interventionreport/InterventionReportWrapper.java b/src/main/java/com/hubsante/model/interventionreport/InterventionReportWrapper.java index c087a38b71..fae473b096 100644 --- a/src/main/java/com/hubsante/model/interventionreport/InterventionReportWrapper.java +++ b/src/main/java/com/hubsante/model/interventionreport/InterventionReportWrapper.java @@ -34,11 +34,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.interventionreport.InterventionReport; import com.hubsante.model.rcde.DistributionElement; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * InterventionReportWrapper @@ -57,6 +59,19 @@ public class InterventionReportWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "interventionReport"; + } + + @Override + public Optional getCaseId() { + return interventionReport instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_INTERVENTION_REPORT = "interventionReport"; private InterventionReport interventionReport; diff --git a/src/main/java/com/hubsante/model/reference/ReferenceWrapper.java b/src/main/java/com/hubsante/model/reference/ReferenceWrapper.java index 462f70a710..6ec650b5bb 100644 --- a/src/main/java/com/hubsante/model/reference/ReferenceWrapper.java +++ b/src/main/java/com/hubsante/model/reference/ReferenceWrapper.java @@ -34,11 +34,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.rcde.DistributionElement; import com.hubsante.model.reference.Reference; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * ReferenceWrapper @@ -56,6 +58,19 @@ public class ReferenceWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "reference"; + } + + @Override + public Optional getCaseId() { + return reference instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_REFERENCE = "reference"; private Reference reference; diff --git a/src/main/java/com/hubsante/model/report/ErrorWrapper.java b/src/main/java/com/hubsante/model/report/ErrorWrapper.java index 7875293a4f..b5a6370459 100644 --- a/src/main/java/com/hubsante/model/report/ErrorWrapper.java +++ b/src/main/java/com/hubsante/model/report/ErrorWrapper.java @@ -35,10 +35,12 @@ import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; import com.hubsante.model.edxl.ContentMessage; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.report.Error; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * ErrorWrapper @@ -48,7 +50,21 @@ @JsonInclude(JsonInclude.Include.NON_EMPTY) public class ErrorWrapper extends ContentMessage { - @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:"; + @JacksonXmlProperty(isAttribute = true) + String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "error"; + } + + @Override + public Optional getCaseId() { + return error instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_ERROR = "error"; private Error error; diff --git a/src/main/java/com/hubsante/model/resources/info/ResourcesEngagement.java b/src/main/java/com/hubsante/model/resources/info/ResourcesEngagement.java index e57f619b8b..76cd822fb7 100644 --- a/src/main/java/com/hubsante/model/resources/info/ResourcesEngagement.java +++ b/src/main/java/com/hubsante/model/resources/info/ResourcesEngagement.java @@ -49,7 +49,8 @@ @JsonTypeName("resourcesEngagement") @JsonInclude(JsonInclude.Include.NON_EMPTY) -public class ResourcesEngagement { +public class ResourcesEngagement + implements com.hubsante.model.edxl.UseCaseWithCaseId { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9:resourcesengagement"; public static final String JSON_PROPERTY_CASE_ID = "caseId"; diff --git a/src/main/java/com/hubsante/model/resources/info/ResourcesEngagementWrapper.java b/src/main/java/com/hubsante/model/resources/info/ResourcesEngagementWrapper.java index 4d8345710e..1d2a2a1b68 100644 --- a/src/main/java/com/hubsante/model/resources/info/ResourcesEngagementWrapper.java +++ b/src/main/java/com/hubsante/model/resources/info/ResourcesEngagementWrapper.java @@ -34,11 +34,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.rcde.DistributionElement; import com.hubsante.model.resources.info.ResourcesEngagement; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * ResourcesEngagementWrapper @@ -57,6 +59,19 @@ public class ResourcesEngagementWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "resourcesEngagement"; + } + + @Override + public Optional getCaseId() { + return resourcesEngagement instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_RESOURCES_ENGAGEMENT = "resourcesEngagement"; private ResourcesEngagement resourcesEngagement; diff --git a/src/main/java/com/hubsante/model/resources/info/ResourcesInfo.java b/src/main/java/com/hubsante/model/resources/info/ResourcesInfo.java index 491667b823..b4301dc2ca 100644 --- a/src/main/java/com/hubsante/model/resources/info/ResourcesInfo.java +++ b/src/main/java/com/hubsante/model/resources/info/ResourcesInfo.java @@ -49,7 +49,8 @@ @JsonTypeName("resourcesInfo") @JsonInclude(JsonInclude.Include.NON_EMPTY) -public class ResourcesInfo { +public class ResourcesInfo + implements com.hubsante.model.edxl.UseCaseWithCaseId { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9:resourcesinfo"; public static final String JSON_PROPERTY_CASE_ID = "caseId"; diff --git a/src/main/java/com/hubsante/model/resources/info/ResourcesInfoWrapper.java b/src/main/java/com/hubsante/model/resources/info/ResourcesInfoWrapper.java index 59e75a82df..0adf46ac15 100644 --- a/src/main/java/com/hubsante/model/resources/info/ResourcesInfoWrapper.java +++ b/src/main/java/com/hubsante/model/resources/info/ResourcesInfoWrapper.java @@ -34,11 +34,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.rcde.DistributionElement; import com.hubsante.model.resources.info.ResourcesInfo; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * ResourcesInfoWrapper @@ -56,6 +58,19 @@ public class ResourcesInfoWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "resourcesInfo"; + } + + @Override + public Optional getCaseId() { + return resourcesInfo instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_RESOURCES_INFO = "resourcesInfo"; private ResourcesInfo resourcesInfo; diff --git a/src/main/java/com/hubsante/model/resources/request/ResourcesRequest.java b/src/main/java/com/hubsante/model/resources/request/ResourcesRequest.java index a1371f9aa2..6dbad5b81c 100644 --- a/src/main/java/com/hubsante/model/resources/request/ResourcesRequest.java +++ b/src/main/java/com/hubsante/model/resources/request/ResourcesRequest.java @@ -48,7 +48,8 @@ @JsonTypeName("resourcesRequest") @JsonInclude(JsonInclude.Include.NON_EMPTY) -public class ResourcesRequest { +public class ResourcesRequest + implements com.hubsante.model.edxl.UseCaseWithCaseId { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9:resourcesrequest"; public static final String JSON_PROPERTY_CASE_ID = "caseId"; diff --git a/src/main/java/com/hubsante/model/resources/request/ResourcesRequestWrapper.java b/src/main/java/com/hubsante/model/resources/request/ResourcesRequestWrapper.java index 5c5a4d2550..f8a96f87ee 100644 --- a/src/main/java/com/hubsante/model/resources/request/ResourcesRequestWrapper.java +++ b/src/main/java/com/hubsante/model/resources/request/ResourcesRequestWrapper.java @@ -34,11 +34,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.rcde.DistributionElement; import com.hubsante.model.resources.request.ResourcesRequest; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * ResourcesRequestWrapper @@ -56,6 +58,19 @@ public class ResourcesRequestWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "resourcesRequest"; + } + + @Override + public Optional getCaseId() { + return resourcesRequest instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_RESOURCES_REQUEST = "resourcesRequest"; private ResourcesRequest resourcesRequest; diff --git a/src/main/java/com/hubsante/model/resources/response/ResourcesResponse.java b/src/main/java/com/hubsante/model/resources/response/ResourcesResponse.java index 540903105f..c734f52b28 100644 --- a/src/main/java/com/hubsante/model/resources/response/ResourcesResponse.java +++ b/src/main/java/com/hubsante/model/resources/response/ResourcesResponse.java @@ -48,7 +48,8 @@ @JsonTypeName("resourcesResponse") @JsonInclude(JsonInclude.Include.NON_EMPTY) -public class ResourcesResponse { +public class ResourcesResponse + implements com.hubsante.model.edxl.UseCaseWithCaseId { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9:resourcesresponse"; public static final String JSON_PROPERTY_CASE_ID = "caseId"; diff --git a/src/main/java/com/hubsante/model/resources/response/ResourcesResponseWrapper.java b/src/main/java/com/hubsante/model/resources/response/ResourcesResponseWrapper.java index 0828dadb82..38fc397480 100644 --- a/src/main/java/com/hubsante/model/resources/response/ResourcesResponseWrapper.java +++ b/src/main/java/com/hubsante/model/resources/response/ResourcesResponseWrapper.java @@ -34,11 +34,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.rcde.DistributionElement; import com.hubsante.model.resources.response.ResourcesResponse; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * ResourcesResponseWrapper @@ -56,6 +58,19 @@ public class ResourcesResponseWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "resourcesResponse"; + } + + @Override + public Optional getCaseId() { + return resourcesResponse instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_RESOURCES_RESPONSE = "resourcesResponse"; private ResourcesResponse resourcesResponse; diff --git a/src/main/java/com/hubsante/model/resources/status/ResourcesStatus.java b/src/main/java/com/hubsante/model/resources/status/ResourcesStatus.java index 22d6672723..5e44daf11c 100644 --- a/src/main/java/com/hubsante/model/resources/status/ResourcesStatus.java +++ b/src/main/java/com/hubsante/model/resources/status/ResourcesStatus.java @@ -48,7 +48,8 @@ @JsonTypeName("resourcesStatus") @JsonInclude(JsonInclude.Include.NON_EMPTY) -public class ResourcesStatus { +public class ResourcesStatus + implements com.hubsante.model.edxl.UseCaseWithCaseId { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9:resourcesstatus"; public static final String JSON_PROPERTY_CASE_ID = "caseId"; diff --git a/src/main/java/com/hubsante/model/resources/status/ResourcesStatusWrapper.java b/src/main/java/com/hubsante/model/resources/status/ResourcesStatusWrapper.java index 49b7c6a529..0f96ef7677 100644 --- a/src/main/java/com/hubsante/model/resources/status/ResourcesStatusWrapper.java +++ b/src/main/java/com/hubsante/model/resources/status/ResourcesStatusWrapper.java @@ -34,11 +34,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.rcde.DistributionElement; import com.hubsante.model.resources.status.ResourcesStatus; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * ResourcesStatusWrapper @@ -56,6 +58,19 @@ public class ResourcesStatusWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "resourcesStatus"; + } + + @Override + public Optional getCaseId() { + return resourcesStatus instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_RESOURCES_STATUS = "resourcesStatus"; private ResourcesStatus resourcesStatus; diff --git a/src/main/java/com/hubsante/model/rpis/RpisWrapper.java b/src/main/java/com/hubsante/model/rpis/RpisWrapper.java index 54041bc53d..629137c188 100644 --- a/src/main/java/com/hubsante/model/rpis/RpisWrapper.java +++ b/src/main/java/com/hubsante/model/rpis/RpisWrapper.java @@ -34,11 +34,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.rcde.DistributionElement; import com.hubsante.model.rpis.Rpis; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * RpisWrapper @@ -56,6 +58,19 @@ public class RpisWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "rpis"; + } + + @Override + public Optional getCaseId() { + return rpis instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_RPIS = "rpis"; private Rpis rpis; diff --git a/src/main/java/com/hubsante/model/sas/AppointmentWrapper.java b/src/main/java/com/hubsante/model/sas/AppointmentWrapper.java index a51ecdb53e..d3c390e37a 100644 --- a/src/main/java/com/hubsante/model/sas/AppointmentWrapper.java +++ b/src/main/java/com/hubsante/model/sas/AppointmentWrapper.java @@ -34,11 +34,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.rcde.DistributionElement; import com.hubsante.model.sas.Appointment; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * AppointmentWrapper @@ -56,6 +58,19 @@ public class AppointmentWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "appointment"; + } + + @Override + public Optional getCaseId() { + return appointment instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_APPOINTMENT = "appointment"; private Appointment appointment; diff --git a/src/main/java/com/hubsante/model/technical/TechnicalWrapper.java b/src/main/java/com/hubsante/model/technical/TechnicalWrapper.java index 4f5cab3cb2..ba27360d41 100644 --- a/src/main/java/com/hubsante/model/technical/TechnicalWrapper.java +++ b/src/main/java/com/hubsante/model/technical/TechnicalWrapper.java @@ -34,11 +34,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.rcde.DistributionElement; import com.hubsante.model.technical.Technical; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * TechnicalWrapper @@ -56,6 +58,19 @@ public class TechnicalWrapper extends DistributionElement { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "technical"; + } + + @Override + public Optional getCaseId() { + return technical instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_TECHNICAL = "technical"; private Technical technical; diff --git a/src/main/java/com/hubsante/model/technical/noreq/TechnicalNoreqWrapper.java b/src/main/java/com/hubsante/model/technical/noreq/TechnicalNoreqWrapper.java index c26a419e2e..0d2dfb596c 100644 --- a/src/main/java/com/hubsante/model/technical/noreq/TechnicalNoreqWrapper.java +++ b/src/main/java/com/hubsante/model/technical/noreq/TechnicalNoreqWrapper.java @@ -35,10 +35,12 @@ import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.dataformat.xml.annotation.*; import com.hubsante.model.edxl.ContentMessage; +import com.hubsante.model.edxl.UseCaseWithCaseId; import com.hubsante.model.technical.noreq.TechnicalNoreq; import java.util.Arrays; import java.util.Arrays; import java.util.Objects; +import java.util.Optional; /** * TechnicalNoreqWrapper @@ -50,6 +52,19 @@ public class TechnicalNoreqWrapper extends ContentMessage { @JacksonXmlProperty(isAttribute = true) String xmlns = "urn:emergency:eda:1.9"; + + @Override + public String getUseCaseName() { + return "technicalNoreq"; + } + + @Override + public Optional getCaseId() { + return technicalNoreq instanceof UseCaseWithCaseId useCaseWithCaseId + ? Optional.ofNullable(useCaseWithCaseId.getCaseId()) + : Optional.empty(); + } + public static final String JSON_PROPERTY_TECHNICAL_NOREQ = "technicalNoreq"; private TechnicalNoreq technicalNoreq; diff --git a/src/main/resources/test-cases/Perimetre_15-15/Partage_de_dossier_simple_(sans_demande_de_prise_en_charge)/1-Reception_RS-EDA_JDD1.json b/src/main/resources/test-cases/Perimetre_15-15/Partage_de_dossier_simple_(sans_demande_de_prise_en_charge)/1-Reception_RS-EDA_JDD1.json deleted file mode 100644 index ca3927cdaf..0000000000 --- a/src/main/resources/test-cases/Perimetre_15-15/Partage_de_dossier_simple_(sans_demande_de_prise_en_charge)/1-Reception_RS-EDA_JDD1.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "createCaseHealth": { - "caseId": "fr.health.samu770-DRFR157702400400055", - "creation": "2024-01-18T15:15:00+01:00", - "referenceVersion": "1.3", - "perimeter": "AMU", - "interventionType": "Primaire", - "qualification": { - "whatsHappen": { - "code": "C02.08.05", - "label": "Atteinte aux personnes ; Traumatisme / Accident ; Par objet tranchant ou perforant" - }, - "locationKind": { - "code": "L01.01.04", - "label": "Domicile ; Maison particulière, pavillon ; dépendance" - }, - "healthMotive": { - "code": "M01.02", - "label": "Détresse vitale; Altération de la conscience; Dont inconscient, coma" - }, - "details": { - "priority": "P0", - "attribution": "DRM.MRU.MU" - } - }, - "owner": "fr.health.samu770", - "patient": [ - { - "id": "fr.health.samu770-DRFR157702400400055.P167", - "identity": { - "strictFeatures": { - "sex": "MASC", - "birthDate": "1959-02-01" - }, - "nonStrictFeatures": { - "complete": "Didier Morel", - "firstName": "Didier ", - "lastName": "Morel" - } - }, - "detail": { - "age": "P65Y" - } - } - ], - "location": { - "locID": "555fb03a-4df5-8zg6-8e81-990c4511256", - "country": "FR", - "detailedAddress": { - "complete": "12 Rue Louis Aristide Verdier " - }, - "city": { - "name": "Vaires-sur-Marne", - "inseeCode": "77479" - }, - "freetext": "Aller directement dans le garage", - "geometry": { - "obsDatime": "2024-01-04T00:05:00+01:00", - "point": { - "coord": { - "lat": 48.866920471191406, - "lon": 2.631575345993042, - "precision": "ADDRESS" - } - } - } - }, - "initialAlert": { - "id": "ALRT-2024-ABC123", - "reception": "2024-01-18T15:15:00+01:00", - "reporting": "STANDARD", - "caller": { - "callerContact": { - "type": "PHNADD", - "detail": "0607080915", - "channel": "Personne" - }, - "callbackContact": { - "type": "PHNADD", - "detail": "0607080915", - "channel": "Personne" - }, - "language": "fr", - "type": "FAMILLE", - "detailedName": { - "complete": "Sébastien Morel", - "firstName": "Sébastien", - "lastName": "Morel" - } - }, - "notes": [ - { - "freetext": "Coupure grave causée par une scie circulaire au niveau de la main; saigne beaucoup. " - }, - { - "freetext": "La victime est inconsciente (perte de connaissance)." - } - ], - "callTaker": { - "organization": "fr.health.samu770", - "controlRoom": "CRRA 77" - } - } - } -} \ No newline at end of file diff --git a/src/main/resources/test-cases/Perimetre_15-15/Partage_de_dossier_simple_(sans_demande_de_prise_en_charge)/1-Reception_RS-EDA_JDD2.json b/src/main/resources/test-cases/Perimetre_15-15/Partage_de_dossier_simple_(sans_demande_de_prise_en_charge)/1-Reception_RS-EDA_JDD2.json deleted file mode 100644 index 296f7d3560..0000000000 --- a/src/main/resources/test-cases/Perimetre_15-15/Partage_de_dossier_simple_(sans_demande_de_prise_en_charge)/1-Reception_RS-EDA_JDD2.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "createCaseHealth": { - "caseId": "fr.health.samu950-DRFR159502400400159", - "creation": "2024-01-18T15:15:00+01:00", - "referenceVersion": "1.4", - "perimeter": "AMU", - "interventionType": "Primaire", - "qualification": { - "whatsHappen": { - "code": "C02.08.02", - "label": "Atteinte aux personnes ; Traumatisme / Accident ; Accident domestique" - }, - "locationKind": { - "code": "L01.02.10", - "label": "Domicile ; Lieu d'habitation collectif ou foyer d'hébergement ; escaliers" - }, - "healthMotive": { - "code": "M02.07", - "label": "Traumatisme sérieux, plaie intermédiaire" - }, - "details": { - "priority": "P2", - "attribution": "DRM.MRU.MU" - } - }, - "owner": "fr.health.samu950", - "patient": [ - { - "id": "fr.health.samu950-DRFR159502400400159.P5", - "identity": { - "strictFeatures": { - "sex": "FEM", - "birthDate": "2014-03-03" - }, - "nonStrictFeatures": { - "complete": "Lola Halimi", - "firstName": "Lola ", - "lastName": "Halimi" - } - }, - "detail": { - "age": "P10Y" - } - } - ], - "location": { - "locID": "567op03a-3qr4-5st6-7uv8-109u8765432", - "country": "FR", - "detailedAddress": { - "complete": "4 rue Danielle Mitterrand" - }, - "city": { - "name": "Bezons", - "inseeCode": "95063" - }, - "access": { - "floor": "3", - "interphone": "Halimi", - "accessCode": "5678", - "elevator": "ESC B", - "buildingName": "A" - }, - "freetext": "dans la cage d’escalier B", - "geometry": { - "obsDatime": "2024-01-04T00:05:00+01:00", - "point": { - "coord": { - "lat": 48.92399978637695, - "lon": 2.2162439823150635, - "precision": "ADDRESS" - } - } - } - }, - "initialAlert": { - "id": "ALRT-2024-ZGY594", - "reception": "2024-01-18T15:15:00+01:00", - "reporting": "STANDARD", - "caller": { - "callerContact": { - "type": "PHNADD", - "detail": "702880946", - "channel": "Personne" - }, - "callbackContact": { - "type": "PHNADD", - "detail": "702880946", - "channel": "Personne" - }, - "language": "fr", - "type": "TIERS", - "detailedName": { - "complete": "Amina BERTRAND ", - "firstName": "Amina ", - "lastName": "BERTRAND " - } - }, - "notes": [ - { - "freetext": "Entorse de la cheville, avec possible fracture. " - }, - { - "freetext": "Cheville gonflée et douloureuse. " - }, - { - "freetext": "Marche impossible." - } - ], - "callTaker": { - "organization": "fr.health.samu950", - "controlRoom": "CRRA 95" - } - } - } -} \ No newline at end of file diff --git a/src/main/resources/test-cases/Perimetre_15-15/Partage_de_dossier_simple_(sans_demande_de_prise_en_charge)/1-Reception_RS-EDA_JDD3.json b/src/main/resources/test-cases/Perimetre_15-15/Partage_de_dossier_simple_(sans_demande_de_prise_en_charge)/1-Reception_RS-EDA_JDD3.json deleted file mode 100644 index a4eb466a70..0000000000 --- a/src/main/resources/test-cases/Perimetre_15-15/Partage_de_dossier_simple_(sans_demande_de_prise_en_charge)/1-Reception_RS-EDA_JDD3.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "createCaseHealth": { - "caseId": "fr.health.samu009-DRFR150092400401259", - "creation": "2024-01-18T15:15:00+01:00", - "referenceVersion": "1.4", - "perimeter": "AMU", - "interventionType": "Primaire", - "qualification": { - "whatsHappen": { - "code": "C02.05.00", - "label": "Atteinte aux personnes ; Pathologie / maladie" - }, - "locationKind": { - "code": "L04.12.00", - "label": "Lieu accueillant du public ; Hébergement touristique" - }, - "healthMotive": { - "code": "M03.08", - "label": "Signes d’AVC" - }, - "details": { - "priority": "P1", - "attribution": "DRM.MRU.MU" - } - }, - "owner": "fr.health.samu009", - "patient": [ - { - "id": "fr.health.samu009-DRFR150092400401259.P90", - "identity": { - "strictFeatures": { - "sex": "INCONNU" - } - }, - "detail": { - "age": "P80Y" - } - } - ], - "location": { - "locID": "654ij03a-1kl2-3mn4-5op6-210p9876543", - "country": "FR", - "name": "Le gite du Moulin ", - "detailedAddress": { - "complete": "Rue principale" - }, - "city": { - "name": "Aulus-les-Bains", - "inseeCode": "9029" - }, - "access": { - "phoneNumber": "561964589" - }, - "freetext": "Maison avec la porte verte, 100 m après le lavoir" - }, - "initialAlert": { - "id": "ALRT-2024-AMP697", - "reception": "2024-01-18T15:15:00+01:00", - "reporting": "STANDARD", - "caller": { - "callerContact": { - "type": "PHNADD", - "detail": "632085528", - "channel": "Personne" - }, - "callbackContact": { - "type": "PHNADD", - "detail": "561964589", - "channel": "Personne" - }, - "language": "fr", - "type": "TIERS", - "detailedName": { - "complete": "Lucas Bernardi ", - "firstName": "Lucas", - "lastName": "Bernardi " - } - }, - "notes": [ - { - "freetext": "Confusion, étourdissements, s’exprime difficilement" - } - ], - "callTaker": { - "organization": "fr.health.samu090", - "controlRoom": "CRRA 09" - } - } - } -} \ No newline at end of file diff --git a/src/test/java/com/hubsante/model/edxlhandler/EdxlHandlerTest.java b/src/test/java/com/hubsante/model/edxlhandler/EdxlHandlerTest.java index 814b5d3b48..d2f7081477 100644 --- a/src/test/java/com/hubsante/model/edxlhandler/EdxlHandlerTest.java +++ b/src/test/java/com/hubsante/model/edxlhandler/EdxlHandlerTest.java @@ -26,7 +26,6 @@ import com.hubsante.model.edxl.EdxlMessage; import com.hubsante.model.exception.ValidationException; import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.opentest4j.AssertionFailedError; @@ -34,16 +33,13 @@ import javax.xml.stream.XMLInputFactory; import java.io.File; import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; @@ -52,7 +48,6 @@ import static com.hubsante.model.TestMessagesHelper.getInvalidMessage; import static com.hubsante.model.Utils.createCustomJavaTimeModule; import static com.hubsante.model.Utils.getXmlMapper; -import static com.hubsante.model.config.Constants.FULL_SCHEMA; import static com.hubsante.model.config.Constants.FULL_XSD; import static com.hubsante.model.utils.TestFileUtils.getMessageByFileName; import static com.hubsante.model.utils.TestFileUtils.getMessageString; @@ -97,92 +92,6 @@ public void deserializeCompleteMessages() throws IOException { EdxlMessage expectedMessage = converter.deserializeXmlEDXL(useCaseXml); } - @Test - @DisplayName("all examples files deserializing") - public void examplesBundlePassingTest() { - String rootFolder = TestMessagesHelper.class.getClassLoader().getResource("sample/examples").getFile(); - File[] subFolders = new File(rootFolder).listFiles(File::isDirectory); - assert subFolders != null; - - List files = new ArrayList<>(); - Arrays.stream(subFolders).forEach(folder -> { - files.addAll(Arrays.asList(Objects.requireNonNull(folder.listFiles()))); - }); - - AtomicBoolean allPass = new AtomicBoolean(true); - - files.forEach(file -> { - try { - if(file.getName().endsWith(".json")) { - String useCaseJson = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); - // We wrap the use case message in a full json message, except for messages which do not - // require RC-DE header - String fullJson; - if (Arrays.stream(useCasesWithNoRcDe).anyMatch(file.getName()::contains)) - fullJson = wrapUseCaseMessageWithoutDistributionElement(useCaseJson); - else - fullJson = wrapUseCaseMessage(useCaseJson); - - converter.deserializeJsonEDXL(fullJson); - } else { - String useCaseXml = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); - converter.deserializeXmlEDXL(useCaseXml); - } - log.info("File {} has been successfully deserialized", file.getName()); - - }catch (JsonProcessingException e) { - allPass.set(false); - log.error("File " + file.getName() + " could have not been deserialized: " + e.getMessage()); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - - if (!allPass.get()) { - fail("Some files are not valid against schema"); - } - } - - @Test - @Disabled // ToDo(SSV): remove when recette Excel is up-to-date - @DisplayName("all auto-generated test-case reception step files passing") - public void autoGeneratedTestCasesPassingTest() throws IOException, URISyntaxException { - // Get all files from resources/test-cases - URI uri = Objects.requireNonNull(getClass().getClassLoader().getResource("test-cases")).toURI(); - Path path = Paths.get(uri); - List files = Files.walk(path) - .filter(Files::isRegularFile) - .map(Path::toFile) - .collect(Collectors.toList()); - - AtomicBoolean allPass = new AtomicBoolean(true); - - files.forEach(file -> { - try { - String useCaseJson = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); - String fullJson = wrapUseCaseMessage(useCaseJson); - - converter.deserializeJsonEDXL(fullJson); - log.info("File {} has been successfully deserialized", file.getName()); - - validator.validateJSON(fullJson, FULL_SCHEMA); - log.info("File {} is valid against schema", file.getName()); - - }catch (JsonProcessingException e) { - allPass.set(false); - log.error("File " + file.getName() + " could have not been deserialized: " + e.getMessage()); - } catch (IOException e) { - throw new RuntimeException(e); - } catch (ValidationException e) { - allPass.set(false); - log.error("File " + file.getName() + " is not valid against schema: " + e.getMessage()); - } - }); - if (!allPass.get()) { - fail("Some files are not valid against schema"); - } - } - @Test @DisplayName("deserialization of a message with an unknown additional property not at root level fails") public void deserializationOfMessageWithUnknownPropertyNotAtRootLevelFails() throws IOException { @@ -260,6 +169,95 @@ public void severalContentElements() throws IOException, ValidationException { assertFalse(xml.contains(" { + try { + String fullJson = wrapExample(file); + endToEndDeserializationCheck(fullJson, false); + + String fullXml = converter.serializeXmlEDXL(converter.deserializeJsonEDXL(fullJson)); + endToEndDeserializationCheck(fullXml, true); + log.info("File {} has been successfully round tripped", file.getName()); + } catch (IOException | RuntimeException | AssertionFailedError e) { + allPass.set(false); + log.error("File {} could not be round tripped: {}", file.getName(), e.getMessage()); + } + }); + + if (!allPass.get()) { + fail("Some files could not be round tripped"); + } + } + + @Test + @DisplayName("use case name matches the example root element and is not serialized") + public void useCaseNameMatchesRootElementAndIsNotSerialized() { + AtomicBoolean allPass = new AtomicBoolean(true); + + getJsonExampleFiles().forEach(file -> { + try { + String useCaseName = converter.jsonMapper.readTree(file).fieldNames().next(); + EdxlMessage message = converter.deserializeJsonEDXL(wrapExample(file)); + + assertEquals(useCaseName, message.getFirstContentMessage().getUseCaseName()); + assertFalse(converter.serializeJsonEDXL(message).contains("useCaseName"), "useCaseName found in JSON"); + assertFalse(converter.serializeXmlEDXL(message).contains("useCaseName"), "useCaseName found in XML"); + } catch (IOException | AssertionFailedError e) { + allPass.set(false); + log.error("File {} has an invalid use case name: {}", file.getName(), e.getMessage()); + } + }); + + if (!allPass.get()) { + fail("Some files have an invalid use case name"); + } + } + + @Test + @DisplayName("case id matches the example root caseId when provided") + public void caseIdMatchesRootCaseId() { + AtomicBoolean allPass = new AtomicBoolean(true); + + getJsonExampleFiles().forEach(file -> { + try { + JsonNode rootCaseId = converter.jsonMapper.readTree(file).elements().next().get("caseId"); + Optional expectedCaseId = Optional.ofNullable(rootCaseId).map(JsonNode::asText); + EdxlMessage message = converter.deserializeJsonEDXL(wrapExample(file)); + + assertEquals(expectedCaseId, message.getFirstContentMessage().getCaseId()); + } catch (IOException | AssertionFailedError e) { + allPass.set(false); + log.error("File {} does't have expected case id: {}", file.getName(), e.getMessage()); + } + }); + + if (!allPass.get()) { + fail("Some files have unexpected case id"); + } + } + + private List getJsonExampleFiles() { + String rootFolder = TestMessagesHelper.class.getClassLoader().getResource("sample/examples").getFile(); + File[] subFolders = new File(rootFolder).listFiles(File::isDirectory); + assert subFolders != null; + + return Arrays.stream(subFolders) + .flatMap(folder -> Arrays.stream(Objects.requireNonNull(folder.listFiles()))) + .filter(file -> file.getName().endsWith(".json")) + .collect(Collectors.toList()); + } + + private String wrapExample(File file) throws IOException { + String useCaseJson = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); + if (Arrays.stream(useCasesWithNoRcDe).anyMatch(file.getName()::contains)) + return wrapUseCaseMessageWithoutDistributionElement(useCaseJson); + return wrapUseCaseMessage(useCaseJson); + } + @Test @DisplayName("XXE injection should succeed in vulnerable config and fail in safe config") public void testXXEDifferentialBehavior() throws Exception {