Skip to content

Commit

Permalink
Feature: Adjust "Trans health - youth care" tag to respond to policy …
Browse files Browse the repository at this point in the history
…changes (ECB-91) (#1455)

<!--- Please provide a general summary of your changes in the title
above -->

# Pull Request type

<!-- Please try to limit your pull request to one type; submit multiple
pull requests if needed. -->

Please check the type of change your PR introduces:

- [ ] Bugfix
- [x] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no API changes)
- [ ] Build-related changes
- [ ] Documentation content changes
- [ ] Other (please describe):

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying, or
link to a relevant issue. -->

Issue Number: N/A

## What is the new behavior?
(1) Update our "Trans health - youth care" tag to be more vague; new tag
name = "Trans youth support"

(2) Move new renamed tag from showing under “Medical” category and just
list under the “Mental Health” category (& cross-list under the “Trans
Focused Services” category) on the live front-end and in the data
portal.

-
-
-

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this does introduce a breaking change, please describe the
impact and migration path for existing applications below. -->

## Other information

<!-- Any other information that is important to this PR, such as
screenshots of how the component looks before and after the change. -->
  • Loading branch information
trigal2012 authored Jan 29, 2025
2 parents 0d01a05 + 753f321 commit f8a779e
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/app/public/locales/en/services.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"trans-health-hormone-therapy": "Trans health - hormone therapy",
"trans-health-primary-care": "Trans health - primary care",
"trans-health-speech-therapy": "Trans health - speech therapy",
"trans-health-youth-care": "Trans health - youth care"
"trans-health-youth-care": "Trans youth support"
},
"mental-health": {
"CATEGORYNAME": "Mental Health",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { type MigrationJob } from '~db/prisma/dataMigrationRunner'
import { type JobDef } from '~db/prisma/jobPreRun'

/** Define the job metadata here. */
const jobDef: JobDef = {
jobId: '2025-01-29_update-parent-category-for-trans-you-health',
title: 'update parent category for trans you health',
createdBy: 'Diana Garbarino',
/** Optional: Longer description for the job */
description: undefined,
}
/**
* Job export - this variable MUST be UNIQUE
*/
export const job20250129_update_parent_category_for_trans_you_health = {
title: `[${jobDef.jobId}] ${jobDef.title}`,
task: async (ctx, task) => {
const { createLogger, downloadFromDatastore, generateId, formatMessage, jobPostRunner, prisma } = ctx
/** Create logging instance */
createLogger(task, jobDef.jobId)
const log = (...args: Parameters<typeof formatMessage>) => (task.output = formatMessage(...args))
/**
* Start defining your data migration from here.
*
* To log output, use `task.output = 'Message to log'`
*
* This will be written to `stdout` and to a log file in `/prisma/migration-logs/`
*/

// Do stuff

const update = await prisma.$transaction([
prisma.serviceTag.update({
where: { id: 'svtg_01HAD647BVMT10DWEXFG1EFM9J' },
data: { name: 'Trans - youth care' },
}),
])

// Extract the serviceTagId from the update result
const serviceTagId = update[0].id
console.log('Updated ServiceTag ID:', serviceTagId)

// Find the category IDs for "Medical" and "Mental Health"
const categories = await prisma.serviceCategory.findMany({
where: {
category: {
in: ['Medical', 'Mental Health'],
},
},
select: { id: true, category: true },
})

// Extract the IDs for "Medical" and "Mental Health"
const medicalCategory = categories.find((c) => c.category === 'Medical')
const mentalHealthCategory = categories.find((c) => c.category === 'Mental Health')

if (!medicalCategory || !mentalHealthCategory) {
throw new Error("Could not find category IDs for 'Medical' or 'Mental Health'")
}

console.log('Medical Category ID:', medicalCategory.id)
console.log('Mental Health Category ID:', mentalHealthCategory.id)

// Update ServiceTagToCategory where categoryId = Medical and serviceTagId = updated serviceTagId
const updateResult = await prisma.$transaction([
prisma.serviceTagToCategory.updateMany({
where: {
categoryId: medicalCategory.id,
serviceTagId: serviceTagId,
},
data: {
categoryId: mentalHealthCategory.id, // Change to Mental Health's ID
},
}),
])

console.log('Updated ServiceTagToCategory rows:', updateResult)
console.log('Category ID changed from', medicalCategory.id, 'to', mentalHealthCategory.id)
console.log('For ServiceTag ID:', serviceTagId)

console.log('Update complete!')

log(`serviceTag records updated: ${update.length}`)

/**
* DO NOT REMOVE BELOW
*
* This writes a record to the DB to register that this migration has run successfully.
*/
await jobPostRunner(jobDef)
},
def: jobDef,
} satisfies MigrationJob
1 change: 1 addition & 0 deletions packages/db/prisma/data-migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export * from './2025-01-15_new_food-service-tag'
export * from './2025-01-15_new_medical-service-tag'
export * from './2025-01-15_update-cost-tags'
export * from './2025-01-15_update-food-tags'
export * from './2025-01-29_update-parent-category-for-trans-you-health'
// codegen:end

0 comments on commit f8a779e

Please sign in to comment.