-
Notifications
You must be signed in to change notification settings - Fork 331
Insurance otr 1373 #5255
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
Insurance otr 1373 #5255
Changes from 1 commit
6afd52e
61cb72d
61f65f3
ad85f4d
5748f1f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,11 +121,15 @@ export const parseCoverageEligibilityResponse = ( | |
| (e) => e.url === 'https://extensions.fhir.oystehr.com/raw-response' | ||
| )?.valueString; | ||
| let copay: PatientPaymentBenefit[] | undefined; | ||
| let deductible: PatientPaymentBenefit[] | undefined; | ||
| if (fullBenefitJSON) { | ||
| try { | ||
| // cSpell:disable-next eligibility | ||
| const benefitList = JSON.parse(fullBenefitJSON)?.elig?.benefit; | ||
| copay = parseObjectsToCopayBenefits(benefitList); | ||
| copay = parseObjectsToCopayBenefits(benefitList).filter( | ||
| (benefit) => benefit.coverageCode === 'A' || benefit.coverageCode === 'B' | ||
| ); | ||
| deductible = parseObjectsToCopayBenefits(benefitList).filter((benefit) => benefit.coverageCode === 'C'); | ||
|
||
| } catch (error) { | ||
| console.error('Error parsing fullBenefitJSON', error); | ||
| } | ||
|
|
@@ -134,6 +138,7 @@ export const parseCoverageEligibilityResponse = ( | |
| status: InsuranceEligibilityCheckStatus.eligibilityConfirmed, | ||
| dateISO, | ||
| copay, | ||
| deductible, | ||
| errors: coverageResponse.error, | ||
| }; | ||
| } else { | ||
|
|
@@ -154,17 +159,9 @@ export const parseCoverageEligibilityResponse = ( | |
| }; | ||
|
|
||
| export const parseObjectsToCopayBenefits = (input: any[]): PatientPaymentBenefit[] => { | ||
| const filteredInputs = input.filter((item) => { | ||
| return ( | ||
| item && | ||
| typeof item === 'object' && | ||
| (item['benefit_coverage_code'] === 'B' || item['benefit_coverage_code'] === 'A') | ||
| ); | ||
| }); | ||
|
|
||
| return filteredInputs | ||
| return input | ||
| .map((item) => { | ||
| const benefitCoverageCode = item['benefit_coverage_code'] as 'A' | 'B'; | ||
| const benefitCoverageCode = item['benefit_coverage_code'] as 'A' | 'B' | 'C'; | ||
| const CP: PatientPaymentBenefit = { | ||
| amountInUSD: item['benefit_amount'] ?? 0, | ||
| percentage: item['benefit_percent'] ?? 0, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -188,17 +188,21 @@ export interface CoverageBenefitInfo { | |
|
|
||
| inNetwork: boolean; | ||
| } | ||
| export interface CoinsuranceBenefit extends CoverageBenefitInfo { | ||
| coverageCode: 'A'; | ||
| } | ||
| export interface CopayBenefit extends CoverageBenefitInfo { | ||
| coverageCode: 'B'; | ||
| } | ||
| export interface CoinsuranceBenefit extends CoverageBenefitInfo { | ||
| coverageCode: 'A'; | ||
| export interface DeductibleBenefit extends CoverageBenefitInfo { | ||
| coverageCode: 'C'; | ||
| } | ||
| export type PatientPaymentBenefit = CopayBenefit | CoinsuranceBenefit; | ||
| export type PatientPaymentBenefit = CopayBenefit | CoinsuranceBenefit | DeductibleBenefit; | ||
| export interface InsuranceCheckStatusWithDate { | ||
| status: InsuranceEligibilityCheckStatus; | ||
| dateISO: string; | ||
| copay?: PatientPaymentBenefit[]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't you have stronger types you can use here? There is a "CopayBenefit" in the union type "PatientPaymentBenefit", and likewise with "DeductibleBenefit", but then the "copay" and "deductible" fields can both include their titular type, plus any others in the union. If there is a good reason for this it would be nice to have a comment because this was all reading very clearly to me until i got to this last interface. |
||
| deductible?: PatientPaymentBenefit[]; | ||
| errors?: { code: CodeableConcept }[]; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this to a helper function. It can use
useGetPatientAccountanduseGetPatientCoveragesunder the hood to provide a useful abstraction and to avoid using low-level logic in high-level components.