Skip to content

Commit

Permalink
[#76] CH EMED EPR: PDF: added active ingredients under medication name
Browse files Browse the repository at this point in the history
  • Loading branch information
dvribeira committed Oct 4, 2024
1 parent dba5671 commit 4875dac
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,37 @@
<th:block th:fragment="table-line(medStmt, dosage, index, size, lang)">
<tr class="statement-row" th:classappend="${(index == 0)? ' treatment-first-row' : ''}">
<th:block th:if="${index} == 0">
<td class="treatment-plan-common-cell" th:rowspan="${size} * 2"/>
<td class="treatment-plan-common-cell" th:rowspan="${size}"/>
</th:block>
<!-- Nom du médicament -->
<td>
[[${medStmt.resolveMedication().resolveMedicationName()}]]
<td class="medication" th:with="medication=${medStmt.resolveMedication()}">
<div class="medication-name">[[${medication.resolveMedicationName()}]]</div>
<div class="medication-description">
<th:block th:with="activeIngredients=${medication.resolveActiveIngredients()}">
<ul class="medication-active-ingredients" th:unless="${activeIngredients.isEmpty}">
<li th:each="activeIngredient : ${activeIngredients}">
[[${activeIngredient.resolveActiveIngredient().getDisplayName(lang.getLanguageCode())}]]
</li>
</ul>
</th:block>

<div class="treatment-line-period" th:if="${dosage.period().hasStart() and dosage.period().hasEnd()}">
À prendre du
<th:block th:insert="~{datatypes :: date-time(${dosage.period().getStartElement()}, ${lang})}"/>
au
<th:block th:insert="~{datatypes :: date-time(${dosage.period().getEndElement()}, ${lang})}"/>
</div>
<div class="treatment-line-period" th:if="${dosage.period().hasStart() and not dosage.period().hasEnd()}">
À prendre dès le
<th:block th:insert="~{datatypes :: date-time(${dosage.period().getStartElement()}, ${lang})}"/>
</div>
<div class="treatment-line-period" th:if="${not dosage.period().hasStart() and dosage.period().hasEnd()}">
À prendre jusqu'au
<th:block th:insert="~{datatypes :: date-time(${dosage.period().getEndElement()}, ${lang})}"/>
</div>

<div class="treatment-line-max-dose" th:if="${dosage.hasMaxDose()}" th:insert="~{datatypes::max-doses(${dosage}, ${lang})}"/>
</div>
</td>

<!-- Dosage -->
Expand Down Expand Up @@ -66,24 +92,4 @@
th:text="${fopase.getMessage(dosage.routeOfAdministration(), lang)}"/>
</td>
</tr>
<tr>
<td colspan="8" class="description">
<th:block th:if="${dosage.period().hasStart() and dosage.period().hasEnd()}">
À prendre du
<th:block th:insert="~{datatypes :: date-time(${dosage.period().getStartElement()}, ${lang})}"/>
au
<th:block th:insert="~{datatypes :: date-time(${dosage.period().getEndElement()}, ${lang})}"/>
</th:block>
<th:block th:if="${dosage.period().hasStart() and not dosage.period().hasEnd()}">
À prendre dès le
<th:block th:insert="~{datatypes :: date-time(${dosage.period().getStartElement()}, ${lang})}"/>
</th:block>
<th:block th:if="${not dosage.period().hasStart() and dosage.period().hasEnd()}">
À prendre jusqu'au
<th:block th:insert="~{datatypes :: date-time(${dosage.period().getEndElement()}, ${lang})}"/>
</th:block>

<th:block th:if="${dosage.hasMaxDose()}" th:insert="~{datatypes::max-doses(${dosage}, ${lang})}"/>
</td>
</tr>
</th:block>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import ca.uhn.fhir.model.api.annotation.ResourceDef;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.Medication;
import org.hl7.fhir.r4.model.UriType;
Expand Down Expand Up @@ -211,8 +210,10 @@ public PharmaceuticalDoseFormEdqm resolveForm() throws InvalidEmedContentExcepti
public List<ChEmedEprMedicationIngredient> resolveActiveIngredients() {
return this.getIngredient().stream()
.filter(MedicationIngredientComponent::getIsActive)
.filter(ChEmedEprMedicationIngredient.class::isInstance)
.map(ChEmedEprMedicationIngredient.class::cast)
.map(ingredient -> {
if (ingredient instanceof ChEmedEprMedicationIngredient chEmedEprIngredient) return chEmedEprIngredient;
else return new ChEmedEprMedicationIngredient(ingredient);
})
.toList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ public ChEmedEprMedicationIngredient() {
super();
}

/**
* Constructor from {@link Medication.MedicationIngredientComponent} object.
* @param ingredientComponent the ingredient
*/
public ChEmedEprMedicationIngredient(final Medication.MedicationIngredientComponent ingredientComponent) {
ingredientComponent.copyValues(this);
}

/**
* Resolves the dose per unit.
*
Expand Down

0 comments on commit 4875dac

Please sign in to comment.