forked from ohcnetwork/care_fe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HCX Integration - Claims Disabled (ohcnetwork#5108)
Co-authored-by: Mathew Alex <[email protected]> Co-authored-by: rithviknishad <[email protected]> Co-authored-by: Gigin George <[email protected]>
- Loading branch information
1 parent
ef35fd0
commit c1cfd19
Showing
43 changed files
with
2,266 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ jobs: | |
issue_opened_and_reopened: | ||
name: issue_opened_and_reopened | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'issues' && github.event.action == 'opened' || github.event.action == 'reopened' | ||
if: github.repository == 'coronasafe/care_fe' && github.event_name == 'issues' && github.event.action == 'opened' || github.event.action == 'reopened' | ||
steps: | ||
- name: 'Move issue to "Triage"' | ||
uses: leonsteinhaeuser/[email protected] | ||
|
@@ -23,7 +23,7 @@ jobs: | |
issue_closed: | ||
name: issue_closed | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'issues' && github.event.action == 'closed' | ||
if: github.repository == 'coronasafe/care_fe' && github.event_name == 'issues' && github.event.action == 'closed' | ||
steps: | ||
- name: 'Moved issue to "Done"' | ||
uses: leonsteinhaeuser/[email protected] | ||
|
@@ -36,7 +36,7 @@ jobs: | |
issue_assigned: | ||
name: issue_assigned | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'issues' && github.event.action == 'assigned' | ||
if: github.repository == 'coronasafe/care_fe' && github.event_name == 'issues' && github.event.action == 'assigned' | ||
steps: | ||
- name: 'Move issue to "In Progress"' | ||
uses: leonsteinhaeuser/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { useEffect } from "react"; | ||
|
||
type onMessage = (data: any) => void; | ||
|
||
export const useMessageListener = (onMessage: onMessage) => { | ||
useEffect(() => { | ||
const handleMessage = (e: MessageEvent) => { | ||
onMessage(e.data); | ||
}; | ||
navigator.serviceWorker.addEventListener("message", handleMessage); | ||
|
||
return () => { | ||
navigator.serviceWorker.removeEventListener("message", handleMessage); | ||
}; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/Components/Common/PMJAYProcedurePackageAutocomplete.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { useAsyncOptions } from "../../Common/hooks/useAsyncOptions"; | ||
import { listPMJYPackages } from "../../Redux/actions"; | ||
import { Autocomplete } from "../Form/FormFields/Autocomplete"; | ||
import FormField from "../Form/FormFields/FormField"; | ||
import { | ||
FormFieldBaseProps, | ||
useFormFieldPropsResolver, | ||
} from "../Form/FormFields/Utils"; | ||
|
||
type PMJAYPackageItem = { | ||
name?: string; | ||
code?: string; | ||
price?: number; | ||
package_name?: string; | ||
}; | ||
|
||
type Props = FormFieldBaseProps<PMJAYPackageItem>; | ||
|
||
export default function PMJAYProcedurePackageAutocomplete(props: Props) { | ||
const field = useFormFieldPropsResolver(props as any); | ||
|
||
const { fetchOptions, isLoading, options } = | ||
useAsyncOptions<PMJAYPackageItem>("code"); | ||
|
||
return ( | ||
<FormField field={field}> | ||
<Autocomplete | ||
required | ||
id={field.id} | ||
disabled={field.disabled} | ||
value={field.value} | ||
onChange={field.handleChange} | ||
options={options(field.value ? [field.value] : []).map((o) => { | ||
// TODO: update backend to return price as number instead | ||
return { | ||
...o, | ||
price: | ||
o.price && parseFloat(o.price?.toString().replaceAll(",", "")), | ||
}; | ||
})} | ||
optionLabel={optionLabel} | ||
optionDescription={optionDescription} | ||
optionValue={(option) => option} | ||
onQuery={(query) => fetchOptions(listPMJYPackages(query))} | ||
isLoading={isLoading} | ||
/> | ||
</FormField> | ||
); | ||
} | ||
|
||
const optionLabel = (option: PMJAYPackageItem) => { | ||
if (option.name) return option.name; | ||
if (option.package_name) return `${option.package_name} (Package)`; | ||
return "Unknown"; | ||
}; | ||
|
||
const optionDescription = (option: PMJAYPackageItem) => { | ||
const code = option.code || "Unknown"; | ||
const packageName = option.package_name || "Unknown"; | ||
return `Package: ${packageName} (${code})`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { useCallback, useEffect, useState } from "react"; | ||
import { useDispatch } from "react-redux"; | ||
import { HCXActions } from "../../Redux/actions"; | ||
import PageTitle from "../Common/PageTitle"; | ||
import ClaimDetailCard from "../HCX/ClaimDetailCard"; | ||
import CreateClaimCard from "../HCX/CreateClaimCard"; | ||
import { HCXClaimModel } from "../HCX/models"; | ||
import { useMessageListener } from "../../Common/hooks/useMessageListener"; | ||
import { navigate } from "raviger"; | ||
import * as Notification from "../../Utils/Notifications"; | ||
|
||
interface Props { | ||
facilityId: string; | ||
patientId: string; | ||
consultationId: string; | ||
} | ||
|
||
export default function ConsultationClaims({ | ||
facilityId, | ||
consultationId, | ||
patientId, | ||
}: Props) { | ||
const dispatch = useDispatch<any>(); | ||
const [claims, setClaims] = useState<HCXClaimModel[]>(); | ||
const [isCreateLoading, setIsCreateLoading] = useState(false); | ||
|
||
const fetchClaims = useCallback(async () => { | ||
const res = await dispatch( | ||
HCXActions.claims.list({ | ||
ordering: "-modified_date", | ||
consultation: consultationId, | ||
}) | ||
); | ||
|
||
if (res.data && res.data.results) { | ||
setClaims(res.data.results); | ||
if (isCreateLoading) | ||
Notification.Success({ msg: "Fetched Claim Approval Results" }); | ||
} else { | ||
if (isCreateLoading) | ||
Notification.Success({ msg: "Error Fetched Claim Approval Results" }); | ||
} | ||
setIsCreateLoading(false); | ||
}, [dispatch, consultationId]); | ||
|
||
useEffect(() => { | ||
fetchClaims(); | ||
}, [fetchClaims]); | ||
|
||
useMessageListener((data) => { | ||
if ( | ||
data.type === "MESSAGE" && | ||
(data.from === "claim/on_submit" || data.from === "preauth/on_submit") && | ||
data.message === "success" | ||
) { | ||
fetchClaims(); | ||
} | ||
}); | ||
|
||
return ( | ||
<div className="pb-2 relative flex flex-col"> | ||
<PageTitle | ||
title="Claims" | ||
className="pl-6 flex-grow-0" | ||
onBackClick={() => { | ||
navigate( | ||
`/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}` | ||
); | ||
return false; | ||
}} | ||
/> | ||
|
||
<div className="flex flex-col justify-center gap-16 w-full max-w-5xl mx-auto"> | ||
<div className="p-8 bg-white rounded-lg"> | ||
<CreateClaimCard | ||
consultationId={consultationId} | ||
patientId={patientId} | ||
isCreating={isCreateLoading} | ||
setIsCreating={setIsCreateLoading} | ||
/> | ||
</div> | ||
|
||
<div className="flex flex-col gap-8 w-full max-w-3xl mx-auto"> | ||
{claims?.map((claim) => ( | ||
<div className="p-8 bg-white rounded-lg"> | ||
<ClaimDetailCard claim={claim} /> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.