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

Clean Refactor Scribe as MFE | Support for Questionnaires #9636

Open
wants to merge 41 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
cc09a00
Scribe for Questionnaire
shivankacker Dec 26, 2024
5455150
added cui support for shadcn components
shivankacker Dec 28, 2024
2a55a9e
fix merge conflicts
shivankacker Dec 28, 2024
71fb36b
structured inputs
shivankacker Dec 28, 2024
cc2e16f
fix merge conflicts
shivankacker Dec 28, 2024
470571b
Merge branch 'form-field-v1' of https://github.com/ohcnetwork/care_fe…
shivankacker Dec 29, 2024
0be90e6
fix merge conflicts
shivankacker Dec 29, 2024
35876be
support for other fields
shivankacker Dec 30, 2024
efa2f47
finishing up
shivankacker Dec 31, 2024
719ab94
rebase to develop
shivankacker Dec 31, 2024
b964266
cleanup
shivankacker Dec 31, 2024
cff9c80
Init
shivankacker Dec 31, 2024
be083d4
Shifted structured prompts to scribe
shivankacker Jan 1, 2025
626b8b9
updates
shivankacker Jan 2, 2025
fd7c909
changed state on injection
shivankacker Jan 2, 2025
a279cd2
Update Prompts; Add env
gigincg Jan 2, 2025
77e7e1b
Merge branch 'develop' into form-field-scribe
gigincg Jan 2, 2025
b85c900
Merge branch 'develop' into form-field-scribe
gigincg Jan 2, 2025
bd5d914
Minor CHanges
gigincg Jan 2, 2025
53e37a9
Fix Issues with AllergyQuestion
gigincg Jan 2, 2025
62754a9
fix merge conlicts
shivankacker Jan 2, 2025
3908e18
Merge branch 'develop' into form-field-scribe
gigincg Jan 2, 2025
ab34a7f
Merge branch 'develop' into form-field-scribe
gigincg Jan 2, 2025
f057eaa
Removed value injectors from structured inputs
shivankacker Jan 2, 2025
f926948
cleanup
shivankacker Jan 2, 2025
7cc5e59
Working Demo
gigincg Jan 3, 2025
fef419a
fix merge conflicts
shivankacker Jan 7, 2025
e98095b
fix merge conflicts
shivankacker Jan 7, 2025
af626a2
removed all value injectors everywhere
shivankacker Jan 7, 2025
13fa3b7
fix merge conflicts
shivankacker Jan 7, 2025
e1c36c8
more cleanup
shivankacker Jan 7, 2025
a7a6d4c
more cleanup
shivankacker Jan 7, 2025
a0ac2ac
updated encounter question to update on formstate
shivankacker Jan 7, 2025
fffa67e
Merge branch 'develop' into scribe-exit
shivankacker Jan 7, 2025
e45f502
cleanup and temp fix to get deploy preview running
shivankacker Jan 8, 2025
9bbc954
Merge branch 'scribe-exit' of https://github.com/ohcnetwork/care_fe i…
shivankacker Jan 8, 2025
c972f4a
Merge branch 'develop' of https://github.com/ohcnetwork/care_fe into …
shivankacker Jan 8, 2025
455a043
temp fixes to plugin setup
shivankacker Jan 8, 2025
38b5a2a
more temp changes
shivankacker Jan 8, 2025
5b41ef1
fixed allergy not getting updated when formstate changes
shivankacker Jan 9, 2025
57167c7
remove console log
shivankacker Jan 9, 2025
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
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ ESLINT_NO_DEV_ERRORS=true
CARE_CDN_URL="https://egov-s3-facility-10bedicu.s3.amazonaws.com https://egov-s3-patient-data-10bedicu.s3.amazonaws.com http://localhost:4566"
REACT_ALLOWED_LOCALES="en,hi,ta,ml,mr,kn"

REACT_ENABLED_APPS=""
REACT_ENABLED_APPS="care-scribe-fe.pages.dev/ohcnetwork/care_scribe_fe"
shivankacker marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,4 @@
"node": ">=22.8.0"
},
"packageManager": "[email protected]"
}
}
9 changes: 0 additions & 9 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@
"auth_method_unsupported": "This authentication method is not supported, please try a different method",
"authorize_shift_delete": "Authorize shift delete",
"auto_generated_for_care": "Auto Generated for Care",
"autofilled_fields": "Autofilled Fields",
"available_features": "Available Features",
"available_in": "Available in",
"available_time_slots": "Available Time Slots",
Expand Down Expand Up @@ -626,9 +625,7 @@
"continue_watching": "Continue watching",
"contribute_github": "Contribute on Github",
"copied_to_clipboard": "Copied to clipboard",
"copilot_thinking": "Copilot is thinking...",
"copy_phone_number": "Copy Phone Number",
"could_not_autofill": "We could not autofill any fields from what you said",
"could_not_load_page": "We are facing some difficulties showing the Page you were looking for. Our Engineers have been notified and we'll make sure that this is resolved on the fly!",
"countries_travelled": "Countries travelled",
"covid_19_cat_gov": "Covid_19 Clinical Category as per Govt. of Kerala guideline (A/B/C)",
Expand Down Expand Up @@ -1486,7 +1483,6 @@
"prn_prescriptions": "PRN Prescriptions",
"procedure_suggestions": "Procedure Suggestions",
"procedures_select_placeholder": "Select procedures to add details",
"process_transcript": "Process Again",
"professional_info": "Professional Information",
"professional_info_note": "View or update user's professional information",
"professional_info_note_self": "View or update your professional information",
Expand Down Expand Up @@ -1709,7 +1705,6 @@
"start_consultation": "Start Consultation",
"start_datetime": "Start Date/Time",
"start_dosage": "Start Dosage",
"start_review": "Start Review",
"state": "State",
"status": "Status",
"stop": "Stop",
Expand Down Expand Up @@ -1758,9 +1753,6 @@
"total_patients": "Total Patients",
"total_staff": "Total Staff",
"total_users": "Total Users",
"transcribe_again": "Transcribe Again",
"transcript_edit_info": "You can update this if we made an error",
"transcript_information": "This is what we heard",
"transfer_allowed": "Transfer Allowed",
"transfer_blocked": "Transfer Blocked",
"transfer_in_progress": "TRANSFER IN PROGRESS",
Expand Down Expand Up @@ -1909,7 +1901,6 @@
"vitals": "Vitals",
"vitals_monitor": "Vitals Monitor",
"vitals_present": "Vitals Monitor present",
"voice_autofill": "Voice Autofill",
"volunteer_assigned": "Volunteer assigned successfully",
"volunteer_contact": "Volunteer Contact",
"volunteer_contact_detail": "Provide the name and contact details of a volunteer who can assist the patient in emergencies. This should be someone outside the family.",
Expand Down
55 changes: 0 additions & 55 deletions src/Utils/useValueInjectionObserver.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions src/components/Common/DateInputV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import DateTextInput from "@/components/Common/DateTextInput";

import * as Notification from "@/Utils/Notifications";
import dayjs from "@/Utils/dayjs";
import { useValueInjectionObserver } from "@/Utils/useValueInjectionObserver";
import { classNames } from "@/Utils/utils";

