@tekkare/romulus 0.1.259 → 0.1.261

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.258",
7
+ "version": "0.1.260",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -20,6 +20,8 @@
20
20
  <RmCopyCode :value="linkedNct.nct_id" :lang="lang" />
21
21
  <OipScienceClinicalTrialsPairBadge />
22
22
  </template>
23
+ <!-- Etiquette posee par la liste a cote des numeros (essai prioritaire). -->
24
+ <slot name="code-extra" />
23
25
  </template>
24
26
 
25
27
  <template #title>
@@ -20,6 +20,8 @@
20
20
  <RmCopyCode label="EUCT" :value="linkedEuct.euct_number" :lang="lang" />
21
21
  <OipScienceClinicalTrialsPairBadge />
22
22
  </template>
23
+ <!-- Etiquette posee par la liste a cote des numeros (essai prioritaire). -->
24
+ <slot name="code-extra" />
23
25
  </template>
24
26
 
25
27
  <template #title>
@@ -79,13 +79,26 @@
79
79
  :data="row.doc"
80
80
  :linked-euct="row.linked"
81
81
  :highlight="highlight"
82
+ :class="{ linked_priority: isPriority(row) }"
82
83
  >
84
+ <template #code-extra>
85
+ <RmTag v-if="isPriority(row)" variant="indigo">{{ priority?.label }}</RmTag>
86
+ </template>
83
87
  <template #extra>
84
88
  <RmTag v-if="row.extra?.role" variant="gray">{{ row.extra.role }}</RmTag>
85
89
  <OipScienceCommonScoreBadge :score="row.extra?.score" />
86
90
  </template>
87
91
  </OipScienceClinicalTrialsCardsGlobal>
88
- <OipScienceClinicalTrialsCards v-else :data="row.doc" :linked-nct="row.linked" :highlight="highlight">
92
+ <OipScienceClinicalTrialsCards
93
+ v-else
94
+ :data="row.doc"
95
+ :linked-nct="row.linked"
96
+ :highlight="highlight"
97
+ :class="{ linked_priority: isPriority(row) }"
98
+ >
99
+ <template #code-extra>
100
+ <RmTag v-if="isPriority(row)" variant="indigo">{{ priority?.label }}</RmTag>
101
+ </template>
89
102
  <template #extra>
90
103
  <RmTag v-if="row.extra?.role" variant="gray">{{ row.extra.role }}</RmTag>
91
104
  <OipScienceCommonScoreBadge :score="row.extra?.score" />
@@ -94,7 +107,8 @@
94
107
  </template>
95
108
  </div>
96
109
 
97
- <RmEmptyState v-if="!filtered.length" :title="$t('oipScience.common.noMatchingResult')" />
110
+ <RmLoadingState v-if="isLoadingRest" :lines="2" />
111
+ <RmEmptyState v-else-if="!filtered.length" :title="$t('oipScience.common.noMatchingResult')" />
98
112
  <RmButton
99
113
  v-if="visible.length < filtered.length"
100
114
  variant="secondary"
@@ -136,10 +150,22 @@ const props = withDefaults(
136
150
  loading?: boolean;
137
151
  /** Termes a surligner dans les cartes (filterStore dans FAS). */
138
152
  highlight?: string[];
153
+ /**
154
+ * Essais a mettre en tete et en avant, par numero NCT ou EUCT (ceux d'une
155
+ * recherche par maladie dans FAS), avec le libelle de leur etiquette.
156
+ */
157
+ priority?: { ids: string[]; label: string } | null;
139
158
  }>(),
140
- { nctIds: () => [], euctIds: () => [], extras: () => ({}), loading: false, highlight: () => [] },
159
+ { nctIds: () => [], euctIds: () => [], extras: () => ({}), loading: false, highlight: () => [], priority: null },
141
160
  );
142
161
 
162
+ const priorityIds = computed(() => new Set(props.priority?.ids ?? []));
163
+ /** Un essai compte aussi par son jumeau de l'autre registre. */
164
+ const isPriority = (row: Row) =>
165
+ priorityIds.value.has(row.id) ||
166
+ priorityIds.value.has(row.linked?.euct_number) ||
167
+ priorityIds.value.has(row.linked?.nct_id);
168
+
143
169
  const { locale } = useI18n();
144
170
  const lang = computed<'fr' | 'en'>(() => (locale.value === 'en' ? 'en' : 'fr'));
