Skip to content

Adding New Datasets

Mike Lyttle edited this page Aug 31, 2023 · 1 revision

1. At a Glance

Some items on this list may not be needed if the infrastructure already exists, as in the case of patient data datasets, however all should be checked.

  1. Add the new API models
    • Create src/models/{yourApiModel}.ts, or update src/models/patientDataResponse.ts if this is an extension to the patient data datasets
  2. Add the service (unless this is an extension to the patient data datasets)
    • Create src/services/rest{Dataset}Service.ts
    • Update src/services/interfaces.ts to include an interface for the service
    • Update src/ioc/identifer.ts to include a new service identifier
    • Update src/ioc/initialization.ts to initialise the service
  3. Add new type values in src/constants
    • Update entryTypes.ts to include a new EntryType and populate the details in entryTypeMap
    • Update commentEntryType.ts to include a new CommentEntryType if comments are available for this entry type
    • Update dataSource.ts to include a new DataSource
    • Update errorType.ts to include a new ErrorSourceType
  4. Create a new Pinia store in src/stores
  5. Create a subclass of TimelineEntry in src/models
  6. Create a timeline component in src/components/private/timeline/entry
    • Register the component in src/plugins/components.ts
  7. Update TimelineComponent in src/components/private/timeline to retrieve data
  8. Update FilterComponent in src/components/private/timeline to return the record count in getFilterCount function
  9. Add the EntryType to the LandingView.vue component if required

2. Breakdown

2.1 Communicating with the API

Inside src/services, extend interfaces.ts with the new API details, whether that's a new interface or additional endpoints on an existing interface. Add or update the rest{feature}Service.ts file required for this new dataset. Any supporting models should be under the models folder.

Remember to check if the feature is enabled through the featuretoggleconfig.json retrieved with the configuration endpoint call on startup.

2.2 Pinia Store

Add a Pinia store definition to src/stores. Follow the last implementation for the latest standards in implementing and managing the management of loading flags.

2.3 Types

The entryType.ts and its accompanying details map will expose data to the many recurring components/features within the application. This includes the quick links and the landing page sections. The details here include the description, which is used on the landing page and the quick link text. An important aspect here is to add the name of the upcoming timeline entry component for the component property. This is used to tell Vue what component should be rendered for a particular timeline entry.

If the dataset allows for notes, then commentEntryTypes.ts needs to be extended to include the new code that will be used to store the comment with the correct relationship in the database, this value can be found within the database's CommentEntryTypeCode table. This should have already been added with the back-end work related to this dataset.

dataSource.ts should be correctly extended with the datasource value used by the admin/API to block access to the data. Forgetting this will cause needless API calls that return empty responses. After creating the new DataSource entry, src/utility/dataSourceUtil.ts should be updated to check if the dataset is blocked before issuing API calls.

2.4 Timeline

2.4.1 TimelineEntry

Dataset data must be transformed from the API data models to a model that inherits from the TimelineEntry class. This class includes the function used to perform text filtering on the timeline.

Thus, taking the API data model that was added under the models folder, one creates a dataset-specific {dataset}TimelineEntry class within models/timeline. This class will house the constructor which sets the EntryType for the entry instance and will also become the wrapping class to abstract the underlying data from the API model.

This new {dataset}TimelineEntry class will be responsible for exposing the underlying data to the upcoming timeline entry component.

2.4.2 Timeline Entry Component

This component renders the data associated with a single record and is the crux of this endeavour to display and allow users to interact with the returned data.

Each component's particular needs are dictated by user story requirements. As a guide for the latest coding standards, follow the implementation of the most recently added dataset.

You will need to register the name of this new timeline entry component in /src/plugins/components.ts, matching the component value in entryTypeMap for the dataset. Otherwise, the component will not be rendered.

2.4.3 TimelineComponent

TimelineComponent is the hub for all the datasets and handles retrieval and filtering entries before they are displayed to the user. You will need extend the fetchDataset method with a new case. TimelineComponent is also responsible for determining if data is still being retrieved and the conditions under datasetIsLoading should be extended for this purpose.

In theory, on a basic dataset extension, this should be all the changes necessary to get the data to the timeline.

2.5 LandingView

The landing view is often used to tell users what we offer, so adding the EntryType to the collection for datasets or services will cause all required data to be displayed (with the help of the details stored in the entryTypeMap).

Clone this wiki locally