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

[MCR-3886] Display the shared rate UI on historic submissions #2326

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,103 @@ describe('RateDetailsSummarySection', () => {
).toBeNull()
})

it('renders all necessary information for documents with shared rate certifications', async () => {
const draftContract = mockContractPackageDraft()
if (
draftContract.draftRevision &&
draftContract.draftRates &&
draftContract.draftRates[0].draftRevision
) {
draftContract.draftRates[0].draftRevision.formData.packagesWithSharedRateCerts =
[
{
packageId: '333b4225-5b49-4e82-aa71-be0d33d7418d',
packageName: 'MCR-MN-0001-SNBC',
},
{
packageId: '21467dba-6ae8-11ed-a1eb-0242ac120002',
packageName: 'MCR-MN-0002-PMAP',
},
]
}

renderWithProviders(
<RateDetailsSummarySection
documentDateLookupTable={{ previousSubmissionDate: '01/01/01' }}
contract={draftContract}
editNavigateTo="rate-details"
submissionName="MN-PMAP-0001"
statePrograms={statePrograms}
/>,
{
apolloProvider,
}
)
await waitFor(() => {
const rateDocsTable = screen.getByRole('table', {
name: /Rate certification/,
})
// has shared tag
expect(within(rateDocsTable).getByTestId('tag').textContent).toBe(
'SHARED'
)
// table has 'linked submissions' column
expect(
within(rateDocsTable).getByText('Linked submissions')
).toBeInTheDocument()
// table includes the correct submissions
expect(
within(rateDocsTable).getByText('MCR-MN-0001-SNBC')
).toBeInTheDocument()
expect(
within(rateDocsTable).getByText('MCR-MN-0002-PMAP')
).toBeInTheDocument()
// the document names link to the correct submissions
expect(
within(rateDocsTable).getByRole('link', {
name: 'MCR-MN-0001-SNBC',
})
).toHaveAttribute(
'href',
'/submissions/333b4225-5b49-4e82-aa71-be0d33d7418d'
)
expect(
within(rateDocsTable).getByRole('link', {
name: 'MCR-MN-0002-PMAP',
})
).toHaveAttribute(
'href',
'/submissions/21467dba-6ae8-11ed-a1eb-0242ac120002'
)
})
})

it('does not render shared rate cert info if none are present', async () => {
renderWithProviders(
<RateDetailsSummarySection
documentDateLookupTable={{ previousSubmissionDate: '01/01/01' }}
contract={draftContract}
editNavigateTo="rate-details"
submissionName="MN-PMAP-0001"
statePrograms={statePrograms}
/>,
{
apolloProvider,
}
)
await waitFor(() => {
const rateDocsTable = screen.getByRole('table', {
name: /Rate certification/,
})
expect(
within(rateDocsTable).queryByTestId('tag')
).not.toBeInTheDocument()
expect(
within(rateDocsTable).queryByText('Linked submissions')
).not.toBeInTheDocument()
})
})

it('renders inline error when bulk URL is unavailable', async () => {
const s3Provider = {
...testS3Client(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
Program,
RateRevision,
RateFormData,
HealthPlanPackageStatus,
} from '../../../../../gen/gqlClient'

export type RateDetailsSummarySectionV2Props = {
Expand All @@ -34,6 +35,18 @@ export type RateDetailsSummarySectionV2Props = {
onDocumentError?: (error: true) => void
}

type SharedRateCertDisplay = {
packageId?: string
packageName?: string
}
type PackageNameType = string
type PackageNamesLookupType = {
[id: string]: {
packageName: PackageNameType
status: HealthPlanPackageStatus
}
}

export function renderDownloadButton(
zippedFilesURL: string | undefined | Error
) {
Expand All @@ -57,6 +70,7 @@ export const RateDetailsSummarySectionV2 = ({
submissionName,
statePrograms,
onDocumentError,
isCMSUser,
}: RateDetailsSummarySectionV2Props): React.ReactElement => {
const isSubmitted = contract.status === 'SUBMITTED'
const isEditing = !isSubmitted && editNavigateTo !== undefined
Expand All @@ -70,6 +84,29 @@ export const RateDetailsSummarySectionV2 = ({
const [zippedFilesURL, setZippedFilesURL] = useState<
string | undefined | Error
>(undefined)
const [packageNamesLookup] = React.useState<PackageNamesLookupType | null>(
null
)

const refreshPackagesWithSharedRateCert = (
rateFormData: RateFormData
): SharedRateCertDisplay[] | undefined => {
return rateFormData.packagesWithSharedRateCerts?.map(
({ packageId, packageName }) => {
const refreshedName =
packageId &&
packageNamesLookup &&
packageNamesLookup[packageId]?.packageName
const isDraftText =
isCMSUser && !refreshedName ? ' (Draft)' : ''
return {
packageId,
packageName:
refreshedName ?? `${packageName}${isDraftText}`,
}
}
)
}

const rateCapitationType = (rate: Rate | RateRevision) => {
const rateFormData = getRateFormData(rate)
Expand Down Expand Up @@ -291,6 +328,9 @@ export const RateDetailsSummarySectionV2 = ({
documentDateLookupTable={
documentDateLookupTable
}
packagesWithSharedRateCerts={refreshPackagesWithSharedRateCert(
rateFormData
)}
multipleDocumentsAllowed={false}
caption="Rate certification"
documentCategory="Rate certification"
Expand All @@ -304,6 +344,9 @@ export const RateDetailsSummarySectionV2 = ({
documentDateLookupTable={
documentDateLookupTable
}
packagesWithSharedRateCerts={refreshPackagesWithSharedRateCert(
rateFormData
)}
caption="Rate supporting documents"
isSupportingDocuments
documentCategory="Rate-supporting"
Expand Down
Loading