From 2aa99f570f5cb88a13d25ed049eb8c74a74690bc Mon Sep 17 00:00:00 2001 From: Poh Anson <50758680+PohAnson@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:12:56 +0800 Subject: [PATCH] Alert when editing vitals of old visits. --- pages/records/patient-vitals/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pages/records/patient-vitals/index.js b/pages/records/patient-vitals/index.js index 95610f6..b32bdd1 100644 --- a/pages/records/patient-vitals/index.js +++ b/pages/records/patient-vitals/index.js @@ -15,6 +15,7 @@ import axiosInstance from '@/pages/api/_axiosInstance'; import CustomModal from '@/components/CustomModal'; import useWithLoading from '@/utils/loading'; import NoVisitPlaceholder from '@/components/records/NoVisitPlaceholder'; +import { checkRecency } from '@/utils/check'; const PatientVitals = () => { const [mounted, setMounted] = useState(false); @@ -118,6 +119,19 @@ const PatientVitals = () => { }); const submitVitalsForm = useWithLoading(async () => { + const THREE_DAY_IN_MIN = 4320; // 3 * 60 * 24 + + const toSubmit = await checkRecency( + patient.pk, + THREE_DAY_IN_MIN, + false, + `Are you sure you want to edit this vital? + Press OK to SUBMIT. + Press CANCEL to NOT SUBMIT.` + ); + if (!toSubmit) { + return; + } const formPayload = { ...vitalsFormDetails, visit: selectedVisitID,