@tekkare/romulus 0.1.280 → 0.1.282

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.
@@ -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>
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Tout ce que les sept index disent d'une association, pour sa fiche (portage
2
+ * Tout ce que les huit index disent d'une association, pour sa fiche (portage
3
3
  * de useAssociationDetail de fr_drugs_app).
4
4
  *
5
- * Cinq index portent `association_label_regroup` et se lisent directement.
5
+ * Six index portent `association_label_regroup` et se lisent directement.
6
6
  * Les deux autres ne l'ont pas : les seances du comite d'interface ANSM se
7
7
  * rejoignent par `session_url` en passant par la liste des participants, et le
8
8
  * texte des debats HAS par `has_code` + `transcription_url` en passant par la
@@ -12,7 +12,7 @@
12
12
  import type { Ref } from "vue";
13
13
  import { ES_INDEX } from "../esIndices";
14
14
  import type { EsIndexName } from "../esIndices";
15
- import { ASSOCIATION_FIELDS, NATIONAL_ASSEMBLY_FIELDS } from "../utils/associationFields";
15
+ import { AMENDMENT_FIELDS, ASSOCIATION_FIELDS, NATIONAL_ASSEMBLY_FIELDS, amendmentReportsQuery } from "../utils/associationFields";
16
16
  import useOipDrugsElastic from "./useOipDrugsElastic";
17
17
  import { useAssociationHasBrands } from "./useAssociationExport";
18
18
 
@@ -31,6 +31,7 @@ export function useAssociationDetail(label: Ref<string>) {
31
31
  const transcriptions = ref<any[]>([]);
32
32
  const sessions = ref<any[]>([]);
33
33
  const nationalAssembly = ref<any[]>([]);
34
+ const amendments = ref<any[]>([]);
34
35
  const loading = ref(true);
35
36
 
36
37
  /**
@@ -144,7 +145,7 @@ export function useAssociationDetail(label: Ref<string>) {
144
145
  directory.value = directoryHits[0] ?? null;
145
146
  knownLabels.value = labelsFrom(directory.value);
146
147
 
147
- const [contributionHits, transcriptionHits, sessionHits, nationalAssemblyHits] = await Promise.all([
148
+ const [contributionHits, transcriptionHits, sessionHits, nationalAssemblyHits, amendmentHits] = await Promise.all([
148
149
  hits(ES_INDEX.ASSOCIATION_CONTRIBUTION_HAS, {
149
150
  size: PAGE_SIZE,
150
151
  query: { bool: { must: [byLabel()] } },
@@ -173,12 +174,20 @@ export function useAssociationDetail(label: Ref<string>) {
173
174
  },
174
175
  sort: [{ [NATIONAL_ASSEMBLY_FIELDS.sessionDate]: { order: "desc" } }],
175
176
  }),
177
+ // Les amendements PLFSS qui la citent, du plus recent depot au plus
178
+ // ancien (l'examen manque aux irrecevables).
179
+ hits(ES_INDEX.ASSOCIATION_AMENDMENT_NATIONAL_ASSEMBLY, {
180
+ size: PAGE_SIZE,
181
+ query: { terms: { [AMENDMENT_FIELDS.associations]: knownLabels.value } },
182
+ sort: [{ [AMENDMENT_FIELDS.filingDate]: { order: "desc" } }],
183
+ }),
176
184
  ]);
177
185
 
178
186
  contributions.value = contributionHits;
179
187
  transcriptions.value = transcriptionHits;
180
188
  sessions.value = sessionHits;
181
189
  nationalAssembly.value = nationalAssemblyHits;
190
+ amendments.value = amendmentHits;
182
191
  loading.value = false;
183
192
 
184
193
  // Apres coup : les cartes s'affichent sans attendre, le lien vers l'avis
@@ -205,16 +214,23 @@ export function useAssociationDetail(label: Ref<string>) {
205
214
  });
206
215
  }
207
216
 
217
+ /** Les comptes rendus ou un amendement est discute (cf. amendmentReportsQuery). */
218
+ async function loadAmendmentReports(amendment: any) {
219
+ return await hits(ES_INDEX.ASSOCIATION_COMMISSION_SESSION_NATIONAL_ASSEMBLY, amendmentReportsQuery(amendment));
220
+ }
221
+
208
222
  return {
209
223
  directory,
210
224
  contributions,
211
225
  transcriptions,
212
226
  sessions,
213
227
  nationalAssembly,
228
+ amendments,
214
229
  sessionAttendees,
215
230
  loading,
216
231
  load,
217
232
  loadBlocks,
233
+ loadAmendmentReports,
218
234
  brands,
219
235
  };
220
236
  }
@@ -123,6 +123,8 @@ export const ES_INDEX = {
123
123
  ASSOCIATION_TRANSCRIPTION_BLOCK_HAS: "fr__association_transcription_block__has",
124
124
  ASSOCIATION_COMMISSION_SESSION_NATIONAL_ASSEMBLY:
125
125
  "fr__association_commission_session__national_assembly",
126
+ ASSOCIATION_AMENDMENT_NATIONAL_ASSEMBLY:
127
+ "fr__association_social_security_bill_amendment__national_assembly",
126
128
 
127
129
  // Portail (prix, approbations, sources)
128
130
  DRUG_CARDS: "aa862a6e-0eb2-453a-b020-46756088e102", // ope_block303_drug_cards
@@ -1289,7 +1289,8 @@
1289
1289
  "contributions": "HAS contributions",
1290
1290
  "transcriptions": "HAS debates",
1291
1291
  "sessions": "ANSM committees",
1292
- "nationalAssembly": "National Assembly"
1292
+ "nationalAssembly": "National Assembly",
1293
+ "amendments": "PLFSS amendments"
1293
1294
  },
1294
1295
  "contributionDetail": "Contribution detail",
1295
1296
  "fields": {
@@ -1317,7 +1318,8 @@
1317
1318
  "seeLinkedOpinion": "See the {brand} opinion",
1318
1319
  "otherAttendees": "Other participating associations",
1319
1320
  "seePdf": "View the PDF",
1320
- "noNationalAssembly": "No committee report mentions this association"
1321
+ "noNationalAssembly": "No committee report mentions this association",
1322
+ "noAmendments": "No amendment citing this association"
1321
1323
  },
1322
1324
  "kpis": {
1323
1325
  "associations": "Associations",
@@ -1453,6 +1455,21 @@
1453
1455
  "formIntro": "Name the session concerned and what looks wrong or missing. The page and the current filters are attached automatically.",
1454
1456
  "formDescription": "Session and error spotted",
1455
1457
  "formReason": "Error in a National Assembly sheet"
1458
+ },
1459
+ "amendments": {
1460
+ "card": {
1461
+ "number": "Amendment {n}",
1462
+ "examined": "Examined on {date}",
1463
+ "filed": "Filed on {date}",
1464
+ "associations": "Associations cited",
1465
+ "dispositif": "Operative text",
1466
+ "summary": "Summary statement",
1467
+ "showMore": "Show more",
1468
+ "showLess": "Show less",
1469
+ "seeOnAn": "See on assemblee-nationale.fr",
1470
+ "pdf": "View PDF",
1471
+ "report": "Read in the minutes"
1472
+ }
1456
1473
  }
1457
1474
  }
1458
1475
  },
@@ -1468,7 +1485,8 @@
1468
1485
  "lastPrice": "Latest price",
1469
1486
  "lastProtocol": "Latest protocol",
1470
1487
  "lastSession": "Latest session",
1471
- "lastUpdate": "Latest update"
1488
+ "lastUpdate": "Latest update",
1489
+ "lastAmendment": "Latest filing"
1472
1490
  }
1473
1491
  },
1474
1492
  "home": {
@@ -1289,7 +1289,8 @@
1289
1289
  "contributions": "Contributions HAS",
1290
1290
  "transcriptions": "Débats HAS",
1291
1291
  "sessions": "Comités ANSM",
1292
- "nationalAssembly": "Assemblée nationale"
1292
+ "nationalAssembly": "Assemblée nationale",
1293
+ "amendments": "Amendements PLFSS"
1293
1294
  },
1294
1295
  "contributionDetail": "Détail de la contribution",
1295
1296
  "fields": {
@@ -1317,7 +1318,8 @@
1317
1318
  "seeLinkedOpinion": "Voir l'avis {brand}",
1318
1319
  "otherAttendees": "Autres associations participantes",
1319
1320
  "seePdf": "Voir le PDF",
1320
- "noNationalAssembly": "Aucun compte rendu de commission où l'association est citée"
1321
+ "noNationalAssembly": "Aucun compte rendu de commission où l'association est citée",
1322
+ "noAmendments": "Aucun amendement où l'association est citée"
1321
1323
  },
1322
1324
  "kpis": {
1323
1325
  "associations": "Associations",
@@ -1453,6 +1455,21 @@
1453
1455
  "formIntro": "Indiquez la séance concernée et ce qui vous semble faux ou manquant. La page et les filtres en cours sont joints automatiquement.",
1454
1456
  "formDescription": "Séance et erreur repérée",
1455
1457
  "formReason": "Erreur dans une fiche Assemblée nationale"
1458
+ },
1459
+ "amendments": {
1460
+ "card": {
1461
+ "number": "Amendement {n}",
1462
+ "examined": "Examiné le {date}",
1463
+ "filed": "Déposé le {date}",
1464
+ "associations": "Associations citées",
1465
+ "dispositif": "Dispositif",
1466
+ "summary": "Exposé sommaire",
1467
+ "showMore": "Afficher tout",
1468
+ "showLess": "Réduire",
1469
+ "seeOnAn": "Voir sur assemblee-nationale.fr",
1470
+ "pdf": "Voir le PDF",
1471
+ "report": "Lire dans le compte rendu"
1472
+ }
1456
1473
  }
1457
1474
  }
1458
1475
  },
@@ -1468,7 +1485,8 @@
1468
1485
  "lastPrice": "Dernier prix",
1469
1486
  "lastProtocol": "Dernier protocole",
1470
1487
  "lastSession": "Dernière séance",
1471
- "lastUpdate": "Dernière mise à jour"
1488
+ "lastUpdate": "Dernière mise à jour",
1489
+ "lastAmendment": "Dernier dépôt"
1472
1490
  }
1473
1491
  },
1474
1492
  "home": {
@@ -48,6 +48,10 @@ export const ASSOCIATION_FIELDS = {
48
48
  nationalAssembly: "is_national_assembly_commission",
49
49
  /** Nombre de comptes rendus de commission de l'Assemblee nationale qui la citent. */
50
50
  nationalAssemblyCount: "national_assembly_commission_count",
51
+ /** Est citee dans un amendement PLFSS examine en commission de l'Assemblee nationale. */
52
+ nationalAssemblyAmendment: "is_national_assembly_amendment",
53
+ /** Nombre d'amendements PLFSS de l'Assemblee nationale qui la citent. */
54
+ nationalAssemblyAmendmentCount: "national_assembly_amendment_count",
51
55
  } as const;
52
56
 
53
57
  /**
@@ -102,6 +106,94 @@ export const NATIONAL_ASSEMBLY_FIELDS = {
102
106
  fiche: "fiche",
103
107
  } as const;
104
108
 
109
+ /**
110
+ * Champs des amendements au PLFSS examines par la commission des affaires
111
+ * sociales de l'Assemblee nationale
112
+ * (`ES_INDEX.ASSOCIATION_AMENDMENT_NATIONAL_ASSEMBLY`), un document par
113
+ * amendement.
114
+ *
115
+ * Tout est `keyword` sauf le dispositif et l'expose, `text` analyses en
116
+ * francais sans accents. Les associations citees sont un tableau de noms
117
+ * regroupes (cf. ASSOCIATION_FIELDS.label) : un `term` dessus suffit.
118
+ */
119
+ export const AMENDMENT_FIELDS = {
120
+ /** Identifiant de l'amendement, aussi `_id` du document. */
121
+ id: "amendment_id",
122
+ /** Numero en commission (« AS3 »). */
123
+ number: "amendment_number",
124
+ /** Article vise (« ART. 21 », « APRÈS ART. 45 BIS »). */
125
+ location: "location",
126
+ /** Etat : Discuté, Irrecevable, Irrecevable 40, Retiré. */
127
+ status: "status",
128
+ /** Precision de l'etat : le sort pour un amendement discute, le motif court sinon. */
129
+ subStatus: "sub_status",
130
+ /** Sort en commission (Adopté, Rejeté, Tombé, Non soutenu, Retiré), vide sans examen. */
131
+ outcome: "outcome",
132
+ /** Date d'examen en commission, vrai `date`, vide sans examen. */
133
+ examinationDate: "examination_date",
134
+ /** Date de depot, vrai `date`. */
135
+ filingDate: "filing_date",
136
+ /** Texte amende (« Projet de loi de financement de la sécurité sociale pour 2026, n° 1907 »). */
137
+ targetText: "target_text",
138
+ /** Stade de lecture. */
139
+ readingStage: "reading_stage",
140
+ /** Commission saisie (toujours la commission des affaires sociales). */
141
+ examinedBy: "examined_by",
142
+ /** Code modifie, vide quand l'amendement n'en vise pas. */
143
+ code: "code_concerned",
144
+ /** Dispositif de l'amendement, analyseur francais. */
145
+ dispositif: "location_text",
146
+ /** Expose sommaire, analyseur francais. */
147
+ summary: "summary_statement",
148
+ /** Motif d'irrecevabilite, en toutes lettres. */
149
+ irrecevability: "irrecevability_reason",
150
+ /** Associations citees dans le dispositif ou l'expose, noms regroupes. */
151
+ associations: "association_label_regroup",
152
+ /** L'amendement sur assemblee-nationale.fr. */
153
+ url: "url",
154
+ } as const;
155
+
156
+ /**
157
+ * Le PDF d'un amendement : l'Assemblee le sert a l'adresse de sa page, suffixee
158
+ * de `.pdf` (l'index ne porte que la page). Vide sans page.
159
+ */
160
+ export function amendmentPdfUrl(doc: any): string {
161
+ const url = String(doc?.[AMENDMENT_FIELDS.url] ?? "");
162
+ return url ? `${url.replace(/\/+$/, "")}.pdf` : "";
163
+ }
164
+
165
+ /**
166
+ * Un amendement discute en commission : examine, et soutenu. Un amendement
167
+ * « Non soutenu » n'est pas defendu en seance, le compte rendu ne le cite pas.
168
+ */
169
+ export function amendmentDiscussed(doc: any): boolean {
170
+ return !!doc?.[AMENDMENT_FIELDS.examinationDate] && doc?.[AMENDMENT_FIELDS.outcome] !== "Non soutenu";
171
+ }
172
+
173
+ /**
174
+ * Le ou les comptes rendus ou un amendement est discute. Les deux index ne
175
+ * partagent aucune cle : le lien tient a la seance du jour d'examen dont le
176
+ * texte cite le numero (« AS592 »). Le numero seul ne suffit pas, il repart a
177
+ * 1 a chaque texte de loi ; la date seule non plus, la commission tient deux
178
+ * ou trois seances par jour. Les deux ensemble relient 99 % des amendements
179
+ * discutes a un compte rendu, rarement deux (discussion sur deux seances).
180
+ */
181
+ export function amendmentReportsQuery(doc: any) {
182
+ return {
183
+ size: 5,
184
+ _source: { excludes: [NATIONAL_ASSEMBLY_FIELDS.text] },
185
+ query: {
186
+ bool: {
187
+ filter: [
188
+ { term: { [NATIONAL_ASSEMBLY_FIELDS.sessionDate]: doc?.[AMENDMENT_FIELDS.examinationDate] } },
189
+ { match_phrase: { [NATIONAL_ASSEMBLY_FIELDS.text]: doc?.[AMENDMENT_FIELDS.number] } },
190
+ ],
191
+ },
192
+ },
193
+ sort: [{ [NATIONAL_ASSEMBLY_FIELDS.documentNumber]: { order: "asc" } }],
194
+ };
195
+ }
196
+
105
197
  /** Les drapeaux de l'annuaire valent la chaine "1" quand ils sont leves. */
106
198
  export const ASSOCIATION_FLAG_ON = "1";
107
199
 
@@ -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
+ }