Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Health Data #60

Merged
merged 72 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
f437ef7
Add allergy intolerance groups
kylewadebwell Jun 10, 2024
1e45f99
Add ability to show json or table
kylewadebwell Jun 10, 2024
068fa98
Handle errors and pending state
kylewadebwell Jun 10, 2024
2710271
Fix imports, minor refactor
kylewadebwell Jun 12, 2024
e40b2e4
Minor refactor
kylewadebwell Jun 12, 2024
327359e
Use a ToggleButtonGroup rather than a Button
kylewadebwell Jun 12, 2024
c39aee6
Move toggle into a reusable component with Redux state, simplify Alle…
kylewadebwell Jun 12, 2024
d58465a
Initialize toggle state on mount, add getAllergyIntolerances request
kylewadebwell Jun 12, 2024
0f3cd97
Initialize a default rather than using a side effect
kylewadebwell Jun 12, 2024
67a42ad
Add mui datagrid reference; add Connections page, Redux stuff and exa…
kylewadebwell Jun 24, 2024
e67605e
Fix dates in datagrid
kylewadebwell Jun 24, 2024
6ab1af6
Rewrite Allergy Intolerance Groups to use DataGrid; remove Allergy In…
kylewadebwell Jun 24, 2024
f3ba29d
Remove Hello page, add withAuthCheck HOC, use server pagination in mu…
kylewadebwell Jun 24, 2024
4b8b6cd
Add state persistence to local storage, logout feature, refactor out …
kylewadebwell Jun 25, 2024
6ccecfe
Minor bug fixes and refactors
kylewadebwell Jun 25, 2024
7d657a9
Fix SDK rehydration; add allergy intolerances; add bottom page margin
kylewadebwell Jun 28, 2024
e7124d3
Remove unused stuff
kylewadebwell Jun 28, 2024
66d8787
Remove unused code
kylewadebwell Jun 28, 2024
f7b8dfd
Refactor to make more reusable components
kylewadebwell Jun 28, 2024
21c3b85
Remove getSdk's reliance on state; remove logging
kylewadebwell Jun 28, 2024
bdf3ae2
Fix tableOrJsonToggle
kylewadebwell Jun 28, 2024
1a48023
Fix rehydration error message logic, no longer need to await getSdk
kylewadebwell Jun 29, 2024
873ccbc
Remove console logging, add Health Summary
kylewadebwell Jun 29, 2024
329f07d
Add Conditions
kylewadebwell Jun 29, 2024
10f9d35
Adjust table
kylewadebwell Jun 29, 2024
4b06d37
Add spaces to menu
kylewadebwell Jun 29, 2024
af0e890
Add columns to AllergyIntoleranceGroups
kylewadebwell Jun 29, 2024
0b42f22
Add source to condition groups
kylewadebwell Jun 29, 2024
24ea78c
Add Labs
kylewadebwell Jun 29, 2024
aaa86d6
Add referenceRange to Labs
kylewadebwell Jun 29, 2024
85e9caf
Add Care Plans
kylewadebwell Jun 29, 2024
a2e6a04
Add Encounters
kylewadebwell Jun 29, 2024
44dc8df
Add Immunizations
kylewadebwell Jun 29, 2024
3239caa
Add Procedures
kylewadebwell Jun 29, 2024
734cf9d
Add Vital Signs; fix pagination
kylewadebwell Jun 29, 2024
4ef9f24
Change dayMonthYear to monthDayYear
kylewadebwell Jun 29, 2024
cd2b8f6
Refactor to reduce duplicate code
kylewadebwell Jun 29, 2024
1c54c27
Clean up store directory
kylewadebwell Jun 29, 2024
649386a
Add Medications
kylewadebwell Jun 29, 2024
e2b6de0
Add Medication Knowledge
kylewadebwell Jun 29, 2024
39746d7
Add Lab Knowledge
kylewadebwell Jun 29, 2024
e8af302
Turn off row selection message
kylewadebwell Jun 29, 2024
9b993f8
Display HTML as well as JSON for Knowledge
kylewadebwell Jun 29, 2024
4ce25fa
Genericize toggle state and make it work better
kylewadebwell Jun 29, 2024
67663f7
Add HTML-JSON toggle to DisplayKnowledge
kylewadebwell Jun 29, 2024
67ef300
Remove console logging and unneeded default
kylewadebwell Jun 29, 2024
a834eea
Remove tests, fix page frameworks
kylewadebwell Jun 29, 2024
fd21753
Add test cases for Initialize
kylewadebwell Jun 29, 2024
5312b92
Remove unused key
kylewadebwell Jun 29, 2024
e792af6
Reset knowledge on page load
kylewadebwell Jun 29, 2024
88b2fbc
Standardize connections
kylewadebwell Jun 30, 2024
dff3371
Use reducers for request info
kylewadebwell Jun 30, 2024
c25ac91
Remove unused prop
kylewadebwell Jun 30, 2024
bab0ec9
Add groupCode to requestInfoSlice
kylewadebwell Jul 1, 2024
ed6df6c
Disable row selection for now
kylewadebwell Jul 1, 2024
225d3ed
Add groupCode support to HealthData pages
kylewadebwell Jul 1, 2024
e9e44f0
Update README
kylewadebwell Jul 1, 2024
b71a3aa
Hide Initialize page while rehydrating
kylewadebwell Jul 1, 2024
aeb474f
Fix weird login behavior
kylewadebwell Jul 2, 2024
8cb0ba5
Skip rehydration in brand-new session
kylewadebwell Jul 9, 2024
2dc45c7
Add getRows support to HealthDataGrid
kylewadebwell Jul 9, 2024
c04ba4e
Support client pagination for Connections screen
kylewadebwell Jul 9, 2024
aed4a05
Always await initialization
kylewadebwell Jul 19, 2024
f734fd1
Remove console log
kylewadebwell Jul 19, 2024
1f5cec9
Refactor tests, fix broken tests, add 'Log Out' option to side menu
kylewadebwell Jul 21, 2024
438077b
Fix TypeScript errors so it's possible to build
kylewadebwell Jul 22, 2024
23600ed
Update Readme and fix a bug on Medications
kylewadebwell Jul 22, 2024
c4dc3f0
Update .env.example
kylewadebwell Jul 22, 2024
84ad0c2
Fix error messages in tests; expect network error when well-formed ke…
kylewadebwell Jul 22, 2024
4c29c83
Move health reducers into a separate combineReducers call
kylewadebwell Jul 22, 2024
22306af
Remove key from .env.example
kylewadebwell Jul 22, 2024
f69f91e
Add TableOrJsonToggle to Connections
kylewadebwell Jul 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix rehydration error message logic, no longer need to await getSdk
  • Loading branch information
