@tekkare/romulus 0.1.280 → 0.1.281

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.16.0"
6
6
  },
7
- "version": "0.1.279",
7
+ "version": "0.1.280",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -1,77 +1,34 @@
1
1
  <!--
2
- Fiche d'un acte de l'AIFA (Italy One, type ItApproval), par son `_id`
3
- (opinion_id) : nature, date, molecule, laboratoire, indication et texte de
4
- la determination. Puis les autres actes de la meme marque, en bref : la
5
- page de la marque d'Italy One les montre ensemble.
2
+ Un acte de l'AIFA range dans un projet (Italy One, type ItApproval), par son
3
+ `_id` (opinion_id). Comme la page de la marque d'Italy One : on relit
4
+ l'acte pour sa marque, puis on monte la fiche de la marque (actes et prix),
5
+ celle que montre /approvals/details/<marque>.
6
6
 
7
7
  Montee par le tiroir des projets ; le lien vers l'app passe par le slot
8
8
  `title-link`.
9
9
  -->
10
10
  <template>
11
- <div class="oip-italy">
12
- <RmPageHeader :eyebrow="en ? 'AIFA regulatory act' : 'Acte réglementaire de l’AIFA'">
13
- <template #title>
14
- <span class="oip-italy__title">{{ doc?.brand || id }}</span>
15
- <slot name="title-link" />
16
- </template>
17
- </RmPageHeader>
18
-
19
- <div class="oip-italy__body">
20
- <RmLoadingState v-if="loading" spinner />
21
- <RmEmptyState v-else-if="!doc" icon="Prohibit" :title="en ? 'Act not found' : 'Acte introuvable'" />
22
- <template v-else>
23
- <div class="oip-italy__tags">
24
- <RmTag variant="gray">{{ documentType(doc.document_type) }}</RmTag>
25
- <RmTag v-if="doc.nature_of_request_en || doc.nature_of_request" variant="violet">
26
- {{ doc.nature_of_request_en || doc.nature_of_request }}
27
- </RmTag>
28
- <RmTag v-if="hasIndication" variant="emerald">Indication</RmTag>
29
- </div>
30
-
31
- <RmCard padding="md">
32
- <h3 class="oip-italy__card-title">{{ en ? "Act" : "Acte" }}</h3>
33
- <dl class="oip-italy__rows">
34
- <template v-for="row in rows" :key="row.label">
35
- <dt>{{ row.label }}</dt>
36
- <dd>{{ row.value }}</dd>
37
- </template>
38
- </dl>
39
- </RmCard>
40
-
41
- <RmCard v-if="hasIndication" padding="md">
42
- <h3 class="oip-italy__card-title">Indication</h3>
43
- <p class="oip-italy__text">{{ doc.indication_en || doc.indication }}</p>
44
- </RmCard>
45
-
46
- <RmCard v-if="essential" padding="md">
47
- <h3 class="oip-italy__card-title">{{ en ? "Determination" : "Détermination" }}</h3>
48
- <p class="oip-italy__text oip-italy__text--long">{{ essential }}</p>
49
- <a v-if="doc.aifa_url" class="oip-italy__link" :href="doc.aifa_url" target="_blank" rel="noopener">
50
- {{ en ? "Act on AIFA Trovanorme" : "L’acte sur Trovanorme (AIFA)" }} ↗
51
- </a>
52
- </RmCard>
53
-
54
- <RmCard v-if="others.length" padding="md">
55
- <h3 class="oip-italy__card-title">
56
- {{ en ? `Other acts of ${doc.brand}` : `Autres actes de ${doc.brand}` }} ({{ othersTotal }})
57
- </h3>
58
- <ul class="oip-italy__list">
59
- <li v-for="other in others" :key="other.opinion_id">
60
- <span class="oip-italy__date">{{ date(other.decision_date) }}</span>
61
- <span>{{ other.nature_of_request_en || other.nature_of_request || documentType(other.document_type) }}</span>
62
- </li>
63
- </ul>
64
- <p v-if="othersTotal > others.length" class="oip-italy__note">
65
- {{ en ? `The ${others.length} most recent.` : `Les ${others.length} plus récents.` }}
66
- </p>
67
- </RmCard>
68
- </template>
69
- </div>
11
+ <div class="oip-italy-act">
12
+ <RmLoadingState v-if="pending" spinner />
13
+
14
+ <OipItalyAifaBrandFiche v-else-if="brand" :brand="brand" :lang="lang">
15
+ <template #title-link><slot name="title-link" /></template>
16
+ </OipItalyAifaBrandFiche>
17
+
18
+ <template v-else>
19
+ <RmPageHeader :eyebrow="en ? 'AIFA regulatory act' : 'Acte réglementaire de l’AIFA'">
20
+ <template #title>
21
+ {{ id }}
22
+ <slot name="title-link" />
23
+ </template>
24
+ </RmPageHeader>
25
+ <RmEmptyState icon="Prohibit" :title="en ? 'Act not found' : 'Acte introuvable'" />
26
+ </template>
70
27
  </div>
71
28
  </template>
72
29
 
73
30
  <script setup lang="ts">
74
- import { oipEsGet, oipEsSearch } from "../../composables/useOipResources";
31
+ import { oipEsGet } from "../../composables/useOipResources";
75
32
  import { ITALY_INDEX } from "../../oip-italy/kinds";
76
33
 
77
34
  const props = withDefaults(
@@ -85,152 +42,16 @@ const props = withDefaults(
85
42
  { type: "ItApproval", lang: "fr", highlight: () => [] },
86
43
  );
87
44
 
88
- const OTHERS_SHOWN = 30;
89
-
90
45
  const en = computed(() => props.lang === "en");
91
- const loading = ref(true);
92
- const doc = ref<Record<string, any> | null>(null);
93
- const others = ref<Record<string, any>[]>([]);
94
- const othersTotal = ref(0);
95
-
96
- /** Les cinq canaux de publication de Trovanorme, nommes comme le portail. */
97
- const DOCUMENT_TYPES: Record<string, string> = {
98
- GU: "Gazzetta Ufficiale",
99
- MSF: "Modifiche secondarie di farmaci",
100
- TNF: "Testi normativi farmaceutici",
101
- AIFA: "Documenti AIFA",
102
- NEWS: "News",
103
- };
104
- const documentType = (code: unknown) => DOCUMENT_TYPES[String(code ?? "")] ?? (String(code ?? "") || "-");
105
-
106
- const date = (value: unknown) => {
107
- const parsed = new Date(String(value ?? ""));
108
- return Number.isNaN(parsed.getTime())
109
- ? "-"
110
- : parsed.toLocaleDateString(en.value ? "en-GB" : "fr-FR", { day: "numeric", month: "short", year: "numeric" });
111
- };
112
-
113
- const hasIndication = computed(() => !!(doc.value?.indication_en || doc.value?.indication));
114
- // le texte traduit quand il existe, l'original italien sinon (champ « None » quand le quota de traduction est epuise)
115
- const essential = computed(() => {
116
- const translated = doc.value?.essential_en;
117
- return translated && translated !== "None" ? translated : (doc.value?.essential ?? "");
118
- });
119
-
120
- const rows = computed(() => {
121
- const d = doc.value ?? {};
122
- return [
123
- { label: "Date", value: date(d.decision_date) },
124
- { label: en.value ? "Reference" : "Référence", value: d.has_code },
125
- { label: en.value ? "Molecule" : "Molécule", value: d.atc5_code_label || d.molecule },
126
- { label: en.value ? "Company" : "Laboratoire", value: d.company },
127
- { label: en.value ? "Therapeutic area" : "Aire thérapeutique", value: d.theme_en || d.theme },
128
- ].filter((row) => row.value);
129
- });
46
+ const pending = ref(true);
47
+ const brand = ref("");
130
48
 
131
49
  async function read() {
132
- loading.value = true;
133
- doc.value = null;
134
- others.value = [];
135
- othersTotal.value = 0;
136
- const hit = await oipEsGet<any>("drugs", ITALY_INDEX.aifa, props.id).catch(() => null);
137
- doc.value = hit?._source ?? null;
138
- if (doc.value?.brand) {
139
- const res = await oipEsSearch<any>("drugs", ITALY_INDEX.aifa, {
140
- size: OTHERS_SHOWN + 1,
141
- track_total_hits: true,
142
- _source: ["opinion_id", "decision_date", "document_type", "nature_of_request", "nature_of_request_en"],
143
- query: { term: { "brand.keyword": doc.value.brand } },
144
- sort: [{ decision_date: "desc" }],
145
- }).catch(() => null);
146
- const list = (res?.hits?.hits ?? []).map((h: any) => h._source).filter((s: any) => s.opinion_id !== props.id);
147
- others.value = list.slice(0, OTHERS_SHOWN);
148
- othersTotal.value = Math.max(0, (res?.hits?.total?.value ?? list.length) - 1);
149
- }
150
- loading.value = false;
50
+ pending.value = true;
51
+ const hit = await oipEsGet<any>("drugs", ITALY_INDEX.aifa, props.id, ["brand"]).catch(() => null);
52
+ brand.value = String(hit?._source?.brand ?? "");
53
+ pending.value = false;
151
54
  }
152
55
 
153
56
  watch(() => props.id, read, { immediate: true });
154
57
  </script>
155
-
156
- <style scoped>
157
- .oip-italy__body {
158
- display: flex;
159
- flex-direction: column;
160
- gap: var(--space-16);
161
- padding: var(--space-20) var(--space-32) var(--space-32);
162
- }
163
- .oip-italy__title {
164
- margin-right: var(--space-12);
165
- }
166
- .oip-italy__tags {
167
- display: flex;
168
- flex-wrap: wrap;
169
- gap: var(--space-6);
170
- }
171
- .oip-italy__card-title {
172
- margin: 0 0 var(--space-12);
173
- font-size: var(--font-16);
174
- font-weight: var(--weight-bold);
175
- }
176
- .oip-italy__text {
177
- margin: 0;
178
- font-size: var(--font-14);
179
- line-height: 1.6;
180
- }
181
- .oip-italy__text--long {
182
- max-height: 320px;
183
- overflow-y: auto;
184
- white-space: pre-line;
185
- }
186
- .oip-italy__rows {
187
- display: grid;
188
- grid-template-columns: minmax(140px, max-content) 1fr;
189
- gap: var(--space-8) var(--space-20);
190
- margin: 0;
191
- font-size: var(--font-14);
192
- }
193
- .oip-italy__rows dt {
194
- padding-top: 2px;
195
- color: var(--text-muted);
196
- font-size: var(--font-12);
197
- font-weight: var(--weight-semibold);
198
- text-transform: uppercase;
199
- }
200
- .oip-italy__rows dd {
201
- margin: 0;
202
- line-height: 1.5;
203
- }
204
- .oip-italy__link {
205
- display: inline-block;
206
- margin-top: var(--space-16);
207
- color: var(--color-primary);
208
- font-size: var(--font-13);
209
- font-weight: var(--weight-semibold);
210
- }
211
- .oip-italy__list {
212
- display: flex;
213
- flex-direction: column;
214
- gap: var(--space-8);
215
- margin: 0;
216
- padding: 0;
217
- font-size: var(--font-13);
218
- line-height: 1.5;
219
- list-style: none;
220
- }
221
- .oip-italy__list li {
222
- display: flex;
223
- gap: var(--space-12);
224
- }
225
- .oip-italy__date {
226
- flex: none;
227
- width: 96px;
228
- color: var(--text-muted);
229
- font-variant-numeric: tabular-nums;
230
- }
231
- .oip-italy__note {
232
- margin: var(--space-10) 0 0;
233
- color: var(--text-muted);
234
- font-size: var(--font-12);
235
- }
236
- </style>
@@ -0,0 +1,369 @@
1
+ <!--
2
+ Fiche marque des actes de l'AIFA (portage de pages/approvals/details de
3
+ Italy One) : identite de la marque, dernier texte publie, historique
4
+ reglementaire (une ligne s'ouvre sur le texte complet de l'acte), puis
5
+ l'onglet Prix (la meme marque dans le Price Tracker italien).
6
+
7
+ Ce que la page lisait dans sa route arrive en props (`brand`, `tab`) ;
8
+ l'onglet choisi part par `update:tab`. L'export, les alertes et le bouton
9
+ Projet restent dans la page d'Italy One, qui les pose dans le slot
10
+ `actions` et lit les actes charges par `loaded` ; dans le tiroir d'un
11
+ projet, rien n'y est passe et le lien vers l'app passe par `title-link`.
12
+ -->
13
+ <template>
14
+ <div class="oip-italy-brand">
15
+ <RmPageHeader
16
+ :eyebrow="en ? 'AIFA · Regulatory acts' : 'AIFA · Actes réglementaires'"
17
+ :have-return="haveReturn"
18
+ :back-to="backTo"
19
+ :tabs="headerTabs"
20
+ :tabs-label="en ? 'Record sections' : 'Sections de la fiche'"
21
+ @tab="selectTab"
22
+ >
23
+ <template #title>
24
+ <span class="oip-italy-brand__title">{{ title }}</span>
25
+ <slot name="title-link" />
26
+ </template>
27
+ <template v-if="$slots.actions" #actions>
28
+ <slot name="actions" :acts="acts" :latest-act="latestAct" :brand="title" :tab="activeTab" />
29
+ </template>
30
+ </RmPageHeader>
31
+
32
+ <!-- dans une page, la colonne du cadre pose les gouttieres ; dans le
33
+ tiroir d'un projet, la fiche les pose elle-meme -->
34
+ <div class="oip-italy-brand__body" :class="{ 'oip-italy-brand__body--page': haveReturn }">
35
+ <RmLoadingState v-if="loading" :lines="3" :chart-height="240" />
36
+
37
+ <RmEmptyState v-else-if="!acts.length" :title="en ? 'Brand not found.' : 'Marque introuvable.'" :text="brand" />
38
+
39
+ <template v-else-if="activeTab === 1">
40
+ <!-- identite de la marque -->
41
+ <RmSectionCard position="none">
42
+ <div class="oip-italy-brand__stack">
43
+ <p class="oip-italy-brand__meta">
44
+ {{ acts.length }} {{ en ? "acts" : "actes" }}
45
+ · {{ en ? "from" : "de" }}
46
+ <RmDate :date="firstActDate" :lang="lang" compact />
47
+ {{ en ? "to" : "à" }}
48
+ <RmDate :date="latestAct?.decision_date" :lang="lang" compact />
49
+ <template v-if="latestAct?.nature_of_request_en">
50
+ · {{ en ? "latest act:" : "dernier acte :" }}
51
+ {{ latestAct.nature_of_request_en }}
52
+ </template>
53
+ </p>
54
+ <div class="oip-italy-brand__tags">
55
+ <RmTag v-if="latestAct?.molecule" variant="gray">{{ latestAct.molecule }}</RmTag>
56
+ <RmTag v-if="latestAct?.company" variant="gray">{{ latestAct.company }}</RmTag>
57
+ <RmTag variant="gray">ATC5 : {{ latestAct?.atc5_code || "N/A" }}</RmTag>
58
+ <RmTag v-if="latestAct?.theme_en" variant="gray">{{ titleCase(latestAct.theme_en) }}</RmTag>
59
+ </div>
60
+
61
+ <!-- la derniere indication de la marque, ou le texte de son
62
+ dernier acte quand elle n'en a pas ; le tag dit lequel -->
63
+ <div class="oip-italy-brand__stack oip-italy-brand__stack--tight">
64
+ <div class="oip-italy-brand__row">
65
+ <p class="oip-italy-brand__subtitle">{{ en ? "Latest published text" : "Dernier texte publié" }}</p>
66
+ <RmTag :variant="indicationAct ? 'emerald' : 'gray'">
67
+ {{ indicationAct ? "Indication" : en ? "Act text" : "Texte de l'acte" }}
68
+ </RmTag>
69
+ <p v-if="textAct" class="oip-italy-brand__meta">
70
+ <RmDate :date="textAct.decision_date" :lang="lang" compact />
71
+ · {{ textAct.nature_of_request_en }}
72
+ </p>
73
+ </div>
74
+ <p v-if="publishedText" class="oip-italy-brand__text">{{ publishedText }}</p>
75
+ <p v-else class="oip-italy-brand__meta">
76
+ {{ en ? "No text published by AIFA for this brand." : "Aucun texte publié par l'AIFA pour cette marque." }}
77
+ </p>
78
+ </div>
79
+ </div>
80
+ </RmSectionCard>
81
+
82
+ <!-- tous les actes publies pour la marque ; une ligne s'ouvre sur le
83
+ texte complet de la determination -->
84
+ <RmTableCard :lang="lang" :source="source" :verified="verified" :payload="historyPayload">
85
+ <template #header>
86
+ <h3 class="rm-table-card__title">{{ en ? "Regulatory history" : "Historique réglementaire" }}</h3>
87
+ <p class="rm-table-card__context">
88
+ {{ acts.length }} {{ en ? "acts" : "actes" }}
89
+ <span v-if="historyCapped">({{ en ? "most recent" : "les plus récents" }})</span>
90
+ </p>
91
+ </template>
92
+ <RmTable
93
+ flat
94
+ expandable
95
+ row-key="id"
96
+ :columns="tableColumns"
97
+ :rows="tableRows"
98
+ :page-size="20"
99
+ :empty-text="en ? 'No data' : 'Aucune donnée'"
100
+ >
101
+ <template #date="{ value }">
102
+ <p class="oip-italy-brand__nowrap"><RmDate :date="value" :lang="lang" compact /></p>
103
+ </template>
104
+ <template #document="{ row }">
105
+ <p>
106
+ {{ documentTypeLabel(row.documentType) }}
107
+ <span class="oip-italy-brand__muted">{{ row.code }}</span>
108
+ </p>
109
+ </template>
110
+ <template #nature="{ value }">
111
+ <p>{{ value || "-" }}</p>
112
+ </template>
113
+ <template #indication="{ value }">
114
+ <p v-if="value" class="oip-italy-brand__clamp">{{ value }}</p>
115
+ <span v-else class="oip-italy-brand__muted">-</span>
116
+ </template>
117
+ <template #text="{ value }">
118
+ <p v-if="value" class="oip-italy-brand__clamp oip-italy-brand__clamp--one">{{ value }}</p>
119
+ <span v-else class="oip-italy-brand__muted">-</span>
120
+ </template>
121
+ <template #expanded="{ row }">
122
+ <div class="oip-italy-brand__more">
123
+ <div class="oip-italy-brand__row oip-italy-brand__row--between">
124
+ <p class="oip-italy-brand__subtitle">
125
+ {{ en ? "Act text" : "Texte de l'acte" }}
126
+ <span class="oip-italy-brand__meta">
127
+ {{
128
+ row.act.essential_en && row.act.essential_en !== "None"
129
+ ? en
130
+ ? "(machine translation)"
131
+ : "(traduction automatique)"
132
+ : en
133
+ ? "(in Italian, as published by AIFA)"
134
+ : "(en italien, tel que publié par l'AIFA)"
135
+ }}
136
+ </span>
137
+ </p>
138
+ <a v-if="row.act.aifa_url" :href="row.act.aifa_url" target="_blank" rel="noopener" class="oip-italy-brand__link">
139
+ {{ en ? "View on AIFA" : "Voir sur AIFA" }}
140
+ </a>
141
+ </div>
142
+ <p v-if="row.indication" class="oip-italy-brand__text">
143
+ <span class="oip-italy-brand__meta">Indication : </span>{{ row.indication }}
144
+ </p>
145
+ <p class="oip-italy-brand__text">{{ essentialOf(row.act) || "-" }}</p>
146
+ </div>
147
+ </template>
148
+ </RmTable>
149
+ </RmTableCard>
150
+ </template>
151
+
152
+ <!-- la meme marque dans le Price Tracker italien -->
153
+ <OipItalyBrandPrices v-else-if="activeTab === 2" :brand="title" :lang="lang" />
154
+ </div>
155
+ </div>
156
+ </template>
157
+
158
+ <script setup lang="ts">
159
+ import { oipEsSearch } from "../../composables/useOipResources";
160
+ import { ITALY_INDEX } from "../../oip-italy/kinds";
161
+ import { useAifaSource } from "../../oip-italy/useAifaSource";
162
+ import {
163
+ OPINION_FIELDS,
164
+ actSheetSchema,
165
+ documentTypeLabel,
166
+ essentialOf,
167
+ titleCase,
168
+ type OpinionDoc,
169
+ } from "../../utils/italyApprovals";
170
+
171
+ const props = withDefaults(
172
+ defineProps<{
173
+ /** La marque, telle que l'URL la porte (casse indifferente). */
174
+ brand: string;
175
+ /** Onglet ouvert : 1 actes, 2 prix. */
176
+ tab?: number;
177
+ lang?: "fr" | "en";
178
+ /** Fleche de retour du bandeau (page d'Italy One). */
179
+ haveReturn?: boolean;
180
+ backTo?: string;
181
+ }>(),
182
+ { tab: 1, lang: "fr", haveReturn: false, backTo: undefined },
183
+ );
184
+
185
+ const emit = defineEmits<{
186
+ "update:tab": [tab: number];
187
+ /** Les actes charges : la page en tire son export et ses alertes. */
188
+ loaded: [acts: OpinionDoc[]];
189
+ }>();
190
+
191
+ const HISTORY_SIZE = 500;
192
+
193
+ const en = computed(() => props.lang === "en");
194
+ const { source, verified } = useAifaSource(() => props.lang);
195
+
196
+ // l'onglet suit la prop (page, `?tab=`) ; dans le tiroir, il vit ici
197
+ const localTab = ref(props.tab);
198
+ watch(
199
+ () => props.tab,
200
+ (value) => (localTab.value = value),
201
+ );
202
+ const activeTab = computed(() => (localTab.value === 2 ? 2 : 1));
203
+ function selectTab(key: string | number) {
204
+ localTab.value = Number(key) || 1;
205
+ emit("update:tab", localTab.value);
206
+ }
207
+ const headerTabs = computed(() =>
208
+ (en.value ? ["AIFA acts", "Prices"] : ["Actes AIFA", "Prix"]).map((label, index) => ({
209
+ key: String(index + 1),
210
+ label,
211
+ active: activeTab.value === index + 1,
212
+ })),
213
+ );
214
+
215
+ const loading = ref(true);
216
+ const acts = ref<OpinionDoc[]>([]);
217
+ const historyCapped = ref(false);
218
+
219
+ // la casse canonique, telle que l'AIFA l'ecrit, une fois les actes charges
220
+ const title = computed(() => acts.value[0]?.brand || props.brand);
221
+ const latestAct = computed(() => acts.value[0] ?? null);
222
+ const firstActDate = computed(() => acts.value[acts.value.length - 1]?.decision_date ?? "");
223
+ // l'indication vient rarement avec le dernier acte : le plus recent qui en porte une
224
+ const indicationAct = computed(() => acts.value.find((x) => (x.indication_en || x.indication || "").trim()) ?? null);
225
+ const indicationText = computed(() => indicationAct.value?.indication_en || indicationAct.value?.indication || "");
226
+ // sans indication dans tout l'historique : le texte du dernier acte
227
+ const textAct = computed(() => indicationAct.value ?? latestAct.value);
228
+ const publishedText = computed(() => indicationText.value || essentialOf(latestAct.value));
229
+
230
+ const tableColumns = computed(() => [
231
+ { key: "date", label: "Date", width: "11%" },
232
+ { key: "document", label: "Document", width: "17%" },
233
+ { key: "nature", label: en.value ? "Nature of request" : "Nature de la demande", width: "18%" },
234
+ { key: "indication", label: "Indication", width: "27%" },
235
+ { key: "text", label: en.value ? "Text" : "Texte", width: "27%" },
236
+ ]);
237
+
238
+ const tableRows = computed(() =>
239
+ acts.value.map((row) => ({
240
+ id: row.opinion_id,
241
+ date: row.decision_date,
242
+ documentType: row.document_type,
243
+ code: row.has_code,
244
+ nature: row.nature_of_request_en,
245
+ indication: (row.indication_en || row.indication || "").trim(),
246
+ text: essentialOf(row).trim(),
247
+ act: row,
248
+ })),
249
+ );
250
+
251
+ // le tableau peint 20 actes par page et un extrait de chacun : l'export de la
252
+ // carte emporte tous les actes charges, textes complets
253
+ const historyPayload = () => ({
254
+ title: `${title.value}, ${en.value ? "regulatory history" : "historique réglementaire"}`,
255
+ sheets: [
256
+ {
257
+ name: en.value ? "Regulatory history" : "Historique réglementaire",
258
+ data: acts.value,
259
+ schema: actSheetSchema(!en.value),
260
+ },
261
+ ],
262
+ });
263
+
264
+ async function load() {
265
+ loading.value = true;
266
+ acts.value = [];
267
+ const res = await oipEsSearch<any>("drugs", ITALY_INDEX.aifa, {
268
+ size: HISTORY_SIZE,
269
+ _source: OPINION_FIELDS,
270
+ query: { term: { "brand.keyword": { value: props.brand, case_insensitive: true } } },
271
+ sort: [{ decision_date: { order: "desc" } }],
272
+ track_total_hits: true,
273
+ }).catch(() => null);
274
+ acts.value = (res?.hits?.hits ?? []).map((hit: any) => hit._source as OpinionDoc);
275
+ historyCapped.value = (res?.hits?.total?.value ?? 0) > acts.value.length;
276
+ loading.value = false;
277
+ emit("loaded", acts.value);
278
+ }
279
+
280
+ watch(() => props.brand, load, { immediate: true });
281
+ </script>
282
+
283
+ <style scoped>
284
+ .oip-italy-brand__body {
285
+ display: flex;
286
+ flex-direction: column;
287
+ gap: var(--space-16);
288
+ padding: var(--space-16) var(--space-24) var(--space-32);
289
+ }
290
+ .oip-italy-brand__body--page {
291
+ padding: 0;
292
+ margin-top: var(--space-12);
293
+ }
294
+ .oip-italy-brand__title {
295
+ margin-right: var(--space-12);
296
+ }
297
+ .oip-italy-brand__stack {
298
+ display: flex;
299
+ flex-direction: column;
300
+ gap: var(--space-12);
301
+ }
302
+ .oip-italy-brand__stack--tight {
303
+ gap: var(--space-6);
304
+ }
305
+ .oip-italy-brand__row {
306
+ display: flex;
307
+ flex-wrap: wrap;
308
+ align-items: center;
309
+ gap: var(--space-8);
310
+ }
311
+ .oip-italy-brand__row--between {
312
+ justify-content: space-between;
313
+ gap: var(--space-16);
314
+ }
315
+ .oip-italy-brand__tags {
316
+ display: flex;
317
+ flex-wrap: wrap;
318
+ gap: var(--space-8);
319
+ }
320
+ .oip-italy-brand__meta {
321
+ margin: 0;
322
+ color: var(--text-secondary);
323
+ font-size: var(--font-12);
324
+ }
325
+ .oip-italy-brand__subtitle {
326
+ margin: 0;
327
+ color: var(--text-primary);
328
+ font-size: var(--font-16);
329
+ font-weight: var(--weight-bold);
330
+ }
331
+ .oip-italy-brand__text {
332
+ margin: 0;
333
+ color: var(--text-primary);
334
+ line-height: 1.7;
335
+ white-space: pre-wrap;
336
+ }
337
+ .oip-italy-brand__muted {
338
+ color: var(--text-muted);
339
+ }
340
+ .oip-italy-brand__nowrap {
341
+ white-space: nowrap;
342
+ }
343
+ .oip-italy-brand__link {
344
+ color: var(--color-primary);
345
+ font-size: var(--font-12);
346
+ font-weight: var(--weight-semibold);
347
+ text-decoration: none;
348
+ white-space: nowrap;
349
+ }
350
+ .oip-italy-brand__link:hover {
351
+ text-decoration: underline;
352
+ }
353
+ .oip-italy-brand__clamp {
354
+ display: -webkit-box;
355
+ overflow: hidden;
356
+ -webkit-box-orient: vertical;
357
+ -webkit-line-clamp: 2;
358
+ }
359
+ .oip-italy-brand__clamp--one {
360
+ -webkit-line-clamp: 1;
361
+ }
362
+ .oip-italy-brand__more {
363
+ display: flex;
364
+ flex-direction: column;
365
+ gap: var(--space-8);
366
+ width: 100%;
367
+ padding: var(--space-8) var(--space-4) var(--space-12);
368
+ }
369
+ </style>
@@ -0,0 +1,247 @@
1
+ <!--
2
+ Onglet Prix de la fiche marque AIFA (portage de components/approvals/
3
+ BrandPrices d'Italy One) : les presentations de la marque dans le Price
4
+ Tracker italien, leur dernier prix, puis la trajectoire des prix (dernier
5
+ prix connu de chaque annee).
6
+
7
+ Les liens passent par la navigation des ressources : sur place dans Italy
8
+ One, dans un onglet depuis une autre app.
9
+ -->
10
+ <template>
11
+ <div class="oip-italy-prices">
12
+ <RmLoadingState v-if="loading" :lines="3" :chart-height="240" />
13
+
14
+ <RmEmptyState
15
+ v-else-if="!skus.length"
16
+ :title="en ? 'No Italian price for this brand.' : 'Aucun prix italien pour cette marque.'"
17
+ :text="
18
+ en
19
+ ? 'A hospital product with no listed price, withdrawn, or marketed under another name.'
20
+ : 'Produit hospitalier non tarifé, retiré du marché, ou commercialisé sous un autre nom.'
21
+ "
22
+ />
23
+
24
+ <template v-else>
25
+ <div class="oip-italy-prices__head">
26
+ <p class="oip-italy-prices__meta">
27
+ <b>{{ skus.length }}</b>
28
+ {{ en ? (skus.length === 1 ? "presentation" : "presentations") : skus.length === 1 ? "présentation" : "présentations" }}
29
+ </p>
30
+ <a class="oip-italy-prices__link" :href="nav.appHref('italy_one_app', '/price-tracker/')" @click.prevent="nav.openApp('italy_one_app', '/price-tracker/')">
31
+ {{ en ? "Open the Price Tracker" : "Ouvrir le Price Tracker" }}
32
+ </a>
33
+ </div>
34
+
35
+ <RmTableCard :lang="lang" :source="source" :verified="verified" :payload="pricesPayload">
36
+ <template #header>
37
+ <h3 class="rm-table-card__title">{{ en ? "Prices in Italy" : "Prix en Italie" }}</h3>
38
+ </template>
39
+ <RmTable flat :columns="tableColumns" :rows="skus" :page-size="20" :empty-text="en ? 'No data' : 'Aucune donnée'">
40
+ <template #category="{ value }">
41
+ <RmTag v-if="value" variant="gray">{{ value }}</RmTag>
42
+ <span v-else class="oip-italy-prices__muted">-</span>
43
+ </template>
44
+ <template #atc="{ value }">
45
+ <p class="oip-italy-prices__nowrap">{{ value || "-" }}</p>
46
+ </template>
47
+ <template #price="{ value }">
48
+ <p v-if="value !== null" class="oip-italy-prices__nowrap">{{ euro(value) }}</p>
49
+ <p v-else class="oip-italy-prices__muted">-</p>
50
+ </template>
51
+ <template #priceDate="{ value }">
52
+ <p class="oip-italy-prices__nowrap">
53
+ <RmDate v-if="value" :date="value" :lang="lang" compact />
54
+ <span v-else class="oip-italy-prices__muted">-</span>
55
+ </p>
56
+ </template>
57
+ <template #id="{ value }">
58
+ <a
59
+ v-if="value"
60
+ class="oip-italy-prices__link"
61
+ :href="nav.appHref('italy_one_app', detailPath(value))"
62
+ @click.prevent="nav.openApp('italy_one_app', detailPath(value))"
63
+ >
64
+ {{ en ? "Details" : "Détail" }}
65
+ </a>
66
+ </template>
67
+ </RmTable>
68
+ </RmTableCard>
69
+
70
+ <!-- un point par an et par presentation : l'historique est un releve par
71
+ revision, le dernier prix connu de chaque annee suffit a lire la
72
+ trajectoire -->
73
+ <RmChartCard
74
+ v-if="chart.series.length"
75
+ :title="en ? 'Price trajectory (€, last known price per year)' : 'Évolution du prix (€, dernier prix connu par an)'"
76
+ :source="source"
77
+ :verified="verified"
78
+ :lang="lang"
79
+ >
80
+ <RmLineChart :categories="chart.categories" :series="chart.series" :value-formatter="euro" :height="320" />
81
+ </RmChartCard>
82
+ </template>
83
+ </div>
84
+ </template>
85
+
86
+ <script setup lang="ts">
87
+ import { oipEsSearch } from "../../composables/useOipResources";
88
+ import { useOipResourceNav } from "../../composables/useOipResourceNav";
89
+ import { ITALY_INDEX } from "../../oip-italy/kinds";
90
+ import { useAifaSource } from "../../oip-italy/useAifaSource";
91
+
92
+ const props = withDefaults(defineProps<{ brand: string; lang?: "fr" | "en" }>(), { lang: "fr" });
93
+
94
+ const en = computed(() => props.lang === "en");
95
+ const nav = useOipResourceNav();
96
+ const { source, verified } = useAifaSource(() => props.lang);
97
+
98
+ type Sku = {
99
+ id: string;
100
+ label: string;
101
+ category: string;
102
+ atc: string;
103
+ price: number | null;
104
+ priceDate: string;
105
+ history: { date: string; price: number }[];
106
+ };
107
+
108
+ const loading = ref(true);
109
+ const skus = ref<Sku[]>([]);
110
+
111
+ const detailPath = (id: string) => `/price-tracker/details/${encodeURIComponent(id)}/`;
112
+
113
+ const euro = (value: unknown) => {
114
+ const n = Number(value);
115
+ return Number.isFinite(n)
116
+ ? `${n.toLocaleString(en.value ? "en-GB" : "fr-FR", { minimumFractionDigits: 2, maximumFractionDigits: 2 })} €`
117
+ : "-";
118
+ };
119
+
120
+ const tableColumns = computed(() => [
121
+ { key: "label", label: en.value ? "Presentation" : "Présentation", width: "44%" },
122
+ { key: "category", label: en.value ? "Category" : "Catégorie", width: "12%" },
123
+ { key: "atc", label: "ATC", width: "11%" },
124
+ { key: "price", label: en.value ? "Price" : "Prix", width: "11%", align: "right" as const },
125
+ { key: "priceDate", label: en.value ? "Last revision" : "Dernière révision", width: "11%" },
126
+ { key: "id", label: "", width: "11%", align: "right" as const },
127
+ ]);
128
+
129
+ // la carte montre 20 presentations et leur dernier prix : l'export emporte
130
+ // toutes les presentations et toutes les revisions, en nombres bruts
131
+ const pricesPayload = () => ({
132
+ title: `${props.brand}, ${en.value ? "prices in Italy" : "prix en Italie"}`,
133
+ sheets: [
134
+ {
135
+ name: en.value ? "Prices" : "Prix",
136
+ data: skus.value.flatMap((sku) =>
137
+ (sku.history.length ? sku.history : [{ date: "", price: null }]).map((point) => ({ ...sku, point })),
138
+ ),
139
+ schema: [
140
+ { column: en.value ? "Presentation" : "Présentation", type: String, width: 50, value: (x: any) => x.label },
141
+ { column: en.value ? "ID" : "Identifiant", type: String, value: (x: any) => x.id },
142
+ { column: en.value ? "Category" : "Catégorie", type: String, value: (x: any) => x.category },
143
+ { column: "ATC", type: String, value: (x: any) => x.atc },
144
+ { column: en.value ? "Application date" : "Date d'application", type: String, value: (x: any) => x.point.date },
145
+ { column: en.value ? "Price (€)" : "Prix (€)", type: Number, value: (x: any) => x.point.price },
146
+ ],
147
+ },
148
+ ],
149
+ });
150
+
151
+ // dernier prix connu de chaque annee, une serie par presentation
152
+ const chart = computed(() => {
153
+ const years = new Set<string>();
154
+ const perSku = skus.value.map((sku) => {
155
+ const lastOfYear = new Map<string, { date: string; price: number }>();
156
+ sku.history.forEach((point) => {
157
+ const year = point.date.slice(0, 4);
158
+ const kept = lastOfYear.get(year);
159
+ if (!kept || point.date > kept.date) lastOfYear.set(year, point);
160
+ });
161
+ lastOfYear.forEach((_point, year) => years.add(year));
162
+ return { name: sku.label, lastOfYear };
163
+ });
164
+ const categories = [...years].sort();
165
+ return {
166
+ categories,
167
+ series: perSku
168
+ .filter((sku) => sku.lastOfYear.size)
169
+ .map((sku) => ({ name: sku.name, data: categories.map((year) => sku.lastOfYear.get(year)?.price ?? null) })),
170
+ };
171
+ });
172
+
173
+ async function load() {
174
+ loading.value = true;
175
+ skus.value = [];
176
+ // les marques sont en capitales dans les deux index, mais une URL tapee a la
177
+ // main ou un changement de casse doit encore trouver la marque
178
+ const res = await oipEsSearch<any>("drugs", ITALY_INDEX.prices, {
179
+ size: 200,
180
+ _source: ["local_drug_id", "label_local", "price_category", "atc_who", "atc_local", "price_history"],
181
+ query: {
182
+ bool: {
183
+ must: [
184
+ { term: { "country_code.keyword": "it" } },
185
+ { term: { "brand.keyword": { value: props.brand, case_insensitive: true } } },
186
+ ],
187
+ },
188
+ },
189
+ }).catch(() => null);
190
+ skus.value = (res?.hits?.hits ?? []).map((hit: any) => {
191
+ const row = hit._source;
192
+ const history = (row.price_history || [])
193
+ .map((point: any) => ({ date: point.application_date as string, price: Number(point.new_price) }))
194
+ .filter((point: any) => point.date && Number.isFinite(point.price))
195
+ .sort((a: any, b: any) => b.date.localeCompare(a.date));
196
+ return {
197
+ id: row.local_drug_id ?? "",
198
+ label: row.label_local ?? "",
199
+ category: row.price_category ?? "",
200
+ atc: row.atc_who || row.atc_local || "",
201
+ price: history[0]?.price ?? null,
202
+ priceDate: history[0]?.date ?? "",
203
+ history,
204
+ };
205
+ });
206
+ loading.value = false;
207
+ }
208
+
209
+ watch(() => props.brand, load, { immediate: true });
210
+ </script>
211
+
212
+ <style scoped>
213
+ .oip-italy-prices {
214
+ display: flex;
215
+ flex-direction: column;
216
+ gap: var(--space-16);
217
+ width: 100%;
218
+ }
219
+ .oip-italy-prices__head {
220
+ display: flex;
221
+ flex-wrap: wrap;
222
+ align-items: center;
223
+ justify-content: space-between;
224
+ gap: var(--space-16);
225
+ }
226
+ .oip-italy-prices__meta {
227
+ margin: 0;
228
+ color: var(--text-secondary);
229
+ font-size: var(--font-12);
230
+ }
231
+ .oip-italy-prices__nowrap {
232
+ white-space: nowrap;
233
+ }
234
+ .oip-italy-prices__muted {
235
+ color: var(--text-muted);
236
+ }
237
+ .oip-italy-prices__link {
238
+ color: var(--color-primary);
239
+ font-size: var(--font-12);
240
+ font-weight: var(--weight-semibold);
241
+ text-decoration: none;
242
+ white-space: nowrap;
243
+ }
244
+ .oip-italy-prices__link:hover {
245
+ text-decoration: underline;
246
+ }
247
+ </style>
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Source et date de verification des cartes d'Italy One (AIFA), lues dans
3
+ * Directus par /api/oip/sources : meme libelle « Producteur (jeu) » que les
4
+ * pieds de carte de l'app (useCardSource), pour les fiches que le layer monte
5
+ * dans une page comme dans le tiroir d'un projet.
6
+ */
7
+
8
+ /** Le jeu Directus des listes et prix de l'AIFA (cf. useDirectusSources d'Italy One). */
9
+ export const AIFA_SOURCE_UUID = "a91e97d1-b6b2-4f65-98b4-0914d14c4ac0";
10
+
11
+ function pickTranslation(rows: any[] | null | undefined, field: string, lang: string): string {
12
+ const list = rows ?? [];
13
+ const wanted = lang === "fr" ? "fr-FR" : "en-US";
14
+ const hit = list.find((t) => t?.languages_code === wanted) ?? list.find((t) => t?.languages_code === "en-US") ?? list[0];
15
+ const value = hit?.[field];
16
+ return typeof value === "string" ? value.trim() : "";
17
+ }
18
+
19
+ function buildName(source: any, lang: string): string {
20
+ const dataset = pickTranslation(source?.translations, "source_name", lang) || String(source?.Nickname ?? "").trim();
21
+ const provider = pickTranslation(source?.provider?.translations, "provider_name", lang);
22
+ if (!provider) return dataset;
23
+ if (!dataset) return provider;
24
+ if (dataset.includes("(")) return `${provider}, ${dataset}`;
25
+ return `${provider} (${dataset})`;
26
+ }
27
+
28
+ export function useAifaSource(lang: () => "fr" | "en") {
29
+ const record = ref<any>(null);
30
+
31
+ onMounted(async () => {
32
+ try {
33
+ const response = await $fetch<{ sources: any[] }>("/api/oip/sources", {
34
+ method: "POST",
35
+ body: { uuids: [AIFA_SOURCE_UUID] },
36
+ });
37
+ record.value = response?.sources?.[0] ?? null;
38
+ } catch {
39
+ record.value = null;
40
+ }
41
+ });
42
+
43
+ return {
44
+ source: computed(() => (record.value ? buildName(record.value, lang()) : "") || "Agenzia Italiana del Farmaco (AIFA)"),
45
+ verified: computed(() => String(record.value?.latest_download_date || "/")),
46
+ };
47
+ }
@@ -0,0 +1,92 @@
1
+ // Actes reglementaires de l'AIFA (it__drug_opinion__aifa) : forme d'un acte,
2
+ // libelles et schema d'export, communs a la fiche marque du layer
3
+ // (components/oip-italy) et aux pages d'Italy One.
4
+ //
5
+ // `tekkare_pdf_url` porte le meme lien tronque sur tous les documents :
6
+ // `aifa_url` est le seul lien utilisable.
7
+
8
+ export type OpinionDoc = {
9
+ opinion_id: string;
10
+ document_type: string;
11
+ has_code: string;
12
+ decision_date: string;
13
+ brand: string;
14
+ molecule: string;
15
+ company: string;
16
+ atc5_code: string;
17
+ nature_of_request: string;
18
+ nature_of_request_en: string;
19
+ theme: string;
20
+ theme_en: string;
21
+ indication: string;
22
+ indication_en: string;
23
+ essential: string;
24
+ essential_en: string;
25
+ aifa_url: string;
26
+ };
27
+
28
+ export const OPINION_FIELDS = [
29
+ "opinion_id",
30
+ "document_type",
31
+ "has_code",
32
+ "decision_date",
33
+ "brand",
34
+ "molecule",
35
+ "company",
36
+ "atc5_code",
37
+ "nature_of_request",
38
+ "nature_of_request_en",
39
+ "theme",
40
+ "theme_en",
41
+ "indication",
42
+ "indication_en",
43
+ "essential",
44
+ "essential_en",
45
+ "aifa_url",
46
+ ];
47
+
48
+ // Le texte d'un acte tel que le lecteur le voit : la traduction DeepL quand
49
+ // elle existe, l'original italien sinon (essential_en reste vide, ou vaut
50
+ // « None », une fois le quota mensuel de traduction epuise).
51
+ export const essentialOf = (x: { essential_en?: string; essential?: string } | null) =>
52
+ (x?.essential_en && x.essential_en !== "None" ? x.essential_en : "") || x?.essential || "";
53
+
54
+ // Les cinq canaux de publication du portail Trovanorme, nommes comme lui
55
+ // (detGU / modSecFar / detTNF / docAIFA / news).
56
+ export const DOCUMENT_TYPES = [
57
+ { code: "GU", label: "Gazzetta Ufficiale" },
58
+ { code: "MSF", label: "Modifiche secondarie di farmaci" },
59
+ { code: "TNF", label: "Testi normativi farmaceutici" },
60
+ { code: "AIFA", label: "Documenti AIFA" },
61
+ { code: "NEWS", label: "News" },
62
+ ];
63
+
64
+ export const documentTypeLabel = (code: string) =>
65
+ DOCUMENT_TYPES.find((x) => x.code === code)?.label ?? (code || "-");
66
+
67
+ // "MUSCULO-SKELETAL SYSTEM" -> "Musculo-skeletal system"
68
+ export function titleCase(value: string) {
69
+ const clean = (value ?? "").trim();
70
+ if (!clean) return "";
71
+ return clean.charAt(0).toUpperCase() + clean.slice(1).toLowerCase();
72
+ }
73
+
74
+ const day = (value?: string) => (value ?? "").slice(0, 10);
75
+
76
+ /** Colonnes d'export d'un acte, partagees par la fiche marque et les pages d'Italy One. */
77
+ export function actSheetSchema(fr: boolean) {
78
+ return [
79
+ { column: fr ? "Date de décision" : "Decision date", type: String, value: (x: OpinionDoc) => day(x.decision_date) },
80
+ { column: fr ? "Marque" : "Brand", type: String, width: 25, value: (x: OpinionDoc) => x.brand },
81
+ { column: fr ? "Molécule" : "Molecule", type: String, width: 35, value: (x: OpinionDoc) => x.molecule },
82
+ { column: fr ? "Laboratoire" : "Company", type: String, width: 35, value: (x: OpinionDoc) => x.company },
83
+ { column: "ATC5", type: String, value: (x: OpinionDoc) => x.atc5_code },
84
+ { column: fr ? "Nature de la demande" : "Nature of request", type: String, width: 30, value: (x: OpinionDoc) => x.nature_of_request_en },
85
+ { column: fr ? "Aire thérapeutique" : "Therapeutic area", type: String, width: 35, value: (x: OpinionDoc) => x.theme_en },
86
+ { column: fr ? "Type de document" : "Document type", type: String, value: (x: OpinionDoc) => x.document_type },
87
+ { column: fr ? "Code du document" : "Document code", type: String, value: (x: OpinionDoc) => x.has_code },
88
+ { column: "Indication", type: String, width: 80, value: (x: OpinionDoc) => x.indication_en },
89
+ { column: fr ? "Texte (IT)" : "Text (IT)", type: String, width: 100, value: (x: OpinionDoc) => x.essential },
90
+ { column: fr ? "Lien AIFA" : "AIFA link", type: String, width: 60, value: (x: OpinionDoc) => x.aifa_url },
91
+ ];
92
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/romulus",
3
- "version": "0.1.280",
3
+ "version": "0.1.281",
4
4
  "description": "Romulus Design System - Nuxt module by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",