From 889df5a720c5bf934843512dbc12cb97d75123c1 Mon Sep 17 00:00:00 2001 From: Aditya Shah Date: Mon, 8 Dec 2025 14:13:14 +0530 Subject: [PATCH 1/6] adds quickmed boolean in prescription model --- server/models/Appointment/Prescription.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/models/Appointment/Prescription.js b/server/models/Appointment/Prescription.js index a3fb23b..82076b6 100644 --- a/server/models/Appointment/Prescription.js +++ b/server/models/Appointment/Prescription.js @@ -37,6 +37,7 @@ const prescriptionSchema = new mongoose.Schema({ followUpDate: { type: Date }, isDigitalSignature: { type: Boolean, default: false }, signature: { type: String }, + quickmed: { type: Boolean, default: false }, }); export default mongoose.model('Prescription', prescriptionSchema); From 65320d76c91af16b7db019f01a4eac73b362f646 Mon Sep 17 00:00:00 2001 From: Aditya Shah Date: Mon, 8 Dec 2025 14:17:58 +0530 Subject: [PATCH 2/6] adds quickmed boolean in prescription model --- server/models/Appointment/Prescription.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/models/Appointment/Prescription.js b/server/models/Appointment/Prescription.js index 82076b6..1df57b3 100644 --- a/server/models/Appointment/Prescription.js +++ b/server/models/Appointment/Prescription.js @@ -25,6 +25,7 @@ const prescriptionSchema = new mongoose.Schema({ frequency: { type: String, required: true }, duration: { type: String, required: true }, instructions: { type: String }, + quickmed: { type: Boolean, default: false }, }, ], tests: [ @@ -37,7 +38,6 @@ const prescriptionSchema = new mongoose.Schema({ followUpDate: { type: Date }, isDigitalSignature: { type: Boolean, default: false }, signature: { type: String }, - quickmed: { type: Boolean, default: false }, }); export default mongoose.model('Prescription', prescriptionSchema); From 58a8d1d5e6d786eccc76d868959e8aee0774c7ae Mon Sep 17 00:00:00 2001 From: Aditya Shah Date: Mon, 8 Dec 2025 14:24:54 +0530 Subject: [PATCH 3/6] adds method for fetching medicine suggestion --- .../src/pages/doctor/AppointmentDetails.jsx | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/client/src/pages/doctor/AppointmentDetails.jsx b/client/src/pages/doctor/AppointmentDetails.jsx index cdc0ea4..bdae96b 100644 --- a/client/src/pages/doctor/AppointmentDetails.jsx +++ b/client/src/pages/doctor/AppointmentDetails.jsx @@ -25,11 +25,13 @@ import { getAppointmentPrescription, updatePrescription, } from '../../service/prescriptionApiSevice'; +import { getMedicineSuggestions } from '../../service/medicineApiService'; const AppointmentDetails = () => { const { appointmentId } = useParams(); const navigate = useNavigate(); - + const [medicineSuggestions, setMedicineSuggestions] = useState([]); + const [showSuggestions, setShowSuggestions] = useState(false); const [appointment, setAppointment] = useState(null); const [patientInfo, setPatientInfo] = useState(null); const [prescription, setPrescription] = useState(null); @@ -51,7 +53,22 @@ const AppointmentDetails = () => { fetchAppointmentData(); } }, [appointmentId]); - + const fetchSuggestions = useCallback( + debounce(async (query) => { + if (query.length >= 2) { + try { + const suggestions = await getMedicineSuggestions(query); + setMedicineSuggestions(suggestions); + setShowSuggestions(true); + } catch (err) { + console.error('Suggestion fetch failed', err); + } + } else { + setShowSuggestions(false); + } + }, 300), + [] + ); const fetchAppointmentData = async () => { try { setLoading(true); From 1a46126da0582fd4ddd1af8487894dc21faf44af Mon Sep 17 00:00:00 2001 From: Aditya Shah Date: Mon, 8 Dec 2025 14:40:11 +0530 Subject: [PATCH 4/6] adds jsx to show suggestions to user --- .../src/pages/doctor/AppointmentDetails.jsx | 73 ++++++++++++++----- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/client/src/pages/doctor/AppointmentDetails.jsx b/client/src/pages/doctor/AppointmentDetails.jsx index bdae96b..7379072 100644 --- a/client/src/pages/doctor/AppointmentDetails.jsx +++ b/client/src/pages/doctor/AppointmentDetails.jsx @@ -13,7 +13,7 @@ import { VideoCameraIcon, XMarkIcon, } from '@heroicons/react/24/outline'; -import { useEffect, useState } from 'react'; +import { useEffect, useState, useCallback, useRef } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import { getAppointmentDetails, @@ -47,28 +47,43 @@ const AppointmentDetails = () => { followUpDate: '', }); const [savingPrescription, setSavingPrescription] = useState(false); + const useDebounce = (callback, delay) => { + const timeoutRef = useRef(null); + return useCallback( + (...args) => { + if (timeoutRef.current) { + clearTimeout(timeoutRef.current); + } + timeoutRef.current = setTimeout(() => callback(...args), delay); + }, + [callback, delay] + ); + }; useEffect(() => { if (appointmentId) { fetchAppointmentData(); } }, [appointmentId]); - const fetchSuggestions = useCallback( - debounce(async (query) => { - if (query.length >= 2) { - try { - const suggestions = await getMedicineSuggestions(query); - setMedicineSuggestions(suggestions); - setShowSuggestions(true); - } catch (err) { - console.error('Suggestion fetch failed', err); - } - } else { - setShowSuggestions(false); + const fetchSuggestions = useDebounce(async (query) => { + if (query.length >= 2) { + try { + const suggestions = await getMedicineSuggestions(query); + setMedicineSuggestions(suggestions.suggestions); + setShowSuggestions(true); + } catch (err) { + console.error('Suggestion fetch failed', err); } - }, 300), - [] - ); + } else { + setShowSuggestions(false); + setMedicineSuggestions([]); + } + }, 300); + // Update medicine name input onChange + const handleMedicineNameChange = (index, value) => { + updateMedication(index, 'name', value); + fetchSuggestions(value); + }; const fetchAppointmentData = async () => { try { setLoading(true); @@ -656,10 +671,32 @@ const AppointmentDetails = () => { type="text" placeholder="Medicine name" value={medication.name} - onChange={(e) => updateMedication(index, 'name', e.target.value)} + onChange={(e) => handleMedicineNameChange(index, e.target.value)} className="w-full p-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500" - required /> + {showSuggestions && medicineSuggestions.length > 0 && ( +
+ {medicineSuggestions.map((suggestion, sugIndex) => ( + + ))} +
+ )}
Date: Mon, 8 Dec 2025 14:57:33 +0530 Subject: [PATCH 5/6] adds 'see in quickmed' button along with suggestions --- .../src/pages/doctor/AppointmentDetails.jsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/client/src/pages/doctor/AppointmentDetails.jsx b/client/src/pages/doctor/AppointmentDetails.jsx index 7379072..7420856 100644 --- a/client/src/pages/doctor/AppointmentDetails.jsx +++ b/client/src/pages/doctor/AppointmentDetails.jsx @@ -689,9 +689,22 @@ const AppointmentDetails = () => { className="w-full text-left p-3 hover:bg-gray-50 border-b border-gray-100 last:border-b-0" >
{suggestion}
-
- {suggestion.dosage} - {suggestion.frequency} -
+ +
QuickMed ✓
))} From 40d6f2c29092776bfb6e07208e95b2083a0a81ba Mon Sep 17 00:00:00 2001 From: Aditya Shah Date: Mon, 8 Dec 2025 15:32:52 +0530 Subject: [PATCH 6/6] adds button in the patinet prescription --- .../AppointmentDetails/prescription/Medications.jsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client/src/components/Patient/AppointmentDetails/prescription/Medications.jsx b/client/src/components/Patient/AppointmentDetails/prescription/Medications.jsx index 6b405c1..44532a3 100644 --- a/client/src/components/Patient/AppointmentDetails/prescription/Medications.jsx +++ b/client/src/components/Patient/AppointmentDetails/prescription/Medications.jsx @@ -31,6 +31,18 @@ const Medications = ({ medications }) => { {med.instructions || 'As directed'} + + {med.quickmed === true && ( + + See in QuickMed + + )} + ))}