Skip to content

Commit

Permalink
Wire note and priority
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-learner committed Dec 15, 2024
1 parent afcfd70 commit ec119e2
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/components/LabTest/CreateServiceRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Label } from "../ui/label";
import { RadioGroup, RadioGroupItem } from "../ui/radio-group";
import { Textarea } from "../ui/textarea";
import LabOrderCodeSelect from "./LabOrderCodeSelect";
import { Coding, ServiceRequest } from "./types";
import { Annotation, Coding, ServiceRequest } from "./types";

type CreateServiceRequestProps = {
encounter: ConsultationModel;
Expand All @@ -26,10 +26,21 @@ export default function CreateServiceRequest({
const { t } = useTranslation();

const [code, setCode] = useState<Coding>();
const [note, setNote] = useState<string>();
const [note, setNote] = useState<Annotation[]>([]);
const [priority, setPriority] = useState<ServiceRequest["priority"]>();
const [recurrence, setRecurrence] = useState<unknown>();

const handleNoteChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
const updatedNote: Annotation[] = [
{
text: e.target.value,
authorString: "CurrentUser", // Replace with actual user
time: new Date().toISOString(),
},
];
setNote(updatedNote);
};

return (
<Card className="bg-inherit shadow-none rounded-md">
<CardHeader className="grid gap-3">
Expand All @@ -42,6 +53,7 @@ export default function CreateServiceRequest({
placeholder="Type your note here."
id="note"
className="bg-white"
onChange={handleNoteChange}
/>
</div>
)}
Expand All @@ -53,6 +65,9 @@ export default function CreateServiceRequest({
<RadioGroup
defaultValue={priority}
className="flex items-center gap-3"
onValueChange={(value) =>
setPriority(value as ServiceRequest["priority"])
}
>
{["routine", "urgent", "asap", "stat"].map((value) => (
<div className="flex items-center space-x-1.5">
Expand All @@ -72,7 +87,7 @@ export default function CreateServiceRequest({
<div className="flex items-center gap-2 w-full">
{note === undefined && (
<Button
onClick={() => setNote("")}
onClick={() => setNote([])}
variant="ghost"
className="flex items-center gap-1.5"
>
Expand Down Expand Up @@ -118,6 +133,8 @@ export default function CreateServiceRequest({
code,
subject: encounter.patient,
encounter: encounter.id,
priority,
note,
},
},
);
Expand Down

0 comments on commit ec119e2

Please sign in to comment.