DiseaseExporter

Internal members (not exported)

Factory

Create #

Instantiate a DiseaseExporter with its dependencies configured.

Signature:

Public Function Create(ByVal workbookManager As IDiseaseExportWorkbook) As IDiseaseExporter

Parameters:

Returns: IDiseaseExporter ready to generate exports.


Self #

Return the current instance as its interface.

Signature:

Public Property Get Self() As IDiseaseExporter

Configuration

Initialise #

Attach the workbook manager and application guard.

Signature:

Public Sub Initialise(ByVal workbookManager As IDiseaseExportWorkbook, _
                      ByVal appGuard As IDiseaseApplicationState)

Disease Export

BuildDiseaseWorkbook #

Populate a workbook with dictionary, choices, translations, and metadata.

Signature:

Public Function BuildDiseaseWorkbook(ByVal diseaseSheet As Worksheet, _
                                     ByVal translationTable As ListObject, _
                                     ByVal ribbonTranslations As ITranslationObject, _
                                     ByVal diseaseName As String, _
                                     ByVal languageTag As String, _
                                     Optional ByVal diseaseCode As String = vbNullString) As Workbook

ExportDisease #

Export the disease workbook to disk and return the saved file path.

Signature:

Public Function ExportDisease(ByVal exportFolder As String, _
                              ByVal diseaseSheet As Worksheet, _
                              ByVal translationTable As ListObject, _
                              ByVal ribbonTranslations As ITranslationObject, _
                              ByVal diseaseName As String, _
                              ByVal languageTag As String, _
                              Optional ByVal diseaseCode As String = vbNullString) As String

Migration Export

BuildMigrationWorkbook #

Build a workbook aggregating all diseases for migration.

Signature:

Public Function BuildMigrationWorkbook(ByVal sourceWorkbook As Workbook, _
                                       ByVal diseaseNames As BetterArray) As Workbook

ExportForMigration #

Persist the migration workbook to disk and return the saved file path.

Signature:

Public Function ExportForMigration(ByVal exportFolder As String, _
                                   ByVal sourceWorkbook As Workbook, _
                                   ByVal diseaseNames As BetterArray) As String

Internal Helpers

EnsureFreshWorkbook #

Ensure the workbook manager has a pristine workbook.

Signature:

Private Sub EnsureFreshWorkbook()

BeginGuard #

Begin the guarded Application state only once per call.

Signature:

Private Sub BeginGuard(ByRef guardStarted As Boolean)

RestoreGuard #

Restore guarded Application state when required.

Signature:

Private Sub RestoreGuard(ByVal guardStarted As Boolean)

ValidateDiseaseInputs #

Validate disease export inputs.

Signature:

Private Sub ValidateDiseaseInputs(ByVal diseaseSheet As Worksheet, _
                                  ByVal diseaseName As String, _
                                  ByVal languageTag As String)

ValidateMigrationInputs #

Validate migration export inputs.

Signature:

Private Sub ValidateMigrationInputs(ByVal sourceWorkbook As Workbook, _
                                    ByVal diseaseNames As BetterArray)

ValidateFolder #

Validate that a folder path was supplied.

Signature:

Private Sub ValidateFolder(ByVal exportFolder As String)

PrepareSheets #

Prepare disease export worksheets.

Signature:

Private Sub PrepareSheets(ByVal workbook As Workbook, _
                          ByRef metadataSheet As Worksheet, _
                          ByRef dictionarySheet As Worksheet, _
                          ByRef choicesSheet As Worksheet, _
                          ByRef translationsSheet As Worksheet)

PrepareMigrationSheets #

Prepare migration workbook worksheets.

Signature:

Private Sub PrepareMigrationSheets(ByVal workbook As Workbook)

ResolveDiseaseTable #

Retrieve the disease table from the worksheet.

Signature:

Private Function ResolveDiseaseTable(ByVal diseaseSheet As Worksheet) As ListObject

ResolveListObject #

Retrieve a ListObject from a named worksheet.

Signature:

Private Function ResolveListObject(ByVal workbook As Workbook, ByVal sheetName As String) As ListObject

ResolveSheets #

Enumerate worksheets from provided disease names.

Signature:

Private Function ResolveSheets(ByVal workbook As Workbook, ByVal diseaseNames As BetterArray) As Collection

PopulateMetadata #

Populate metadata worksheet with export details.

Signature:

Private Sub PopulateMetadata(ByVal metadataSheet As Worksheet, _
                             ByVal diseaseName As String, _
                             ByVal languageTag As String, _
                             ByVal diseaseCode As String)

