Move medipostPrivateMessage.service to separate classes, improve logging
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
'use server';
|
||||
|
||||
import type { IMedipostResponseXMLBase } from '@/packages/shared/src/types/medipost-analysis';
|
||||
import type { AnalysisOrder } from '~/lib/types/order';
|
||||
|
||||
import { parseXML } from '../util/xml.service';
|
||||
import { MedipostValidationError } from './MedipostValidationError';
|
||||
import { getAccountAdmin } from '../account.service';
|
||||
|
||||
export async function validateMedipostResponse(
|
||||
response: string,
|
||||
@@ -24,3 +26,20 @@ export async function validateMedipostResponse(
|
||||
throw new MedipostValidationError(response);
|
||||
}
|
||||
}
|
||||
|
||||
export async function validateOrderPerson({
|
||||
analysisOrder,
|
||||
patientPersonalCode,
|
||||
}: {
|
||||
analysisOrder: AnalysisOrder;
|
||||
patientPersonalCode: string;
|
||||
}) {
|
||||
const orderPerson = await getAccountAdmin({
|
||||
primaryOwnerUserId: analysisOrder.user_id,
|
||||
});
|
||||
if (orderPerson.personal_code !== patientPersonalCode) {
|
||||
throw new Error(
|
||||
`Order person personal code does not match Medipost message Patsient.Isikukood=${patientPersonalCode}, orderPerson.personal_code=${orderPerson.personal_code}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user