145
171
  const { queryCustomElastic } = useOipElastic();
@@ -149,47 +175,73 @@ const { linked: linkedNct, load: loadLinkedNct } = useLinkedTrials('nct');
149
175
  const nctDocs = ref<any[]>([]);
150
176
  const euctDocs = ref<any[]>([]);
151
177
  const isLoadingDocs = ref(false);
178
+ /** Les essais prioritaires sont affiches, la suite se charge. */
179
+ const isLoadingRest = ref(false);
180
+ let loadCall = 0;
181
+
182
+ /** Les essais d'une partie des numeros, et leurs jumeaux. */
183
+ async function fetchDocs(nctIds: string[], euctIds: string[]) {
184
+ const [nctRes, euctRes] = await Promise.all([
185
+ nctIds.length
186
+ ? queryCustomElastic({
187
+ index: indexConfig.globalCT.index,
188
+ cluster: indexConfig.globalCT.cluster,
189
+ customQuery: { size: nctIds.length, query: { ids: { values: nctIds } } },
190
+ })
191
+ : Promise.resolve({ results: [] }),
192
+ euctIds.length
193
+ ? queryCustomElastic({
194
+ index: indexConfig.euct.index,
195
+ cluster: indexConfig.euct.cluster,
196
+ customQuery: {
197
+ size: euctIds.length,
198
+ query: { terms: { 'euct_number.keyword': euctIds } },
199
+ },
200
+ })
201
+ : Promise.resolve({ results: [] }),
202
+ ]);
203
+ const nct: any[] = nctRes?.results || [];
204
+ const euct: any[] = euctRes?.results || [];
205
+ // Jumeaux hors de la liste, comme sur les pages de recherche.
206
+ await Promise.all([
207
+ loadLinkedEuct(nct.map((d) => d.nct_id)),
208
+ loadLinkedNct(euct.map((d) => d.nct_number)),
209
+ ]);
210
+ return { nct, euct };
211
+ }
152
212
 
153
213
  async function loadDocs() {
214
+ const call = ++loadCall;
154
215
  const nctIds = [...new Set(props.nctIds.filter(Boolean))];
155
216
  const euctIds = [...new Set(props.euctIds.filter(Boolean))];
156
- if (!nctIds.length && !euctIds.length) {
157
- nctDocs.value = [];
158
- euctDocs.value = [];
159
- return;
160
- }
217
+ nctDocs.value = [];
218
+ euctDocs.value = [];
219
+ if (!nctIds.length && !euctIds.length) return;
220
+ // Les essais prioritaires d'abord : la liste s'affiche des qu'ils sont la,
221
+ // le reste suit. Une fiche a plusieurs centaines d'essais attend sinon tout.
222
+ const first = (ids: string[]) => ids.filter((id) => priorityIds.value.has(id));
223
+ const rest = (ids: string[]) => ids.filter((id) => !priorityIds.value.has(id));
224
+ const parts = priorityIds.value.size
225
+ ? [[first(nctIds), first(euctIds)], [rest(nctIds), rest(euctIds)]]
226
+ : [[nctIds, euctIds]];
161
227
  isLoadingDocs.value = true;
162
228
  try {
163
- const [nctRes, euctRes] = await Promise.all([
164
- nctIds.length
165
- ? queryCustomElastic({
166
- index: indexConfig.globalCT.index,
167
- cluster: indexConfig.globalCT.cluster,
168
- customQuery: { size: nctIds.length, query: { ids: { values: nctIds } } },
169
- })
170
- : Promise.resolve({ results: [] }),
171
- euctIds.length
172
- ? queryCustomElastic({
173
- index: indexConfig.euct.index,
174
- cluster: indexConfig.euct.cluster,
175
- customQuery: {
176
- size: euctIds.length,
177
- query: { terms: { 'euct_number.keyword': euctIds } },
178
- },
179
- })
180
- : Promise.resolve({ results: [] }),
181
- ]);
182
- nctDocs.value = nctRes?.results || [];
183
- euctDocs.value = euctRes?.results || [];
184
- // Jumeaux hors de la liste, comme sur les pages de recherche.
185
- await Promise.all([
186
- loadLinkedEuct(nctDocs.value.map((d) => d.nct_id)),
187
- loadLinkedNct(euctDocs.value.map((d) => d.nct_number)),
188
- ]);
229
+ for (const [nct, euct] of parts) {
230
+ if (!nct!.length && !euct!.length) continue;
231
+ if (!isLoadingDocs.value) isLoadingRest.value = true;
232
+ const docs = await fetchDocs(nct!, euct!);
233
+ if (call !== loadCall) return;
234
+ nctDocs.value = [...nctDocs.value, ...docs.nct];
235
+ euctDocs.value = [...euctDocs.value, ...docs.euct];
236
+ isLoadingDocs.value = false;
237
+ }
189
238
  } catch (e) {
190
239
  console.error(e);
191
240
  } finally {
192
- isLoadingDocs.value = false;
241
+ if (call === loadCall) {
242
+ isLoadingDocs.value = false;
243
+ isLoadingRest.value = false;
244
+ }
193
245
  }
194
246
  }
