MED-238: Improve logging

This commit is contained in:
Karli
2025-11-10 16:54:01 +02:00
parent 452440e8db
commit 6ee2e65938
2 changed files with 4 additions and 13 deletions

View File

@@ -377,7 +377,7 @@ export async function readPrivateMessageResponse({
messageResponse,
});
console.error(
`Invalid !order id or message response or patient personal code, medipostExternalOrderId=${medipostExternalOrderId}, privateMessageId=${privateMessageId}`,
`Invalid order id or message response or patient personal code, medipostExternalOrderId=${medipostExternalOrderId}, privateMessageId=${privateMessageId}, patientPersonalCode=${patientPersonalCode}`,
);
await upsertMedipostActionLog({
action: 'sync_analysis_results_from_medipost',

View File

@@ -509,18 +509,9 @@ class UserAnalysesApi {
}
const analysisOrder = await this.getAnalysisOrder({ analysisOrderId });
const userId = analysisOrder.user_id;
const { data: account } = await this.client
.schema('medreport')
.from('accounts')
.select('id')
.eq('primary_owner_user_id', userId)
.maybeSingle()
.throwOnError();
const accountId = account?.id;
if (!accountId) {
if (!userId) {
console.warn(
`Order ${analysisOrderId} got new responses but no account found for user_id=${userId}. Skipping notification.`,
`Order ${analysisOrderId} got new responses but user_id is missing. Skipping notification. AnalysisOrder=${JSON.stringify(analysisOrder)}`,
);
return;
}
@@ -534,7 +525,7 @@ class UserAnalysesApi {
if (hasFullAnalysisResponse || hasPartialAnalysisResponse) {
await notificationsApi.createNotification({
account_id: accountId,
account_id: userId,
body: t('analysis-results:notification.body'),
link: `${pathsConfig.app.analysisResults}/${analysisOrderId}`,
});