Skip to content

Commit 11a65ca

Browse files
committed
Agregar readiness al spec default
1 parent 9a1e55f commit 11a65ca

2 files changed

Lines changed: 18 additions & 20 deletions

File tree

src/app/maturity/maturity-main/maturity-main.component.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,25 +90,23 @@ export class MaturityMainComponent implements OnInit {
9090
}
9191
}
9292
}
93-
94-
// Check if a specific spec is requested via query parameter (e.g., ?spec=readiness-1)
95-
if (params['spec']) {
96-
const specName = params['spec'];
97-
try {
98-
// Load spec from assets/maturity/{specName}.json
99-
this.baseMaturityQuestions = await lastValueFrom(
100-
this.http.get(`assets/maturity/${specName}.json`)
101-
);
102-
this.initializeForm();
103-
return;
104-
} catch (error) {
105-
console.error(`Error loading spec "${specName}" from assets:`, error);
106-
// Fall through to load default spec if specified spec fails
107-
}
108-
}
109-
110-
// Load default spec if not in preview mode, no spec specified, or spec loading failed
111-
this.baseMaturityQuestions = await lastValueFrom(this.http.get('assets/maturity/maturityLevels.json'));
93+
94+
// Load default spec and always append readiness stakeholders at the end.
95+
const [defaultSpec, readinessSpec] = await Promise.all([
96+
lastValueFrom(this.http.get<any>('assets/maturity/maturityLevels.json')),
97+
lastValueFrom(this.http.get<any>('assets/maturity/readiness-1.json'))
98+
]);
99+
100+
const defaultStakeholders = Array.isArray(defaultSpec?.stakeHolders) ? defaultSpec.stakeHolders : [];
101+
const readinessStakeholders = Array.isArray(readinessSpec?.stakeHolders) ? readinessSpec.stakeHolders : [];
102+
const existingIds = new Set(defaultStakeholders.map((stakeholder: any) => stakeholder.id));
103+
const stakeholdersToAppend = readinessStakeholders.filter((stakeholder: any) => !existingIds.has(stakeholder.id));
104+
105+
this.baseMaturityQuestions = {
106+
...defaultSpec,
107+
stakeHolders: [...defaultStakeholders, ...stakeholdersToAppend]
108+
};
109+
112110
this.initializeForm();
113111
// Flatten all questions into one array for one-at-a-time display
114112
// this.flattenQuestions();

src/assets/maturity/readiness-1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
{
8282
"name": "Prospective member",
8383
"id": "prospective",
84-
"description": "A country that is not yet a member",
84+
"description": "A country that is interested inm becoming a member, and wants to assess its readiness to adopt SNOMED CT.",
8585
"kpas": [
8686
{
8787
"name": "Political and Legal",

0 commit comments

Comments
 (0)