Skip to content

Commit

Permalink
Only returning active patient objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Filienko committed Nov 18, 2023
1 parent 22b1d29 commit 54c8fb7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/FhirClientProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ export default function FhirClientProvider(props: Props): JSX.Element {
console.log("Using stored patient id ", queryPatientId);
return getFhirData(client, "/Patient/" + queryPatientId).then(
(value: any) => {
return Patient.from(value);
let patient: Patient = Patient.from(value)
let active_patient: Patient = patient.active === true ? patient : undefined;
return active_patient;
}
);
}
// Get the Patient resource
return await client.patient.read().then((value: any) => {
return Patient.from(value);
});
let patient: Patient = Patient.from(value)
let active_patient: Patient = patient.active === true ? patient : undefined;
return active_patient;
});
}

async function getPractitioner(
Expand Down
8 changes: 7 additions & 1 deletion src/components/ScheduleSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,12 @@ export default class ScheduleSetup extends React.Component<
);
}

if (!patient.active) {
return new Promise((resolve, reject) =>
reject("The patient is not active.")
);
}

let params = new URLSearchParams({
telecom: `${patient.smsContactPoint}`,
// FIXME
Expand All @@ -488,7 +494,7 @@ export default class ScheduleSetup extends React.Component<
}
}
);
if (patients.find((o) => o.id !== patient.id)) {
if ((patients.find((o) => o.id !== patient.id && o.active == true))) {
// exclude current patient, workaround for above FIXME
reject(
`Phone number is already associated with: ${patients
Expand Down
3 changes: 2 additions & 1 deletion src/model/CommunicationRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ export class CommunicationRequest implements ICommunicationRequest {
sender: Patient | Practitioner = null,
note: string = ""
) {
return this.createNewOutgoingMessage(
let c = this.createNewOutgoingMessage(
messageContent,
patient,
carePlan,
IsaccMessageCategory.isaccManuallySentMessage,
sender,
note
);
return c
}

static createNewOutgoingMessage(
Expand Down

0 comments on commit 54c8fb7

Please sign in to comment.