Skip to content

Commit

Permalink
Update Goal Edit to support reloading GoalList
Browse files Browse the repository at this point in the history
  • Loading branch information
drbgfc committed Jul 25, 2024
1 parent 8791eea commit 3524a23
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 27 deletions.
16 changes: 12 additions & 4 deletions src/components/edit-forms/GoalEditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,25 @@ 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 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 [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 @@ -79,6 +85,8 @@ export default function GoalEditForm(formData?: EditFormData) {

createSharedDataResource(goal)

incrementGoalCount && incrementGoalCount()

// update FHIRData shared state

history.goBack()
Expand Down
18 changes: 16 additions & 2 deletions src/components/summaries/GoalList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ 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 @@ -115,7 +128,8 @@ export const GoalList: FC<GoalListProps> = ({ fhirDataCollection, goalSummaryMat
goalData: goal,
prepopulatedDescription: goal.Description,
prepopulatedDate: goal.StartDate || null,
prepopulatedDueDate: goal?.Target?.[0]?.DueDate || null
prepopulatedDueDate: goal?.Target?.[0]?.DueDate || null,
incrementGoalCount: incrementGoalCount
}
});
};
Expand Down Expand Up @@ -339,4 +353,4 @@ const buildTargetValueAndDueDate = (curTarget: GoalTarget): SummaryRowItem => {
data1: curTarget.TargetValue === null ? '' : 'Target: ' + curTarget.TargetValue,
data2: curTarget.DueDate === null ? '' : 'Due: ' + curTarget.DueDate,
};
};
};
33 changes: 12 additions & 21 deletions src/data-services/endpoints/providers.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
[
{
"name": "MCC Develop Sandbox",
"config": {
"iss": "https://gw.interop.community/MCCDevelopment/data",
"redirectUri": "./index.html",
"clientId": "5fa54c47-ed80-405b-a0b7-611eee5d0159",
"scope": "launch launch/patient openid fhirUser patient/Patient.read patient/Practitioner.read patient/RelatedPerson.read patient/Condition.read patient/DiagnosticReport.read patient/Observation.read patient/Procedure.read patient/CarePlan.read patient/CareTeam.read patient/Goal.read patient/Immunization.read patient/MedicationRequest.read patient/ServiceRequest.read patient/Task.read patient/Questionnaire.read patient/QuestionnaireResponse.write patient/Goal.write patient/MedicationRequest.write patient/Condition.write patient/Provenance.read"
}
},
{
"name": "MCC Testing Sandbox",
"name": "SDS: eCare Shared Data",
"config": {
"iss": "https://gw.interop.community/MCCTesting/data",
"iss": "https://gw.interop.community/eCareSharedData/open/",
"redirectUri": "./index.html",
"clientId": "5fa54c47-ed80-405b-a0b7-611eee5d0159",
"scope": "launch launch/patient openid fhirUser patient/Patient.read patient/Practitioner.read patient/RelatedPerson.read patient/Condition.read patient/DiagnosticReport.read patient/Observation.read patient/Procedure.read patient/CarePlan.read patient/CareTeam.read patient/Goal.read patient/Immunization.read patient/MedicationRequest.read patient/ServiceRequest.read patient/Task.read patient/Questionnaire.read patient/QuestionnaireResponse.write patient/Goal.write patient/MedicationRequest.write patient/Condition.write patient/Provenance.read"
"scope": "launch/patient openid fhirUser patient/*.read patient/*.write"
}
},
{
"name": "MCC Staging Sandbox",
"name": "Test Data: Epic Sandbox",
"config": {
"iss": "https://gw.interop.community/MCCStaging/data",
"iss": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4",
"redirectUri": "./index.html",
"clientId": "5fa54c47-ed80-405b-a0b7-611eee5d0159",
"scope": "launch launch/patient openid fhirUser patient/Patient.read patient/Practitioner.read patient/RelatedPerson.read patient/Condition.read patient/DiagnosticReport.read patient/Observation.read patient/Procedure.read patient/CarePlan.read patient/CareTeam.read patient/Goal.read patient/Immunization.read patient/MedicationRequest.read patient/ServiceRequest.read patient/Task.read patient/Questionnaire.read patient/QuestionnaireResponse.write patient/Goal.write patient/MedicationRequest.write patient/Condition.write patient/Provenance.read"
"clientId": "821ea3c1-011f-4f70-a8ae-299043b7e0be",
"scope": "launch launch/patient openid fhirUser patient/Patient.read patient/Practitioner.read patient/RelatedPerson.read patient/Condition.read patient/DiagnosticReport.read patient/Observation.read patient/Procedure.read patient/CarePlan.read patient/CareTeam.read patient/Goal.read patient/Immunization.read patient/MedicationRequest.read patient/Medication.read patient/Provenance.read patient/Organization.read"
}
},
{
"name": "SDS: eCare Shared Data",
"name": "Test Data: Cerner Sandbox",
"config": {
"iss": "https://gw.interop.community/eCareSharedData/open/",
"iss": "https://fhir-myrecord.cerner.com/r4/ec2458f2-1e24-41c8-b71b-0e701af7583d",
"redirectUri": "./index.html",
"scope": "launch/patient openid fhirUser patient/*.read patient/*.write"
"clientId": "3992b136-a2d8-47e5-9ea3-62663c0dc7dc",
"scope": "launch/patient openid fhirUser offline_access patient/Patient.read user/Practitioner.read user/Location.read user/Organization.read patient/CarePlan.read patient/CareTeam.read patient/Condition.read patient/Goal.read patient/Immunization.read patient/Observation.read patient/Procedure.read patient/MedicationRequest.read patient/RelatedPerson.read patient/ServiceRequest.read patient/Provenance.read"
}
}
}
]

0 comments on commit 3524a23

Please sign in to comment.