PopulateDictionary #

Populate dictionary sheet using array-based assignment.

Signature:

Private Sub PopulateDictionary(ByVal dictionarySheet As Worksheet, ByVal diseaseTable As ListObject)

BuildDictionaryMatrix #

Build a dictionary matrix selecting required columns.

Signature:

Private Function BuildDictionaryMatrix(ByRef sourceData As Variant, ByVal rowCount As Long) As Variant

PopulateChoices #

Populate choices sheet translating headers when available.

Signature:

Private Sub PopulateChoices(ByVal choicesSheet As Worksheet, _
                            ByVal diseaseTable As ListObject, _
                            ByVal headerCache As IDiseaseTranslationCache)

BuildChoiceRows #

Build a collection containing distinct choice rows.

Signature:

Private Function BuildChoiceRows(ByRef sourceData As Variant) As Collection

ContainsKey #

Determine whether a key has already been processed.

Signature:

Private Function ContainsKey(ByVal keys As BetterArray, ByVal key As String) As Boolean

FindWorksheet #

Locate a worksheet by name without relying on implicit errors.

Signature:

Private Function FindWorksheet(ByVal workbook As Workbook, ByVal sheetName As String) As Worksheet

SplitChoices #

Split choice strings safely.

Signature:

Private Function SplitChoices(ByVal rawValue As Variant) As Variant

PopulateTranslations #

Populate a worksheet with a ListObject using a single array assignment.

Signature:

Private Sub PopulateTranslations(ByVal targetSheet As Worksheet, ByVal sourceTable As ListObject)

PopulateMigrationDisease #

Populate a migration worksheet with disease data.

Signature:

Private Sub PopulateMigrationDisease(ByVal targetSheet As Worksheet, ByVal diseaseSheet As Worksheet)

ApplySheetCosmetics #

Apply light formatting to export worksheets.

Signature:

Private Sub ApplySheetCosmetics(ByVal metadataSheet As Worksheet, _
                                ByVal dictionarySheet As Worksheet, _
                                ByVal choicesSheet As Worksheet, _
                                ByVal translationsSheet As Worksheet)

ApplyMigrationFormatting #

Apply formatting to migration workbook sheets.

Signature:

Private Sub ApplyMigrationFormatting(ByVal workbook As Workbook)

AutoFitSheet #

Auto fit worksheet columns and style header row.

Signature:

Private Sub AutoFitSheet(ByVal sheet As Worksheet)

EnsureWorksheet #

Ensure a worksheet exists and optionally rename the provided template.

Signature:

Private Function EnsureWorksheet(ByVal workbook As Workbook, _
                                 ByVal sheetName As String, _
                                 Optional ByVal template As Worksheet = Nothing) As Worksheet

ClearSheet #

Clear worksheet contents while preserving structure.

Signature:

Private Sub ClearSheet(ByVal sheet As Worksheet)

ArrayToRow #

Convert one-dimensional array into a 1xN matrix for assignment.

Signature:

Private Function ArrayToRow(ByVal values As Variant) As Variant

CollectionToMatrix #

Convert a collection of row arrays into a matrix.

Signature:

Private Function CollectionToMatrix(ByVal rows As Collection, ByVal columnCount As Long) As Variant

TranslateHeader #

Translate headers when the translation object is provided.

Signature:

Private Function TranslateHeader(ByVal cache As IDiseaseTranslationCache, _
                                 ByVal key As String, _
                                 ByVal fallback As String) As String

KeyOf #

Build a unique key for deduplication.

Signature:

Private Function KeyOf(ByVal controlName As String, ByVal choiceValue As String) As String

LastUsedColumn #

Determine the last used column within the target sheet.

Signature:

Private Function LastUsedColumn(ByVal sheet As Worksheet) As Long

BuildDiseaseFilePath #

Build path for disease export.

Signature:

Private Function BuildDiseaseFilePath(ByVal exportFolder As String, ByVal diseaseName As String) As String

BuildMigrationFilePath #

Build path for migration export.

Signature:

Private Function BuildMigrationFilePath(ByVal exportFolder As String) As String

SanitizeFileName #

Remove characters invalid in file names.

Signature:

Private Function SanitizeFileName(ByVal fileName As String) As String

ErrorHandling

ThrowError #

Centralised ProjectError-based exception helper.

Signature:

Private Sub ThrowError(ByVal errNumber As ProjectError, ByVal errMessage As String)

Used in (4 file(s))