diff --git a/apps/resources/messages/compiled/adl_messages_db.e b/apps/resources/messages/compiled/adl_messages_db.e index ee275459b..d3772c224 100755 --- a/apps/resources/messages/compiled/adl_messages_db.e +++ b/apps/resources/messages/compiled/adl_messages_db.e @@ -24,7 +24,7 @@ feature -- Initialisation make do - create message_table.make (977) + create message_table.make (978) message_table.put ("Terminology initialisation failed; reason: $1", ec_terminology_init_failed) message_table.put ("Using ADL version $1 for output serialisation", ec_adl_version_warning) message_table.put ("Validation level STRICT", ec_validation_strict) @@ -547,7 +547,8 @@ feature -- Initialisation message_table.put ("Create in directory: ", ec_archetype_dir_label_text) message_table.put ("Archetype id: ", ec_archetype_id_label_text) message_table.put ("Parent id: ", ec_parent_archetype_id_label_text) - message_table.put ("Id $1 already exists in library", ec_duplicate_archetype_id_err_msg) + message_table.put ("Archetype with id $1 already exists in library", ec_duplicate_archetype_id_err_msg) + message_table.put ("Template overlay id $1 in template $2 already exists in template $3", ec_duplicate_template_overlay_id_err_msg) message_table.put ("Concept $1 contains invalid characters", ec_invalid_archetype_id_concept_err) message_table.put ("Configure object constraint", ec_initial_c_object_config_dialog_title) message_table.put ("Constraint type: ", ec_initial_c_object_config_constraint_type_text) diff --git a/apps/resources/messages/compiled/adl_messages_ids.e b/apps/resources/messages/compiled/adl_messages_ids.e index cf9629931..4469d8c0b 100755 --- a/apps/resources/messages/compiled/adl_messages_ids.e +++ b/apps/resources/messages/compiled/adl_messages_ids.e @@ -533,6 +533,7 @@ feature -- Definitions ec_archetype_id_label_text: STRING = "archetype_id_label_text" ec_parent_archetype_id_label_text: STRING = "parent_archetype_id_label_text" ec_duplicate_archetype_id_err_msg: STRING = "duplicate_archetype_id_err_msg" + ec_duplicate_template_overlay_id_err_msg: STRING = "duplicate_template_overlay_id_err_msg" ec_invalid_archetype_id_concept_err: STRING = "invalid_archetype_id_concept_err" ec_initial_c_object_config_dialog_title: STRING = "initial_c_object_config_dialog_title" ec_initial_c_object_config_constraint_type_text: STRING = "initial_c_object_config_constraint_type_text" diff --git a/apps/resources/messages/source/app_awb_ui_messages.txt b/apps/resources/messages/source/app_awb_ui_messages.txt index d4cee9e98..3ddbc649d 100755 --- a/apps/resources/messages/source/app_awb_ui_messages.txt +++ b/apps/resources/messages/source/app_awb_ui_messages.txt @@ -258,7 +258,8 @@ templates = < ["archetype_dir_label_text"] = <"Create in directory: "> ["archetype_id_label_text"] = <"Archetype id: "> ["parent_archetype_id_label_text"] = <"Parent id: "> - ["duplicate_archetype_id_err_msg"] = <"Id $1 already exists in library"> + ["duplicate_archetype_id_err_msg"] = <"Archetype with id $1 already exists in library"> + ["duplicate_template_overlay_id_err_msg"] = <"Template overlay id $1 in template $2 already exists in template $3"> ["invalid_archetype_id_concept_err"] = <"Concept $1 contains invalid characters"> -- INITIAL_C_OBJECT_DIALOG diff --git a/components/adl_compiler/src/interface/Archetype_library_report.e b/components/adl_compiler/src/interface/Archetype_library_report.e index add5c3014..8d44329a0 100644 --- a/components/adl_compiler/src/interface/Archetype_library_report.e +++ b/components/adl_compiler/src/interface/Archetype_library_report.e @@ -72,7 +72,7 @@ feature {ARCHETYPE_REPORTER} -- Processing feature {NONE} - text_quote_agent: FUNCTION [ANY, TUPLE[STRING], STRING] + text_quote_agent: FUNCTION [ANY, TUPLE[READABLE_STRING_8], READABLE_STRING_8] -- function to use to quote output format attribute Result := default_text_quoting_agent diff --git a/components/adl_compiler/src/interface/Id_code_report.e b/components/adl_compiler/src/interface/Id_code_report.e index 6068f2021..1d54e1475 100644 --- a/components/adl_compiler/src/interface/Id_code_report.e +++ b/components/adl_compiler/src/interface/Id_code_report.e @@ -42,7 +42,7 @@ feature -- Access Result := "All id-coded nodes in archetype library" end - output_table: ARRAYED_LIST[TUPLE [arch_id, id_code, path, use_ref, description, loinc_code: STRING]] + output_table: ARRAYED_LIST[TUPLE [arch_id, id_code, path, use_ref, description, loinc_code: READABLE_STRING_8]] once create Result.make(0) end diff --git a/components/adl_compiler/src/interface/Loinc_archetype_map_report.e b/components/adl_compiler/src/interface/Loinc_archetype_map_report.e index d5fc2293c..bf6149d8e 100644 --- a/components/adl_compiler/src/interface/Loinc_archetype_map_report.e +++ b/components/adl_compiler/src/interface/Loinc_archetype_map_report.e @@ -42,7 +42,7 @@ feature -- Access Result := "LOINC to Archetype id map" end - output_table: ARRAYED_LIST [TUPLE [loinc_code, arch_id, id_code, path, use_ref, description: STRING]] + output_table: ARRAYED_LIST [TUPLE [loinc_code, arch_id, id_code, path, use_ref, description: READABLE_STRING_8]] once create Result.make(0) end diff --git a/components/adl_compiler/src/interface/arch_id_to_tpl_id_report.e b/components/adl_compiler/src/interface/arch_id_to_tpl_id_report.e index 368daa3e9..3ad158b23 100644 --- a/components/adl_compiler/src/interface/arch_id_to_tpl_id_report.e +++ b/components/adl_compiler/src/interface/arch_id_to_tpl_id_report.e @@ -42,7 +42,7 @@ feature -- Access Result := "Archetype ID to Template ID map" end - output_table: ARRAYED_LIST[TUPLE [arch_id, tpl_id: STRING]] + output_table: ARRAYED_LIST[TUPLE [arch_id, tpl_id: READABLE_STRING_8]] once create Result.make(0) end diff --git a/components/adl_compiler/src/interface/archetype_reporter.e b/components/adl_compiler/src/interface/archetype_reporter.e index 4206e64cb..4e960f927 100644 --- a/components/adl_compiler/src/interface/archetype_reporter.e +++ b/components/adl_compiler/src/interface/archetype_reporter.e @@ -60,6 +60,7 @@ feature -- Access report3: ARCH_ID_TO_TPL_ID_MAP report4: VALUE_SETS_REPORT report5: SPECIALIZATION_GRAPH + report6: KEYWORDS_FREQUENCY_REPORT once create Result.make(0) @@ -80,6 +81,9 @@ feature -- Access create report5.make Result.put (report5, report5.title) + + create report6.make + Result.put (report6, report6.title) end feature -- Commands @@ -160,6 +164,9 @@ feature {NONE} -- Commands -- Generate `syntax' serialisation of archetypes under `an_export_dir' from all archetypes that have already been built. do current_library.do_all_archetypes (agent process_archetype) + across reports as rpts_csr loop + rpts_csr.item.finalise + end end valid_setup_args (args: like build_args_type): BOOLEAN @@ -228,7 +235,7 @@ feature {NONE} -- Implementation create Result end - text_quote_agent: FUNCTION [ANY, TUPLE[STRING], STRING] + text_quote_agent: FUNCTION [ANY, TUPLE[READABLE_STRING_8], READABLE_STRING_8] -- function to use to quote output format attribute Result := default_text_quoting_agent diff --git a/components/adl_compiler/src/interface/keywords_report.e b/components/adl_compiler/src/interface/keywords_report.e new file mode 100644 index 000000000..d8a0d091d --- /dev/null +++ b/components/adl_compiler/src/interface/keywords_report.e @@ -0,0 +1,86 @@ +note + component: "openEHR ADL Tools" + description: "Keywords frequency report" + keywords: "export, archetype, ADL" + author: "Thomas Beale " + support: "openEHR AWB project " + copyright: "Copyright (c) 2024- openEHR International" + license: "Apache 2.0 License " + +class KEYWORDS_FREQUENCY_REPORT + +inherit + ARCHETYPE_LIBRARY_REPORT + export + {NONE} all + redefine + output_table, finalise + end + + SHARED_ARCHETYPE_LIBRARIES + export + {NONE} all + end + + EXCEPTIONS + export + {NONE} all + end + +create + make + +feature -- Access + + id: STRING + do + Result := "keywords_fequency_report" + end + + title: STRING + do + Result := "Keywords frequency in archetype library" + end + + output_table: ARRAYED_LIST[TUPLE [keyword, arch_count: READABLE_STRING_8]] + once + create Result.make(0) + end + +feature {ARCHETYPE_REPORTER} -- Processing + + process_archetype (auth_ara: ARCH_LIB_ARCHETYPE) + -- Generate serialised output under `output_dir' from `ara', optionally building it first if necessary. + local + description: RESOURCE_DESCRIPTION + do + if attached {ARCH_LIB_AUTHORED_ARCHETYPE} auth_ara as aca and then attached aca.differential_archetype as arch then + if attached arch.description as desc and then attached desc.detail_for_language(Default_language) as desc_details then + if attached desc_details.keywords as kws then + across kws as kws_csr loop + if not keywords_table.has (kws_csr.item) then + keywords_table.put (1, kws_csr.item) + else + keywords_table.force (keywords_table.item (kws_csr.item) + 1, kws_csr.item) + end + end + end + end + end + end + + finalise + do + across keywords_table as kw_csr loop + output_table.extend ([text_quote_agent.item([kw_csr.key.as_string_8]), kw_csr.item.out]) + end + end + +feature {NONE} -- Implementation + + keywords_table: STRING_TABLE[INTEGER] + attribute + create Result.make(0) + end + +end diff --git a/components/adl_compiler/src/interface/specialization_graph_report.e b/components/adl_compiler/src/interface/specialization_graph_report.e index 8d5282930..45282ddd4 100644 --- a/components/adl_compiler/src/interface/specialization_graph_report.e +++ b/components/adl_compiler/src/interface/specialization_graph_report.e @@ -42,7 +42,7 @@ feature -- Access Result := "Specialization graph of archetype library" end - output_table: ARRAYED_LIST[TUPLE [arch_id, spec_lineage: STRING]] + output_table: ARRAYED_LIST[TUPLE [arch_id, spec_lineage: READABLE_STRING_8]] once create Result.make(0) end diff --git a/components/adl_compiler/src/syntax/adl/adl_2_engine.e b/components/adl_compiler/src/syntax/adl/adl_2_engine.e index 76590f6e0..f41b4d310 100755 --- a/components/adl_compiler/src/syntax/adl/adl_2_engine.e +++ b/components/adl_compiler/src/syntax/adl/adl_2_engine.e @@ -233,13 +233,22 @@ feature -- Parsing amp.parse_from_text (overlay_texts_csr.item, tpl_aca.id.physical_id + " @overlay " + overlay_texts_csr.target_index.out) if not amp.has_errors and then attached amp.last_archetype as arch_thumbnail then -- now create a descriptor for this overlay - check not current_library.has_archetype_with_id (arch_thumbnail.archetype_id.physical_id) end - if attached arch_thumbnail.parent_archetype_id as att_parent_id and then current_library.has_archetype_matching_ref (att_parent_id) then - create arch_lib_tpl_ovl.make (arch_thumbnail.archetype_id, att_parent_id, tpl_aca) - current_library.put_new_archetype (arch_lib_tpl_ovl) - tpl_aca.add_overlay (arch_lib_tpl_ovl, overlay_texts_csr.item, arch_thumbnail.archetype_id.physical_id) + if not current_library.has_archetype_with_id (arch_thumbnail.archetype_id.physical_id) then + if attached arch_thumbnail.parent_archetype_id as att_parent_id and then current_library.has_archetype_matching_ref (att_parent_id) then + create arch_lib_tpl_ovl.make (arch_thumbnail.archetype_id, att_parent_id, tpl_aca) + current_library.put_new_archetype (arch_lib_tpl_ovl) + tpl_aca.add_overlay (arch_lib_tpl_ovl, overlay_texts_csr.item, arch_thumbnail.archetype_id.physical_id) + else + errors.add_error ({ADL_MESSAGES_IDS}.ec_VTPIOV, <>, generator + ".parse") + end else - errors.add_error ({ADL_MESSAGES_IDS}.ec_VTPIOV, <>, generator + ".parse") + if attached {ARCH_LIB_TEMPLATE_OVERLAY} current_library.archetype_with_id (arch_thumbnail.archetype_id.physical_id) as aca_ovl then + errors.add_error ({ADL_MESSAGES_IDS}.ec_duplicate_template_overlay_id_err_msg, + <>, generator + ".parse") + else + errors.add_error ({ADL_MESSAGES_IDS}.ec_duplicate_template_overlay_id_err_msg, + <>, generator + ".parse") + end end else errors.add_error ({ADL_MESSAGES_IDS}.ec_STOV, Void, generator + ".parse") diff --git a/components/archetype_repository/src/library/arch_lib_template_overlay.e b/components/archetype_repository/src/library/arch_lib_template_overlay.e index 8d5e769f8..5294a19eb 100755 --- a/components/archetype_repository/src/library/arch_lib_template_overlay.e +++ b/components/archetype_repository/src/library/arch_lib_template_overlay.e @@ -93,6 +93,9 @@ feature -- Artefacts differential_archetype: detachable TEMPLATE_OVERLAY + template: ARCH_LIB_TEMPLATE + -- owning template + feature {ARCH_LIB_ARCHETYPE} -- Compilation compile_actions: HASH_TABLE [PROCEDURE [ARCH_LIB_ARCHETYPE, TUPLE], INTEGER] @@ -131,11 +134,6 @@ feature -- Editing -- set revision appropriately end -feature {NONE} -- Implementation - - template: ARCH_LIB_TEMPLATE - -- owning template - invariant Is_specialised: is_specialised diff --git a/libraries/openehr/src/am/archetype/archetype_definitions.e b/libraries/openehr/src/am/archetype/archetype_definitions.e index d0ec25498..192dbb5f6 100755 --- a/libraries/openehr/src/am/archetype/archetype_definitions.e +++ b/libraries/openehr/src/am/archetype/archetype_definitions.e @@ -132,7 +132,7 @@ feature -- Export Types not_empty: not Result.is_empty end - text_quoting_agents: HASH_TABLE [FUNCTION [ANY, TUPLE[STRING], STRING], STRING] + text_quoting_agents: HASH_TABLE [FUNCTION [ANY, TUPLE[READABLE_STRING_8], READABLE_STRING_8], READABLE_STRING_8] once create Result.make(0) Result.put (agent json_quote_text, {ODIN_DEFINITIONS}.syntax_type_json) @@ -145,12 +145,13 @@ feature -- Export Types Result := s end - csv_quote_text (s: STRING): STRING + csv_quote_text (s: READABLE_STRING_8): READABLE_STRING_8 do - Result := Csv_default_quote + s + Csv_default_quote + -- create {STRING} Result.make_from_string (Csv_default_quote + s + Csv_default_quote) + Result := Csv_default_quote + s + Csv_default_quote end - default_text_quoting_agent: FUNCTION [ANY, TUPLE[STRING], STRING] + default_text_quoting_agent: FUNCTION [ANY, TUPLE[READABLE_STRING_8], READABLE_STRING_8] once Result := agent csv_quote_text end diff --git a/libraries/openehr/src/am/archetype/description/archetype_description.e b/libraries/openehr/src/am/archetype/description/archetype_description.e index 096410ad2..4d05f4fe2 100644 --- a/libraries/openehr/src/am/archetype/description/archetype_description.e +++ b/libraries/openehr/src/am/archetype/description/archetype_description.e @@ -35,7 +35,6 @@ feature -- Initialisation create original_author.make(0) ensure then lifecycle_state_set: lifecycle_state.is_equal(Default_lifecycle_state) - details_exists: details /= Void end make @@ -68,7 +67,7 @@ feature -- Access -- Original author of this archetype, with all relevant details, -- including organisation. - archetype_package_uri: URI + archetype_package_uri: detachable URI -- URI of archetype package details: HASH_TABLE [ARCHETYPE_DESCRIPTION_ITEM, STRING] @@ -79,15 +78,15 @@ feature -- Access -- submitted, experimental, awaiting_approval, approved, -- superseded, obsolete. State machine defined by archetype system - other_contributors: ARRAYED_LIST [STRING] + other_contributors: detachable ARRAYED_LIST [STRING] - other_details: HASH_TABLE [STRING, STRING] + other_details: detachable HASH_TABLE [STRING, STRING] - details_for_lang(a_lang: STRING): ARCHETYPE_DESCRIPTION_ITEM + details_for_lang(a_lang: STRING): detachable ARCHETYPE_DESCRIPTION_ITEM -- get details for given language -- Void if nothing for that language require - Lang_valid: a_lang /= Void and then not a_lang.is_empty + Lang_valid: not a_lang.is_empty do if details.has(a_lang) then Result := details.item(a_lang) diff --git a/libraries/openehr/src/am/archetype/description/archetype_description_item.e b/libraries/openehr/src/am/archetype/description/archetype_description_item.e index b73712a24..422f20c45 100644 --- a/libraries/openehr/src/am/archetype/description/archetype_description_item.e +++ b/libraries/openehr/src/am/archetype/description/archetype_description_item.e @@ -31,11 +31,16 @@ feature -- Initialisation make_lang (a_lang, a_purpose: STRING) require - Lang_valid: a_lang /= Void and then not a_lang.is_empty - Purpose_valid: a_purpose /= Void and then not a_purpose.is_empty + Lang_valid: not a_lang.is_empty + Purpose_valid: not a_purpose.is_empty do language := a_lang purpose := a_purpose + create use.make_empty + create keywords.make (0) + create misuse.make_empty + create copyright.make_empty + create other_details.make (0) ensure Language_set: language = a_lang Purpose_set: purpose = a_purpose @@ -65,7 +70,7 @@ feature -- Access -- Rights over the archetype as a knowledge resource; -- usually copyright and/or license to use. - original_resource_uri: HASH_TABLE [URI, STRING] + original_resource_uri: detachable HASH_TABLE [URI, STRING] -- URI of precursor resource of archetype, e.g. natural language -- document, semi-formal description