@tekkare/romulus 0.1.260 → 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.259",
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>
@@ -81,8 +81,10 @@
81
81
  :highlight="highlight"
82
82
  :class="{ linked_priority: isPriority(row) }"
83
83
  >
84
- <template #extra>
84
+ <template #code-extra>
85
85
  <RmTag v-if="isPriority(row)" variant="indigo">{{ priority?.label }}</RmTag>
86
+ </template>
87
+ <template #extra>
86
88
  <RmTag v-if="row.extra?.role" variant="gray">{{ row.extra.role }}</RmTag>
87
89
  <OipScienceCommonScoreBadge :score="row.extra?.score" />
88
90
  </template>
@@ -94,8 +96,10 @@
94
96
  :highlight="highlight"
95
97
  :class="{ linked_priority: isPriority(row) }"
96
98
  >
97
- <template #extra>
99
+ <template #code-extra>
98
100
  <RmTag v-if="isPriority(row)" variant="indigo">{{ priority?.label }}</RmTag>
101
+ </template>
102
+ <template #extra>
99
103
  <RmTag v-if="row.extra?.role" variant="gray">{{ row.extra.role }}</RmTag>
100
104
  <OipScienceCommonScoreBadge :score="row.extra?.score" />
101
105
  </template>
@@ -103,7 +107,8 @@
103
107
  </template>
104
108
  </div>
105
109
 
106
- <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')" />
107
112
  <RmButton
108
113
  v-if="visible.length < filtered.length"
109
114
  variant="secondary"
@@ -170,47 +175,73 @@ const { linked: linkedNct, load: loadLinkedNct } = useLinkedTrials('nct');
170
175
  const nctDocs = ref<any[]>([]);
171
176
  const euctDocs = ref<any[]>([]);
172
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
+ }
173
212
 
174
213
  async function loadDocs() {
214
+ const call = ++loadCall;
175
215
  const nctIds = [...new Set(props.nctIds.filter(Boolean))];
176
216
  const euctIds = [...new Set(props.euctIds.filter(Boolean))];
177
- if (!nctIds.length && !euctIds.length) {
178
- nctDocs.value = [];
179
- euctDocs.value = [];
180
- return;
181
- }
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]];
182
227
  isLoadingDocs.value = true;
183
228
  try {
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
- nctDocs.value = nctRes?.results || [];
204
- euctDocs.value = euctRes?.results || [];
205
- // Jumeaux hors de la liste, comme sur les pages de recherche.
206
- await Promise.all([
207
- loadLinkedEuct(nctDocs.value.map((d) => d.nct_id)),
208
- loadLinkedNct(euctDocs.value.map((d) => d.nct_number)),
209
- ]);
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
+ }
210
238
  } catch (e) {
211
239
  console.error(e);
212
240
  } finally {
213
- isLoadingDocs.value = false;
241
+ if (call === loadCall) {
242
+ isLoadingDocs.value = false;
243
+ isLoadingRest.value = false;
244
+ }
214
245
  }
215
246
  }
216
247
 
@@ -15,13 +15,14 @@
15
15
  :highlight="highlight"
16
16
  :class="{ linked_priority: isPriority(res) }"
17
17
  >
18
- <template #extra>
18
+ <template #code-extra>
19
19
  <RmTag v-if="isPriority(res)" variant="indigo">{{ priority?.label }}</RmTag>
20
20
  </template>
21
21
  </OipSciencePubmedCards>
22
22
  </div>
23
23
  </div>
24
24
  <RmLoadingState v-if="isLoading" :lines="3" :chart-height="240" />
25
+ <RmLoadingState v-else-if="isLoadingRest" :lines="2" />
25
26
  <RmEmptyState
26
27
  v-if="!isLoading && !pubmedResults.length"
27
28
  :title="$t('oipScience.common.noDataTitle')"
