@tekkare/romulus 0.1.375 → 0.1.376

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.374",
7
+ "version": "0.1.375",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -122,16 +122,18 @@
122
122
  {{ tr("Aucun sujet pour l'instant.", "No subject yet.") }}
123
123
  </p>
124
124
 
125
- <!-- Les pays des donnees : ils filtrent les sources des trois blocs. -->
125
+ <!-- Les pays des donnees : ils filtrent les sources des trois blocs. Les
126
+ pays suggeres ont aussi le reglementaire et les ventes ; les autres,
127
+ la science seule. -->
126
128
  <div class="prj_gd_country_pick">
127
129
  <p class="prj_gd_lead">{{ tr("Dans quel(s) pays ?", "In which countr(y/ies)?") }}</p>
128
130
  <div class="prj_gd_countries" role="group" :aria-label="tr('Pays', 'Countries')">
129
131
  <button
130
132
  type="button"
131
133
  class="prj_gd_country"
132
- :class="{ 'is-on': !countries.length }"
133
- :aria-pressed="!countries.length"
134
- @click="countries = []"
134
+ :class="{ 'is-on': !chosenCountries.length }"
135
+ :aria-pressed="!chosenCountries.length"
136
+ @click="allCountries"
135
137
  >
136
138
  {{ tr("Tous", "All") }}
137
139
  </button>
@@ -147,7 +149,36 @@
147
149
  <RmFlag :code="entry.code" :height="12" />
148
150
  {{ entry.label[lang] }}
149
151
  </button>
152
+ <button
153
+ v-for="code in otherCountries"
154
+ :key="code"
155
+ type="button"
156
+ class="prj_gd_country is-on"
157
+ aria-pressed="true"
158
+ :title="tr('Retirer ce pays', 'Remove this country')"
159
+ @click="removeOther(code)"
160
+ >
161
+ <RmFlag :code="code" :height="12" />
162
+ {{ guidedCountryName(code, lang) }}
163
+ <RmIcon name="X" :size="12" />
164
+ </button>
150
165
  </div>
166
+ <RmMultipleSelect
167
+ v-model="otherNames"
168
+ :label="tr('Autres pays', 'Other countries')"
169
+ :options="otherOptions.map((entry) => entry.name)"
170
+ :empty-label="tr('Ajouter un pays', 'Add a country')"
171
+ :search-placeholder="tr('Rechercher un pays', 'Search a country')"
172
+ :lang="lang"
173
+ />
174
+ <p class="prj_gd_hint">
175
+ {{
176
+ tr(
177
+ "Les pays suggérés couvrent le réglementaire, les ventes et la science. Les autres pays couvrent les essais, leurs centres, leurs investigateurs et les publications.",
178
+ "Suggested countries cover regulatory, sales and science. Other countries cover trials, their centers, their investigators and publications.",
179
+ )
180
+ }}
181
+ </p>
151
182
  </div>
152
183
  </section>
153
184
 
@@ -163,7 +194,7 @@
163
194
  </p>
164
195
  <div class="prj_gd_blocks">
165
196
  <article
166
- v-for="block in blocks"
197
+ v-for="block in shownBlocks"
167
198
  :key="block.key"
168
199
  class="prj_gd_block"
169
200
  :class="{ 'is-on': blockOn(block.key) }"
@@ -277,7 +308,8 @@
277
308
  <details v-for="type in phaseTypes" :key="type" class="prj_gd_review" open>
278
309
  <summary class="prj_gd_review_head">
279
310
  <span class="prj_gd_review_title">
280
- <RmFlag :code="guidedFamilyCountry(type)" :height="12" class="prj_gd_review_flag" />
311
+ <RmIcon v-if="guidedFamilyWorld(type)" name="Globe" :size="12" class="prj_gd_review_flag" />
312
+ <RmFlag v-else :code="guidedFamilyCountry(type)" :height="12" class="prj_gd_review_flag" />
281
313
  {{ familyLabel(type) }}
282
314
  </span>
283
315
  <span class="prj_gd_review_count">
