|
584 | 584 | try { parsed = JSON.parse(rawJson); } catch { return; } |
585 | 585 | if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) return; |
586 | 586 |
|
| 587 | + const importedIdCount = Array.isArray(parsed.importedPatientIds) ? parsed.importedPatientIds.length : 0; |
| 588 | + const importedBundleCount = Array.isArray(parsed.importedPatientBundles) ? parsed.importedPatientBundles.length : 0; |
| 589 | + const rawPatientCount = parsed.patientCount; |
| 590 | + const parsedPatientCount = typeof rawPatientCount === 'number' |
| 591 | + ? rawPatientCount |
| 592 | + : Number.parseFloat(String(rawPatientCount ?? '0')); |
| 593 | + const basePatientCount = Number.isFinite(parsedPatientCount) ? parsedPatientCount : 0; |
| 594 | + const effectivePatientCount = basePatientCount + importedIdCount + importedBundleCount; |
| 595 | +
|
| 596 | + function formatArrayItem(item, key, index) { |
| 597 | + if (item === null || item === undefined) return ''; |
| 598 | + if (typeof item !== 'object') return escapeHtml(String(item)); |
| 599 | +
|
| 600 | + if (key === 'importedPatientIds') { |
| 601 | + const patientId = item.patientId || item.PatientId; |
| 602 | + return escapeHtml(String(patientId || `Patient ${index + 1}`)); |
| 603 | + } |
| 604 | +
|
| 605 | + if (key === 'importedPatientBundles') { |
| 606 | + const fileName = item.fileName || item.FileName; |
| 607 | + const patientId = item.patientId || item.PatientId; |
| 608 | + return escapeHtml(String(fileName || patientId || `Bundle ${index + 1}`)); |
| 609 | + } |
| 610 | +
|
| 611 | + const fallback = item.name ?? item.id ?? item.patientId ?? item.fileName; |
| 612 | + if (fallback !== undefined && fallback !== null) |
| 613 | + return escapeHtml(String(fallback)); |
| 614 | +
|
| 615 | + try { return escapeHtml(JSON.stringify(item)); } |
| 616 | + catch { return escapeHtml(String(item)); } |
| 617 | + } |
| 618 | +
|
587 | 619 | // Keys rendered elsewhere or otherwise not surfaced as plain key/value pairs. |
588 | 620 | const skip = new Set([ |
589 | 621 | 'id', 'isSystemScenario', |
|
599 | 631 | selectedMeasures: 'Measures', |
600 | 632 | seed: 'Seed', |
601 | 633 | patientCount: 'Patients', |
| 634 | + importedPatientIds: 'Imported Patient IDs', |
| 635 | + importedPatientBundles: 'Imported Patient Bundles', |
602 | 636 | queryPlanTemplateName: 'Query Plan', |
603 | 637 | cleanupServiceData: 'Cleanup Service Data', |
604 | 638 | cleanupFhirData: 'Cleanup FHIR Data' |
|
614 | 648 | if (k === 'selectedMeasures') { |
615 | 649 | display = v.map(m => escapeHtml(measureShortNames[m] || toLabel(m))).join(', '); |
616 | 650 | } else { |
617 | | - display = v.map(item => escapeHtml(String(item))).join(', '); |
| 651 | + display = v.map((item, index) => formatArrayItem(item, k, index)).join(', '); |
618 | 652 | } |
| 653 | + } else if (k === 'patientCount') { |
| 654 | + display = escapeHtml(String(effectivePatientCount)); |
619 | 655 | } else if (typeof v === 'boolean') { |
620 | 656 | display = v ? '<i class="bi bi-check-circle-fill text-success"></i> Yes' : '<i class="bi bi-x-circle text-muted"></i> No'; |
621 | 657 | } else if (typeof v === 'object') { |
|
0 commit comments