From af2d3c78187d2c5dc060c2ca397c28927587968c Mon Sep 17 00:00:00 2001 From: Sean <> Date: Fri, 26 Jul 2024 09:31:19 -0400 Subject: [PATCH 1/2] Updates for 2.2.3 Update version add logic wait for sds on start up Rolled back goal refresh updates --- .env | 2 +- package.json | 2 +- src/App.tsx | 10 ++++++++++ src/components/edit-forms/GoalEditForm.tsx | 16 ++++------------ src/components/summaries/GoalList.tsx | 18 ++---------------- 5 files changed, 18 insertions(+), 30 deletions(-) diff --git a/.env b/.env index e157071..8c275eb 100644 --- a/.env +++ b/.env @@ -89,6 +89,6 @@ REACT_APP_LOG_ENABLED=false REACT_APP_LOG_API_KEY=<...> REACT_APP_LOG_ENDPOINT_URI="http://localhost:8085" -REACT_APP_VERSION="version - SDS Beta" +REACT_APP_VERSION="version - 2.2.3" # Set to have HHS Banner REACT_APP_HHS_BANNER=false \ No newline at end of file diff --git a/package.json b/package.json index 4e030db..6f93753 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mycareplanner", - "version": "2.0.0", + "version": "2.2.3", "private": true, "homepage": "https://chronic-care.github.io/mycareplanner", "dependencies": { diff --git a/src/App.tsx b/src/App.tsx index 499142d..03e2098 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -625,6 +625,16 @@ class App extends React.Component { console.log('setSupplementalDataClient()') let client = await getSupplementalDataClient(patientId) + // wait for client to get online to fix refresh issue + var attempts = 0 + while (!client) { + client = await getSupplementalDataClient(patientId); + attempts++; + if (attempts < 10) { + break; + } + } + if (client) { // We have a valid client for the SDS, but, we don't know if it has any data yet // (or a valid patient / patient with data) diff --git a/src/components/edit-forms/GoalEditForm.tsx b/src/components/edit-forms/GoalEditForm.tsx index bf65bb2..13ffeed 100644 --- a/src/components/edit-forms/GoalEditForm.tsx +++ b/src/components/edit-forms/GoalEditForm.tsx @@ -18,25 +18,19 @@ import { createSharedDataResource } from '../../data-services/fhirService'; export default function GoalEditForm(formData?: EditFormData) { let history = useHistory() - const location = useLocation(); + const location = useLocation(); const prepopulatedDescription = (location.state as { prepopulatedDescription?: string })?.prepopulatedDescription ?? ''; - const prepopulatedDate = (location.state as { prepopulatedDate?: Date })?.prepopulatedDate ?? null; - const prepopulatedDueDate = (location.state as { prepopulatedDueDate?: Date })?.prepopulatedDueDate ?? null; - const incrementGoalCount = (location.state as { incrementGoalCount?: Function })?.incrementGoalCount ?? null; + const prepopulatedDate = (location.state as { prepopulatedDate?: Date })?.prepopulatedDate ?? null; + const prepopulatedDueDate = (location.state as {prepopulatedDueDate?: Date})?.prepopulatedDueDate ?? null; const [description, setDescription] = React.useState(prepopulatedDescription); const [startDate, setStartDate] = React.useState( prepopulatedDate ? moment(prepopulatedDate).add(0, 'day').toDate() : null ); - + const [dueDate, setDueDate] = React.useState( prepopulatedDueDate ? moment(prepopulatedDueDate).add(0, 'day').toDate() : null ); - // useEffect(() => { - // save should update this - // incrementGoalCount() - // }, [?if WHAT changes, we increment above ?]) - const patientID = formData?.supplementalDataClient?.getPatientId() const patientName: string | null = null // TODO: find patient with matching ID from formData?patientSummaries const fhirUser = formData?.supplementalDataClient?.getFhirUser() @@ -85,8 +79,6 @@ export default function GoalEditForm(formData?: EditFormData) { createSharedDataResource(goal) - incrementGoalCount && incrementGoalCount() - // update FHIRData shared state history.goBack() diff --git a/src/components/summaries/GoalList.tsx b/src/components/summaries/GoalList.tsx index d8ffed3..163d614 100644 --- a/src/components/summaries/GoalList.tsx +++ b/src/components/summaries/GoalList.tsx @@ -26,19 +26,6 @@ export const GoalList: FC = ({ fhirDataCollection, goalSummaryMat const [sortedAndFilteredGoals, setSortedAndFilteredGoals] = useState<{ goal: GoalSummary, provider: string }[]>([]); const [filteringOptions, setFilteringOptions] = useState<{ value: string; label: string }[]>([]); - const [goalCount, setGoalCount] = useState(0) - // callback for GoalEditForm - const incrementGoalCount = () => { - let newCount: number = goalCount - newCount++ - setGoalCount(newCount) - } - - useEffect(() => { - console.log("if goalCount was updated by GoalEditForm via save...reload the data") - applySortingAndFiltering(); - }, [goalCount]) - useEffect(() => { applySortingAndFiltering(); }, [goalSummaryMatrix, sortingOption, filteringOption]); @@ -128,8 +115,7 @@ export const GoalList: FC = ({ fhirDataCollection, goalSummaryMat goalData: goal, prepopulatedDescription: goal.Description, prepopulatedDate: goal.StartDate || null, - prepopulatedDueDate: goal?.Target?.[0]?.DueDate || null, - incrementGoalCount: incrementGoalCount + prepopulatedDueDate: goal?.Target?.[0]?.DueDate || null } }); }; @@ -353,4 +339,4 @@ const buildTargetValueAndDueDate = (curTarget: GoalTarget): SummaryRowItem => { data1: curTarget.TargetValue === null ? '' : 'Target: ' + curTarget.TargetValue, data2: curTarget.DueDate === null ? '' : 'Due: ' + curTarget.DueDate, }; -}; +}; \ No newline at end of file From 9d6017a977eaa9f64c506277a799ac51d0de5624 Mon Sep 17 00:00:00 2001 From: Sean <> Date: Mon, 29 Jul 2024 11:08:46 -0400 Subject: [PATCH 2/2] Updates for goal processing Rolled back initial version of useeffect --- .env | 7 +++- src/components/edit-forms/GoalEditForm.tsx | 5 ++- src/components/summaries/GoalList.tsx | 4 +++ src/data-services/fhirService.ts | 41 ++++++++++++++++++++-- 4 files changed, 51 insertions(+), 6 deletions(-) diff --git a/.env b/.env index 8c275eb..fe27b8b 100644 --- a/.env +++ b/.env @@ -11,13 +11,18 @@ GENERATE_SOURCEMAP=false # REACT_APP_SHARED_DATA_AUTH_ENDPOINT= # REACT_APP_SHARED_DATA_SCOPE="launch/patient openid fhirUser patient/*.read patient/*.write" +REACT_APP_SHARED_DATA_ENDPOINT=http://localhost:8080/fhir +REACT_APP_SHARED_DATA_AUTH_ENDPOINT=https://gw.interop.community/MCCDevelopment/data +REACT_APP_SHARED_DATA_SCOPE="launch/patient openid fhirUser patient/* user/*.cruds patient/*.cruds" + + # These 2 parameters are only used when Shared Data is a separate FHIR server with its own SMART launch flow. REACT_APP_SHARED_DATA_CLIENT_ID= REACT_APP_SHARED_DATA_REDIRECT_URI="./index.html" REACT_APP_MELD_SANDBOX_NAME=MCCDevelopment -REACT_APP_MELD_SANDBOX_CLIENT_ID=<...> +REACT_APP_MELD_SANDBOX_CLIENT_ID=5fa54c47-ed80-405b-a0b7-611eee5d0159 # Logica sandbox REACT_APP_CLIENT_ID_logica=<...> diff --git a/src/components/edit-forms/GoalEditForm.tsx b/src/components/edit-forms/GoalEditForm.tsx index 13ffeed..4e4d6d7 100644 --- a/src/components/edit-forms/GoalEditForm.tsx +++ b/src/components/edit-forms/GoalEditForm.tsx @@ -77,9 +77,7 @@ export default function GoalEditForm(formData?: EditFormData) { } console.log('New Goal: ' + JSON.stringify(goal)) - createSharedDataResource(goal) - - // update FHIRData shared state + createSharedDataResource(goal,formData?.fhirDataCollection) history.goBack() }; @@ -155,3 +153,4 @@ export default function GoalEditForm(formData?: EditFormData) { ); } + diff --git a/src/components/summaries/GoalList.tsx b/src/components/summaries/GoalList.tsx index 163d614..155a534 100644 --- a/src/components/summaries/GoalList.tsx +++ b/src/components/summaries/GoalList.tsx @@ -10,6 +10,7 @@ import { SortModal } from '../sort-modal/sortModal'; import { SortOnlyModal } from '../sort-only-modal/sortOnlyModal'; import EditIcon from '@mui/icons-material/Edit'; import Button from '@mui/material/Button'; +import GoalEditForm from '../edit-forms/GoalEditForm'; interface GoalListProps { fhirDataCollection?: FHIRData[]; @@ -121,7 +122,10 @@ export const GoalList: FC = ({ fhirDataCollection, goalSummaryMat }; return ( + +
+

