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

Consolidate contract and rate types #1872

Merged
merged 5 commits into from
Aug 14, 2023
Merged

Conversation

macrael
Copy link
Contributor

@macrael macrael commented Aug 14, 2023

Summary

This PR updates all the Rate types to match the Contract types and gets rid of the separate Draft types for both.

All of our contract and rate functions can now return this full table type.

  • Added draftRevision to ContractType and RateType
  • got rid of all of our constructed —Table types and replaced them with generated types from Prisma

I think some of the files could be consolidated now but I messed it up on my first try so I scrapped that for today.

Related issues

Screenshots

Test cases covered

QA guidance

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.

Thank you! I would love to get this merged and work on top of this code.

@@ -74,6 +74,11 @@ function convertContractToUnlockedHealthPlanPackage(
): HealthPlanPackageType | Error {
console.info('Attempting to convert contract to health plan package')

// Since drafts come in separate on the Contract type, we push it onto the revisions before converting below
if (contract.draftRevision) {
contract.revisions.unshift(contract.draftRevision)
Copy link
Contributor

@haworku haworku Aug 14, 2023

Choose a reason for hiding this comment

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

🔴 should we do anything else to verify that the first revision is indeed a draft here or can we be confident?

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 think we're good here, a draft should be a draft if we put it on draftRevision

if (!rateRev.submitInfo) {
if (draftRevision) {
return new Error(
'PROGRAMMING ERROR: a contract may not have multiple drafts simultaneously. ID: ' +
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'PROGRAMMING ERROR: a contract may not have multiple drafts simultaneously. ID: ' +
'PROGRAMMING ERROR: a rate may not have multiple drafts simultaneously. ID: ' +

const rateRevisions = rate.revisions
let draftRevision: RateRevisionWithContractsType | undefined = undefined
for (const rateRev of rateRevisions) {
// no drafts allowed
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// no drafts allowed
// We have already set the draft revision aside, all ordered revisions here should be submitted

draftContracts: DraftContractsTable[]
): ContractRevisionType[] {
return draftContracts.map((dc) =>
contractRevisionToDomainModel(dc.revisions[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice this is good - I like this way of making sure we only grab the first by putting it just at the level of the domain transform function

@macrael macrael temporarily deployed to dev August 14, 2023 16:54 — with GitHub Actions Inactive
@macrael macrael temporarily deployed to dev August 14, 2023 16:54 — with GitHub Actions Inactive
@macrael macrael temporarily deployed to dev August 14, 2023 16:54 — with GitHub Actions Inactive
@macrael macrael temporarily deployed to dev August 14, 2023 16:54 — with GitHub Actions Inactive
@macrael macrael temporarily deployed to dev August 14, 2023 16:54 — with GitHub Actions Inactive
@macrael macrael temporarily deployed to dev August 14, 2023 16:54 — with GitHub Actions Inactive
@macrael macrael temporarily deployed to dev August 14, 2023 16:54 — with GitHub Actions Inactive
@macrael macrael temporarily deployed to dev August 14, 2023 16:54 — with GitHub Actions Inactive
@macrael macrael temporarily deployed to dev August 14, 2023 16:54 — with GitHub Actions Inactive
@macrael macrael temporarily deployed to dev August 14, 2023 16:54 — with GitHub Actions Inactive
@macrael macrael merged commit 01f5e9a into main Aug 14, 2023
27 checks passed
@macrael macrael deleted the wml-consolodate-contract-types branch August 14, 2023 18:38
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