@@ -52,11 +53,22 @@ const props = withDefaults(
52
53
  const { queryCustomElastic, queryOneElastic } = useOipElastic();
53
54
 
54
55
  const isLoading = ref(true);
56
+ /** Les publications prioritaires sont affichees, la suite se charge. */
57
+ const isLoadingRest = ref(false);
58
+ let loadCall = 0;
55
59
  const pubmedResults = ref<any[]>([]);
56
60
  const scoreByPmid = ref<Record<string, number | null>>({});
57
61
  const methodByPmid = ref<Record<string, string | null>>({});
58
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
+
59
70
  async function load(urlId: string) {
71
+ const call = ++loadCall;
60
72
  isLoading.value = true;
61
73
  pubmedResults.value = [];
62
74
  scoreByPmid.value = {};
@@ -80,8 +92,9 @@ async function load(urlId: string) {
80
92
 
81
93
  if (pubmedIds.length === 0) return;
82
94
 
83
- // Fetch per-paper match scores for this HCP from the per-trial hcpPubmed index
84
- 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({
85
98
  index: indexConfig.hcpPubmed.index,
86
99
  cluster: indexConfig.hcpPubmed.cluster,
87
100
  customQuery: {
@@ -101,25 +114,33 @@ async function load(urlId: string) {
101
114
  },
102
115
  },
103
116
  },
104
- });
105
-
106
- const scoreMap: Record<string, number | null> = {};
107
- const methodMap: Record<string, string | null> = {};
108
- for (const doc of scoresRes?.results || []) {
109
- if (!doc?.PubMed_ID) continue;
110
- const matched = (doc?.hcp || []).find((h: any) => h?.hcp_code === urlId);
111
- if (matched) {
112
- scoreMap[doc.PubMed_ID] = typeof matched.score === 'number' ? matched.score : null;
113
- 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
+ }
114
127
  }
115
- }
116
- scoreByPmid.value = scoreMap;
117
- methodByPmid.value = methodMap;
128
+ if (call !== loadCall) return;
129
+ scoreByPmid.value = scoreMap;
130
+ methodByPmid.value = methodMap;
131
+ });
118
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[][] = [];
119
138
  const batchSize = 1000;
120
- const all: any[] = [];
121
- for (let i = 0; i < pubmedIds.length; i += batchSize) {
122
- 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;
123
144
  const res = await queryCustomElastic({
124
145
  index: indexConfig.pubmed.index,
125
146
  cluster: indexConfig.pubmed.cluster,
@@ -129,24 +150,23 @@ async function load(urlId: string) {
129
150
  sort: [{ article_date: { order: 'desc' } }],
130
151
  },
131
152
  });
132
- all.push(...(res?.results || []));
153
+ if (call !== loadCall) return;
154
+ pubmedResults.value = [...pubmedResults.value, ...(res?.results || [])];
155
+ isLoading.value = false;
133
156
  }
134
- pubmedResults.value = all;
157
+ await scores;
135
158
  } catch (e) {
136
159
  console.error(e);
137
160
  } finally {
138
- isLoading.value = false;
161
+ if (call === loadCall) {
162
+ isLoading.value = false;
163
+ isLoadingRest.value = false;
164
+ }
139
165
  }
140
166
  }
141
167
 
142
168
  watch(() => props.id, (id) => { if (id) load(id); }, { immediate: true });
143
169
 
144
- const priorityIds = computed(() => new Set(props.priority?.ids ?? []));
145
- const isPriority = (res: any) => priorityIds.value.has(String(res?.PubMed_ID));
146
- /** Les publications prioritaires d'abord, chaque groupe gardant l'ordre par date. */
147
- const ordered = computed(() =>
148
- [...pubmedResults.value].sort((a, b) => Number(isPriority(b)) - Number(isPriority(a))),
149
- );
150
170
  </script>
151
171
 
152
172
  <style scoped>
@@ -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>
@@ -53,7 +55,6 @@
53
55
  :class="matchScore >= 0.85 ? 'score-high' : 'score-low'"
54
56
  :data-tooltip="$t('oipScience.common.matchingScoreTooltip')"
55
57
  >{{ $t('oipScience.cards.matchingScore') }} : {{ Math.round(matchScore * 100) }}%</span>
56
- <slot name="extra" />
57
58
  </template>
58
59
 
59
60
  <RmDrawer v-model="showModal" size="md" :label="$t('oipScience.cards.pubmedAbstract')">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/romulus",
3
- "version": "0.1.260",
3
+ "version": "0.1.261",
4
4
  "description": "Romulus Design System - Nuxt module by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",