Skip to content
Open
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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"cmdk": "^1.1.1",
"date-fns": "^4.1.0",
"dayjs": "^1.11.13",
"hi-profiles": "^2.2.0",
"hi-profiles": "^2.3.0",
"input-otp": "^1.4.2",
"lucide-react": "^0.487.0",
"qrcode.react": "^4.2.0",
Expand All @@ -56,15 +56,15 @@
"@tailwindcss/vite": "^4.1.3",
"@tanstack/eslint-plugin-query": "^5.72.2",
"@types/node": "^22.14.1",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"@types/react": "^19.1.1",
"@types/react-dom": "^19.1.2",
"@vitejs/plugin-react": "^4.3.4",
"eslint": "^9.24.0",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^16.0.0",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"tailwindcss": "^4.1.3",
"typescript": "~5.8.3",
"typescript-eslint": "^8.29.1",
Expand Down
14 changes: 14 additions & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@
"consent__status__GRANTED": "Granted",
"consent__status__REQUESTED": "Requested",
"consent__status__REVOKED": "Revoked",
"valid_till": "Valid until {{date}}",
"consent_records_date_range": "Records requested from {{from}} to {{to}}",
"hi_types": "HI Types",
"artefact_status__waiting": "Waiting",
"artefact_status__fetched": "Fetched",
"unknown_facility": "Unknown Facility",
"view": "View",
"status": "Status",
"expand": "Expand",
"collapse": "Collapse",
"consent_request__date_range": "Health Records Date Range",
"consent_request__expiry": "Consent Expiry Date",
"consent_request__hi_types": "Health Information Types",
Expand All @@ -55,6 +65,7 @@
"abha__disclaimer_5": "I, {{user}}, confirm that I have duly informed and explained the beneficiary of the contents of consent for aforementioned purposes.",
"abha__disclaimer_6": "I, <input />, have been explained about the consent as stated above and hereby provide my consent for the aforementioned purposes.",
"abha__qr_scanning_error": "Error scanning QR code, Invalid QR code",
"abha_account": "ABHA Account",
"abha_address": "ABHA Address",
"abha_address_created_error": "Failed to create Abha Address. Please try again later.",
"abha_address_created_success": "Abha Address has been created successfully.",
Expand All @@ -81,6 +92,8 @@
"abha_number_exists_description": "There is an ABHA Number already linked with the given Aadhaar Number, Do you want to create a new ABHA Address?",
"abha_number_linked_successfully": "ABHA Number has been linked successfully.",
"abha_profile": "ABHA Profile",
"choose_abha_account": "Choose an ABHA Account",
"choose_abha_account_description": "Multiple ABHA accounts are linked. Select the one you want to link.",
"send_otp": "Send OTP",
"resend_otp": "Resend OTP",
"verify_otp": "Verify OTP",
Expand Down Expand Up @@ -114,6 +127,7 @@
"checking_consent_status": "Consent request status is being checked!",
"async_operation_warning": "This operation may take some time. Please check back later.",
"loading_health_information": "Loading Health Information",
"back": "Back",
"configure_health_facility": "Configure Health Facility",
"configure_health_facility_description": "Configure the health facility, link your ABDM health facility with care and register it as a service in bridge",
"generate_scan_and_share_qr": "Generate Scan and Share QR",
Expand Down
19 changes: 17 additions & 2 deletions src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "@/types/consent";
import { queryString, request } from "./request";

