feat(MED-161): create analysis-order service

This commit is contained in:
2025-09-17 11:15:44 +03:00
parent 000cad7f05
commit cee37178df
3 changed files with 23 additions and 7 deletions

View File

@@ -22,6 +22,7 @@ import { composeOrderXML, OrderedAnalysisElement } from './medipostXML.service';
import { getAccountAdmin } from '../account.service';
import { logMedipostDispatch } from '../audit.service';
import { MedipostValidationError } from './MedipostValidationError';
import { getExistingAnalysisResponseElements } from '../analysis-order.service';
const BASE_URL = process.env.MEDIPOST_URL!;
const USER = process.env.MEDIPOST_USER!;
@@ -152,14 +153,9 @@ export async function syncPrivateMessage({
);
}
const { data: allOrderResponseElements } = await supabase
.schema('medreport')
.from('analysis_response_elements')
.select('*')
.eq('analysis_response_id', analysisResponseId)
.throwOnError();
const existingAnalysisResponseElements = await getExistingAnalysisResponseElements({ analysisResponseId });
const expectedOrderResponseElements = order.analysis_element_ids?.length ?? 0;
if (allOrderResponseElements.length !== expectedOrderResponseElements) {
if (existingAnalysisResponseElements.length !== expectedOrderResponseElements) {
return { isPartial: true };
}