195
247
 
@@ -226,7 +278,7 @@ const rows = computed<Row[]>(() => {
226
278
  date: new Date(doc.decision_date || doc.last_update_date || 0).getTime(),
227
279
  });
228
280
  }
229
- return out.sort((a, b) => b.date - a.date);
281
+ return out.sort((a, b) => Number(isPriority(b)) - Number(isPriority(a)) || b.date - a.date);
230
282
  });
231
283
 
232
284
  // ::::: Filtres locaux
@@ -359,6 +411,9 @@ watch(
359
411
  </script>
360
412
 
361
413
  <style scoped>
414
+ .linked_priority {
415
+ box-shadow: inset 3px 0 0 var(--color-secondary);
416
+ }
362
417
  .load_more {
363
418
  align-self: center;
364
419
  justify-self: center;
@@ -13,6 +13,7 @@
13
13
  :sources="['CT.gov', 'EUCT', 'FINESS']"
14
14
  index-last-update="CT.gov"
15
15
  :loading="isLoading"
16
+ :priority="priority"
16
17
  />
17
18
  </div>
18
19
  </template>
@@ -23,10 +24,20 @@ import useEstablishmentCrossData from '../../../oip-science/composables/useEstab
23
24
  // Meme forme que LinkedTrialExtra de clinical-trials/LinkedList.vue.
24
25
  type LinkedTrialExtra = { score?: number | null; role?: string | null };
25
26
 
26
- const props = withDefaults(defineProps<{ id: string; highlight?: string[]; lang?: 'fr' | 'en' }>(), {
27
- highlight: () => [],
28
- lang: undefined,
29
- });
27
+ const props = withDefaults(
28
+ defineProps<{
29
+ id: string;
30
+ highlight?: string[];
31
+ lang?: 'fr' | 'en';
32
+ /** Essais a mettre en tete et en avant (cf. clinical-trials/LinkedList.vue). */
33
+ priority?: { ids: string[]; label: string } | null;
34
+ }>(),
35
+ {
36
+ highlight: () => [],
37
+ lang: undefined,
38
+ priority: null,
39
+ },
40
+ );
30
41
 
31
42
  const { fetchCrossData } = useEstablishmentCrossData();
32
43
 
@@ -12,6 +12,7 @@
12
12
  :sources="['CT.gov', 'EUCT', 'RPPS']"
13
13
  index-last-update="HCPs"
14
14
  :loading="isLoading"
15
+ :priority="priority"
15
16
  />
16
17
  </div>
17
18
  </template>
@@ -24,10 +25,20 @@ import useOipElastic from '../../../oip-science/composables/useOipElastic';
24
25
  type LinkedTrialExtra = { score?: number | null; role?: string | null };
25
26
  type HcpTrialName = { first_name?: string; last_name?: string; name?: string; match_method: string; score: number };
26
27
 
27
- const props = withDefaults(defineProps<{ id: string; highlight?: string[]; lang?: 'fr' | 'en' }>(), {
28
- highlight: () => [],
29
- lang: undefined,
30
- });
28
+ const props = withDefaults(
29
+ defineProps<{
30
+ id: string;
31
+ highlight?: string[];
32
+ lang?: 'fr' | 'en';
33
+ /** Essais a mettre en tete et en avant (cf. clinical-trials/LinkedList.vue). */
34
+ priority?: { ids: string[]; label: string } | null;
35
+ }>(),
36
+ {
37
+ highlight: () => [],
38
+ lang: undefined,
39
+ priority: null,
40
+ },
41
+ );
31
42
 
32
43
  const { queryOneElastic } = useOipElastic();
33
44
 
@@ -6,17 +6,23 @@
6
6
  <div class="oip-science">
7
7
  <div v-if="!isLoading && pubmedResults.length" class="oip_grid gap-24">
8
8
  <RmResultsLine icon="Article" :items="[{ count: pubmedResults.length, label: $t('oipScience.resultKpis.publications', pubmedResults.length) }]" />
9
- <div v-for="(res, index) in pubmedResults" :key="index">
9
+ <div v-for="(res, index) in ordered" :key="index">
10
10
  <OipSciencePubmedCards
11
11
  :data="res"
12
12
  :id="res.PubMed_ID"
13
13
  :match-score="scoreByPmid[res.PubMed_ID] ?? null"
14
14
  :match-method="methodByPmid[res.PubMed_ID] || null"
15
15
  :highlight="highlight"
16
- />
16
+ :class="{ linked_priority: isPriority(res) }"
17
+ >
18
+ <template #code-extra>
19
+ <RmTag v-if="isPriority(res)" variant="indigo">{{ priority?.label }}</RmTag>
20
+ </template>
21
+ </OipSciencePubmedCards>
17
22
  </div>
18
23
  </div>
19
24
  <RmLoadingState v-if="isLoading" :lines="3" :chart-height="240" />
25
+ <RmLoadingState v-else-if="isLoadingRest" :lines="2" />
20
26
  <RmEmptyState
21
27
  v-if="!isLoading && !pubmedResults.length"
22
28
  :title="$t('oipScience.common.noDataTitle')"
@@ -29,19 +35,40 @@
29
35
  import indexConfig from '../../../oip-science/indexConfig.json';
30
36
  import useOipElastic from '../../../oip-science/composables/useOipElastic';
31
37
 
32
- const props = withDefaults(defineProps<{ id: string; highlight?: string[]; lang?: 'fr' | 'en' }>(), {
33
- highlight: () => [],
34
- lang: undefined,
35
- });
38
+ const props = withDefaults(
39
+ defineProps<{
40
+ id: string;
41
+ highlight?: string[];
42
+ lang?: 'fr' | 'en';
43
+ /** Publications a mettre en tete et en avant, par PMID. */
44
+ priority?: { ids: string[]; label: string } | null;
45
+ }>(),
46
+ {
47
+ highlight: () => [],
48
+ lang: undefined,
49
+ priority: null,
50
+ },
51
+ );
36
52
 
37
53
  const { queryCustomElastic, queryOneElastic } = useOipElastic();
38
54
 
39
55
  const isLoading = ref(true);
56
+ /** Les publications prioritaires sont affichees, la suite se charge. */
57
+ const isLoadingRest = ref(false);
58
+ let loadCall = 0;
40
59
  const pubmedResults = ref<any[]>([]);
41
60
  const scoreByPmid = ref<Record<string, number | null>>({});
42
61
  const methodByPmid = ref<Record<string, string | null>>({});
43
62
 
63
+ const priorityIds = computed(() => new Set(props.priority?.ids ?? []));
64
+ const isPriority = (res: any) => priorityIds.value.has(String(res?.PubMed_ID));
65
+ /** Les publications prioritaires d'abord, chaque groupe gardant l'ordre par date. */
66
+ const ordered = computed(() =>
67
+ [...pubmedResults.value].sort((a, b) => Number(isPriority(b)) - Number(isPriority(a))),
68
+ );
69
+
44
70
  async function load(urlId: string) {
71
+ const call = ++loadCall;
45
72
  isLoading.value = true;
46
73
  pubmedResults.value = [];
47
74
  scoreByPmid.value = {};
@@ -65,8 +92,9 @@ async function load(urlId: string) {
65
92
 
66
93
  if (pubmedIds.length === 0) return;
67
94
 
68
- // Fetch per-paper match scores for this HCP from the per-trial hcpPubmed index
69
- const scoresRes = await queryCustomElastic({
95
+ // Fetch per-paper match scores for this HCP from the per-trial hcpPubmed index,
96
+ // sans attendre : les cartes s'affichent, les scores les rejoignent.
97
+ const scores = queryCustomElastic({
70
98
  index: indexConfig.hcpPubmed.index,
71
99
  cluster: indexConfig.hcpPubmed.cluster,
72
100
  customQuery: {
@@ -86,25 +114,33 @@ async function load(urlId: string) {
86
114
  },
87
115
  },
88
116
  },
89
- });
90
-
91
- const scoreMap: Record<string, number | null> = {};
92
- const methodMap: Record<string, string | null> = {};
93
- for (const doc of scoresRes?.results || []) {
94
- if (!doc?.PubMed_ID) continue;
95
- const matched = (doc?.hcp || []).find((h: any) => h?.hcp_code === urlId);
96
- if (matched) {
97
- scoreMap[doc.PubMed_ID] = typeof matched.score === 'number' ? matched.score : null;
98
- methodMap[doc.PubMed_ID] = matched.match_method || null;
117
+ }).then((scoresRes) => {
118
+ const scoreMap: Record<string, number | null> = {};
119
+ const methodMap: Record<string, string | null> = {};
120
+ for (const doc of scoresRes?.results || []) {
121
+ if (!doc?.PubMed_ID) continue;
122
+ const matched = (doc?.hcp || []).find((h: any) => h?.hcp_code === urlId);
123
+ if (matched) {
124
+ scoreMap[doc.PubMed_ID] = typeof matched.score === 'number' ? matched.score : null;
125
+ methodMap[doc.PubMed_ID] = matched.match_method || null;
126
+ }
99
127
  }
100
- }
101
- scoreByPmid.value = scoreMap;
102
- methodByPmid.value = methodMap;
128
+ if (call !== loadCall) return;
129
+ scoreByPmid.value = scoreMap;
130
+ methodByPmid.value = methodMap;
131
+ });
103
132
 
133
+ // Les publications prioritaires d'abord : la liste s'affiche des
134
+ // qu'elles sont la, le reste suit, par paquets dates.
135
+ const first = pubmedIds.filter((pmid) => priorityIds.value.has(pmid));
136
+ const pmids = [...first, ...pubmedIds.filter((pmid) => !priorityIds.value.has(pmid))];
137
+ const batches: string[][] = [];
104
138
  const batchSize = 1000;
105
- const all: any[] = [];
106
- for (let i = 0; i < pubmedIds.length; i += batchSize) {
107
- const batch = pubmedIds.slice(i, i + batchSize);
139
+ for (const [from, to] of [[0, first.length], [first.length, pmids.length]]) {
140
+ for (let i = from!; i < to!; i += batchSize) batches.push(pmids.slice(i, Math.min(i + batchSize, to!)));
141
+ }
142
+ for (const batch of batches) {
143
+ if (!isLoading.value) isLoadingRest.value = true;
108
144
  const res = await queryCustomElastic({
109
145
  index: indexConfig.pubmed.index,
110
146
  cluster: indexConfig.pubmed.cluster,
@@ -114,15 +150,27 @@ async function load(urlId: string) {
114
150
  sort: [{ article_date: { order: 'desc' } }],
115
151
  },
116
152
  });
117
- all.push(...(res?.results || []));
153
+ if (call !== loadCall) return;
154
+ pubmedResults.value = [...pubmedResults.value, ...(res?.results || [])];
155
+ isLoading.value = false;
118
156
  }
119
- pubmedResults.value = all;
157
+ await scores;
120
158
  } catch (e) {
121
159
  console.error(e);
122
160
  } finally {
123
- isLoading.value = false;
161
+ if (call === loadCall) {
162
+ isLoading.value = false;
163
+ isLoadingRest.value = false;
164
+ }
124
165
  }
125
166
  }
126
167
 
127
168
  watch(() => props.id, (id) => { if (id) load(id); }, { immediate: true });
169
+
128
170
  </script>
171
+
172
+ <style scoped>
173
+ .linked_priority {
174
+ box-shadow: inset 3px 0 0 var(--color-secondary);
175
+ }
176
+ </style>
@@ -25,6 +25,8 @@
25
25
  >
26
26
  {{ $t('oipScience.cards.readAbstract') }}
27
27
  </RmButton>
28
+ <!-- Etiquette posee par la liste a cote des numeros (essai prioritaire). -->
29
+ <slot name="code-extra" />
28
30
  </template>
29
31
 
30
32
  <template #title>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/romulus",
3
- "version": "0.1.259",
3
+ "version": "0.1.261",
4
4
  "description": "Romulus Design System - Nuxt module by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",