import { AbhaNumber } from "@/types/abhaNumber";
import { AbhaLoginAccount, AbhaNumber } from "@/types/abhaNumber";
import { GovtOrganization } from "@/types/govtOrganization";
import { HealthFacility } from "@/types/healthFacility";
import { HealthInformation } from "@/types/healthInformation";
Expand All @@ -22,6 +22,7 @@ export const apis = {
list: async (query?: {
facility?: string;
patient?: string;
encounter?: string;
ordering?: string;
}) => {
return await request<PaginatedResponse<ConsentRequest>>(
Expand All @@ -31,6 +32,7 @@ export const apis = {

create: async (body: {
patient_abha: string;
encounter: string;
hi_types: ConsentHIType[];
purpose: ConsentPurpose;
from_time: Date | string;
Expand Down Expand Up @@ -347,11 +349,24 @@ export const apis = {
otp: string;
transaction_id: string;
otp_system: "abdm" | "aadhaar";
}) => {
return await request<{
transaction_id: string;
accounts: AbhaLoginAccount[];
}>("/api/abdm/v3/health_id/login/verify_otp/", {
method: "POST",
body: JSON.stringify(body),
});
},

abhaLoginVerifyUser: async (body: {
transaction_id: string;
account_id: number;
}) => {
return await request<{
abha_number: AbhaNumber;
created: boolean;
}>("/api/abdm/v3/health_id/login/verify_otp/", {
}>("/api/abdm/v3/health_id/login/verify_user/", {
method: "POST",
body: JSON.stringify(body),
});
Expand Down
52 changes: 28 additions & 24 deletions src/components/CreateConsentRequestForm.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import dayjs from "@/lib/dayjs";

import { zodResolver } from "@hookform/resolvers/zod";
import { useMutation } from "@tanstack/react-query";
import { FC } from "react";
import { useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { z } from "zod";
import {
CONSENT_HI_TYPES,
CONSENT_PURPOSES,
ConsentRequest,
} from "@/types/consent";
import {
Form,
FormControl,
Expand All @@ -14,30 +11,35 @@ import {
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { toast } from "@/lib/utils";
import { apis } from "@/apis";
import { AbhaNumber } from "@/types/abhaNumber";
import {
CONSENT_HI_TYPES,
CONSENT_PURPOSES,
ConsentRequest,
} from "@/types/consent";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { DatePickerWithRange } from "./ui/date-range-picker";

import { AbhaNumber } from "@/types/abhaNumber";
import { Button } from "@/components/ui/button";
import { DatePicker } from "./ui/date-picker";
import { MultiSelect } from "./ui/multi-select";
import { DatePickerWithRange } from "./ui/date-range-picker";
import { Encounter } from "@/types/encounter";
import { FC } from "react";
import { I18NNAMESPACE } from "@/lib/constants";
import { Input } from "@/components/ui/input";
import { MultiSelect } from "./ui/multi-select";
import { apis } from "@/apis";
import dayjs from "@/lib/dayjs";
import { toast } from "@/lib/utils";
import { useForm } from "react-hook-form";
import { useMutation } from "@tanstack/react-query";
import { useTranslation } from "react-i18next";
import { z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod";

type CreateConsentRequestFormProps = {
abhaNumber?: AbhaNumber;
encounter: Encounter;
onSuccess?: (consentRequest: ConsentRequest) => void;
};

Expand All @@ -58,6 +60,7 @@ type CreateConsentRequestFormValues = z.infer<

const CreateConsentRequestForm: FC<CreateConsentRequestFormProps> = ({
abhaNumber,
encounter,
onSuccess,
}) => {
const { t } = useTranslation(I18NNAMESPACE);
Expand All @@ -76,7 +79,7 @@ const CreateConsentRequestForm: FC<CreateConsentRequestFormProps> = ({
},
});

const createConsentRequestOtpMutation = useMutation({
const createConsentRequestMutation = useMutation({
mutationFn: apis.consent.create,
onSuccess: (data) => {
toast.success(t("consent_requested_successfully"));
Expand All @@ -85,9 +88,10 @@ const CreateConsentRequestForm: FC<CreateConsentRequestFormProps> = ({
});

function onSubmit(values: CreateConsentRequestFormValues) {
createConsentRequestOtpMutation.mutate({
createConsentRequestMutation.mutate({
...values,
patient_abha: form.getValues("patient_abha"),
encounter: encounter.id,
from_time: values.time_range.from,
to_time: values.time_range.to,
});
Expand Down Expand Up @@ -184,7 +188,7 @@ const CreateConsentRequestForm: FC<CreateConsentRequestFormProps> = ({
render={({ field }) => (
<FormItem className="flex flex-col">
<FormLabel>{t("consent_request__expiry")}</FormLabel>
<DatePicker value={field.value} onChange={field.onChange} />
<DatePicker date={field.value} onChange={field.onChange} />
<FormMessage />
</FormItem>
)}
Expand All @@ -193,7 +197,7 @@ const CreateConsentRequestForm: FC<CreateConsentRequestFormProps> = ({
<Button
type="submit"
variant="default"
loading={createConsentRequestOtpMutation.isPending}
loading={createConsentRequestMutation.isPending}
>
{t("request_consent")}
</Button>
Expand Down
Loading
Loading