@@ -426,7 +458,10 @@ import { PROJECT_GUIDED_BLOCKS, useGuidedCountries } from "#oip-projects";
426
458
  import {
427
459
  GUIDED_BLOCKS,
428
460
  GUIDED_COUNTRIES,
461
+ GUIDED_WORLD_COUNTRIES,
462
+ guidedCountryName,
429
463
  guidedFamilyCountry,
464
+ guidedFamilyWorld,
430
465
  type GuidedCountry,
431
466
  GUIDED_GROUPED_TYPES,
432
467
  collectGuided,
@@ -469,23 +504,55 @@ const blocks = computed<GuidedBlock[]>(() => GUIDED_BLOCKS.filter((block) => (PR
469
504
 
470
505
  /** Les pays que la licence ouvre ; `null` : tous. */
471
506
  const licensed = useGuidedCountries();
472
- /** Les pays proposes : ceux de la creation guidee que la licence ouvre. */
507
+ /** Les pays suggeres : ceux de la creation guidee que la licence ouvre (reglementaire, ventes, science). */
473
508
  const allowedCountries = computed(() =>
474
509
  GUIDED_COUNTRIES.filter((entry) => !licensed.value || licensed.value.includes(entry.code)),
475
510
  );
511
+ const allowedCodes = computed(() => allowedCountries.value.map((entry) => entry.code));
476
512
 
477
- /** Les pays choisis a l'etape des sujets ; vide : tous ceux de la licence. */
513
+ /** Les pays suggeres choisis a l'etape des sujets. */
478
514
  const countries = ref<GuidedCountry[]>([]);
479
- /** Les pays effectivement cherches : le choix, sinon tous ceux de la licence. */
480
- const searchedCountries = computed<GuidedCountry[]>(() =>
481
- countries.value.length ? countries.value : licensed.value ? allowedCountries.value.map((entry) => entry.code) : [],
515
+ /** Les autres pays choisis : la science seule. */
516
+ const otherCountries = ref<GuidedCountry[]>([]);
517
+ /** Tous les pays choisis ; vide : « Tous ». */
518
+ const chosenCountries = computed(() => [...countries.value, ...otherCountries.value]);
519
+
520
+ /** Les autres pays proposes : le monde entier, hors pays suggeres. */
521
+ const otherOptions = computed(() =>
522
+ GUIDED_WORLD_COUNTRIES.filter((code) => !allowedCodes.value.includes(code))
523
+ .map((code) => ({ code, name: guidedCountryName(code, lang.value) }))
524
+ .sort((a, b) => a.name.localeCompare(b.name, lang.value)),
525
+ );
526
+ /** Les autres pays par leur nom, pour le champ de choix. */
527
+ const otherNames = computed<string[]>({
528
+ get: () => otherCountries.value.map((code) => guidedCountryName(code, lang.value)),
529
+ set: (names) => {
530
+ otherCountries.value = otherOptions.value.filter((entry) => names.includes(entry.name)).map((entry) => entry.code);
531
+ },
532
+ });
533
+
534
+ /** Les pays des familles nationales : les suggeres choisis, sinon tous ceux de la licence. */
535
+ const nationalCountries = computed<GuidedCountry[]>(() =>
536
+ chosenCountries.value.length ? chosenCountries.value.filter((code) => allowedCodes.value.includes(code)) : allowedCodes.value,
482
537
  );
538
+ /** Les pays de la science : le choix, sinon ceux de la licence ; vide : le monde entier. */
539
+ const scienceCountries = computed<GuidedCountry[]>(() =>
540
+ chosenCountries.value.length ? chosenCountries.value : licensed.value ? allowedCodes.value : [],
541
+ );
542
+
483
543
  function toggleCountry(code: GuidedCountry) {
484
544
  countries.value = countries.value.includes(code) ? countries.value.filter((entry) => entry !== code) : [...countries.value, code];
485
545
  }
486
- const inCountries = (type: string) => !searchedCountries.value.length || searchedCountries.value.includes(guidedFamilyCountry(type));
546
+ function removeOther(code: GuidedCountry) {
547
+ otherCountries.value = otherCountries.value.filter((entry) => entry !== code);
548
+ }
549
+ function allCountries() {
550
+ countries.value = [];
551
+ otherCountries.value = [];
552
+ }
553
+ const inCountries = (type: string) => guidedFamilyWorld(type) || nationalCountries.value.includes(guidedFamilyCountry(type));
487
554
  /** Plusieurs pays en jeu : le libelle d'une famille d'un autre pays que la France le dit. */
488
- const manyCountries = computed(() => searchedCountries.value.length !== 1);
555
+ const manyCountries = computed(() => nationalCountries.value.length !== 1);
489
556
 
490
557
  const step = ref<Step>("subjects");
491
558
  const stepIndex = computed(() => STEPS.findIndex((entry) => entry.key === step.value));
@@ -586,17 +653,21 @@ const familyState = (type: string): GuidedFamilyState => states.value[type] ?? {
586
653
  const familyCount = (type: string) => familyState(type).rows.length;
587
654
  const familyLabel = (type: string) => {
588
655
  const label = guidedFamilyLabel(type, lang.value);
656
+ if (guidedFamilyWorld(type)) return label;
589
657
  const code = guidedFamilyCountry(type);
590
658
  if (!manyCountries.value || code === "fr") return label;
591
- const name = GUIDED_COUNTRIES.find((entry) => entry.code === code)?.label[lang.value];
659
+ const name = guidedCountryName(code, lang.value);
592
660
  return name && !label.includes(name) ? `${label} (${name})` : label;
593
661
  };
594
662
 
663
+ /** Les blocs qu'un pays choisi couvre : un pays hors suggestions n'a que la science. */
664
+ const shownBlocks = computed(() => blocks.value.filter((block) => block.types.some(inCountries)));
665
+
595
666
  const blockOf = (key: GuidedBlockKey) => blocks.value.find((block) => block.key === key)!;
596
667
  const blockCount = (key: GuidedBlockKey) => blockOf(key).types.filter(inCountries).reduce((sum, type) => sum + familyCount(type), 0);
597
668
  const blockLoading = (key: GuidedBlockKey) => blockOf(key).types.filter(inCountries).some((type) => familyState(type).loading);
598
669
  /** Un bloc se coche de lui-meme quand il a des fiches, tant qu'on n'a rien choisi. */
599
- const blockOn = (key: GuidedBlockKey) => blockChoice[key] ?? blockCount(key) > 0;
670
+ const blockOn = (key: GuidedBlockKey) => (blockChoice[key] ?? blockCount(key) > 0) && blockOf(key).types.some(inCountries);
600
671
  const toggleBlock = (key: GuidedBlockKey) => {
601
672
  blockChoice[key] = !blockOn(key);
602
673
  };
@@ -608,7 +679,11 @@ const sortedTypes = (block: GuidedBlock) =>
608
679
  const countLabel = (count: number) => (count ? tr(`${count} fiches`, `${count} records`) : tr("rien trouvé", "nothing found"));
609
680
 
610
681
  function startSearch() {
611
- const key = [...subjects.value.map((subject) => subject.key).sort(), ...[...searchedCountries.value].sort()].join("|");
682
+ const key = [
683
+ ...subjects.value.map((subject) => subject.key).sort(),
684
+ `n:${[...nationalCountries.value].sort().join(",")}`,
685
+ `s:${[...scienceCountries.value].sort().join(",")}`,
686
+ ].join("|");
612
687
  if (key === searchedKey) return;
613
688
  searchedKey = key;
614
689
  states.value = {};
@@ -620,7 +695,7 @@ function startSearch() {
620
695
  states.value = { ...states.value, [type]: state };
621
696
  // Une famille qui repond se coche si elle a des fiches, sauf choix deja fait.
622
697
  if (!state.loading && families[type] === undefined) families[type] = state.rows.length > 0;
623
- }, [...searchedCountries.value]).finally(() => {
698
+ }, { national: [...nationalCountries.value], science: [...scienceCountries.value] }).finally(() => {
624
699
  if (searchedKey === mine) searching.value = false;
625
700
  });
626
701
  }
@@ -689,8 +764,8 @@ function propose() {
689
764
  ? `${tr("Médicaments", "Drugs")}${sep}${drugs.map((subject) => withHint(subject.label, subject.focus === "brand" ? subject.hint.toLowerCase() : subject.hint, subject.focus === "molecule")).join(", ")}.`
690
765
  : "",
691
766
  `${tr("Périmètre", "Scope")}${sep}${
692
- searchedCountries.value.length
693
- ? searchedCountries.value.map((code) => GUIDED_COUNTRIES.find((entry) => entry.code === code)?.label[lang.value]).join(", ")
767
+ scienceCountries.value.length
768
+ ? scienceCountries.value.map((code) => guidedCountryName(code, lang.value)).join(", ")
694
769
  : tr("tous les pays", "all countries")
695
770
  }.`,
696
771
  followed.length ? `${tr("Sources suivies", "Followed sources")}${sep}${followed.join(", ")}.` : "",
@@ -986,7 +1061,7 @@ function requestClose(value: boolean) {
986
1061
 
987
1062
  function reset() {
988
1063
  step.value = "subjects";
989
- countries.value = [];
1064
+ allCountries();
990
1065
  reached.value = 0;
991
1066
  reviewPhase.value = 0;
992
1067
  query.value = "";
@@ -14,10 +14,17 @@
14
14
  * - la marque (fr_drugs_app) : les avis HAS directs, les marques saisies et
15
15
  * celles des molecules (repertoire des marques) cherchent les familles qui
16
16
  * ne connaissent que la marque (ventes, prix, ANSM...) ;
17
- * - l'essai (France Augmented Science) : les essais directs en France
18
- * cherchent leurs sites et leurs investigateurs, puis les publications et
17
+ * - l'essai (France Augmented Science) : les essais directs des pays choisis
18
+ * cherchent leurs sites et leurs investigateurs (centres et investigateurs
19
+ * NCT et EUCT partout, FINESS et RPPS en France), puis les publications et
19
20
  * les appels a projets qui les citent.
20
21
  *
22
+ * Deux sortes de pays. Les pays suggeres (GUIDED_COUNTRIES) ont leurs propres
23
+ * familles reglementaires et de ventes, ouvertes par la licence. Tous les
24
+ * autres (GUIDED_WORLD_COUNTRIES) n'ont que la science : essais, centres,
25
+ * investigateurs et publications se cherchent dans n'importe quel pays, les
26
+ * pays suggeres compris.
27
+ *
21
28
  * Chaque fiche porte l'`_id` Elasticsearch que l'API des projets verifie
22
29
  * (R-02), et ses preuves : ce qui la relie au sujet.
23
30
  */
@@ -25,6 +32,7 @@
25
32
  import { ES_INDEX } from "../oip-drugs/esIndices";
26
33
  import scienceIndexConfig from "../oip-science/indexConfig.json";
27
34
  import { oipResourceSpec } from "../utils/oipResources";
35
+ import { ISO_ALPHA2 } from "../utils/countries";
28
36
  import {
29
37
  LIMIT,
30
38
  clean,
@@ -50,9 +58,14 @@ type Text = { fr: string; en: string };
50
58
 
51
59
  export type GuidedBlockKey = "drugs" | "regulatory" | "science";
52
60
 
53
- /** Les pays que la creation guidee sait chercher (code ISO alpha-2, minuscules). */
54
- export type GuidedCountry = "fr" | "it" | "de" | "es" | "au" | "nz";
61
+ /** Un pays, en code ISO 3166-1 alpha-2 minuscule. */
62
+ export type GuidedCountry = string;
55
63
 
64
+ /**
65
+ * Les pays suggeres : ceux ou la creation guidee cherche plus que la science
66
+ * (reglementaire, ventes, prix). Les autres pays du monde n'ont que le bloc
67
+ * science (GUIDED_WORLD_COUNTRIES).
68
+ */
56
69
  export const GUIDED_COUNTRIES: Array<{ code: GuidedCountry; label: Text }> = [
57
70
  { code: "fr", label: { fr: "France", en: "France" } },
58
71
  { code: "it", label: { fr: "Italie", en: "Italy" } },
@@ -62,6 +75,89 @@ export const GUIDED_COUNTRIES: Array<{ code: GuidedCountry; label: Text }> = [
62
75
  { code: "nz", label: { fr: "Nouvelle-Zélande", en: "New Zealand" } },
63
76
  ];
64
77
 
78
+ /** Tous les pays du monde, suggeres compris : ceux ou se cherche la science. */
79
+ export const GUIDED_WORLD_COUNTRIES: GuidedCountry[] = ISO_ALPHA2.map((code) => code.toLowerCase());
80
+
81
+ /** Le nom d'un pays dans la langue de l'interface. */
82
+ export function guidedCountryName(code: GuidedCountry, lang: GuidedLang) {
83
+ const known = GUIDED_COUNTRIES.find((entry) => entry.code === code);
84
+ if (known) return known.label[lang];
85
+ try {
86
+ return new Intl.DisplayNames([lang], { type: "region" }).of(code.toUpperCase()) ?? code.toUpperCase();
87
+ } catch {
88
+ return code.toUpperCase();
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Les noms qu'un pays porte dans les index d'essais, de centres et
94
+ * d'investigateurs, au-dela de son nom anglais (Intl). ClinicalTrials.gov et
95
+ * CTIS gardent les noms officiels d'avant (« Korea, Republic of », « Czech
96
+ * Republic »), les investigateurs NCT des abreviations (« Usa »). La
97
+ * comparaison ignore la casse.
98
+ */
99
+ const COUNTRY_ALIASES: Record<string, string[]> = {
100
+ us: ["United States", "Usa"],
101
+ gb: ["United Kingdom", "Uk", "United Kingdom of Great Britain and Northern Ireland"],
102
+ tr: ["Turkey", "Turkey (Türkiye)", "Türkiye"],
103
+ kr: ["Korea, Republic of", "South Korea"],
104
+ kp: ["Korea, Democratic People's Republic of"],
105
+ ru: ["Russian Federation", "Russia"],
106
+ hk: ["Hong Kong"],
107
+ mo: ["Macau", "Macao"],
108
+ cz: ["Czech Republic", "Czechia"],
109
+ ir: ["Iran, Islamic Republic of", "Iran"],
110
+ ba: ["Bosnia and Herzegovina"],
111
+ md: ["Moldova, Republic of", "Moldova"],
112
+ sy: ["Syrian Arab Republic", "Syria"],
113
+ mk: ["Macedonia, The Former Yugoslav Republic of", "North Macedonia"],
114
+ cd: ["Congo, The Democratic Republic of the", "Democratic Republic of the Congo", "The Democratic Republic of the Congo"],
115
+ cg: ["Congo", "Republic of the Congo"],
116
+ ci: ["Côte D'Ivoire", "Côte d'Ivoire", "Ivory Coast"],
117
+ re: ["Reunion", "Réunion"],
118
+ ps: ["Palestinian Territory, occupied", "Palestinian Territories, Occupied", "Palestine"],
119
+ mm: ["Myanmar", "Burma"],
120
+ la: ["Lao People's Democratic Republic", "Laos"],
121
+ ag: ["Antigua and Barbuda"],
122
+ tt: ["Trinidad and Tobago"],
123
+ sz: ["Swaziland", "Eswatini"],
124
+ ly: ["Libyan Arab Jamahiriya", "Libya"],
125
+ gm: ["The Gambia", "Gambia"],
126
+ vi: ["Virgin Islands (U.S.)", "Virgin Islands"],
127
+ fo: ["Faroe Islands"],
128
+ yt: ["Mayotte"],
129
+ bn: ["Brunei Darussalam", "Brunei"],
130
+ kn: ["Saint Kitts and Nevis"],
131
+ lc: ["Saint Lucia"],
132
+ vc: ["Saint Vincent and the Grenadines"],
133
+ va: ["Holy See", "Holy See (Vatican City State)", "Vatican City"],
134
+ bs: ["The Bahamas", "Bahamas"],
135
+ ax: ["Aland Islands", "Åland Islands"],
136
+ fm: ["Federated States of Micronesia", "Micronesia"],
137
+ cv: ["Cabo Verde", "Cape Verde"],
138
+ };
139
+
140
+ /** Les noms d'un pays tels que les index les ecrivent. */
141
+ export function guidedCountryIndexNames(code: GuidedCountry) {
142
+ let english = "";
143
+ try {
144
+ english = (new Intl.DisplayNames(["en"], { type: "region" }).of(code.toUpperCase()) ?? "").replace(/ & /g, " and ").replace(/^St\. /, "Saint ");
145
+ } catch {
146
+ // Pas d'Intl : les alias seuls.
147
+ }
148
+ return uniq([english, ...(COUNTRY_ALIASES[code] ?? [])].filter(Boolean));
149
+ }
150
+
151
+ /** Un filtre sur le champ pays d'un index (`keyword`), pour une liste de pays. */
152
+ export function guidedCountryFilter(field: string, codes: GuidedCountry[]) {
153
+ return {
154
+ bool: {
155
+ should: codes.flatMap(guidedCountryIndexNames).map((name) => ({ term: { [field]: { value: name, case_insensitive: true } } })),
156
+ minimum_should_match: 1,
157
+ },
158
+ };
159
+ }
160
+
65
161
  /**
66
162
  * Un bloc de sources, le meme quel que soit le pays : ses familles sont
67
163
  * celles de tous les pays (les actes AIFA sont du reglementaire, les prix
@@ -123,16 +219,46 @@ export const GUIDED_BLOCKS: GuidedBlock[] = [
123
219
  key: "science",
124
220
  label: { fr: "Augmented Science", en: "Augmented Science" },
125
221
  description: {
126
- fr: "Essais en France, sites, investigateurs, publications, appels à projets.",
127
- en: "Trials in France, sites, investigators, publications, calls for projects.",
222
+ fr: "Essais, centres, investigateurs et publications dans tous les pays, appels à projets en France.",
223
+ en: "Trials, centers, investigators and publications in every country, calls for projects in France.",
128
224
  },
129
225
  icon: "Flask",
130
- // Les essais et les publications d'abord : les professionnels et les
131
- // etablissements s'en deduisent.
132
- types: ["ClinicalTrialsEUCT", "ClinicalTrialsNCT", "PubMed", "HCP", "Establishment", "PHRC"],
226
+ // Les essais et les publications d'abord : les centres, les
227
+ // investigateurs, les professionnels et les etablissements s'en deduisent.
228
+ types: [
229
+ "ClinicalTrialsEUCT",
230
+ "ClinicalTrialsNCT",
231
+ "PubMed",
232
+ "ClinicalTrialsCentersNCT",
233
+ "ClinicalTrialsCentersEUCT",
234
+ "ClinicalTrialsInvestigatorsNCT",
235
+ "ClinicalTrialsInvestigatorsEUCT",
236
+ "HCP",
237
+ "Establishment",
238
+ "PHRC",
239
+ ],
133
240
  },
134
241
  ];
135
242
 
243
+ /**
244
+ * Les familles qui se cherchent dans tous les pays : les essais, leurs
245
+ * centres et leurs investigateurs, les publications. Le pays choisi les
246
+ * filtre, il ne les ecarte pas. HCP, etablissements et PHRC restent
247
+ * francais (RPPS, FINESS).
248
+ */
249
+ export const GUIDED_WORLD_TYPES = new Set([
250
+ "ClinicalTrialsNCT",
251
+ "ClinicalTrialsEUCT",
252
+ "PubMed",
253
+ "ClinicalTrialsCentersNCT",
254
+ "ClinicalTrialsCentersEUCT",
255
+ "ClinicalTrialsInvestigatorsNCT",
256
+ "ClinicalTrialsInvestigatorsEUCT",
257
+ ]);
258
+
259
+ /** Une famille cherchee dans tous les pays (cf. GUIDED_WORLD_TYPES). */
260
+ export const guidedFamilyWorld = (type: string) => GUIDED_WORLD_TYPES.has(type);
261
+
136
262
  /** Le pays des donnees d'une famille (celui de sa spec), la France par defaut. */
137
263
  export function guidedFamilyCountry(type: string): GuidedCountry {
138
264
  return (oipResourceSpec(type)?.kind.country as GuidedCountry | undefined) ?? "fr";
@@ -191,15 +317,24 @@ function merge(rows: GuidedRow[], limit = LIMIT) {
191
317
  return [...byId.values()].sort((a, b) => KIND_ORDER[a.kind] - KIND_ORDER[b.kind]).slice(0, limit);
192
318
  }
193
319
 
320
+ /** Ou chercher : les pays des familles nationales, et ceux de la science. */
321
+ export interface GuidedScope {
322
+ /** Les pays dont les familles nationales (HAS, ventes, prix...) sont cherchees ; absent : tous. */
323
+ national?: GuidedCountry[];
324
+ /** Les pays des essais, centres, investigateurs et publications ; vide ou absent : le monde entier. */
325
+ science?: GuidedCountry[];
326
+ }
327
+
194
328
  /** Lance la recherche de toutes les familles ; `onFamily` recoit chacune des qu'elle repond. */
195
329
  export async function collectGuided(
196
330
  subjects: GuidedSubject[],
197
331
  lang: GuidedLang,
198
332
  onFamily: (type: string, state: GuidedFamilyState) => void,
199
- /** Les pays choisis ; vide : tous. Une famille d'un autre pays n'est pas cherchee. */
200
- countries: GuidedCountry[] = [],
333
+ scope: GuidedScope = {},
201
334
  ) {
202
- const wanted = (type: string) => !countries.length || countries.includes(guidedFamilyCountry(type));
335
+ const national = scope.national;
336
+ const scienceCountries = scope.science ?? [];
337
+ const wanted = (type: string) => guidedFamilyWorld(type) || !national || national.includes(guidedFamilyCountry(type));
203
338
  const t = (fr: string, en: string) => (lang === "en" ? en : fr);
204
339
  const diseases = subjects.filter((subject) => subject.focus === "disease");
205
340
  const molecules = subjects.filter((subject) => subject.focus === "molecule");
@@ -688,7 +823,7 @@ export async function collectGuided(
688
823
  );
689
824
  }
690
825
 
691
- /** Les essais d'un sujet, en France. Clauses nommees : `condition`, `code`, `intervention` (direct), `text` (mention). */
826
+ /** Les essais d'un sujet, dans les pays choisis. Clauses nommees : `condition`, `code`, `intervention` (direct), `text` (mention). */
692
827
  async function trialsOf(type: "ClinicalTrialsNCT" | "ClinicalTrialsEUCT", subject: GuidedSubject): Promise<GuidedRow[]> {
693
828
  const nct = type === "ClinicalTrialsNCT";
694
829
  const onDisease = subject.focus === "disease";
@@ -720,9 +855,11 @@ export async function collectGuided(
720
855
  },
721
856
  }
722
857
  : { bool: { ...textMatch(subject.label, matchFields).bool, _name: matchName } };
723
- const france = nct
724
- ? { nested: { path: "countries", query: { term: { "countries.countries_name.keyword": "France" } } } }
725
- : { term: { "countries.country_name.keyword": "France" } };
858
+ const inCountries = scienceCountries.length
859
+ ? nct
860
+ ? [{ nested: { path: "countries", query: guidedCountryFilter("countries.countries_name.keyword", scienceCountries) } }]
861
+ : [guidedCountryFilter("countries.country_name.keyword", scienceCountries)]
862
+ : [];
726
863
 
727
864
  const hits = await search(type, {
728
865
  size: 50,
@@ -736,7 +873,7 @@ export async function collectGuided(
736
873
  ],
737
874
  query: {
738
875
  bool: {
739
- filter: [france],
876
+ filter: inCountries,
740
877
  should: [condition, { bool: { ...textMatch(subject.label, titleFields).bool, _name: "text" } }, ...(code ? [code] : [])],
741
878
  minimum_should_match: 1,
742
879
  },
@@ -889,6 +1026,70 @@ export async function collectGuided(
889
1026
  });
890
1027
  });
891
1028
 
1029
+ /**
1030
+ * Les centres et investigateurs NCT et EUCT des essais retenus, dans les
1031
+ * pays choisis : un document par centre ou investigateur, ses essais dans
1032
+ * `records`. Les plus investis d'abord.
1033
+ */
1034
+ const WORLD_ACTORS: Record<string, { source: "nct" | "euct"; role: "site" | "investigator"; country: string }> = {
1035
+ ClinicalTrialsCentersNCT: { source: "nct", role: "site", country: "facility_country" },
1036
+ ClinicalTrialsCentersEUCT: { source: "euct", role: "site", country: "country" },
1037
+ ClinicalTrialsInvestigatorsNCT: { source: "nct", role: "investigator", country: "country" },
1038
+ ClinicalTrialsInvestigatorsEUCT: { source: "euct", role: "investigator", country: "country" },
1039
+ };
1040
+
1041
+ async function worldActorRows(type: string): Promise<GuidedRow[]> {
1042
+ const how = WORLD_ACTORS[type]!;
1043
+ const spec = oipResourceSpec(type);
1044
+ const kept = await keptTrials;
1045
+ const trials = kept[how.source];
1046
+ if (!spec || !trials.length) return [];
1047
+ const idField = how.source === "nct" ? "records.nct_id" : "records.euct_number";
1048
+ const hits = await search(type, {
1049
+ size: 500,
1050
+ _source: [...(spec.kind.source ?? []), idField],
1051
+ query: {
1052
+ bool: {
1053
+ filter: [
1054
+ { terms: { [`${idField}.keyword`]: trials } },
1055
+ ...(scienceCountries.length ? [guidedCountryFilter(`${how.country}.keyword`, scienceCountries)] : []),
1056
+ ],
1057
+ },
1058
+ },
1059
+ });
1060
+ const keptIds = new Set(trials);
1061
+ const field = idField.split(".")[1]!;
1062
+ return hits
1063
+ .map((hit) => ({ hit, ids: uniq(list(hit._source?.records).map((record) => clean(record?.[field]))).filter((id) => keptIds.has(id)) }))
1064
+ .filter(({ ids }) => ids.length)
1065
+ .sort((a, b) => b.ids.length - a.ids.length)
1066
+ .slice(0, LIMIT)
1067
+ .map(({ hit, ids }): GuidedRow => {
1068
+ const s = hit._source ?? {};
1069
+ const count = ids.length;
1070
+ const lines = ids.slice(0, 5).map((id) => trialLine(kept.titles, id));
1071
+ if (count > 5) lines.push(t(`et ${count - 5} autres`, `and ${count - 5} more`));
1072
+ return {
1073
+ id: hit._id,
1074
+ title: spec.kind.title(s, lang) || hit._id,
1075
+ subtitle: joinDot(actorCount(how.role, count), spec.kind.subtitle?.(s, lang)),
1076
+ kind: "deduced",
1077
+ evidence: [
1078
+ {
1079
+ label:
1080
+ how.role === "site"
1081
+ ? t(`Centre de ${count} essai${count > 1 ? "s" : ""} sur « ${subjectNames} »`, `Center of ${count} trial${count > 1 ? "s" : ""} on "${subjectNames}"`)
1082
+ : t(`Investigateur dans ${count} essai${count > 1 ? "s" : ""} sur « ${subjectNames} »`, `Investigator in ${count} trial${count > 1 ? "s" : ""} on "${subjectNames}"`),
1083
+ values: lines,
1084
+ },
1085
+ ],
1086
+ source: s,
1087
+ };
1088
+ });
1089
+ }
1090
+
1091
+ const worldActorTasks = Object.keys(WORLD_ACTORS).map((type) => run(type, () => worldActorRows(type)));
1092
+
892
1093
  /** Le sujet dans une publication : code ou titre pour une maladie, titre et substances pour le reste. */
893
1094
  const publicationSubject = {
894
1095
  bool: {
@@ -940,10 +1141,29 @@ export async function collectGuided(
940
1141
  },
941
1142
  });
942
1143
  }
943
- // Un auteur francais (RPPS connu) sur le sujet.
1144
+ // Le sujet, par un auteur des pays choisis (en France, un auteur au RPPS
1145
+ // connu compte aussi) ; sans pays, tout le monde.
1146
+ const authorCountry = scienceCountries.length
1147
+ ? [
1148
+ {
1149
+ nested: {
1150
+ path: "authors",
1151
+ query: {
1152
+ bool: {
1153
+ should: [
1154
+ { terms: { "authors.country_code.keyword": scienceCountries.map((code) => code.toUpperCase()) } },
1155
+ ...(scienceCountries.includes("fr") ? [{ exists: { field: "authors.hcp_code" } }] : []),
1156
+ ],
1157
+ minimum_should_match: 1,
1158
+ },
1159
+ },
1160
+ },
1161
+ },
1162
+ ]
1163
+ : [];
944
1164
  should.push({
945
1165
  constant_score: {
946
- filter: { bool: { filter: [publicationSubject, { nested: { path: "authors", query: { exists: { field: "authors.hcp_code" } } } }], _name: "subject" } },
1166
+ filter: { bool: { filter: [publicationSubject, ...authorCountry], _name: "subject" } },
947
1167
  boost: 1,
948
1168
  },
949
1169
  });
@@ -1143,6 +1363,7 @@ export async function collectGuided(
1143
1363
  ...Object.entries(brandTasks).map(([type, task]) => run(type, task)),
1144
1364
  nctRows,
1145
1365
  euctRows,
1366
+ ...worldActorTasks,
1146
1367
  establishmentRows,
1147
1368
  hcpRows,
1148
1369
  publicationRows,
@@ -1,6 +1,6 @@
1
1
  // ISO 3166-1 alpha-2 codes → localized country names via Intl.DisplayNames.
2
2
  // Used by the onboarding country picker (searchable select).
3
- const ISO_ALPHA2 = [
3
+ export const ISO_ALPHA2 = [
4
4
  "AF","AX","AL","DZ","AS","AD","AO","AI","AQ","AG","AR","AM","AW","AU","AT","AZ",
5
5
  "BS","BH","BD","BB","BY","BE","BZ","BJ","BM","BT","BO","BA","BW","BR","IO","BN",
6
6
  "BG","BF","BI","KH","CM","CA","CV","KY","CF","TD","CL","CN","CO","KM","CG","CD",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/romulus",
3
- "version": "0.1.375",
3
+ "version": "0.1.376",
4
4
  "description": "Romulus Design System - Nuxt module by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",