type DatePickerType = "date" | "month" | "year";
Expand Down Expand Up @@ -65,7 +64,6 @@ const DateInputV2: React.FC<Props> = ({
const minutes = dayjs(value).minute();
const ampm = dayjs(value).hour() > 11 ? "PM" : "AM";

const dateInputRef = useRef<HTMLDivElement>(null);
const hourScrollerRef = useRef<HTMLDivElement>(null);
const minuteScrollerRef = useRef<HTMLDivElement>(null);

Expand Down Expand Up @@ -351,25 +349,10 @@ const DateInputV2: React.FC<Props> = ({
return `${right ? "sm:-translate-x-1/2" : ""} ${top ? "md:-translate-y-[calc(100%+50px)]" : ""} ${right ? "max-sm:-translate-x-1/2" : ""} ${top ? "max-sm:-translate-y-[calc(100%+50px)]" : ""}`.trim();
};

const domValue = useValueInjectionObserver<string>({
targetElement: dateInputRef.current,
attribute: "data-cui-dateinput-value",
});

useEffect(() => {
if (value !== domValue && typeof domValue !== "undefined")
onChange(dayjs(domValue).toDate());
}, [domValue]);

return (
<div>
<div
ref={dateInputRef}
className={`${containerClassName ?? "container mx-auto text-black"}`}
data-cui-dateinput
data-cui-dateinput-value={JSON.stringify(
dayjs(value).format("YYYY-MM-DDTHH:mm"),
)}
>
<Popover className="relative">
{({ open, close }) => {
Expand Down
20 changes: 1 addition & 19 deletions src/components/Form/FormFields/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ComboboxOption,
ComboboxOptions,
} from "@headlessui/react";
import { ReactNode, useEffect, useRef, useState } from "react";
import { ReactNode, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";

import CareIcon from "@/CAREUI/icons/CareIcon";
Expand All @@ -18,7 +18,6 @@ import {
} from "@/components/Form/FormFields/Utils";
import { dropdownOptionClassNames } from "@/components/Form/MultiSelectMenuV2";

import { useValueInjectionObserver } from "@/Utils/useValueInjectionObserver";
import { classNames } from "@/Utils/utils";

type OptionCallback<T, R> = (option: T) => R;
Expand Down Expand Up @@ -114,7 +113,6 @@ type AutocompleteProps<T, V = T> = {
export const Autocomplete = <T, V>(props: AutocompleteProps<T, V>) => {
const { t } = useTranslation();
const [query, setQuery] = useState(""); // Ensure lower case
const menuRef = useRef<HTMLDivElement>(null);

useEffect(() => {
props.onQuery?.(query);
Expand Down Expand Up @@ -165,30 +163,14 @@ export const Autocomplete = <T, V>(props: AutocompleteProps<T, V>) => {
? options.filter((o) => o.search.includes(query))
: options;

const domValue = useValueInjectionObserver<V>({
targetElement: menuRef.current,
attribute: "data-cui-listbox-value",
});

useEffect(() => {
if (props.value !== domValue && typeof domValue !== "undefined")
props.onChange(domValue);
}, [domValue]);

return (
<div
ref={menuRef}
className={
props.requiredError || props.error
? "rounded border border-red-500 " + props.className
: props.className
}
id={props.id}
data-cui-listbox
data-cui-listbox-options={JSON.stringify(
options.map((option) => [option.value, option.label?.toString()]),
)}
data-cui-listbox-value={JSON.stringify(props.value)}
>
<Combobox
immediate
Expand Down
26 changes: 2 additions & 24 deletions src/components/Form/SelectMenuV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import {
ListboxOption,
ListboxOptions,
} from "@headlessui/react";
import { ReactNode, useEffect, useRef } from "react";
import { ReactNode } from "react";

import CareIcon from "@/CAREUI/icons/CareIcon";

import { dropdownOptionClassNames } from "@/components/Form/MultiSelectMenuV2";

import { useValueInjectionObserver } from "@/Utils/useValueInjectionObserver";
import { classNames } from "@/Utils/utils";

type OptionCallback<T, R> = (option: T) => R;
Expand Down Expand Up @@ -55,8 +54,6 @@ type SelectMenuProps<T, V = T> = {
* customizability.
*/
const SelectMenuV2 = <T, V>(props: SelectMenuProps<T, V>) => {
const menuRef = useRef<HTMLDivElement>(null);

const valueOptions = props.options.map((option) => {
const label = props.optionLabel(option);
return {
Expand Down Expand Up @@ -92,27 +89,8 @@ const SelectMenuV2 = <T, V>(props: SelectMenuProps<T, V>) => {

const value = options.find((o) => props.value == o.value) ?? defaultOption;

const domValue = useValueInjectionObserver<V>({
targetElement: menuRef.current,
attribute: "data-cui-listbox-value",
});

useEffect(() => {
if (props.value !== domValue && typeof domValue !== "undefined")
props.onChange(domValue);
}, [domValue]);

return (
<div
className={props.className}
ref={menuRef}
id={props.id}
data-cui-listbox
data-cui-listbox-options={JSON.stringify(
options.map((option) => [option.value, option.label?.toString()]),
)}
data-cui-listbox-value={JSON.stringify(props.value)}
>
<div className={props.className} id={props.id}>
<Listbox
disabled={props.disabled || valueOptions?.length === 0}
value={value}
Expand Down
73 changes: 28 additions & 45 deletions src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,64 +62,47 @@ export function EncounterQuestion({
enabled: !!encounterId,
});

const [encounter, setEncounter] = useState<EncounterEditRequest>(() => {
if (!encounterData) {
shivankacker marked this conversation as resolved.
Show resolved Hide resolved
return {
status: "unknown" as EncounterStatus,
encounter_class: "amb" as EncounterClass,
period: {
start: new Date().toISOString(),
end: undefined,
},
priority: "routine" as EncounterPriority,
external_identifier: "",
hospitalization: {
re_admission: false,
admit_source: "other" as EncounterAdmitSources,
discharge_disposition: "home" as EncounterDischargeDisposition,
diet_preference: "none" as EncounterDietPreference,
},
facility: "",
patient: "",
organizations: [],
};
}
return {
status: encounterData.status,
encounter_class: encounterData.encounter_class,
period: encounterData.period,
priority: encounterData.priority,
external_identifier: encounterData.external_identifier || "",
hospitalization: encounterData.hospitalization,
facility: encounterData.facility.id,
patient: encounterData.patient.id,
organizations: [],
};
const [encounter, setEncounter] = useState<EncounterEditRequest>({
status: "unknown" as EncounterStatus,
encounter_class: "amb" as EncounterClass,
period: {
start: new Date().toISOString(),
end: undefined,
},
priority: "routine" as EncounterPriority,
external_identifier: "",
hospitalization: {
re_admission: false,
admit_source: "other" as EncounterAdmitSources,
discharge_disposition: "home" as EncounterDischargeDisposition,
diet_preference: "none" as EncounterDietPreference,
},
facility: "",
patient: "",
organizations: [],
});

// Update encounter state when data is loaded
useEffect(() => {
if (encounterData) {
setEncounter({
status: encounterData.status,
encounter_class: encounterData.encounter_class,
period: encounterData.period,
priority: encounterData.priority,
external_identifier: encounterData.external_identifier || "",
hospitalization: encounterData.hospitalization,
facility: encounterData.facility.id,
patient: encounterData.patient.id,
organizations: [],
});
handleUpdateEncounter(encounterData as unknown as EncounterEditRequest);
}
}, [encounterData]);

useEffect(() => {
const formStateValue = (questionnaireResponse.values[0]?.value as any)?.[0];
if (formStateValue) {
setEncounter(() => ({
...formStateValue,
}));
}
}, [questionnaireResponse]);

const handleUpdateEncounter = (
updates: Partial<Omit<EncounterEditRequest, "organizations" | "patient">>,
) => {
clearError();
const newEncounter = { ...encounter, ...updates };
setEncounter(newEncounter);

// Create the full encounter request object
const encounterRequest: EncounterEditRequest = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export function QuestionInput({

return (
<div key={index} className="mt-2 gap-2 flex items-end">
<div className="flex-1 space-y-1">
<div className="flex-1 space-y-1" data-question-id={question.id}>
{index === 0 && <QuestionLabel question={question} />}
{renderSingleInput(index)}
</div>
Expand Down
Loading
Loading