Health Goals

diff --git a/src/data-services/fhirService.ts b/src/data-services/fhirService.ts index aa4ae67..a30aead 100644 --- a/src/data-services/fhirService.ts +++ b/src/data-services/fhirService.ts @@ -851,14 +851,51 @@ const setAndLogNonTerminatingErrorMessageStateForResource = async ( setAndLogErrorMessageState('Non-terminating', message.replaceAll('', resourceName), `Failure in getFHIRData retrieving ${resourceName} data.`, errorCaught) } - -export function createSharedDataResource(resource: Resource) { +export function createSharedDataResource(resource: Resource, fhirDataCollection?: FHIRData[]) { return getSupplementalDataClient(null) .then((client: Client | undefined) => { // console.log('SDS client: ' + JSON.stringify(client)) return client?.create(resource as fhirclient.FHIR.Resource) }) .then((response) => { + + + if (resource.resourceType === "Goal") { + fhirDataCollection?.forEach(fhirData => { + + console.error('fhirData : ' + fhirData.serverUrl) ; + console.error('fhirData : ' + fhirData.isSDS) ; + console.error('fhirData : ' + fhirData.serverUrl) ; + console.error('fhirData : ' + fhirData.isSDS) ; + console.error('fhirData : ' + fhirData.serverUrl) ; + console.error('fhirData : ' + fhirData.isSDS) ; + console.error('fhirData : ' + fhirData.serverUrl) ; + console.error('fhirData : ' + fhirData.isSDS) ; + console.error('fhirData : ' + fhirData.serverUrl) ; + console.error('fhirData : ' + fhirData.isSDS) ; + console.error('fhirData : ' + fhirData.serverUrl) ; + console.error('fhirData : ' + fhirData.isSDS) ; + console.error('fhirData : ' + fhirData.serverUrl) ; + console.error('fhirData : ' + fhirData.isSDS) ; + console.error('fhirData : ' + fhirData.serverUrl) ; + console.error('fhirData : ' + fhirData.isSDS) ; + if (fhirData.isSDS) { + fhirData.goals?.push(resource as Goal); + + console.error('fhirData : ' + JSON.stringify(fhirData.goals)) ; + } + // let index = selected.indexOf(value) + // if (index > -1) { + // selected.splice(index, 1) + // } + // else { + // selected.push(value) + // } + }) + // this.setState({selectedOptions: selected}) + // } + } + console.error('SDS client: ' + JSON.stringify(fhirDataCollection)) ; return response }).catch(error => { console.log('Cannot create shared data resource: ' + resource.resourceType + '/' + resource.id + ' error: ', error)