diff --git a/.github/workflows/build-and-deploy-telemed-ehr.yml b/.github/workflows/build-and-deploy-telemed-ehr.yml index 9d679d40..f694cabd 100644 --- a/.github/workflows/build-and-deploy-telemed-ehr.yml +++ b/.github/workflows/build-and-deploy-telemed-ehr.yml @@ -14,10 +14,8 @@ on: type: choice default: 'development' options: - - development - - dev2 + - development - testing - - staging incrementVersion: description: 'Bump Version?' type: boolean diff --git a/.github/workflows/build-and-deploy-telemed-intake.yml b/.github/workflows/build-and-deploy-telemed-intake.yml index 47057651..4c97c28a 100644 --- a/.github/workflows/build-and-deploy-telemed-intake.yml +++ b/.github/workflows/build-and-deploy-telemed-intake.yml @@ -15,9 +15,7 @@ on: default: 'development' options: - development - - dev2 - testing - - staging incrementVersion: description: 'Bump Version?' type: boolean diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e1ce2d59..e3d59a8d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,6 +43,12 @@ jobs: - name: Set the urgent-care-intake/zambdas/.env/development.json run: cp packages/urgent-care-intake/zambdas/.env/local.template.json packages/urgent-care-intake/zambdas/.env/development.json + - name: Set the telemed-ehr/zambdas/.env/testing.json + run: cp packages/telemed-ehr/zambdas/.env/local.template.json packages/telemed-ehr/zambdas/.env/testing.json + + - name: Set the telemed-intake/zambdas/.env/testing.json + run: cp packages/telemed-intake/zambdas/.env/local.template.json packages/telemed-intake/zambdas/.env/testing.json + - id: get-store-path run: echo STORE_PATH=$(pnpm store path) >> $GITHUB_OUTPUT diff --git a/package.json b/package.json index 89bc37b4..6b18986a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ottehr", - "version": "0.17.0", + "version": "0.18.0", "private": true, "scripts": { "test": "pnpm recursive run test", diff --git a/packages/ehr-utils/package.json b/packages/ehr-utils/package.json index 275c6d23..6d6c1fdc 100644 --- a/packages/ehr-utils/package.json +++ b/packages/ehr-utils/package.json @@ -1,7 +1,7 @@ { "name": "ehr-utils", "private": true, - "version": "0.17.0", + "version": "0.18.0", "main": "lib/main.ts", "types": "lib/main.ts", "scripts": { diff --git a/packages/ottehr-components/package.json b/packages/ottehr-components/package.json index 091a5620..93ab427f 100644 --- a/packages/ottehr-components/package.json +++ b/packages/ottehr-components/package.json @@ -1,7 +1,7 @@ { "name": "ottehr-components", "private": true, - "version": "0.17.0", + "version": "0.18.0", "main": "lib/main.ts", "types": "lib/main.ts", "scripts": { diff --git a/packages/telemed-ehr/app/package.json b/packages/telemed-ehr/app/package.json index d35328d8..6cd59280 100644 --- a/packages/telemed-ehr/app/package.json +++ b/packages/telemed-ehr/app/package.json @@ -1,6 +1,6 @@ { "name": "telemed-ehr-app", - "version": "0.17.0", + "version": "0.18.0", "private": true, "browserslist": { "production": [ @@ -30,6 +30,7 @@ "test": "react-scripts test", "eject": "react-scripts eject", "deploy:development": " PREFIX=development CLOUDFRONT_ID=E10TA6FN58D1OS ENV=development pnpm run ci-deploy-skeleton", + "deploy:testing": " PREFIX=testing CLOUDFRONT_ID=ETFAEVC5V0490 ENV=testing pnpm run ci-deploy-skeleton", "ci-deploy-skeleton": "ENV=${ENV} VITE_APP_SHA=${GIT_HEAD:-$(git rev-parse --short HEAD)} VITE_APP_VERSION=$(node -pe 'require(\"./package.json\").version') pnpm run build:${ENV} && aws s3 sync build/ s3://ehr.ottehr.com --region us-east-1 --delete && aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_ID} --paths '/*' --region us-east-1" }, "dependencies": { @@ -62,4 +63,4 @@ "@types/styled-components": "^5.1.34", "@types/react-page-visibility": "^6.4.4" } -} +} \ No newline at end of file diff --git a/packages/telemed-ehr/app/src/components/EmployeeInformationForm.tsx b/packages/telemed-ehr/app/src/components/EmployeeInformationForm.tsx index f070ff19..cb6b6a58 100644 --- a/packages/telemed-ehr/app/src/components/EmployeeInformationForm.tsx +++ b/packages/telemed-ehr/app/src/components/EmployeeInformationForm.tsx @@ -55,6 +55,8 @@ interface EmployeeForm { lastName: string; nameSuffix: string; roles: string[]; + phoneNumber: string; + npi: string; } const AVAILABLE_ROLES: { @@ -150,22 +152,6 @@ export default function EmployeeInformationForm({ console.log('existingUser', existingUser); - let npiText = 'n/a'; - if (existingUser?.profileResource?.identifier) { - const npi = existingUser.profileResource.identifier.find((identifier) => identifier.system === FHIR_IDENTIFIER_NPI); - if (npi && npi.value) { - npiText = npi.value; - } - } - - let phoneText = ''; - if (existingUser?.profileResource?.telecom) { - const phone = existingUser.profileResource.telecom.find((tel) => tel.system === 'sms')?.value; - if (phone) { - phoneText = phone; - } - } - let photoSrc = ''; if (existingUser?.profileResource?.photo) { const photo = existingUser.profileResource.photo[0]; @@ -201,6 +187,26 @@ export default function EmployeeInformationForm({ setValue('middleName', middleName); setValue('lastName', lastName); setValue('nameSuffix', nameSuffix); + + let phoneText = ''; + if (existingUser?.profileResource?.telecom) { + const phone = existingUser.profileResource.telecom.find((tel) => tel.system === 'sms')?.value; + if (phone) { + phoneText = phone; + } + } + setValue('phoneNumber', phoneText); + + let npiText = 'n/a'; + if (existingUser?.profileResource?.identifier) { + const npi = existingUser.profileResource.identifier.find( + (identifier) => identifier.system === FHIR_IDENTIFIER_NPI, + ); + if (npi && npi.value) { + npiText = npi.value; + } + } + setValue('npi', npiText); } }, [existingUser, setValue]); @@ -229,6 +235,8 @@ export default function EmployeeInformationForm({ nameSuffix: data.nameSuffix, selectedRoles: data.roles, licenses: newLicenses, + phoneNumber: data.phoneNumber, + npi: data.npi, }); } catch (error) { console.log(`Failed to update user: ${error}`); @@ -334,16 +342,19 @@ export default function EmployeeInformationForm({ disabled: true, }} /> - ( + + )} /> @@ -420,7 +431,21 @@ export default function EmployeeInformationForm({ /> )} /> - + ( + + )} + /> {isProviderRoleSelected && ( <> diff --git a/packages/telemed-ehr/app/src/types/types.ts b/packages/telemed-ehr/app/src/types/types.ts index 16af1f72..84eae09a 100644 --- a/packages/telemed-ehr/app/src/types/types.ts +++ b/packages/telemed-ehr/app/src/types/types.ts @@ -38,6 +38,8 @@ export interface UpdateUserParameters { nameSuffix?: string; selectedRoles?: string[] | undefined; licenses?: PractitionerLicense[]; + phoneNumber?: string; + npi?: string; // locations: Location[]; } diff --git a/packages/telemed-ehr/zambdas/package.json b/packages/telemed-ehr/zambdas/package.json index b26627fe..0c4ea8a6 100644 --- a/packages/telemed-ehr/zambdas/package.json +++ b/packages/telemed-ehr/zambdas/package.json @@ -1,6 +1,6 @@ { "name": "telemed-ehrzambdas", - "version": "0.17.0", + "version": "0.18.0", "private": true, "scripts": { "start": "npm run start:local", diff --git a/packages/telemed-ehr/zambdas/scripts/configure-zapehr-secrets.ts b/packages/telemed-ehr/zambdas/scripts/configure-zapehr-secrets.ts index e9e2a238..8b37d2b6 100644 --- a/packages/telemed-ehr/zambdas/scripts/configure-zapehr-secrets.ts +++ b/packages/telemed-ehr/zambdas/scripts/configure-zapehr-secrets.ts @@ -1,5 +1,5 @@ import devConfig from '../.env/development.json'; -// import testingConfig from '../.env/testing.json'; +import testingConfig from '../.env/testing.json'; import { getAuth0Token } from '../src/shared'; import { ZambdaClient } from '@zapehr/sdk'; @@ -37,9 +37,9 @@ const main = async (): Promise => { case 'development': await setupSecrets(devConfig); break; - // case 'testing': - // await setupSecrets(testingConfig); - // break; + case 'testing': + await setupSecrets(testingConfig); + break; default: throw new Error('¯\\_(ツ)_/¯ environment must match a valid zapEHR environment.'); } diff --git a/packages/telemed-ehr/zambdas/src/get-appointments/index.ts b/packages/telemed-ehr/zambdas/src/get-appointments/index.ts index c121f855..43eee98b 100644 --- a/packages/telemed-ehr/zambdas/src/get-appointments/index.ts +++ b/packages/telemed-ehr/zambdas/src/get-appointments/index.ts @@ -296,7 +296,7 @@ export const index = async (input: ZambdaInput): Promise const healthcareServiceIdToResourceMap: Record = {}; searchResultsForSelectedDate.forEach((resource) => { - if (resource.resourceType === 'Appointment') { + if (resource.resourceType === 'Appointment' && (resource as Appointment).serviceType?.[0]?.text === 'in-person') { allAppointments.push(resource as Appointment); } else if (resource.resourceType === 'Patient' && resource.id) { patientIdMap[resource.id] = resource as Patient; diff --git a/packages/telemed-ehr/zambdas/src/update-user/index.ts b/packages/telemed-ehr/zambdas/src/update-user/index.ts index 665c2064..9dfb2cc2 100644 --- a/packages/telemed-ehr/zambdas/src/update-user/index.ts +++ b/packages/telemed-ehr/zambdas/src/update-user/index.ts @@ -1,6 +1,6 @@ import { APIGatewayProxyResult } from 'aws-lambda'; import { Practitioner, HumanName } from 'fhir/r4'; -import { PractitionerLicense, Secrets } from 'ehr-utils'; +import { FHIR_IDENTIFIER_NPI, PractitionerLicense, Secrets } from 'ehr-utils'; import { RoleType } from '../../../app/src/types/types'; import { getSecret } from '../shared'; import { topLevelCatch } from '../shared/errors'; @@ -19,6 +19,8 @@ export interface UpdateUserInput { nameSuffix?: string; selectedRoles?: RoleType[]; licenses?: PractitionerLicense[]; + phoneNumber?: string; + npi?: string; } let m2mtoken: string; @@ -27,7 +29,7 @@ export const index = async (input: ZambdaInput): Promise console.group('validateRequestParameters'); const validatedParameters = validateRequestParameters(input); console.log('validatedParameters:', JSON.stringify(validatedParameters, null, 4)); - const { secrets, userId, firstName, middleName, lastName, nameSuffix, selectedRoles, licenses } = + const { secrets, userId, firstName, middleName, lastName, nameSuffix, selectedRoles, licenses, phoneNumber, npi } = validatedParameters; console.groupEnd(); console.debug('validateRequestParameters success'); @@ -98,14 +100,40 @@ export const index = async (input: ZambdaInput): Promise id: practitionerId, name: name ? [name] : undefined, qualification: practitionerQualificationExtension, + telecom: phoneNumber ? [{ system: 'sms', value: phoneNumber }] : undefined, }); } else { + const existingTelecom = existingPractitionerResource.telecom || []; + const smsIndex = existingTelecom.findIndex((tel) => tel.system === 'sms'); + const updatedTelecom = [...existingTelecom]; + if (phoneNumber) { + if (smsIndex >= 0) { + updatedTelecom[smsIndex] = { system: 'sms', value: phoneNumber }; + } else { + updatedTelecom.push({ system: 'sms', value: phoneNumber }); + } + } + if (npi) { + if (!existingPractitionerResource.identifier) { + existingPractitionerResource.identifier = []; + } + const npiIndex = existingPractitionerResource.identifier.findIndex((id) => id.system === FHIR_IDENTIFIER_NPI); + if (npiIndex >= 0) { + existingPractitionerResource.identifier[npiIndex].value = npi; + } else { + existingPractitionerResource.identifier.push({ + system: FHIR_IDENTIFIER_NPI, + value: npi, + }); + } + } await fhirClient.updateResource({ ...existingPractitionerResource, identifier: existingPractitionerResource.identifier, photo: existingPractitionerResource.photo, name: name ? [name] : undefined, qualification: practitionerQualificationExtension, + telecom: updatedTelecom, }); } } catch (error: unknown) { diff --git a/packages/telemed-ehr/zambdas/src/update-user/validateRequestParameters.ts b/packages/telemed-ehr/zambdas/src/update-user/validateRequestParameters.ts index ab490ff3..d3873e24 100644 --- a/packages/telemed-ehr/zambdas/src/update-user/validateRequestParameters.ts +++ b/packages/telemed-ehr/zambdas/src/update-user/validateRequestParameters.ts @@ -7,7 +7,9 @@ export function validateRequestParameters(input: ZambdaInput): UpdateUserInput { throw new Error('No request body provided'); } - const { userId, firstName, middleName, lastName, nameSuffix, selectedRoles, licenses } = JSON.parse(input.body); + const { userId, firstName, middleName, lastName, nameSuffix, selectedRoles, licenses, phoneNumber, npi } = JSON.parse( + input.body, + ); if ( userId === undefined @@ -36,5 +38,7 @@ export function validateRequestParameters(input: ZambdaInput): UpdateUserInput { licenses, // locations, secrets: input.secrets, + phoneNumber: phoneNumber ? phoneNumber.trim() : phoneNumber, + npi: npi ? npi.trim() : npi, }; } diff --git a/packages/telemed-intake/app/package.json b/packages/telemed-intake/app/package.json index 3c3c7252..98ad67d9 100644 --- a/packages/telemed-intake/app/package.json +++ b/packages/telemed-intake/app/package.json @@ -1,13 +1,15 @@ { "name": "telemed-intake-app", "private": true, - "version": "0.17.0", + "version": "0.18.0", "type": "module", "scripts": { "start:local": "vite", "build:development": "tsc && vite build --mode development", + "build:testing": "tsc && vite build --mode testing", "build": "tsc && vite build", "deploy:development": "ENV=development PREFIX=development CLOUDFRONT_ID=EIYX001DGGQK8 pnpm run ci-deploy-skeleton", + "deploy:testing": "ENV=testing PREFIX=testing CLOUDFRONT_ID=E2IMNWB48TKHJO pnpm run ci-deploy-skeleton", "ci-deploy-skeleton": "ENV=${ENV} VITE_APP_SHA=${GIT_HEAD:-$(git rev-parse --short HEAD)} VITE_APP_VERSION=$(node -pe 'require(\"./package.json\").version') pnpm run build:${ENV} && aws s3 sync build/ s3://telemed.ottehr.com --region us-east-1 --delete && aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_ID} --paths '/*' --region us-east-1" }, "dependencies": { @@ -23,4 +25,4 @@ "devDependencies": { "@types/styled-components": "^5.1.34" } -} +} \ No newline at end of file diff --git a/packages/telemed-intake/app/src/components/VideoControls.tsx b/packages/telemed-intake/app/src/components/VideoControls.tsx index 10d94a7a..95a07443 100644 --- a/packages/telemed-intake/app/src/components/VideoControls.tsx +++ b/packages/telemed-intake/app/src/components/VideoControls.tsx @@ -11,10 +11,13 @@ import { CallSettingsTooltip } from './CallSettingsTooltip'; import { useVideoCallStore } from '../features/video-call'; import { otherColors } from '../IntakeThemeProvider'; import { CallSettings } from './CallSettingsDialog'; +import { useNavigate } from 'react-router-dom'; +import { IntakeFlowPageRoute } from 'src/App'; export const VideoControls: FC = () => { const { toggleVideo, isVideoEnabled } = useLocalVideo(); const { muted, toggleMute } = useToggleLocalMute(); + const navigate = useNavigate(); const meetingManager = useMeetingManager(); const [isSettingsOpen, setIsSettingsOpen] = useState(false); @@ -46,6 +49,7 @@ export const VideoControls: FC = () => { const disconnect = async (): Promise => { await cleanup(); useVideoCallStore.setState({ meetingData: null }); + navigate(IntakeFlowPageRoute.PatientPortal.path); }; return ( diff --git a/packages/telemed-intake/app/src/features/appointments/appointment.store.ts b/packages/telemed-intake/app/src/features/appointments/appointment.store.ts index a199d1cb..eea75ac7 100644 --- a/packages/telemed-intake/app/src/features/appointments/appointment.store.ts +++ b/packages/telemed-intake/app/src/features/appointments/appointment.store.ts @@ -11,6 +11,7 @@ interface AppointmentState { providerID?: string; groupID?: string; scheduleType?: 'location' | 'provider'; + slug?: string; } const APOINTMENT_STATE_INITIAL: AppointmentState = {}; diff --git a/packages/telemed-intake/app/src/pages/ConfirmDateOfBirth.tsx b/packages/telemed-intake/app/src/pages/ConfirmDateOfBirth.tsx index 7dd80b40..c837b907 100644 --- a/packages/telemed-intake/app/src/pages/ConfirmDateOfBirth.tsx +++ b/packages/telemed-intake/app/src/pages/ConfirmDateOfBirth.tsx @@ -15,7 +15,7 @@ import { import { CustomContainer } from '../features/common'; import { useGetPaperwork, usePaperworkStore } from '../features/paperwork'; import { usePatientInfoStore } from '../features/patient-info'; -import { useZapEHRAPIClient } from '../utils'; +import { handleClosePastTimeErrorDialog, isSlotTimePassed, useZapEHRAPIClient } from '../utils'; import { decode } from 'html-entities'; const ConfirmDateOfBirth = (): JSX.Element => { @@ -26,7 +26,11 @@ const ConfirmDateOfBirth = (): JSX.Element => { const [requestErrorDialogOpen, setRequestErrorDialogOpen] = useState(false); const createAppointment = useCreateAppointmentMutation(); const [getPaperworkEnabled, setGetPaperworkEnabled] = useState(false); - const { appointmentID } = getSelectors(useAppointmentStore, ['appointmentID']); + const { appointmentID, selectedSlot, visitType, visitService, scheduleType, slug } = getSelectors( + useAppointmentStore, + ['appointmentID', 'selectedSlot', 'visitType', 'visitService', 'scheduleType', 'slug'], + ); + const [isPastTimeErrorDialogOpen, setIsPastTimeErrorDialogOpen] = useState(false); const { patchCompletedPaperwork, setQuestions } = getSelectors(usePaperworkStore, [ 'patchCompletedPaperwork', 'setQuestions', @@ -116,6 +120,11 @@ const ConfirmDateOfBirth = (): JSX.Element => { }, [challengeDay.name, challengeMonth.name, challengeYear.name, formValuesCopy]); const createOrUpdateAppointment = (unconfirmedDateOfBirth = false): void => { + if (isSlotTimePassed(selectedSlot, visitType)) { + setIsPastTimeErrorDialogOpen(true); + return; + } + if (!apiClient) { throw new Error('apiClient is not defined'); } @@ -261,6 +270,22 @@ const ConfirmDateOfBirth = (): JSX.Element => { closeButtonText={t('general.button.close')} handleClose={() => setRequestErrorDialogOpen(false)} /> + + handleClosePastTimeErrorDialog( + setIsPastTimeErrorDialogOpen, + navigate, + visitType, + visitService, + scheduleType, + slug, + ) + } + /> ); diff --git a/packages/telemed-intake/app/src/pages/PatientInformation.tsx b/packages/telemed-intake/app/src/pages/PatientInformation.tsx index f364e827..a7ae9438 100644 --- a/packages/telemed-intake/app/src/pages/PatientInformation.tsx +++ b/packages/telemed-intake/app/src/pages/PatientInformation.tsx @@ -26,7 +26,7 @@ import { CustomContainer } from '../features/common'; import { useFilesStore } from '../features/files'; import { useGetPaperwork, usePaperworkStore } from '../features/paperwork'; import { usePatientInfoStore } from '../features/patient-info'; -import { useZapEHRAPIClient } from '../utils'; +import { handleClosePastTimeErrorDialog, isSlotTimePassed, useZapEHRAPIClient } from '../utils'; const UPDATEABLE_PATIENT_INFO_FIELDS: (keyof Omit)[] = [ 'firstName', @@ -69,13 +69,17 @@ const PatientInformation = (): JSX.Element => { const { t } = useTranslation(); const [ageErrorDialogOpen, setAgeErrorDialogOpen] = useState(false); const [requestErrorDialogOpen, setRequestErrorDialogOpen] = useState(false); + const [isPastTimeErrorDialogOpen, setIsPastTimeErrorDialogOpen] = useState(false); const { patientInfo: currentPatientInfo, pendingPatientInfoUpdates } = getSelectors(usePatientInfoStore, [ 'patientInfo', 'pendingPatientInfoUpdates', ]); const patientInfo = { ...currentPatientInfo, ...pendingPatientInfoUpdates, id: currentPatientInfo.id }; const initialPatientInfoRef = useRef(currentPatientInfo); - const { appointmentID } = getSelectors(useAppointmentStore, ['appointmentID']); + const { appointmentID, visitType, visitService, scheduleType, slug, selectedSlot } = getSelectors( + useAppointmentStore, + ['appointmentID', 'visitType', 'visitService', 'scheduleType', 'slug', 'selectedSlot'], + ); const { patchCompletedPaperwork, setQuestions } = getSelectors(usePaperworkStore, [ 'patchCompletedPaperwork', 'setQuestions', @@ -165,6 +169,11 @@ const PatientInformation = (): JSX.Element => { return; } + if (isSlotTimePassed(selectedSlot, visitType)) { + setIsPastTimeErrorDialogOpen(true); + return; + } + if (!apiClient) { throw new Error('apiClient is not defined'); } @@ -397,6 +406,22 @@ const PatientInformation = (): JSX.Element => { closeButtonText={t('general.button.close')} handleClose={() => setRequestErrorDialogOpen(false)} /> + + handleClosePastTimeErrorDialog( + setIsPastTimeErrorDialogOpen, + navigate, + visitType, + visitService, + scheduleType, + slug, + ) + } + /> ); }; diff --git a/packages/telemed-intake/app/src/pages/Welcome.tsx b/packages/telemed-intake/app/src/pages/Welcome.tsx index 3433226a..39deeb76 100644 --- a/packages/telemed-intake/app/src/pages/Welcome.tsx +++ b/packages/telemed-intake/app/src/pages/Welcome.tsx @@ -53,8 +53,13 @@ const Welcome = (): JSX.Element => { }, [visitService, setAppointment, visitType, scheduleType]); useEffect(() => { - setAppointment({ locationID: schedule?.locationID, providerID: schedule?.providerID, groupID: schedule?.groupID }); - }, [schedule?.groupID, schedule?.locationID, schedule?.providerID, setAppointment]); + setAppointment({ + locationID: schedule?.locationID, + providerID: schedule?.providerID, + groupID: schedule?.groupID, + slug, + }); + }, [schedule?.groupID, schedule?.locationID, schedule?.providerID, setAppointment, slug]); const clearState = (): void => { useAppointmentStore.setState({ appointmentID: undefined, appointmentDate: undefined }); diff --git a/packages/telemed-intake/app/src/theme/ottehr/i18n-en.json b/packages/telemed-intake/app/src/theme/ottehr/i18n-en.json index c19a3f0f..599bdf2c 100644 --- a/packages/telemed-intake/app/src/theme/ottehr/i18n-en.json +++ b/packages/telemed-intake/app/src/theme/ottehr/i18n-en.json @@ -173,6 +173,11 @@ "requestError": { "title": "Error", "description": "An error occurred. Please, try again in a moment." + }, + "pastTimeError": { + "title": "Error booking visit", + "description": "We are sorry, your selected check-in time has passed. Please click below to select a different time slot.", + "button": "Select a time slot" } }, "patientPortal": { diff --git a/packages/telemed-intake/app/src/utils/checkSlotTime.ts b/packages/telemed-intake/app/src/utils/checkSlotTime.ts new file mode 100644 index 00000000..c1be29d0 --- /dev/null +++ b/packages/telemed-intake/app/src/utils/checkSlotTime.ts @@ -0,0 +1,40 @@ +import { DateTime } from 'luxon'; +import { NavigateFunction } from 'react-router-dom'; +import { IntakeFlowPageRoute } from 'src/App'; + +export const isSlotTimePassed = (selectedSlot: string | undefined, visitType: string | undefined): boolean => { + if (visitType === 'now') { + return false; + } + if (!selectedSlot) return false; + const slotDateTime = DateTime.fromISO(selectedSlot); + console.log('slotDateTime', slotDateTime); + const now = DateTime.now(); + console.log('now', now); + return slotDateTime < now; +}; + +export const handleClosePastTimeErrorDialog = ( + setIsPastTimeErrorDialogOpen: (value: boolean) => void, + navigate: NavigateFunction, + visitType: string | undefined, + visitService: string | undefined, + scheduleType: string | undefined, + slug: string | undefined, +): void => { + if (!visitService || !visitType || !scheduleType || !slug) { + console.error('One or more required parameters are missing'); + navigate(IntakeFlowPageRoute.PatientPortal.path); + return; + } + + setIsPastTimeErrorDialogOpen(false); + + navigate( + `${IntakeFlowPageRoute.Welcome.path + .replace(':schedule-type', scheduleType) + .replace(':slug', slug) + .replace(':visit-service', visitService) + .replace(':visit-type', visitType)}`, + ); +}; diff --git a/packages/telemed-intake/app/src/utils/index.ts b/packages/telemed-intake/app/src/utils/index.ts index 011cb1f4..3bc9a3bd 100644 --- a/packages/telemed-intake/app/src/utils/index.ts +++ b/packages/telemed-intake/app/src/utils/index.ts @@ -2,3 +2,4 @@ export * from './getZapEHRAPI'; export * from './getPaperworkPageInfo'; export * from './mapQuestionsToFormInputFields'; export * from './zustandDevtools'; +export * from './checkSlotTime'; diff --git a/packages/telemed-intake/zambdas/package.json b/packages/telemed-intake/zambdas/package.json index f0247122..06c921e6 100644 --- a/packages/telemed-intake/zambdas/package.json +++ b/packages/telemed-intake/zambdas/package.json @@ -1,6 +1,6 @@ { "name": "telemed-intake-zambdas", - "version": "0.17.0", + "version": "0.18.0", "private": true, "scripts": { "start": "npm run start:local", diff --git a/packages/telemed-intake/zambdas/scripts/setup.ts b/packages/telemed-intake/zambdas/scripts/setup.ts index cf5101d1..49a01fde 100644 --- a/packages/telemed-intake/zambdas/scripts/setup.ts +++ b/packages/telemed-intake/zambdas/scripts/setup.ts @@ -26,8 +26,6 @@ async function createApplication( 'Zambda:Function:telemed-create-paperwork', 'Zambda:Function:telemed-cancel-telemed-appointment', 'Zambda:Function:telemed-cancel-in-person-appointment', - 'Zambda:Function:telemed-video-chat-invites-list', - 'Zambda:Function:telemed-video-chat-invites-create', ], action: ['Zambda:InvokeFunction'], effect: 'Allow', diff --git a/packages/utils/package.json b/packages/utils/package.json index f28e701f..8cd9cb0e 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,7 +1,7 @@ { "name": "ottehr-utils", "private": true, - "version": "0.17.0", + "version": "0.18.0", "main": "lib/main.ts", "types": "lib/main.ts", "scripts": {