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

[Closes #132] Add additional information for the results of the Physician search #135

Merged
merged 23 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9ca8de0
include hospital data for each physician
Oct 4, 2024
24f1a4e
display name of hospital with each physician in form dropdrown
Oct 4, 2024
a036688
Displays physician followed by hospital name only if it exists
Oct 4, 2024
4849cef
Format selected value
Oct 4, 2024
c6ada31
Fixed format issues with Prettier
Oct 4, 2024
1ddac19
Fixed bug related to pagination headers
Oct 8, 2024
9679edd
Formatted with Prettier
Oct 8, 2024
d1e4e4c
Modify pagination parameters to avoid conflicts
Oct 21, 2024
bd4a12a
Update display of dropdown values
Oct 21, 2024
bd63ad8
Include hospitals in physician query
Oct 21, 2024
e9b2490
Restore to previous approach of paginating results
Oct 21, 2024
98c96aa
Refactored data mapping to hospital name
Oct 21, 2024
5ff8584
Update initial physician input
Oct 21, 2024
02e8d16
Modified component with hospital data
Oct 21, 2024
57ae77f
Reformatted physician input value
Oct 21, 2024
09b0e5e
Merge branch dev into issue-132
samau3 Oct 21, 2024
a571345
Add nullish operator to prevent accessing undefined properties
samau3 Oct 21, 2024
09401f1
Modify string creation logic to remove extra characters
samau3 Oct 21, 2024
385885a
Remove passing initial hospital data prop as it is unused
samau3 Oct 21, 2024
c7255d0
Display physician name and their hospital if patient has that informa…
samau3 Oct 21, 2024
179ce4b
Separate out the pieces for string construction of physician details
samau3 Oct 21, 2024
2cf217d
Display physician name, hospital, and phone number in combobox drop down
samau3 Oct 21, 2024
7861aa6
Format files
samau3 Oct 21, 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
1 change: 1 addition & 0 deletions client/src/pages/patients/LifelineAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default class LifelineAPI {
return {
...item,
name: `${item.firstName} ${item.lastName}`,
hospital: item.hospitals[0]?.name,
};
});
}
Expand Down
12 changes: 9 additions & 3 deletions client/src/pages/patients/register/PatientRegistration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,15 @@ export default function PatientRegistration() {

setInitialHospitalData(hospital ? hospital.name : '');

setInitialPhysicianData(
physician ? `${physician.firstName} ${physician.lastName}` : '',
);
if (physician) {
const fullName = `${physician.firstName}${physician.middleName ? ` ${physician.middleName}` : ''} ${physician.lastName}`;
const hospital = physician.hospitals[0]
? physician.hospitals[0].name
: '';
const phone = physician.phone ? `${physician.phone} ` : '';
const physicianDetails = `${fullName}${hospital ? ` (${hospital})` : ''}${phone ? ` - ${phone}` : ''}`;
setInitialPhysicianData(physicianDetails);
}

const patientData = {
firstName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,16 @@ export default function HealthcareChoicesSearch({ form, choice, initialData }) {

const handleSelectValue = (id, key) => {
const name = key.children;
// setValue({ id, name });
setSearch(name);
setSearch(name.join(''));
form.setFieldValue(`healthcareChoices.${choice}Id`, id);
combobox.closeDropdown();
};

const options = (data || []).map((item) => (
<Combobox.Option value={item.id} key={item.id}>
{item.name}
{item.hospital ? ` (${item.hospital})` : ''}
{item.phone ? ` - ${item.phone}` : ''}
</Combobox.Option>
));

Expand Down
9 changes: 7 additions & 2 deletions server/prisma/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ const prisma = new PrismaClient({
name: 'paginate',
model: {
$allModels: {
async paginate({ page, perPage, ...options }) {
async paginate({ page, perPage, include, ...options }) {
const take = parseInt(perPage, 10);
const skip = (parseInt(page, 10) - 1) * take;
const context = Prisma.getExtensionContext(this);
const total = await context.count(options);
const records = await context.findMany({ ...options, skip, take });
const records = await context.findMany({
...options,
include,
skip,
take,
});
return { records, total };
},
},
Expand Down
19 changes: 18 additions & 1 deletion server/routes/api/v1/patients/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ export default async function (fastify, _opts) {
lastName: { type: 'string' },
phone: { type: 'string' },
email: { type: 'string' },
hospitals: {
type: 'array',
items: {
type: 'object',
properties: {
id: { type: 'string' },
name: { type: 'string' },
address: { type: 'string' },
phone: { type: 'string' },
email: { type: 'string' },
},
},
},
},
},
updatedById: { type: 'string' },
Expand Down Expand Up @@ -98,7 +111,11 @@ export default async function (fastify, _opts) {
orderBy: { sortOrder: 'asc' },
},
hospital: true,
physician: true,
physician: {
include: {
hospitals: true,
},
},
},
});
if (!patient) throw new Error('Patient not found');
Expand Down
12 changes: 11 additions & 1 deletion server/routes/api/v1/physicians/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ export default async function (fastify) {
phone: { type: 'string' },
firstName: { type: 'string' },
lastName: { type: 'string' },
hospitals: {
type: 'array',
items: {
type: 'object',
properties: {
id: { type: 'string' },
name: { type: 'string' },
},
},
},
},
},
},
Expand Down Expand Up @@ -71,12 +81,12 @@ export default async function (fastify) {
],
};
}

const options = {
page,
perPage,
orderBy: [{ firstName: 'asc' }, { lastName: 'asc' }],
where: whereClase,
include: { hospitals: true },
};

const { records, total } =
Expand Down