generated from t3-oss/create-t3-turbo
-
-
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.
patient can provide their subscriber id and payor id to get insurance…
… in canvas
- Loading branch information
1 parent
419603e
commit cc11bf8
Showing
7 changed files
with
276 additions
and
36 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
137 changes: 137 additions & 0 deletions
137
apps/nextjs/src/app/(authenticated)/onboarding/_components/coverage-form.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,137 @@ | ||
"use client"; | ||
|
||
import { useRouter } from "next/navigation"; | ||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import { useForm } from "react-hook-form"; | ||
|
||
import { coverageFormSchema } from "@acme/api/src/validators"; | ||
import type { CoverageForm } from "@acme/api/src/validators"; | ||
import { Button } from "@acme/ui/button"; | ||
import { | ||
Form, | ||
FormControl, | ||
FormDescription, | ||
FormField, | ||
FormItem, | ||
FormLabel, | ||
FormMessage, | ||
} from "@acme/ui/form"; | ||
import { Input } from "@acme/ui/input"; | ||
import { useToast } from "@acme/ui/use-toast"; | ||
|
||
import { api } from "~/trpc/react"; | ||
|
||
export function CoverageForm(props: { onSuccess?: () => void }) { | ||
const router = useRouter(); | ||
const toaster = useToast(); | ||
|
||
const mutation = api.canvas.submitCoverage.useMutation({ | ||
onSuccess: (data) => { | ||
toaster.toast({ | ||
title: "You submitted the following values:", | ||
description: ( | ||
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4"> | ||
<code className="text-white">{JSON.stringify(data, null, 2)}</code> | ||
</pre> | ||
), | ||
}); | ||
|
||
// Call the passed onSuccess prop if it exists | ||
if (props.onSuccess) { | ||
props.onSuccess(); | ||
} | ||
}, | ||
onError: (error) => { | ||
// Show an error toast | ||
toaster.toast({ | ||
title: "Error submitting consent", | ||
description: "An issue occurred while submitting. Please try again.", | ||
variant: "destructive", | ||
}); | ||
}, | ||
}); | ||
|
||
const form = useForm<CoverageForm>({ | ||
resolver: zodResolver(coverageFormSchema), | ||
}); | ||
|
||
function onSubmit(data: CoverageForm) { | ||
const requestBody = { | ||
status: "active", | ||
subscriber: { | ||
reference: `Patient/b685d0d97f604e1fb60f9ed089abc410`, | ||
}, | ||
subscriberId: `${data.subscriberId}`, | ||
beneficiary: { | ||
reference: `Patient/b685d0d97f604e1fb60f9ed089abc410`, | ||
}, | ||
relationship: { | ||
coding: [ | ||
{ | ||
system: "http://hl7.org/fhir/ValueSet/subscriber-relationship", | ||
code: "self", | ||
}, | ||
], | ||
}, | ||
payor: [ | ||
{ | ||
identifier: { | ||
system: "https://www.claim.md/services/era/", | ||
value: `${data.payorId}`, | ||
}, | ||
display: "Insurer company name", | ||
}, | ||
], | ||
order: 1, | ||
}; | ||
|
||
// Submit coverage | ||
mutation.mutate({ | ||
query: {}, | ||
body: requestBody, | ||
}); | ||
|
||
toaster.toast({ | ||
title: "You submitted the following values:", | ||
description: ( | ||
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4"> | ||
<code className="text-white">{JSON.stringify(data, null, 2)}</code> | ||
</pre> | ||
), | ||
}); | ||
} | ||
|
||
return ( | ||
<Form {...form}> | ||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6"> | ||
<FormField | ||
control={form.control} | ||
name="subscriberId" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>{`Subscriber ID`}</FormLabel> | ||
<FormControl> | ||
<Input placeholder="" {...field} /> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<FormField | ||
control={form.control} | ||
name="payorId" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>{`Payor ID`}</FormLabel> | ||
<FormControl> | ||
<Input placeholder="" {...field} /> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<Button type="submit">Submit</Button> | ||
</form> | ||
</Form> | ||
); | ||
} |
60 changes: 60 additions & 0 deletions
60
apps/nextjs/src/app/(authenticated)/onboarding/_components/coverage.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,60 @@ | ||
"use client"; | ||
|
||
import { useRouter } from "next/navigation"; | ||
import { motion } from "framer-motion"; | ||
import { Balancer } from "react-wrap-balancer"; | ||
|
||
import { CoverageForm } from "./coverage-form"; | ||
|
||
export default function Coverage() { | ||
const router = useRouter(); | ||
|
||
return ( | ||
<motion.div | ||
className="my-auto flex h-full w-full flex-col items-center justify-center" | ||
exit={{ opacity: 0, scale: 0.95 }} | ||
transition={{ duration: 0.3, type: "spring" }} | ||
> | ||
<motion.div | ||
variants={{ | ||
show: { | ||
transition: { | ||
staggerChildren: 0.2, | ||
}, | ||
}, | ||
}} | ||
initial="hidden" | ||
animate="show" | ||
className="flex flex-col rounded-xl bg-background/60 p-8" | ||
> | ||
<motion.h1 | ||
className="mb-4 font-cal text-2xl font-bold transition-colors sm:text-3xl" | ||
variants={{ | ||
hidden: { opacity: 0, x: 250 }, | ||
show: { | ||
opacity: 1, | ||
x: 0, | ||
transition: { duration: 0.4, type: "spring" }, | ||
}, | ||
}} | ||
> | ||
<Balancer>{`Converage`}</Balancer> | ||
</motion.h1> | ||
<motion.div | ||
variants={{ | ||
hidden: { opacity: 0, x: 100 }, | ||
show: { | ||
opacity: 1, | ||
x: 0, | ||
transition: { duration: 0.4, type: "spring" }, | ||
}, | ||
}} | ||
> | ||
<CoverageForm | ||
onSuccess={() => router.push("/onboarding?step=consent")} | ||
/> | ||
</motion.div> | ||
</motion.div> | ||
</motion.div> | ||
); | ||
} |
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