Skip to content

Commit

Permalink
Merge pull request #82 from swmuir/develop
Browse files Browse the repository at this point in the history
Updates for 2.2.3
  • Loading branch information
swmuir authored Jul 29, 2024
2 parents e886a59 + 9d6017a commit 8121bb7
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 36 deletions.
9 changes: 7 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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=<...>
Expand Down Expand Up @@ -89,6 +94,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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mycareplanner",
"version": "2.0.0",
"version": "2.2.3",
"private": true,
"homepage": "https://chronic-care.github.io/mycareplanner",
"dependencies": {
Expand Down
10 changes: 10 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,16 @@ class App extends React.Component<AppProps, AppState> {
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)
Expand Down
21 changes: 6 additions & 15 deletions src/components/edit-forms/GoalEditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(prepopulatedDescription);
const [startDate, setStartDate] = React.useState<Date | null>(
prepopulatedDate ? moment(prepopulatedDate).add(0, 'day').toDate() : null
);

const [dueDate, setDueDate] = React.useState<Date | null>(
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()
Expand Down Expand Up @@ -83,11 +77,7 @@ export default function GoalEditForm(formData?: EditFormData) {
}
console.log('New Goal: ' + JSON.stringify(goal))

createSharedDataResource(goal)

incrementGoalCount && incrementGoalCount()

// update FHIRData shared state
createSharedDataResource(goal,formData?.fhirDataCollection)

history.goBack()
};
Expand Down Expand Up @@ -163,3 +153,4 @@ export default function GoalEditForm(formData?: EditFormData) {
</React.Fragment>
);
}

22 changes: 6 additions & 16 deletions src/components/summaries/GoalList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -26,19 +27,6 @@ export const GoalList: FC<GoalListProps> = ({ fhirDataCollection, goalSummaryMat
const [sortedAndFilteredGoals, setSortedAndFilteredGoals] = useState<{ goal: GoalSummary, provider: string }[]>([]);
const [filteringOptions, setFilteringOptions] = useState<{ value: string; label: string }[]>([]);

const [goalCount, setGoalCount] = useState<number>(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]);
Expand Down Expand Up @@ -128,14 +116,16 @@ export const GoalList: FC<GoalListProps> = ({ 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
}
});
};

return (


<div className="home-view">

<div className="welcome">
<h4 className="title">Health Goals</h4>

Expand Down Expand Up @@ -353,4 +343,4 @@ const buildTargetValueAndDueDate = (curTarget: GoalTarget): SummaryRowItem => {
data1: curTarget.TargetValue === null ? '' : 'Target: ' + curTarget.TargetValue,
data2: curTarget.DueDate === null ? '' : 'Due: ' + curTarget.DueDate,
};
};
};
41 changes: 39 additions & 2 deletions src/data-services/fhirService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -851,14 +851,51 @@ const setAndLogNonTerminatingErrorMessageStateForResource = async (
setAndLogErrorMessageState('Non-terminating', message.replaceAll('<RESOURCE_NAME>', 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)
Expand Down

0 comments on commit 8121bb7

Please sign in to comment.