feat(MED-131): support multiple elements under same group for creating fake medipost responses
This commit is contained in:
@@ -91,6 +91,12 @@ export async function composeOrderTestResponseXML({
|
||||
// 5 – Tagasi lükatud, 6 – Tühistatud.
|
||||
const orderStatus = 4;
|
||||
const orderNumber = 'TSU000001200';
|
||||
|
||||
const allAnalysisElementsForGroups = analysisElements?.filter((element) => {
|
||||
return analysisGroups.some((group) => group.id === element.analysis_groups.id);
|
||||
});
|
||||
const addedIds = new Set<number>();
|
||||
|
||||
return `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Saadetis xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="TellimusLOINC.xsd">
|
||||
${getPais(USER, RECIPIENT, orderCreatedAt, orderId, "AL")}
|
||||
@@ -118,12 +124,17 @@ export async function composeOrderTestResponseXML({
|
||||
<TellimuseNumber>${orderNumber}</TellimuseNumber>
|
||||
|
||||
<TellimuseOlek>${orderStatus}</TellimuseOlek>
|
||||
${analysisGroups.map((group) => {
|
||||
${allAnalysisElementsForGroups.map((analysisElement) => {
|
||||
const group = analysisGroups.find((group) => group.id === analysisElement.analysis_groups.id);
|
||||
if (!group) {
|
||||
throw new Error(`Failed to find group for analysis element ${analysisElement.id}`);
|
||||
}
|
||||
|
||||
let relatedAnalysisElement = analysisElements?.find(
|
||||
(element) => element.analysis_groups.id === group.id,
|
||||
(element) => element.analysis_groups.id === group.id && !addedIds.has(element.id),
|
||||
);
|
||||
const relatedAnalyses = analyses?.filter((analysis) => {
|
||||
return analysis.analysis_elements.analysis_groups.id === group.id;
|
||||
return analysis.analysis_elements.analysis_groups.id === group.id && !addedIds.has(analysis.analysis_elements.id);
|
||||
});
|
||||
|
||||
if (!relatedAnalysisElement) {
|
||||
@@ -143,6 +154,7 @@ export async function composeOrderTestResponseXML({
|
||||
const lower = getRandomInt(0, 100);
|
||||
const upper = getRandomInt(lower + 1, 500);
|
||||
const result = getRandomInt(lower, upper);
|
||||
addedIds.add(relatedAnalysisElement.id);
|
||||
return (`
|
||||
<UuringuGrupp>
|
||||
<UuringuGruppId>${group.original_id}</UuringuGruppId>
|
||||
|
||||
Reference in New Issue
Block a user