Skip to content

Commit

Permalink
Merge pull request #24 from masslight/more-cleanup
Browse files Browse the repository at this point in the history
More cleanup
  • Loading branch information
OmarZubaidi authored Oct 16, 2023
2 parents 64a409a + 5363050 commit 83a2880
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 47 deletions.
4 changes: 2 additions & 2 deletions packages/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.png" />
<link rel="icon" href="/logo.png" />
<link
rel="stylesheet"
rel="prefetch"
Expand All @@ -14,7 +14,7 @@
<meta name="theme-color" content="#000000" />
<meta name="description" content="ottEHR" build-version="%VITE_VERSION%" build-commit="%VITE_SHA%" />
<script type="text/javascript" src="https://cdn.oncehub.com/mergedjs/so.js"></script>
<link rel="apple-touch-icon" href="/logo192.png" />
<link rel="apple-touch-icon" href="/logo.png" />
<link rel="manifest" href="/manifest.json" />
<title>ottEHR</title>
</head>
Expand Down
Binary file added packages/app/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/app/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "ottEHR",
"icons": [
{
"src": "favicon.png",
"src": "logo.png",
"sizes": "250x250",
"type": "image/png"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/components/SelectSlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Button, Grid, Typography, styled, useTheme } from '@mui/material';
import { DateTime } from 'luxon';
import { useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { IntakeDataContext, updateAppointmentSlot } from '../store';
import { DataContext, updateAppointmentSlot } from '../store';

const AppointmentSlotButton = styled(Button)({
borderRadius: '8px',
Expand All @@ -15,7 +15,7 @@ interface SelectSlotProps {
}

export function SelectSlot({ slots, timezone }: SelectSlotProps): JSX.Element {
const { state, dispatch } = useContext(IntakeDataContext);
const { state, dispatch } = useContext(DataContext);
const theme = useTheme();
const { t } = useTranslation();
const selectedSlot = state.appointmentSlot;
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './useClients';
6 changes: 3 additions & 3 deletions packages/app/src/hooks/useClients.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { FhirClient, ZambdaClient } from '@zapehr/sdk';
import { useContext } from 'react';
import { IntakeDataContext } from '../store';
import { DataContext } from '../store';

export function useFhirClient(): FhirClient | null {
const { state } = useContext(IntakeDataContext);
const { state } = useContext(DataContext);
return state.fhirClient || null;
}

export function useZambdaClient(): ZambdaClient | null {
const { state } = useContext(IntakeDataContext);
const { state } = useContext(DataContext);
return state.zambdaClient || null;
}
6 changes: 3 additions & 3 deletions packages/app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createRoot } from 'react-dom/client';
import App from './App';
import './index.css';
import './lib/i18n';
import { IntakeDataProvider } from './store';
import { DataProvider } from './store';

const root = createRoot(document.getElementById('root') as HTMLElement);
root.render(
Expand All @@ -16,9 +16,9 @@ root.render(
domain="https://zapehr-dev.us.auth0.com"
redirectUri={window.location.origin}
>
<IntakeDataProvider>
<DataProvider>
<App />
</IntakeDataProvider>
</DataProvider>
</Auth0Provider>
</StrictMode>
);
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FhirClient, ZambdaClient } from '@zapehr/sdk';
import { Location, Patient, Slot } from 'fhir/r4';
import { Dispatch } from 'react';
import { IntakeAction, PatientInfo } from './types';
import { Action, PatientInfo } from './types';

export const setFhirClient = (token: string, dispatch: Dispatch<IntakeAction>): void => {
export const setFhirClient = (token: string, dispatch: Dispatch<Action>): void => {
const fhirClient = new FhirClient({
accessToken: token,
apiUrl: import.meta.env.VITE_FHIR_API_URL,
Expand All @@ -14,7 +14,7 @@ export const setFhirClient = (token: string, dispatch: Dispatch<IntakeAction>):
});
};

export const setZambdaClient = (token: string | undefined, dispatch: Dispatch<IntakeAction>): void => {
export const setZambdaClient = (token: string | undefined, dispatch: Dispatch<Action>): void => {
const zambdaClient = new ZambdaClient({
accessToken: token,
apiUrl: import.meta.env.VITE_PROJECT_API_URL,
Expand All @@ -25,134 +25,134 @@ export const setZambdaClient = (token: string | undefined, dispatch: Dispatch<In
});
};

export const updateAdditionalInformation = (additionalInfo: string, dispatch: Dispatch<IntakeAction>): void => {
export const updateAdditionalInformation = (additionalInfo: string, dispatch: Dispatch<Action>): void => {
dispatch({
additionalInformation: additionalInfo,
type: 'UPDATE_ADDITIONAL_INFORMATION',
});
};

export const updateAppointmentId = (appointment: { id: string }, dispatch: Dispatch<IntakeAction>): void => {
export const updateAppointmentId = (appointment: { id: string }, dispatch: Dispatch<Action>): void => {
dispatch({
appointmentId: appointment.id,
type: 'UPDATE_APPOINTMENT_ID',
});
};

// TODO Shouldn't this be a slot?
export const updateAppointmentSlot = (appointmentSlot: string, dispatch: Dispatch<IntakeAction>): void => {
export const updateAppointmentSlot = (appointmentSlot: string, dispatch: Dispatch<Action>): void => {
dispatch({
appointmentSlot: appointmentSlot,
type: 'UPDATE_APPOINTMENT_SLOT',
});
};

export const updateCancellationReason = (cancellationReason: string, dispatch: Dispatch<IntakeAction>): void => {
export const updateCancellationReason = (cancellationReason: string, dispatch: Dispatch<Action>): void => {
dispatch({
cancellationReason: cancellationReason,
type: 'UPDATE_CANCELLATION_REASON',
});
};

export const updateConsentFormId = ({ id }: { id: string }, dispatch: Dispatch<IntakeAction>): void => {
export const updateConsentFormId = ({ id }: { id: string }, dispatch: Dispatch<Action>): void => {
dispatch({
consentFormId: id,
type: 'UPDATE_CONSENT_FORM_ID',
});
};

export const updateConsentFormSignerId = ({ id }: { id: string }, dispatch: Dispatch<IntakeAction>): void => {
export const updateConsentFormSignerId = ({ id }: { id: string }, dispatch: Dispatch<Action>): void => {
dispatch({
consentFormSignerId: id,
type: 'UPDATE_CONSENT_FORM_SIGNER_ID',
});
};

export const updateCoverageId = ({ id }: { id: string }, dispatch: Dispatch<IntakeAction>): void => {
export const updateCoverageId = ({ id }: { id: string }, dispatch: Dispatch<Action>): void => {
dispatch({
coverageId: id,
type: 'UPDATE_COVERAGE_ID',
});
};

export const updateLocationId = (location: { id: string }, dispatch: Dispatch<IntakeAction>): void => {
export const updateLocationId = (location: { id: string }, dispatch: Dispatch<Action>): void => {
dispatch({
locationId: location.id,
type: 'UPDATE_LOCATION_ID',
});
};

export const updateLocations = (locations: Location[], dispatch: Dispatch<IntakeAction>): void => {
export const updateLocations = (locations: Location[], dispatch: Dispatch<Action>): void => {
dispatch({
locations: locations,
type: 'UPDATE_LOCATIONS',
});
};

export const updatePatient = (patient: PatientInfo | undefined, dispatch: Dispatch<IntakeAction>): void => {
export const updatePatient = (patient: PatientInfo | undefined, dispatch: Dispatch<Action>): void => {
dispatch({
patient: patient,
type: 'UPDATE_PATIENT',
});
};

export const updatePatients = (patients: Patient[], dispatch: Dispatch<IntakeAction>): void => {
export const updatePatients = (patients: Patient[], dispatch: Dispatch<Action>): void => {
dispatch({
patients: patients,
type: 'UPDATE_PATIENTS',
});
};

export const updatePhoneNumber = (phoneNumber: string, dispatch: Dispatch<IntakeAction>): void => {
export const updatePhoneNumber = (phoneNumber: string, dispatch: Dispatch<Action>): void => {
dispatch({
phoneNumber: phoneNumber,
type: 'UPDATE_PHONE_NUMBER',
});
};

export const updateRelatedPersonId = ({ id }: { id: string }, dispatch: Dispatch<IntakeAction>): void => {
export const updateRelatedPersonId = ({ id }: { id: string }, dispatch: Dispatch<Action>): void => {
dispatch({
relatedPersonId: id,
type: 'UPDATE_RELATED_PERSON_ID',
});
};

export const updateResponsiblePartyId = ({ id }: { id: string }, dispatch: Dispatch<IntakeAction>): void => {
export const updateResponsiblePartyId = ({ id }: { id: string }, dispatch: Dispatch<Action>): void => {
dispatch({
responsiblePartyId: id,
type: 'UPDATE_RESPONSIBLE_PARTY_ID',
});
};

export const updateSelectedAppointmentSlotId = ({ id }: { id: string }, dispatch: Dispatch<IntakeAction>): void => {
export const updateSelectedAppointmentSlotId = ({ id }: { id: string }, dispatch: Dispatch<Action>): void => {
dispatch({
selectedApptSlotId: id,
type: 'UPDATE_SELECTED_APPOINTMENT_SLOT_ID',
});
};

export const updateSelectedLocation = (location: Location, dispatch: Dispatch<IntakeAction>): void => {
export const updateSelectedLocation = (location: Location, dispatch: Dispatch<Action>): void => {
dispatch({
location: location,
type: 'UPDATE_SELECTED_LOCATION',
});
};

export const updateSlots = (slots: Slot[], dispatch: Dispatch<IntakeAction>): void => {
export const updateSlots = (slots: Slot[], dispatch: Dispatch<Action>): void => {
dispatch({
slots: slots,
type: 'UPDATE_SLOTS',
});
};

export const updateSubmittedInsuranceType = ({ type }: { type: string }, dispatch: Dispatch<IntakeAction>): void => {
export const updateSubmittedInsuranceType = ({ type }: { type: string }, dispatch: Dispatch<Action>): void => {
dispatch({
submittedInsuranceType: type,
type: 'UPDATE_SUBMITTED_INSURANCE_TYPE',
});
};

export const updateTimezone = (timezone: string, dispatch: Dispatch<IntakeAction>): void => {
export const updateTimezone = (timezone: string, dispatch: Dispatch<Action>): void => {
dispatch({
timezone: timezone,
type: 'UPDATE_TIMEZONE',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Dispatch, FC, ReactNode, SetStateAction, createContext, useContext, useReducer, useState } from 'react';
import { Outlet } from 'react-router-dom';
import { IntakeAction, IntakeState } from './types';
import { Action, State } from './types';

const initialState = {};

const PatientContext = createContext<PatientContextProps | undefined>(undefined);

type IntakeDataContextProps = {
dispatch: Dispatch<IntakeAction>;
state: IntakeState;
type DataContextProps = {
dispatch: Dispatch<Action>;
state: State;
};

type PatientContextProps = {
Expand Down Expand Up @@ -42,9 +42,9 @@ export const PatientProvider: FC = () => {
);
};

export const IntakeDataContext = createContext<IntakeDataContextProps>({ dispatch: () => null, state: initialState });
export const DataContext = createContext<DataContextProps>({ dispatch: () => null, state: initialState });

const intakeDataReducer = (state: IntakeState, action: IntakeAction): IntakeState => {
const DataReducer = (state: State, action: Action): State => {
switch (action.type) {
case 'SET_FHIR_CLIENT':
return { ...state, fhirClient: action.fhirClient };
Expand Down Expand Up @@ -93,12 +93,12 @@ const intakeDataReducer = (state: IntakeState, action: IntakeAction): IntakeStat
}
};

interface IntakeDataProviderProps {
interface DataProviderProps {
children: ReactNode;
}

export const IntakeDataProvider: FC<IntakeDataProviderProps> = ({ children }) => {
const [state, dispatch] = useReducer(intakeDataReducer, initialState);
export const DataProvider: FC<DataProviderProps> = ({ children }) => {
const [state, dispatch] = useReducer(DataReducer, initialState);

return <IntakeDataContext.Provider value={{ state, dispatch }}>{children}</IntakeDataContext.Provider>;
return <DataContext.Provider value={{ state, dispatch }}>{children}</DataContext.Provider>;
};
4 changes: 2 additions & 2 deletions packages/app/src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './IntakeActions';
export * from './IntakeContext';
export * from './Actions';
export * from './Context';
4 changes: 2 additions & 2 deletions packages/app/src/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export type PatientInfo = {
sex: PatientSex | undefined;
};

export type IntakeAction =
export type Action =
| { type: 'SET_FHIR_CLIENT'; fhirClient: FhirClient }
| { type: 'SET_ZAMBDA_CLIENT'; zambdaClient: ZambdaClient }
| { type: 'UPDATE_ADDITIONAL_INFORMATION'; additionalInformation: string }
Expand All @@ -94,7 +94,7 @@ export type IntakeAction =
| { type: 'UPDATE_SUBMITTED_INSURANCE_TYPE'; submittedInsuranceType: string }
| { type: 'UPDATE_TIMEZONE'; timezone: string };

export type IntakeState = {
export type State = {
additionalInformation?: string;
appointmentId?: string;
appointmentSlot?: string;
Expand Down

0 comments on commit 83a2880

Please sign in to comment.