Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(medication): EPI-1083: Extend drugs reference data #7047

Conversation

khoi-bes
Copy link
Contributor

Changes

  • Add a new table called reference_drugs that includes additional information from referenceData of the type "drug".
  • Update the import and export of referenceData to incorporate extra information about drugs.

Deploys

  • Deploy to Tamanu Internal

Remember to...

  • ...write or update tests
  • ...add UI screenshots and testing notes to the Linear issue
  • ...add any manual upgrade steps to the Linear issue
  • ...update the config reference, settings reference, or any relevant runbook(s)
  • ...call out additions or changes to config files for the deployment team to take note of

Copy link

linear bot commented Jan 13, 2025

EPI-1083 Extend drugs reference data

Brief Description

This card tracks updates required for reference data type drug.

Requirements:

  • New reference_drugs table as an extension to the existing reference_data of type drug
    • Add columns default_route and default_units
  • Make importer and exporter include the defaultRoute and defaultUnits
    • Even if defaultRoute and defaultUnits are not supplied, an entry in reference_drugs should always be added for each row in the drug sheet
  • Add column default_notes
    • This column should support freetext notes (no character limit) that will automatically populate the 'Notes' field on the new prescription form when a user prescribes the specific medication
  • Also add a blank entry for each item in reference_data of type drug

Testing note:

  • Megan to supply reference data for testing.

Refinement points (DD/MM/YY):

Questions:

Complexities/Unknowns:

Easy wins:

Testing:


Copy link
Member

@edmofro edmofro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice on @khoi-bes, pretty clean - just a couple of small things

{
id: primaryKey,
referenceDataId: {
type: DataTypes.INTEGER,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be TEXT or UUID?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah right, my mistake

@@ -421,3 +421,29 @@ export async function taskTemplateLoader(item, { models, pushError }) {

return rows;
}

export async function drugLoader(item, { models }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested this works for a drug that isn't already in reference_data? It doesn't seem like it will be added to the parent table, but I might be missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I tested this, we did the same thing on "Tasking" before

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh cool, thanks

khoi-bes and others added 3 commits January 16, 2025 16:25
…gsTable.js

Co-authored-by: Edwin Monk-Fromont <edwin.monkfromont@gmail.com>
…yondessential/tamanu into feature/epi-1083-extend-drugs-reference-data
@khoi-bes khoi-bes requested a review from edmofro January 17, 2025 02:29
@@ -15,7 +15,7 @@ export class ReferenceDrug extends Model {
{
id: primaryKey,
referenceDataId: {
type: DataTypes.INTEGER,
type: DataTypes.TEXT,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually use DataTypes.STRING in the migration. Is there a reason the two are different?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, that was clearly my mistake, I was confused myself when reading the feedback

@khoi-bes khoi-bes merged commit 1a3ec9d into epic-medication-enhancements-and-mar Jan 20, 2025
64 checks passed
@khoi-bes khoi-bes deleted the feature/epi-1083-extend-drugs-reference-data branch January 20, 2025 08:18
khoi-bes added a commit that referenced this pull request Feb 19, 2025
* feat(medication): EPI-1083: Extend drugs reference data

* refactor(migrations): Remove unused drug reference data insertion logic

* feat(migrations): Add bulk insert for reference drugs from reference data

* feat(migrations): Add conditional check for bulk insert of reference drugs

* fix(migrations): Update conditional check for bulk insert of reference drugs

* add docs for models

* Update packages/database/src/migrations/1736614067055-addReferenceDrugsTable.js

Co-authored-by: Edwin Monk-Fromont <edwin.monkfromont@gmail.com>

* address feedbacks

* address feedback

* fix dbt models

---------

Co-authored-by: Edwin Monk-Fromont <edwin.monkfromont@gmail.com>
khoi-bes added a commit that referenced this pull request Feb 19, 2025
* feat(medication): EPI-1083: Extend drugs reference data

* refactor(migrations): Remove unused drug reference data insertion logic

* feat(migrations): Add bulk insert for reference drugs from reference data

* feat(migrations): Add conditional check for bulk insert of reference drugs

* fix(migrations): Update conditional check for bulk insert of reference drugs

* add docs for models

* Update packages/database/src/migrations/1736614067055-addReferenceDrugsTable.js

Co-authored-by: Edwin Monk-Fromont <edwin.monkfromont@gmail.com>

* address feedbacks

* address feedback

* fix dbt models

---------

Co-authored-by: Edwin Monk-Fromont <edwin.monkfromont@gmail.com>
khoi-bes added a commit that referenced this pull request Feb 20, 2025
* feat(medication): EPI-1083: Extend drugs reference data

* refactor(migrations): Remove unused drug reference data insertion logic

* feat(migrations): Add bulk insert for reference drugs from reference data

* feat(migrations): Add conditional check for bulk insert of reference drugs

* fix(migrations): Update conditional check for bulk insert of reference drugs

* add docs for models

* Update packages/database/src/migrations/1736614067055-addReferenceDrugsTable.js

Co-authored-by: Edwin Monk-Fromont <edwin.monkfromont@gmail.com>

* address feedbacks

* address feedback

* fix dbt models

---------

Co-authored-by: Edwin Monk-Fromont <edwin.monkfromont@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants