Skip to content

Commit

Permalink
added option to show and hide warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenSommer committed Jul 30, 2024
1 parent c9b3c2d commit fc2057c
Show file tree
Hide file tree
Showing 12 changed files with 3,118 additions and 1,950 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions projects/erp/mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"id": "10ac71f3-3204-4b82-b8a3-f7ecc4a7a98a",
"version": "1.0",
"status": "active",
"last_updated": "2024-07-30 16:51:11",
"last_updated": "2024-07-30 17:55:12",
"mappings": {
"Medication.amount": "Medication.amount",
"Medication.amount.numerator.extension:Gesamtmenge": "Medication.amount.numerator.extension:totalQuantity",
Expand All @@ -31,7 +31,7 @@
"id": "477e227a-6664-437d-8084-325bc9d25405",
"version": "1.0",
"status": "active",
"last_updated": "2024-07-30 16:51:11",
"last_updated": "2024-07-30 17:55:12",
"mappings": {
"Medication.amount": "Medication.amount",
"Medication.amount.numerator.extension:Gesamtmenge": "Medication.amount.numerator.extension:totalQuantity",
Expand Down Expand Up @@ -60,7 +60,7 @@
"id": "10ac71f3-3204-4b82-b8a3-f7ecc4a7a98a",
"version": "1.0",
"status": "active",
"last_updated": "2024-07-30 16:51:11",
"last_updated": "2024-07-30 17:55:12",
"mappings": {
"Medication.batch": "Medication.batch",
"Medication.code": "Medication.code",
Expand All @@ -79,7 +79,7 @@
"id": "477e227a-6664-437d-8084-325bc9d25405",
"version": "1.0",
"status": "active",
"last_updated": "2024-07-30 16:51:11",
"last_updated": "2024-07-30 17:55:12",
"mappings": {
"Medication.batch": "Medication.batch",
"Medication.code": "Medication.code",
Expand All @@ -100,7 +100,7 @@
"id": "10ac71f3-3204-4b82-b8a3-f7ecc4a7a98a",
"version": "1.0",
"status": "active",
"last_updated": "2024-07-30 16:51:11",
"last_updated": "2024-07-30 17:55:12",
"mappings": {
"Medication.amount": "Medication.amount",
"Medication.amount.numerator.extension:Packungsgroesse": "Medication.amount.numerator.extension:packagingSize",
Expand All @@ -124,7 +124,7 @@
"id": "477e227a-6664-437d-8084-325bc9d25405",
"version": "1.0",
"status": "active",
"last_updated": "2024-07-30 16:51:11",
"last_updated": "2024-07-30 17:55:12",
"mappings": {
"Medication.amount": "Medication.amount",
"Medication.amount.numerator.extension:Packungsgroesse": "Medication.amount.numerator.extension:packagingSize",
Expand All @@ -150,7 +150,7 @@
"id": "10ac71f3-3204-4b82-b8a3-f7ecc4a7a98a",
"version": "1.0",
"status": "active",
"last_updated": "2024-07-30 16:51:11",
"last_updated": "2024-07-30 17:55:12",
"mappings": {
"Medication.amount": "Medication.amount",
"Medication.amount.numerator.extension:Packungsgroesse": "Medication.amount.numerator.extension:packagingSize",
Expand All @@ -173,7 +173,7 @@
"id": "477e227a-6664-437d-8084-325bc9d25405",
"version": "1.0",
"status": "active",
"last_updated": "2024-07-30 16:51:11",
"last_updated": "2024-07-30 17:55:12",
"mappings": {
"Medication.amount": "Medication.amount",
"Medication.amount.numerator.extension:Packungsgroesse": "Medication.amount.numerator.extension:packagingSize",
Expand All @@ -198,7 +198,7 @@
"id": "615205d2-7288-47ce-a65a-009c37ed8447",
"version": "1.0",
"status": "active",
"last_updated": "2024-07-30 16:51:11",
"last_updated": "2024-07-30 17:55:12",
"mappings": {
"Practitioner.identifier": "Practitioner.identifier",
"Practitioner.identifier:ANR": "Practitioner.identifier:LANR",
Expand Down Expand Up @@ -228,7 +228,7 @@
"id": "5208113a-6fcc-45ba-a9f7-d8fdb14a1ed9",
"version": "1.0",
"status": "active",
"last_updated": "2024-07-30 16:51:11",
"last_updated": "2024-07-30 17:55:12",
"mappings": {
"Medication.amount": "Medication.amount",
"Medication.batch": "Medication.batch",
Expand Down Expand Up @@ -270,7 +270,7 @@
"id": "0760ae49-8551-459b-bc65-39bfb47697f8",
"version": "1.0",
"status": "active",
"last_updated": "2024-07-30 16:51:11",
"last_updated": "2024-07-30 17:55:12",
"mappings": {
"MedicationRequest.authoredOn": "MedicationRequest.authoredOn",
"MedicationRequest.dispenseRequest": "MedicationRequest.dispenseRequest",
Expand Down Expand Up @@ -301,7 +301,7 @@
"id": "79595f0e-d292-4c12-9413-cb8836d7de34",
"version": "1.0",
"status": "active",
"last_updated": "2024-07-30 16:51:11",
"last_updated": "2024-07-30 17:55:12",
"mappings": {
"Organization.address": "Organization.address",
"Organization.address:Strassenanschrift": "Organization.address:Strassenanschrift",
Expand Down Expand Up @@ -329,7 +329,7 @@
"id": "aeeb2f06-297e-4ed9-b189-d0030fd883fe",
"version": "1.0",
"status": "active",
"last_updated": "2024-07-30 16:51:11",
"last_updated": "2024-07-30 17:55:12",
"mappings": {
"MedicationDispense.authorizingPrescription": "MedicationDispense.authorizingPrescription",
"MedicationDispense.category": "MedicationDispense.category",
Expand Down Expand Up @@ -367,7 +367,7 @@
"id": "86750842-3975-4344-9656-48d74c5d8a00",
"version": "1.0",
"status": "active",
"last_updated": "2024-07-30 16:51:11",
"last_updated": "2024-07-30 17:55:12",
"mappings": {
"MedicationDispense.authorizingPrescription": "MedicationDispense.authorizingPrescription",
"MedicationDispense.category": "MedicationDispense.category",
Expand Down Expand Up @@ -410,7 +410,7 @@
"id": "db59e5db-b93d-4a34-82b3-948bb1656392",
"version": "1.0",
"status": "active",
"last_updated": "2024-07-30 16:51:11",
"last_updated": "2024-07-30 17:55:12",
"mappings": {
"MedicationDispense.authorizingPrescription": "MedicationDispense.authorizingPrescription",
"MedicationDispense.category": "MedicationDispense.category",
Expand Down
42 changes: 26 additions & 16 deletions service/src/structure_comparer/files/template.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<title>Mapping: {% for profile in source_profiles %}{{ profile['key'] }}{% if not loop.last %}, {% endif %}{% endfor %} in {{ target_profile['key'] }}</title>
<link rel='stylesheet' type='text/css' href='./{{ css_file }}'>
<link rel='stylesheet' type='text/css' href='https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css'>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css'>
<script type='text/javascript' src='https://code.jquery.com/jquery-3.6.0.min.js'></script>
<script type='text/javascript' src='https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js'></script>
</head>
Expand Down Expand Up @@ -52,9 +53,7 @@
<th style="text-align: center;">Source Profile</th>
{% endif %}
<th style="text-align: center;">Target Profile</th>
{% if show_warnings %}
<th rowspan="2">Warning</th>
{% endif %}
<th rowspan="2" class="warning-column">Warning</th>
{% if show_remarks %}
<th rowspan="2">Remarks</th>
{% endif %}
Expand All @@ -79,30 +78,41 @@
{% endif %}
</td>
{% endfor %}
{% if show_warnings %}
<td>
{% if entry.warning %}
<ul>
{% for warning in entry.warning %}
<li>{{ warning }}</li>
{% endfor %}
</ul>
{% endif %}
</td>
{% endif %}
<td class="warning-column">
{% if entry.warning %}
<ul>
{% for warning in entry.warning %}
<li>{{ warning }}</li>
{% endfor %}
</ul>
{% endif %}
</td>
{% if show_remarks %}
<td>{{ entry.remark | format_links }}</td>
{% endif %}

</tr>
{% endfor %}
</tbody>
</table>
<script>
$(document).ready(function () {
var warningsVisible = true;
var numberOfWarnings = {{ number_of_warnings }};
$('#resultsTable').DataTable({
'pageLength': -1,
'lengthMenu': [[10, 25, 50, 100, 500, -1], [10, 25, 50, 100, 500, 'All']]
'lengthMenu': [[10, 25, 50, 100, 500, -1], [10, 25, 50, 100, 500, 'All']],
'dom': '<"top"f>rt<"bottom"ilp><"clear">',
'initComplete': function() {
var buttonHtml = '<button id="toggleWarnings"><i class="fas fa-exclamation-triangle"></i> hide warnings (' + numberOfWarnings + ')</button>';
$('#resultsTable_filter').prepend(buttonHtml);
$('#toggleWarnings').click(function () {
$('.warning-column').toggle();
warningsVisible = !warningsVisible;
$(this).html('<i class="fas fa-exclamation-triangle"></i> ' + (warningsVisible ? 'hide warnings (' + numberOfWarnings + ')' : 'show warnings (' + numberOfWarnings + ')'));
});
}
});
});
</script>
Expand Down
79 changes: 47 additions & 32 deletions service/src/structure_comparer/results_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from jinja2 import Environment, FileSystemLoader

from structure_comparer.helpers import split_parent_child


from .classification import Classification
from .data.comparison import Comparison
Expand Down Expand Up @@ -62,51 +64,63 @@ def create_results_html(
for comp in structured_mapping.values():

entries = {}
for prop, entry in comp.fields.items():
warnings = []
number_of_warnings = 0 # Initialize the warning counter

for field, entry in comp.fields.items():
warnings = set() # Use a set to collect unique warnings
target_min_card = entry.profiles[comp.target.profile_key].min_cardinality
target_max_card = entry.profiles[comp.target.profile_key].max_cardinality

parent, _ = split_parent_child(field)
comparison_parent = comp.fields.get(parent)

for profile in comp.sources:
source_min_card = entry.profiles[profile.profile_key].min_cardinality
source_max_card = entry.profiles[profile.profile_key].max_cardinality

if target_max_card < source_max_card and entry.classification not in [
Classification.COPY_TO,
Classification.COPY_FROM,
Classification.EMPTY,
Classification.NOT_USE,
Classification.MANUAL,
Classification.EXTENSION


]:
warnings.append(
"Maximale Kardinalität eines der Sourceprofile übersteigt die minimale Kardinalität des Targetprofils"
)

if source_min_card < target_min_card and entry.classification not in [
Classification.COPY_TO,
Classification.COPY_FROM,
Classification.EMPTY,
Classification.NOT_USE,
Classification.MANUAL,
Classification.EXTENSION


]:
warnings.append(
"Minimale Kardinalität eines der Sourceprofile unterschreitet die minimale Kardinalität des Targetprofils"
)

entries[prop] = {
if comparison_parent and comparison_parent.classification in [
Classification.USE
]:
# Skip the specific warning if the parent is being copied or extended
if target_max_card < source_max_card:
continue

if target_max_card < source_max_card and entry.classification not in [
Classification.COPY_TO,
Classification.COPY_FROM,
Classification.EMPTY,
Classification.NOT_USE,
Classification.MANUAL,
Classification.EXTENSION,
Classification.MEDICATION_SERVICE
]:
warnings.add(
"The maximum cardinality of one of the source profiles exceeds the minimum cardinality of the target profile"
)

if source_min_card < target_min_card and entry.classification not in [
Classification.COPY_TO,
Classification.COPY_FROM,
Classification.EMPTY,
Classification.NOT_USE,
Classification.MANUAL,
Classification.EXTENSION,
Classification.MEDICATION_SERVICE
]:
warnings.add(
"The minimum cardinality of one of the source profiles is less than the minimum cardinality of the target profile"
)

number_of_warnings += len(warnings) # Increment the warning counter

entries[field] = {
"classification": entry.classification,
"css_class": CSS_CLASS[entry.classification],
"extension": entry.extension,
"extra": entry.extra,
"profiles": entry.profiles,
"remark": entry.remark,
"warning": warnings,
"warning": list(warnings), # Convert set back to list
}

data = {
Expand All @@ -125,6 +139,7 @@ def create_results_html(
"entries": entries,
"show_remarks": show_remarks,
"show_warnings": show_warnings,
"number_of_warnings": number_of_warnings, # Add the warning count to the data
"version": comp.version,
"last_updated": comp.last_updated,
"status": comp.status,
Expand Down

0 comments on commit fc2057c

Please sign in to comment.