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

6306 add next of kin to patient edit #6339

Merged
merged 11 commits into from
Jan 30, 2025

Conversation

lache-melvin
Copy link
Contributor

@lache-melvin lache-melvin commented Jan 29, 2025

Fixes #6306

πŸ‘©πŸ»β€πŸ’» What does this PR do?

Adds next of kin to patient edit:
Screenshot 2025-01-29 at 5 14 45β€―PM

Note that this will need to be mapped separately for custom patient implementations in program schemas repo πŸ™

πŸ’Œ Any notes for the reviewer?

NOTE THAT PATIENT INPUT CURRENTLY NOT WORKING PER #6338 - working now :)

πŸ§ͺ Testing

  • Be using default patient schema
  • Go to patient edit view
  • There is a next of kin field
  • You can select another patient to be the next of kin
  • Saves accordingly
  • Also works when creating a new patient

πŸ“ƒ Documentation

  • Part of an epic: documentation will be completed for the feature as a whole
  • No documentation required: no user facing changes or a bug fix which isn't a change in behaviour
  • These areas should be updated or checked:
    1.
    2.

@github-actions github-actions bot added this to the v2.6.0 milestone Jan 29, 2025
Copy link

github-actions bot commented Jan 29, 2025

Bundle size difference

Comparing this PR to main

Old size New size Diff
5.25 MB 5.25 MB 1.08 KB (0.02%)

@Chris-Petty Chris-Petty self-assigned this Jan 29, 2025
Base automatically changed from 6305-add-next-of-kin-to-patient-schema to develop January 29, 2025 23:02
@lache-melvin lache-melvin changed the base branch from develop to 6338-fix-autocomplete January 29, 2025 23:04
@lache-melvin
Copy link
Contributor Author

Hi @Chris-Petty FYI I just rebased this off #6348 so patient input should be working for u to test ❀️

Base automatically changed from 6338-fix-autocomplete to develop January 29, 2025 23:47
Copy link
Contributor

@Chris-Petty Chris-Petty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SWELL, bar the whole input not working thing... maybe I should retest when that's fixed haha

Comment on lines 30 to 33
if (!props.visible) {
return null;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better put this at the top of the func and avoid fetching the patient data for an invisible component?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: could have destructured visible out like the rest of the props at the top

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahaha I was curious what ControlProps were, it's a rabbit hole of jsonforms package types all the way down. Dunno how you're supposed to know what props a component even has, or rather implements? Like how do you know a component actually does anything with the visible prop? Let alone the other dozen on ControlProps that we really don't use in this instance.

Just kinda feels like typescript going full circle, typescripting so hard that the intellisense no longer is reliable haha

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually should have requested changes on the first 2 but I forgot about these comments lol

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahaha I was curious what ControlProps were...

Haha gonna be so honest I just copied from the other JsonForm components, assumed they were handled one way or another πŸ˜…

Wouldn't it be better put this at the top of the func and avoid fetching the patient data for an invisible component?

Can't conditionally render a hook, but can pull this out into another component πŸ™ 10e4d3c

Copy link
Contributor

@Chris-Petty Chris-Petty Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahaha I was curious what ControlProps were...

Haha gonna be so honest I just copied from the other JsonForm components, assumed they were handled one way or another πŸ˜…

Wouldn't it be better put this at the top of the func and avoid fetching the patient data for an invisible component?

Can't conditionally render a hook, but can pull this out into another component πŸ™ 10e4d3c

Oh duh yea, and whoa life hack!

is_deceased,
date_of_death,
next_of_kin_id,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never really questioned it and assumed it must have something to do with DB read/writes as it's often in those areas and tests. But seeing as it's presented itself here... why do we have inline_init it seems like it's just instantiating a struct but with more steps?

To take another random example:

    fn row_4() -> SyncBufferRow {
        inline_init(|r: &mut SyncBufferRow| {
            r.record_id = "4".to_string();
            r.table_name = "name".to_string();
            r.received_datetime = Defaults::naive_date_time();
        })
    }

Or

    fn row_4() -> SyncBufferRow {
        SyncBufferRow {
            record_id: "4".to_string(),
            table_name: "name".to_string(),
            received_datetime: Defaults::naive_date_time(),
            ..Default::default()
        }
    }

Only tangible difference is having to call ..Default::default(), which the compiler will remind you of anyway. I figure a rust NERD would say the latter is more idiomatic, just using the lang feature for instantiating. Also just more readable/less chars imo. Just a guess, because rust has such a surface area or even changed, perhaps ..Default::default() just flew under the radar heh. Pretty easy to happen when std structs can have like 100 std implemented functions.

One heck of a refactor issue 🀣

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah inline_init is old - recommending ..Default::default() now. Yep like you say pretty sure default() was missed, but we should lean on language features. I try to change when I run into them, but yet another thing we haven't taken the time to clean up yet 😭

Especially in this case it's not good, because we actually don't want to default the rest of the input fields, we want to handle them all πŸ˜…

@@ -5,6 +5,7 @@ mod add_index_to_sync_buffer;
mod add_name_next_of_kin_id;
mod add_program_deleted_datetime;
mod backend_plugins;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ”₯

@lache-melvin
Copy link
Contributor Author

bar the whole input not working thing

Should be workin?

Copy link
Contributor

@Chris-Petty Chris-Petty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

IT'S BEAUTIFUL

@lache-melvin lache-melvin merged commit 94029a7 into develop Jan 30, 2025
6 of 7 checks passed
@lache-melvin lache-melvin deleted the 6306-add-next-of-kin-to-patient-edit branch January 30, 2025 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add next of kin to patient edit view
2 participants