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

MR-2364: Dealt with packages with shared rates in the current UI #1945

Merged

Conversation

JasonLin0991
Copy link
Contributor

@JasonLin0991 JasonLin0991 commented Sep 27, 2023

Summary

MR-2364

  • Changed the Prisma schema of packagesWithSharedRateCerts to contractsWithSharedRateRevision.
    • The field is now a many-to-many between ContractTable and RateRevisionTable.
    • Removed SharedRateCertifications join table.
    • Other changes are just formatting.
  • API Work
    • Take a peek at includeDraftRates and subincludeUpdateInfo in the prisma helpers. Added contractsWithSharedRateRevision that includes only the latest contract revision.
      • The idea is we take the latest revision by createdAt with the assumption that we don't care if its draft or submitted.
      • Is that correct?
    • updateDraftContractWithRates just get an array of the contract ids and connect when creating a rate and set when updating. using set here because we are only updating the relationship, no other complexity here unlike updating the rate revisions.
    • rateFormDataToDomainModel function now converts contractsWithSharedRateRevision from our DB to the domain model packagesWithSharedRateCerts.
      • It loops through contractsWithSharedRateRevision and generates the packageName for each item.
      • It will throw an error if even one of the packages fails to generate a name.
    • convertHealthPlanPackageRatesToDomain will filter out any packagesWithSharedRateCerts that is missing a packageId. I don't think it will ever happen, but it's here to satisfy the type and in case we overlooked anything.
    • Removed getProgramsFromState used in tests. This is basically duplicate of findStatePrograms but instead of returning an error, it will return an empty string. Not good for tests, because we should not expect to find no programs for a valid state.
  • Frontend Work
    • PackagesWithSharedRates.tsx now uses the package level id instead of the form data level.
      • This does not affect how old-world shared rate certs work.
      • This does fix our new world where the from data level id is the revision id and not the contract id.
    • Several page components that use useParams was causing an eslint error. Updated the types to get rid of the error.
    • packageName has been refactored to take in arguments needed, instead of the entire package, for generating a name. Now, this can be used with new DB model contracts to generate the same name.
    • generateRateName Move defaulting to package programs into this function instead of packageName.

Related issues

Screenshots

Test cases covered

QA guidance

contractsWithSharedRateRevision: {
include: {
revisions: {
take: 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks fine to me based on the prisma table - to answer your question from the PR description. I think returning just latest rev for the linked contract makes sense.

I think it could be possible then we could display too early the updated programs from a rate that is unlocked and being edited by the state ...but I don't see a way around that since its a contract - rate revision relationship and not a contract revision - rate revision level relationship right now.

Copy link
Contributor

@haworku haworku left a comment

Choose a reason for hiding this comment

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

LGTM - I think its a clever way to keep supporting this feature- watch out for interactions with #1903

…shared-rates

# Conflicts:
#	services/app-api/prisma/schema.prisma
#	services/app-api/src/postgres/contractAndRates/parseContractWithHistory.ts
#	services/app-api/src/postgres/contractAndRates/parseRateWithHistory.ts
#	services/app-api/src/postgres/contractAndRates/prismaSharedContractRateHelpers.ts
#	services/app-api/src/postgres/contractAndRates/updateDraftContractWithRates.ts
#	services/app-api/src/resolvers/healthPlanPackage/submitHealthPlanPackage.test.ts
#	services/app-api/src/resolvers/healthPlanPackage/unlockHealthPlanPackage.test.ts
#	services/app-api/src/resolvers/healthPlanPackage/updateHealthPlanFormData.test.ts
#	services/app-api/src/testHelpers/contractAndRates/contractHelpers.ts
#	services/app-api/src/testHelpers/contractAndRates/rateHelpers.ts
@JasonLin0991 JasonLin0991 merged commit 8e01bdb into main Oct 2, 2023
27 checks passed
@JasonLin0991 JasonLin0991 deleted the jl-mr-2364-new-db-rates-model-packages-with-shared-rates branch October 2, 2023 20:14
Copy link
Contributor

@macrael macrael left a comment

Choose a reason for hiding this comment

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

I don't love how much extra error handling we had to introduce here b/c we had to look up the package names. that will be nice to get into the db and no longer have to check in app space.

Nice work!

// We only care about the contract ID. PackageName is not in our DB, instead when converting DB data to domain
// data we are generating the package name.
const packagesWithSharedRateCerts =
hppRateFormData.packagesWithSharedRateCerts?.reduce(
Copy link
Contributor

Choose a reason for hiding this comment

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

interesting use of reduce, I feel like it might be clearer to chain a filter and a map, here

haworku pushed a commit that referenced this pull request Oct 16, 2023
* Update packagesWithSharedRateCerts to contractsWithSharedRateRevision.

* Refactor packageName parameters to only accept what is used and move hanlding of no rate programs.

* Add real packagesWithSharedRateCerts data from db to rateFormDataToDomainModel. Update conversion functions to return error types.

* Refactor variable sub with pkg for less confusion. Replace setting value with formData id to pkg id.

* Replace using getProgramsFromState with findStatePrograms and throwing errors in tests if programs are not found.

* Fix imports

* Update contractsWithSharedRateRevision

* Update tests for packages with shared rate certs.

* cypress re-run

* cypress re-run

* Fix some merging stuff.

* cypress re-run
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.

3 participants