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

Normalization of Patient Data #1404

Open
jonahkaye opened this issue Jan 4, 2024 · 2 comments
Open

Normalization of Patient Data #1404

jonahkaye opened this issue Jan 4, 2024 · 2 comments

Comments

@jonahkaye
Copy link
Member

Problem

In this PR, we began the conversation about normalising patient data #1160
Some considerations that need to still be addressed:

  1. How to deal with default values
  2. How to handle addresses broadly as well as how to use services like AWS address service
  3. How we deal with patients with multiple names and all the complexity of a patient name
  4. How this interacts with an MPI more broadly, and the structure of "persons" and "patients"

Suggested solution

WIP

Alternatives

No response

Additional context

No response

@jonahkaye
Copy link
Member Author

jonahkaye commented Jan 14, 2024

Code we had in PR:

const defaultValues = {
  firstName: "john",
  lastName: "doe",
  address: [{ addressLine1: "123 main street", city: "anytown", zip: "00000" }],
  contact: [{ email: "example@example.com", phone: "0000000000" }],
};

/**
 * The function checks if a patient's address or name matches the default values and returns null if
 * they do, otherwise it updates the patient's contact information and returns the modified patient
 * object.
 * @param patient - The `patient` parameter is an object of type `Patient`. It
 * represents the data of a patient, including their address, name, and contact information.
 * @returns either a modified `Patient` object or `null`.
 */
function handleDefaultValues(patient: Patient): Patient | undefined {
  const isDefaultAddress = patient.data.address?.some(
    addr =>
      addr &&
      (addr.addressLine1 === defaultValues.address?.[0]?.addressLine1 ||
        addr.city === defaultValues.address?.[0]?.city ||
        addr.zip === defaultValues.address?.[0]?.zip)
  );

  const isDefaultName =
    patient.data.firstName === defaultValues.firstName &&
    patient.data.lastName === defaultValues.lastName;

  if (isDefaultAddress || isDefaultName) {
    return undefined;
  }

  patient.data.contact = (patient.data.contact ?? []).map(contact => {
    const defaultContact = defaultValues.contact?.[0];
    if (!defaultContact) {
      return contact;
    }
    return {
      email: contact.email === defaultContact.email ? "" : contact.email,
      phone: contact.phone === defaultContact.phone ? "" : contact.phone,
    };
  });

  return patient;
}```

@jonahkaye
Copy link
Member Author

Make sure to have unit testing for all pieces of the normalization

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant