@tekkare/romulus 0.1.318 → 0.1.320

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.
@@ -16,9 +16,9 @@
16
16
  import { computed, ref, type Component, type ComputedRef, type Ref } from "vue";
17
17
  import type { RmProjectKind, RmProjectResource, RmProjectScopeRow } from "@tekkare/romulus/utils/projects";
18
18
  import type { RmExportSheet } from "@tekkare/romulus/utils/export";
19
- import type { RmDashboardModel, RmWidgetContext, RmWidgetKind } from "@tekkare/romulus/utils/dashboard";
20
- import { rmNewWidgetId } from "@tekkare/romulus/utils/dashboard";
21
- import type { ProjectSuggestion } from "../types/projects";
19
+ import type { RmDashboardModel, RmDashboardWidget, RmWidgetContext, RmWidgetKind } from "@tekkare/romulus/utils/dashboard";
20
+ import { rmAddableWidgets, rmNewWidgetId } from "@tekkare/romulus/utils/dashboard";
21
+ import type { ProjectInboxItem, ProjectSuggestion } from "../types/projects";
22
22
 
23
23
  type Lang = "fr" | "en";
24
24
  type Text = { fr: string; en: string };
@@ -77,6 +77,12 @@ export const PROJECT_WORDING: {
77
77
  dashboard: Text;
78
78
  /** Ce que suit l'alerte d'un projet (« un statut, une phase... »). */
79
79
  watch: Text;
80
+ /**
81
+ * Ce que dit un widget `usesBrands` quand le projet ne range aucune marque
82
+ * (« ajoutez des actes AIFA depuis Italy One... »). Absent : le mot neutre
83
+ * de RmDashboard, « Aucune marque sélectionnée ».
84
+ */
85
+ noBrands?: Text;
80
86
  } = {
81
87
  empty: {
82
88
  fr: "Un projet rassemble ce que vous mettez de côté au fil des pages.",
@@ -147,20 +153,47 @@ export interface OipProjectWidgetContext extends RmWidgetContext {
147
153
  groups: { label: string; count: number }[];
148
154
  /** Les documents des elements ranges, deja relus par la page. */
149
155
  docs: { type: string; source: Record<string, any> }[];
156
+ /** Le projet, pour les widgets qui relisent l'API (notes, documents). */
157
+ projectId: string;
158
+ /** Les lignes du projet telles que la page les affiche : titre, famille, pays, date d'ajout. */
159
+ rows: RmProjectResource[];
160
+ /** Les messages de l'Inbox, deja lus par la page : ce qui a bouge, ce qui a ete ajoute. */
161
+ inbox: ProjectInboxItem[];
162
+ /** Le client de l'app (`useOipApi()`), capture au montage : un widget ne peut pas l'appeler lui-meme apres un `await`. */
163
+ api: any;
150
164
  }
151
165
 
152
166
  /**
153
167
  * Les marques du projet, que les widgets `usesBrands` lisent : l'app les tire
154
- * des documents ranges (`code` des ventes, marques des avis...). Aucune par defaut.
168
+ * des documents ranges (`code` des ventes, marques des avis...). Aucune par
169
+ * defaut. Une app qui prend les widgets medicament du layer exporte
170
+ * `oipProjectBrands` sous ce nom (cf. oip-defaults/dashboardWidgets.ts) :
171
+ * sans marque, RmDashboardWidget coupe avant le `fetch`.
155
172
  */
156
173
  export function projectBrands(_docs: OipProjectWidgetContext["docs"]): string[] {
157
174
  return [];
158
175
  }
159
176
 
177
+ type WidgetKind = RmWidgetKind<OipProjectWidgetContext>;
178
+
179
+ const PROJECT_GROUP = { fr: "Projet", en: "Project" };
180
+ const T = (lang: Lang, fr: string, en: string) => (lang === "en" ? en : fr);
181
+ const day = (value: unknown) => String(value ?? "").slice(0, 10);
182
+
183
+ /** Le nom d'un pays dans la langue lue ; le code tel quel si le navigateur ne le connait pas. */
184
+ function countryName(code: string, lang: Lang): string {
185
+ try {
186
+ return new Intl.DisplayNames([lang === "en" ? "en" : "fr"], { type: "region" }).of(code.toUpperCase()) ?? code;
187
+ } catch {
188
+ return code;
189
+ }
190
+ }
191
+
160
192
  /** Le widget que toute app sait remplir : le contenu du projet, par famille. */
161
- export const PROJECT_RESOURCES_WIDGET: RmWidgetKind<OipProjectWidgetContext> = {
193
+ export const PROJECT_RESOURCES_WIDGET: WidgetKind = {
162
194
  kind: "project.resources",
163
- group: { fr: "Projet", en: "Project" },
195
+ deps: ({ groups }) => groups,
196
+ group: PROJECT_GROUP,
164
197
  title: { fr: "Contenu du projet", en: "Project content" },
165
198
  description: { fr: "Les éléments rangés dans le projet, par famille.", en: "What the project holds, per family." },
166
199
  viz: ["donut", "bar", "table", "kpi"],
@@ -173,21 +206,253 @@ export const PROJECT_RESOURCES_WIDGET: RmWidgetKind<OipProjectWidgetContext> = {
173
206
  },
174
207
  };
175
208
 
176
- /** Catalogue des widgets du tableau de bord. */
177
- export const PROJECT_DASHBOARD_WIDGETS: RmWidgetKind<OipProjectWidgetContext>[] = [PROJECT_RESOURCES_WIDGET];
209
+ /**
210
+ * Les widgets que le layer remplit sans connaitre la famille : ce que la page
211
+ * a deja relu (lignes, Inbox) et ce que l'API sait du projet (notes,
212
+ * documents). Ils font le tableau de depart de toute app, catalogue ou pas.
213
+ */
214
+
215
+ /** Les derniers elements ranges, du plus recent au plus ancien. */
216
+ export const PROJECT_RECENT_WIDGET: WidgetKind = {
217
+ kind: "project.recent",
218
+ deps: ({ rows }) => rows.map((row) => [row.type, row.id, row.createdAt]),
219
+ group: PROJECT_GROUP,
220
+ title: { fr: "Derniers ajouts", en: "Latest additions" },
221
+ description: { fr: "Les éléments rangés dans le projet, du plus récent au plus ancien.", en: "What was filed in the project, newest first." },
222
+ viz: ["table"],
223
+ sources: [],
224
+ usesBrands: false,
225
+ params: [],
226
+ size: { w: 8, h: 5 },
227
+ async fetch(_params, { rows, lang }) {
228
+ const sorted = [...rows].sort((a, b) => String(b.createdAt ?? "").localeCompare(String(a.createdAt ?? "")));
229
+ return {
230
+ type: "rows",
231
+ columns: [
232
+ { key: "date", label: T(lang, "Ajouté le", "Added on"), date: true },
233
+ { key: "title", label: T(lang, "Élément", "Item"), long: true },
234
+ { key: "family", label: T(lang, "Famille", "Family") },
235
+ { key: "country", label: T(lang, "Pays", "Country"), optional: true },
236
+ ],
237
+ rows: sorted.map((row) => ({
238
+ date: day(row.createdAt),
239
+ title: row.title || T(lang, "Élément inconnu", "Unknown item"),
240
+ family: row.family,
241
+ country: row.country ? countryName(row.country, lang) : null,
242
+ })),
243
+ };
244
+ },
245
+ };
246
+
247
+ /** Les elements par pays de leur donnee. Cache tant qu'aucune ligne n'en porte un. */
248
+ export const PROJECT_COUNTRIES_WIDGET: WidgetKind = {
249
+ kind: "project.byCountry",
250
+ deps: ({ rows }) => rows.map((row) => row.country ?? ""),
251
+ group: PROJECT_GROUP,
252
+ title: { fr: "Éléments par pays", en: "Items per country" },
253
+ description: { fr: "Les éléments du projet, comptés par pays de leur donnée.", en: "The project's items, counted by the country of their data." },
254
+ viz: ["donut", "bar", "table"],
255
+ sources: [],
256
+ usesBrands: false,
257
+ params: [],
258
+ size: { w: 4, h: 5 },
259
+ available: ({ rows }) => rows.some((row) => !!row.country),
260
+ async fetch(_params, { rows, lang }) {
261
+ const counts = new Map<string, number>();
262
+ for (const row of rows) {
263
+ const name = row.country ? countryName(row.country, lang) : T(lang, "Sans pays", "No country");
264
+ counts.set(name, (counts.get(name) ?? 0) + 1);
265
+ }
266
+ return { type: "parts", parts: [...counts].map(([name, value]) => ({ name, value })).sort((a, b) => b.value - a.value) };
267
+ },
268
+ };
269
+
270
+ const CHANGE_LABELS: Record<string, Text> = {
271
+ appeared: { fr: "Apparu", en: "Appeared" },
272
+ changed: { fr: "Modifié", en: "Changed" },
273
+ disappeared: { fr: "Disparu", en: "Disappeared" },
274
+ };
275
+
276
+ /** Les changements detectes sur les fiches du projet, lus dans l'Inbox. Cache tant que l'Inbox n'en a aucun. */
277
+ export const PROJECT_CHANGES_WIDGET: WidgetKind = {
278
+ kind: "project.changes",
279
+ deps: ({ inbox }) => inbox.map((item) => [item.id, item.readAt]),
280
+ group: PROJECT_GROUP,
281
+ title: { fr: "Ce qui a bougé", en: "What changed" },
282
+ description: {
283
+ fr: "Les fiches du projet apparues, modifiées ou disparues, telles que l'Inbox les a vues.",
284
+ en: "The project's records that appeared, changed or disappeared, as the Inbox saw them.",
285
+ },
286
+ viz: ["kpi", "table"],
287
+ sources: [],
288
+ usesBrands: false,
289
+ params: [
290
+ {
291
+ key: "scope",
292
+ label: { fr: "Période", en: "Scope" },
293
+ options: [
294
+ { value: "unread", label: { fr: "Depuis ma dernière visite", en: "Since my last visit" } },
295
+ { value: "all", label: { fr: "Tout l'historique", en: "Whole history" } },
296
+ ],
297
+ },
298
+ ],
299
+ size: { w: 8, h: 5 },
300
+ available: ({ inbox }) => inbox.some((item) => item.kind === "changes" && item.payload?.events?.length),
301
+ async fetch(params, { inbox, lang }) {
302
+ const items = inbox.filter((item) => item.kind === "changes" && (params.scope === "all" || !item.readAt));
303
+ const events = items.flatMap((item) => item.payload?.events ?? []);
304
+ const period = params.scope === "all" ? T(lang, "tout l'historique", "whole history") : T(lang, "depuis ma dernière visite", "since my last visit");
305
+ const count = (kind: string) => events.filter((event) => event.kind === kind).length;
306
+ return {
307
+ type: "kpi",
308
+ period,
309
+ items: (["appeared", "changed", "disappeared"] as const).map((kind) => ({
310
+ label: CHANGE_LABELS[kind]![lang],
311
+ value: count(kind),
312
+ previous: null,
313
+ })),
314
+ note: events.length ? undefined : T(lang, "Rien n'a bougé sur cette période.", "Nothing changed over this period."),
315
+ };
316
+ },
317
+ };
318
+
319
+ /** Les notes et documents du projet, du plus recent au plus ancien. */
320
+ export const PROJECT_ACTIVITY_WIDGET: WidgetKind = {
321
+ kind: "project.activity",
322
+ deps: ({ projectId }) => projectId,
323
+ group: PROJECT_GROUP,
324
+ title: { fr: "Notes et documents récents", en: "Recent notes and documents" },
325
+ description: { fr: "Les dernières notes écrites et les derniers documents déposés dans le projet.", en: "The latest notes written and documents dropped in the project." },
326
+ viz: ["table"],
327
+ sources: [],
328
+ usesBrands: false,
329
+ params: [],
330
+ size: { w: 4, h: 5 },
331
+ async fetch(_params, { api, projectId, lang }) {
332
+ const [notes, documents] = await Promise.all([
333
+ api.projectNotes.list(projectId).then((r: any) => r?.notes ?? []).catch(() => []),
334
+ api.projectDocuments.list(projectId).then((r: any) => r?.documents ?? []).catch(() => []),
335
+ ]);
336
+ const rows = [
337
+ ...notes.map((note: any) => ({
338
+ date: day(note.updatedAt ?? note.createdAt),
339
+ kind: T(lang, "Note", "Note"),
340
+ title: String(note.title || T(lang, "Sans titre", "Untitled")),
341
+ })),
342
+ ...documents.map((document: any) => ({
343
+ date: day(document.createdAt),
344
+ kind: T(lang, "Document", "Document"),
345
+ title: String(document.title || document.filename || ""),
346
+ })),
347
+ ].sort((a, b) => b.date.localeCompare(a.date));
348
+ return {
349
+ type: "rows",
350
+ columns: [
351
+ { key: "date", label: T(lang, "Date", "Date"), date: true },
352
+ { key: "kind", label: T(lang, "Type", "Type") },
353
+ { key: "title", label: T(lang, "Titre", "Title"), long: true },
354
+ ],
355
+ rows,
356
+ note: rows.length ? undefined : T(lang, "Aucune note ni document pour l'instant.", "No note or document yet."),
357
+ };
358
+ },
359
+ };
360
+
361
+ /** Les widgets du layer, que toute app propose avant les siens. */
362
+ export const PROJECT_LAYER_WIDGETS: WidgetKind[] = [
363
+ PROJECT_RESOURCES_WIDGET,
364
+ PROJECT_RECENT_WIDGET,
365
+ PROJECT_COUNTRIES_WIDGET,
366
+ PROJECT_CHANGES_WIDGET,
367
+ PROJECT_ACTIVITY_WIDGET,
368
+ ];
369
+
370
+ /**
371
+ * Catalogue des widgets du tableau de bord. Une app y met les siens apres
372
+ * ceux du layer : `[...PROJECT_LAYER_WIDGETS, ...widgets]`.
373
+ */
374
+ export const PROJECT_DASHBOARD_WIDGETS: WidgetKind[] = PROJECT_LAYER_WIDGETS;
178
375
 
179
- /** Le tableau de depart d'un projet qui n'en a pas encore enregistre. */
180
- export function defaultProjectDashboard(): RmDashboardModel {
376
+ /** Un widget pose a une place, avec sa taille de catalogue. */
377
+ export function oipPlaceWidget(
378
+ catalog: WidgetKind[],
379
+ kind: string,
380
+ viz: RmDashboardWidget["viz"],
381
+ x: number,
382
+ y: number,
383
+ size?: { w: number; h: number },
384
+ ): RmDashboardWidget {
385
+ const entry = catalog.find((item) => item.kind === kind);
386
+ return { id: rmNewWidgetId(), kind, viz, params: {}, layout: { x, y, ...(size ?? entry?.size ?? { w: 4, h: 5 }) } };
387
+ }
388
+
389
+ /**
390
+ * Le tableau d'un projet reduit a ce qui a quelque chose a montrer : les
391
+ * widgets d'une entree cachee du catalogue (sans marque, `available` faux)
392
+ * ne sont pas poses. Pour un tableau de depart ou un modele ; un tableau
393
+ * enregistre garde les siens.
394
+ */
395
+ export function oipPruneDashboard(model: RmDashboardModel, catalog: WidgetKind[], context: OipProjectWidgetContext): RmDashboardModel {
396
+ const addable = new Set(rmAddableWidgets(catalog, context).map((entry) => entry.kind));
397
+ return { ...model, widgets: model.widgets.filter((widget) => addable.has(widget.kind)) };
398
+ }
399
+
400
+ /**
401
+ * Le tableau de depart d'un projet qui n'en a pas encore enregistre : le
402
+ * contenu, les derniers ajouts, les pays, ce qui a bouge, les notes et
403
+ * documents. Sans contexte (contrat d'avant), le seul contenu du projet.
404
+ * Une app pose les siens ; les widgets sans donnee sont retires a l'affichage
405
+ * (oipPruneDashboard), elle n'a pas a le faire elle-meme.
406
+ */
407
+ export function defaultProjectDashboard(context?: OipProjectWidgetContext): RmDashboardModel {
408
+ const place = (kind: string, viz: RmDashboardWidget["viz"], x: number, y: number, size?: { w: number; h: number }) =>
409
+ oipPlaceWidget(PROJECT_LAYER_WIDGETS, kind, viz, x, y, size);
410
+ if (!context) return { version: 1, widgets: [place("project.resources", "donut", 0, 0)] };
181
411
  return {
182
412
  version: 1,
183
413
  widgets: [
184
- {
185
- id: rmNewWidgetId(),
186
- kind: PROJECT_RESOURCES_WIDGET.kind,
187
- viz: "donut",
188
- params: {},
189
- layout: { x: 0, y: 0, ...PROJECT_RESOURCES_WIDGET.size },
190
- },
414
+ place("project.resources", "donut", 0, 0),
415
+ place("project.recent", "table", 4, 0),
416
+ place("project.byCountry", "donut", 0, 5),
417
+ place("project.changes", "kpi", 4, 5),
418
+ place("project.activity", "table", 0, 10, { w: 12, h: 5 }),
191
419
  ],
192
420
  };
193
421
  }
422
+
423
+ /** Un modele de tableau : un jeu de widgets a poser d'un coup, propose dans le menu « Modeles ». */
424
+ export interface OipProjectDashboardTemplate {
425
+ id: string;
426
+ title: Text;
427
+ description?: Text;
428
+ build: (context: OipProjectWidgetContext) => RmDashboardModel;
429
+ }
430
+
431
+ /**
432
+ * Les modeles du menu « Modeles » de l'onglet, apres lesquels viennent les
433
+ * tableaux des autres projets de l'utilisateur (« Copier depuis un projet »).
434
+ * Une app ajoute les siens : `[...PROJECT_LAYER_TEMPLATES, ...]`.
435
+ */
436
+ export const PROJECT_LAYER_TEMPLATES: OipProjectDashboardTemplate[] = [
437
+ {
438
+ id: "overview",
439
+ title: { fr: "Vue d'ensemble", en: "Overview" },
440
+ description: { fr: "Le contenu, les derniers ajouts, les pays, ce qui a bougé.", en: "The content, latest additions, countries, what changed." },
441
+ build: (context) => defaultProjectDashboard(context),
442
+ },
443
+ {
444
+ id: "activity",
445
+ title: { fr: "Activité", en: "Activity" },
446
+ description: { fr: "Ce qui a bougé, les derniers ajouts, les notes et documents.", en: "What changed, latest additions, notes and documents." },
447
+ build: () => ({
448
+ version: 1,
449
+ widgets: [
450
+ oipPlaceWidget(PROJECT_LAYER_WIDGETS, "project.changes", "kpi", 0, 0, { w: 12, h: 4 }),
451
+ oipPlaceWidget(PROJECT_LAYER_WIDGETS, "project.recent", "table", 0, 4, { w: 8, h: 6 }),
452
+ oipPlaceWidget(PROJECT_LAYER_WIDGETS, "project.activity", "table", 8, 4, { w: 4, h: 6 }),
453
+ ],
454
+ }),
455
+ },
456
+ ];
457
+
458
+ export const PROJECT_DASHBOARD_TEMPLATES: OipProjectDashboardTemplate[] = PROJECT_LAYER_TEMPLATES;
@@ -0,0 +1,225 @@
1
+ /**
2
+ * Les familles que Global Oncology range dans un projet, decrites pour tout
3
+ * le portail : les autorisations oncologiques de six agences (EMA, FDA, PMDA,
4
+ * MFDS, MHRA) et les avis de la HAS. Le tiroir d'un projet les montre par la
5
+ * carte oncology-approval (components/oip-oncology/Approval.vue), les avis HAS
6
+ * par la fiche marque de fr_drugs_app (meme index) ; la ligne du projet mene
7
+ * a la page de Global Oncology.
8
+ *
9
+ * Les cles sont celles du registre de l'API (`resource_types`), que le bouton
10
+ * Projet de Global Oncology envoie : `EmaApproval`, `FdaApproval`,
11
+ * `PmdaApproval`, `MpdsApproval` (sic, MFDS), `MhraApproval`, `HeartApproval`
12
+ * (HAS). Les `OncoEmaApproval`... de l'app ne nomment que ses alertes.
13
+ *
14
+ * Index lus sur le cluster `drugs` (meme domaine que fr_drugs_app ;
15
+ * cf. runtimeConfig.oipEs.drugs). Chaque famille relit le tagging des
16
+ * cancers (CIM-10) de ses indications : le tableau de bord du projet compte
17
+ * dessus sans requete de plus.
18
+ *
19
+ * Importe aussi par le serveur : pas d'import propre a Vue ou a Nuxt ici.
20
+ */
21
+
22
+ import type { RmProjectKind, RmProjectLang } from "@tekkare/romulus/utils/projects";
23
+
24
+ const ONCOLOGY = { fr: "Autorisations oncologiques", en: "Oncology approvals" };
25
+
26
+ /**
27
+ * Les index des autorisations de Global Oncology, par leur id Directus
28
+ * (collection ElasticIndices) : le proxy en tire le nom physique, l'index
29
+ * staging en preproduction. Ce sont les index « live » du registre de l'API
30
+ * (migration live_approval_indexes), pas les `ope_block*` que la config prod
31
+ * de l'app lisait encore.
32
+ */
33
+ export const ONCOLOGY_INDEX = {
34
+ /** EMA (oip-discovery-ema), `_id` = identifiant interne, la fiche s'adresse par `ema_product_number`. */
35
+ ema: "eeb2ea64-e896-4586-a654-76e511ffe057",
36
+ /** FDA (ope__us__fda_drug_approval__tekkare), `_id` = <applno>_<drug_name>. */
37
+ fda: "3d1fa751-0e83-4007-a314-a86ea25853c6",
38
+ /** PMDA (ope__jp__pmda_drug_approval__tekkare), `_id` = card_id. */
39
+ pmda: "ab65dac1-8eac-4663-b65e-0b1635dbf3b4",
40
+ /** MFDS (ope__kr__mfds_drug_approval__tekkare), `_id` = product_id. */
41
+ mfds: "9d196b6d-ccbd-429f-82c4-974a36eb3213",
42
+ /** MHRA (ope__uk__mhra_drug_approval__tekkare), `_id` = molecule. */
43
+ mhra: "0cb3a88c-9139-48e1-bef2-9f6b9e0d1867",
44
+ /** HAS (ope_block402_fr__drugs__brand__has), `_id` = brand_group : l'index BRAND_HAS de fr_drugs_app. */
45
+ has: "d736c6f0-0dc6-4bb6-94c4-644a7ad231e7",
46
+ };
47
+
48
+ type Doc = Record<string, any>;
49
+
50
+ const text = (value: unknown) => (value === null || value === undefined ? "" : String(value).trim());
51
+ const list = (value: unknown): Doc[] => (Array.isArray(value) ? value : []);
52
+ const strings = (values: unknown[]) => [...new Set(values.map(text).filter(Boolean))];
53
+
54
+ /**
55
+ * Le jour d'une date telle que l'index la porte : millisecondes (EMA), ISO
56
+ * (FDA, MHRA, HAS) ou « 27 Oct, 2010 » (PMDA, MFDS), rendue telle quelle.
57
+ */
58
+ export const oncologyDay = (value: unknown): string => {
59
+ if (typeof value === "number") return new Date(value).toISOString().slice(0, 10);
60
+ const raw = text(value);
61
+ return /^\d{4}-\d{2}-\d{2}/.test(raw) ? raw.slice(0, 10) : raw;
62
+ };
63
+
64
+ /** Les cancers tagues d'une autorisation (CIM-10), par leur libelle combine. */
65
+ export function oncologyCancers(doc: Doc): string[] {
66
+ const entries = [...list(doc?.diseases), ...list(doc?.oncology_tagging_en)];
67
+ return strings(entries.flatMap((entry) => list(entry.icd10).map((icd) => icd.combined_label || icd.icd_label || icd.icd_code)));
68
+ }
69
+
70
+ const CANCERS = ["icd10.icd_code", "icd10.icd_label", "icd10.combined_label"];
71
+ const tagged = (field: string) => CANCERS.map((path) => `${field}.${path}`);
72
+
73
+ /** Un libelle ATC5 de la MFDS porte la molecule avant « (ATC5 : code) ». */
74
+ const mfdsMolecule = (doc: Doc) => text(doc?.atc_label_en).split(" (ATC")[0] ?? "";
75
+
76
+ const join = (parts: unknown[]) => parts.map(text).filter(Boolean).join(" · ");
77
+
78
+ export const ONCOLOGY_PROJECT_KINDS: RmProjectKind[] = [
79
+ {
80
+ // Une autorisation de l'EMA : la page de l'app s'adresse par le numero
81
+ // de produit, dont elle remplace les « / » par des « - ».
82
+ type: "EmaApproval",
83
+ index: ONCOLOGY_INDEX.ema,
84
+ label: { fr: "Autorisations EMA", en: "EMA approvals" },
85
+ section: ONCOLOGY,
86
+ country: "eu",
87
+ icon: "Stamp",
88
+ source: ["ema_product_number", "product_label", "molecule", "company", "marketing_authorisation_date", "medicine_status", ...tagged("diseases")],
89
+ title: (s) => text(s?.product_label),
90
+ subtitle: (s) => join([s?.molecule, s?.company, oncologyDay(s?.marketing_authorisation_date), s?.medicine_status]),
91
+ path: (s) =>
92
+ s?.ema_product_number
93
+ ? `/approvals/emea/details/${encodeURIComponent(text(s.ema_product_number).replace(/\//g, "-"))}`
94
+ : "/approvals/emea",
95
+ },
96
+ {
97
+ // Une autorisation de la FDA : `_id` = <applno>_<drug_name>, la page le reprend.
98
+ type: "FdaApproval",
99
+ index: ONCOLOGY_INDEX.fda,
100
+ label: { fr: "Autorisations FDA", en: "FDA approvals" },
101
+ section: ONCOLOGY,
102
+ country: "us",
103
+ icon: "Stamp",
104
+ source: ["applno", "drug_name", "molecules", "drug_company", "latest_indication_date", "new_action_date", ...tagged("diseases")],
105
+ title: (s) => text(s?.drug_name),
106
+ subtitle: (s) =>
107
+ join([strings(Array.isArray(s?.molecules) ? s.molecules : [s?.molecules]).join(", "), s?.drug_company, oncologyDay(s?.latest_indication_date ?? s?.new_action_date)]),
108
+ path: (_s, id) => `/approvals/fda/details/${encodeURIComponent(id)}`,
109
+ titleFromId: (id) => id.replace(/^\d+_/, ""),
110
+ },
111
+ {
112
+ // Une autorisation de la PMDA : `_id` = card_id (<n>|<molecule>|<laboratoire>).
113
+ type: "PmdaApproval",
114
+ index: ONCOLOGY_INDEX.pmda,
115
+ label: { fr: "Autorisations PMDA", en: "PMDA approvals" },
116
+ section: ONCOLOGY,
117
+ country: "jp",
118
+ icon: "Stamp",
119
+ source: ["card_id", "molecule_en", "company_en", "last_approval_date", "approval_history.product_list.product_label_en", ...tagged("diseases")],
120
+ title: (s) =>
121
+ strings(list(s?.approval_history).flatMap((a) => list(a.product_list).map((p) => p.product_label_en))).join(", ") || text(s?.molecule_en),
122
+ subtitle: (s) => join([s?.molecule_en, s?.company_en, oncologyDay(s?.last_approval_date)]),
123
+ path: (s, id) => `/approvals/pmda/details/${encodeURIComponent(text(s?.card_id) || id)}`,
124
+ titleFromId: (id) => id.split("|")[1] || id,
125
+ },
126
+ {
127
+ // Une autorisation de la MFDS (Coree) : `_id` = product_id. La cle
128
+ // « MpdsApproval » est celle du registre de l'API, coquille comprise.
129
+ type: "MpdsApproval",
130
+ index: ONCOLOGY_INDEX.mfds,
131
+ label: { fr: "Autorisations MFDS", en: "MFDS approvals" },
132
+ section: ONCOLOGY,
133
+ country: "kr",
134
+ icon: "Stamp",
135
+ source: ["product_id", "product_name_en", "atc_label_en", "company_name_en", "last_approval_date", ...tagged("diseases")],
136
+ title: (s) => text(s?.product_name_en),
137
+ subtitle: (s) => join([mfdsMolecule(s), s?.company_name_en, oncologyDay(s?.last_approval_date)]),
138
+ path: (s, id) => `/approvals/mfds/details/${encodeURIComponent(text(s?.product_id) || id)}`,
139
+ titleFromId: (id) => `MFDS ${id}`,
140
+ },
141
+ {
142
+ // Une molecule autorisee par la MHRA : `_id` = molecule, ses produits dessous.
143
+ type: "MhraApproval",
144
+ index: ONCOLOGY_INDEX.mhra,
145
+ label: { fr: "Autorisations MHRA", en: "MHRA approvals" },
146
+ section: ONCOLOGY,
147
+ country: "gb",
148
+ icon: "Stamp",
149
+ source: ["molecule", "last_approval_date", "products.brand", "products.manufacturer", ...tagged("diseases")],
150
+ title: (s) => strings(list(s?.products).map((p) => p.brand)).join(", ") || text(s?.molecule),
151
+ subtitle: (s) => join([s?.molecule, oncologyDay(s?.last_approval_date)]),
152
+ path: (s, id) => `/approvals/mhra/details/${encodeURIComponent((text(s?.molecule) || id).replace(/ /g, "_"))}`,
153
+ },
154
+ {
155
+ // Un avis de la HAS, par marque : les memes documents que FrHasBrand de
156
+ // fr_drugs_app, relus avec le tagging oncologique en plus. La page de
157
+ // l'app s'adresse par le brand_group (« A / B » devient « A_+_B »).
158
+ type: "HeartApproval",
159
+ index: ONCOLOGY_INDEX.has,
160
+ label: { fr: "Avis HAS", en: "HAS opinions" },
161
+ section: ONCOLOGY,
162
+ country: "fr",
163
+ icon: "Certificate",
164
+ source: ["brand_group", "last_opinion_date", "brand_history.molecule", ...tagged("oncology_tagging_en")],
165
+ title: (s) => text(s?.brand_group),
166
+ subtitle: (s) => join([strings(list(s?.brand_history).map((h) => h.molecule)).join(", "), oncologyDay(s?.last_opinion_date)]),
167
+ path: (s, id) => `/approvals/has/${encodeURIComponent((text(s?.brand_group) || id).replace(/ \/ /g, " + ").replace(/ /g, "_"))}`,
168
+ },
169
+ ];
170
+
171
+ /** L'agence d'une famille, pour le bandeau de sa carte. */
172
+ export const ONCOLOGY_AGENCY: Record<string, { fr: string; en: string }> = {
173
+ EmaApproval: { fr: "EMA, Union européenne", en: "EMA, European Union" },
174
+ FdaApproval: { fr: "FDA, États-Unis", en: "FDA, United States" },
175
+ PmdaApproval: { fr: "PMDA, Japon", en: "PMDA, Japan" },
176
+ MpdsApproval: { fr: "MFDS, Corée du Sud", en: "MFDS, South Korea" },
177
+ MhraApproval: { fr: "MHRA, Royaume-Uni", en: "MHRA, United Kingdom" },
178
+ HeartApproval: { fr: "HAS, France", en: "HAS, France" },
179
+ };
180
+
181
+ /** Les lignes de la carte d'une autorisation (libelle, valeur), vides sautees. */
182
+ export function oncologyRows(type: string, doc: Doc, lang: RmProjectLang): { label: string; value: string }[] {
183
+ const en = lang === "en";
184
+ const rows: { label: string; value: unknown }[] = [];
185
+ const molecule = en ? "Molecule" : "Molécule";
186
+ const company = en ? "Company" : "Laboratoire";
187
+ const approval = en ? "Approval date" : "Date d'autorisation";
188
+ if (type === "EmaApproval") {
189
+ rows.push(
190
+ { label: en ? "Product number" : "Numéro de produit", value: doc.ema_product_number },
191
+ { label: molecule, value: doc.molecule },
192
+ { label: company, value: doc.company },
193
+ { label: en ? "Status" : "Statut", value: doc.medicine_status },
194
+ { label: approval, value: oncologyDay(doc.marketing_authorisation_date) },
195
+ );
196
+ } else if (type === "FdaApproval") {
197
+ rows.push(
198
+ { label: en ? "Application" : "Dossier", value: doc.applno },
199
+ { label: molecule, value: strings(Array.isArray(doc.molecules) ? doc.molecules : [doc.molecules]).join(", ") },
200
+ { label: company, value: doc.drug_company },
201
+ { label: en ? "Latest indication" : "Dernière indication", value: oncologyDay(doc.latest_indication_date ?? doc.new_action_date) },
202
+ );
203
+ } else if (type === "PmdaApproval") {
204
+ rows.push(
205
+ { label: molecule, value: doc.molecule_en },
206
+ { label: company, value: doc.company_en },
207
+ { label: en ? "Latest approval" : "Dernière autorisation", value: oncologyDay(doc.last_approval_date) },
208
+ );
209
+ } else if (type === "MpdsApproval") {
210
+ rows.push(
211
+ { label: molecule, value: mfdsMolecule(doc) },
212
+ { label: "ATC", value: doc.atc_label_en },
213
+ { label: company, value: doc.company_name_en },
214
+ { label: en ? "Latest approval" : "Dernière autorisation", value: oncologyDay(doc.last_approval_date) },
215
+ );
216
+ } else if (type === "MhraApproval") {
217
+ rows.push(
218
+ { label: en ? "Products" : "Produits", value: strings(list(doc.products).map((p) => p.brand)).join(", ") },
219
+ { label: en ? "Manufacturers" : "Fabricants", value: strings(list(doc.products).map((p) => p.manufacturer)).join(", ") },
220
+ { label: en ? "Latest approval" : "Dernière autorisation", value: oncologyDay(doc.last_approval_date) },
221
+ );
222
+ }
223
+ rows.push({ label: en ? "Cancers (ICD-10)" : "Cancers (CIM-10)", value: oncologyCancers(doc).join(", ") });
224
+ return rows.map((row) => ({ label: row.label, value: text(row.value) })).filter((row) => row.value);
225
+ }
@@ -23,6 +23,7 @@ import { ITALY_PROJECT_KINDS } from "../oip-italy/kinds";
23
23
  import { AUSTRALIA_PROJECT_KINDS } from "../oip-australia/kinds";
24
24
  import { NEW_ZEALAND_PROJECT_KINDS } from "../oip-new-zealand/kinds";
25
25
  import { SPAIN_PROJECT_KINDS } from "../oip-spain/kinds";
26
+ import { ONCOLOGY_PROJECT_KINDS } from "../oip-oncology/kinds";
26
27
 
27
28
  /** Les apps qui ont des fiches a montrer, et ou les ouvrir. */
28
29
  export const OIP_RESOURCE_APPS = {
@@ -58,6 +59,10 @@ export const OIP_RESOURCE_APPS = {
58
59
  name: "Spain One",
59
60
  url: "https://spain-one.app.tekkare.com",
60
61
  },
62
+ global_oncology_app: {
63
+ name: "Global Oncology",
64
+ url: "https://global-oncology.app.tekkare.com",
65
+ },
61
66
  } as const;
62
67
 
63
68
  export type OipResourceApp = keyof typeof OIP_RESOURCE_APPS;
@@ -264,6 +269,36 @@ function spainSpec(kind: RmProjectKind, view: string): OipResourceSpec {
264
269
  };
265
270
  }
266
271
 
272
+ /**
273
+ * Une autorisation oncologique de Global Oncology, lue sur le cluster `drugs`
274
+ * et montree d'un seul tenant (components/oip-oncology, ou la fiche marque
275
+ * de fr_drugs_app pour les avis HAS, memes documents) ; la ligne du projet
276
+ * mene a la page de l'app.
277
+ */
278
+ function oncologySpec(kind: RmProjectKind, view: string): OipResourceSpec {
279
+ return {
280
+ type: kind.type,
281
+ app: "global_oncology_app",
282
+ cluster: "drugs",
283
+ kind,
284
+ routeId: (id) => id,
285
+ base: () => "",
286
+ tabs: [],
287
+ view,
288
+ detailPath: (id, _tab, doc) => kind.path?.(doc ?? {}, id) ?? "",
289
+ };
290
+ }
291
+
292
+ /** La fiche de chaque famille de Global Oncology (cf. useOipResourceViews). */
293
+ const ONCOLOGY_VIEWS: Record<string, string> = {
294
+ EmaApproval: "oncology-approval",
295
+ FdaApproval: "oncology-approval",
296
+ PmdaApproval: "oncology-approval",
297
+ MpdsApproval: "oncology-approval",
298
+ MhraApproval: "oncology-approval",
299
+ HeartApproval: "drugs-brand",
300
+ };
301
+
267
302
  /** La fiche de chaque famille de Spain One (cf. useOipResourceViews). */
268
303
  const SPAIN_VIEWS: Record<string, string> = {
269
304
  EsApproval: "spain-aemps-report",
@@ -535,6 +570,7 @@ export const OIP_RESOURCE_SPECS: OipResourceSpec[] = [
535
570
  ...AUSTRALIA_PROJECT_KINDS.map((kind) => australiaSpec(kind, AUSTRALIA_VIEWS[kind.type]!)),
536
571
  ...NEW_ZEALAND_PROJECT_KINDS.map((kind) => newZealandSpec(kind, NEW_ZEALAND_VIEWS[kind.type]!)),
537
572
  ...SPAIN_PROJECT_KINDS.map((kind) => spainSpec(kind, SPAIN_VIEWS[kind.type]!)),
573
+ ...ONCOLOGY_PROJECT_KINDS.map((kind) => oncologySpec(kind, ONCOLOGY_VIEWS[kind.type]!)),
538
574
  ];
539
575
 
540
576
  export function oipResourceSpec(type: string): OipResourceSpec | undefined {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/romulus",
3
- "version": "0.1.318",
3
+ "version": "0.1.320",
4
4
  "description": "Romulus Design System - Nuxt module by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",