kylewadebwell committed Jun 29, 2024
commit 1a48023fc21a901662f2e7cc608f4bcf7dcad2ee
14 changes: 11 additions & 3 deletions bwell-typescript-react/src/components/withAuthCheck.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import { RootState } from '@/store/store';
import { Container } from '@mui/material';

// Higher-order component to do an auth check before rendering a component
function withAuthCheck(title: string, WrappedComponent: React.ComponentType) {
return function ProtectedComponent(props: any) {
const isLoggedIn = useSelector((state: RootState) => state.user.isLoggedIn);
const { isLoggedIn, oauthCreds, isRehydrated } = useSelector((state: RootState) => state.user);
const [errorMessage, setErrorMessage] = useState("Initializing...");

useEffect(() => {
if (!isRehydrated)
setErrorMessage("Rehydrating state...");
if (oauthCreds && !isLoggedIn)
setErrorMessage("Please log in to view this page.");
}, [oauthCreds, isLoggedIn]);

if (!isLoggedIn) {
return (
<Container>
<h1>{title}</h1>
<p>Please log in to view this page</p>
<p>{errorMessage}</p>
</Container>
);
}
Expand Down
3 changes: 1 addition & 2 deletions bwell-typescript-react/src/sdk/bWellSdk.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { RootState } from '@/store/store';
import { BWellSDK } from '@icanbwell/bwell-sdk-ts';

let bWellSdk: BWellSDK;
Expand All @@ -11,6 +10,6 @@ export const initializeSdk = (clientKey: string) => {
bWellSdk = new BWellSDK({ clientKey });
};

export const getSdk = async () => {
export const getSdk = () => {
if (bWellSdk) return bWellSdk;
}
2 changes: 2 additions & 0 deletions bwell-typescript-react/src/sdk/rehydrateSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const sdkMiddleware = (store) => (next) => async (action) => {
} catch (error) {
console.error('Error rehydrating SDK:', error);
}

action.payload.user.isRehydrated = true;
}

return next(action);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { createSlice, createAsyncThunk, PayloadAction } from "@reduxjs/toolkit";
import { getSdk } from "@/sdk/bWellSdk";
import { BWellQueryResult } from "@icanbwell/bwell-sdk-ts/dist/common/results";
import { AllergyIntoleranceGroupsRequest, AllergyIntolerancesGroupsResults } from "@icanbwell/bwell-sdk-ts";
import { PagedRequestInput } from "../../.yalc/@icanbwell/bwell-sdk-ts/dist/api/base/requests/paged-request";

export const getAllergyIntoleranceGroups = createAsyncThunk(
"allergyIntoleranceGroups/getAllergyIntoleranceGroups",
async ({ page, pageSize }: { page: number, pageSize: number }) => {
const bWellSdk = await getSdk();
const request = new AllergyIntoleranceGroupsRequest({ page, pageSize, });
async (inputParams: PagedRequestInput) => {
const bWellSdk = getSdk();
const request = new AllergyIntoleranceGroupsRequest(inputParams);
return bWellSdk?.health.getAllergyIntoleranceGroups(request);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { BWellQueryResult } from "../../.yalc/@icanbwell/bwell-sdk-ts/dist/commo
export const getAllergyIntolerances = createAsyncThunk(
"allergyIntolerances/getAllergyIntolerances",
async (inputParams: HealthDataRequestInput) => {
const bWellSdk = await getSdk();
const bWellSdk = getSdk();
const request = new AllergyIntolerancesRequest(inputParams);
return bWellSdk?.health.getAllergyIntolerances(request);
}
Expand Down
2 changes: 1 addition & 1 deletion bwell-typescript-react/src/store/connectionSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getSdk } from "@/sdk/bWellSdk";
export const getMemberConnections = createAsyncThunk(
"connections/memberConnections",
async () => {
const bWellSdk = await getSdk();
const bWellSdk = getSdk();
return bWellSdk?.connection.getMemberConnections();
}
);
Expand Down
2 changes: 2 additions & 0 deletions bwell-typescript-react/src/store/userSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { OperationOutcome } from "@icanbwell/bwell-sdk-ts/dist/common/models/res
interface UserState {
clientKey?: string;
oauthCreds?: string;
isRehydrated: boolean;
isInitialized: boolean;
isLoggedIn: boolean;
loading: boolean;
Expand Down Expand Up @@ -46,6 +47,7 @@ export const initialize = createAsyncThunk<

const initialState: UserState = {
isLoggedIn: false,
isRehydrated: false,
isInitialized: false,
loading: false,
error: null,
Expand Down