Skip to content

Conversation

alistair-white-horne-tng
Copy link
Contributor

Implement some extra logic when importing, which:

  • automatically accepts any capitalisation differences in relevant import fields, without staging the changes for review
  • matches patients whose postcode only differs by capitalisation
  • saves all incoming parental information to the existing matched parent

MAV-926

@thomasleese thomasleese added the feature New functionality label Apr 9, 2025
@thomasleese thomasleese added this to the v2.2.1 milestone Apr 20, 2025
@alistair-white-horne-tng alistair-white-horne-tng force-pushed the accept-import-caps-differences branch 4 times, most recently from 525d89a to 620165f Compare April 28, 2025 16:32
@thomasleese thomasleese changed the base branch from main to v2.2.1-wip April 30, 2025 13:25
@alistair-white-horne-tng alistair-white-horne-tng force-pushed the accept-import-caps-differences branch 2 times, most recently from 69cf6a4 to d5a8c60 Compare April 30, 2025 16:28
@TheOneFromNorway TheOneFromNorway force-pushed the accept-import-caps-differences branch from d5a8c60 to c3c8688 Compare April 30, 2025 19:05
@alistair-white-horne-tng alistair-white-horne-tng force-pushed the accept-import-caps-differences branch 7 times, most recently from fb56247 to b6f8b99 Compare May 1, 2025 08:48
@alistair-white-horne-tng alistair-white-horne-tng force-pushed the accept-import-caps-differences branch 5 times, most recently from 8ce9388 to 2719233 Compare May 6, 2025 10:03
@alistair-white-horne-tng alistair-white-horne-tng changed the base branch from v2.2.1-wip to v2.2.2-wip May 6, 2025 11:27
@alistair-white-horne-tng alistair-white-horne-tng removed this from the v2.2.1 milestone May 6, 2025
@alistair-white-horne-tng alistair-white-horne-tng added this to the v2.2.2 milestone May 6, 2025
@thomasleese thomasleese force-pushed the v2.2.2-wip branch 3 times, most recently from 70bd51f to 3f6e39d Compare May 6, 2025 11:50
@alistair-white-horne-tng alistair-white-horne-tng force-pushed the accept-import-caps-differences branch from 2719233 to 07d4db9 Compare May 7, 2025 10:32
@thomasleese thomasleese force-pushed the v2.2.2-wip branch 2 times, most recently from 1045f5f to d1cf05b Compare May 12, 2025 10:51
@alistair-white-horne-tng alistair-white-horne-tng force-pushed the accept-import-caps-differences branch 2 times, most recently from c5cbc83 to aa5838b Compare May 13, 2025 08:42

included { attribute :pending_changes, :jsonb, default: {} }

def stage_changes(attributes)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there's potential to refactor this method as I'm finding it a bit complicated/hard to read. I've got a suggestion below which I think works and I find easier to understand:

def stage_changes(attributes)
  attributes.each do |attr, new_value|
    current_value = public_send(attr)

    if normalised(new_value) == normalised(current_value)
      public_send("#{attr}=", new_value)
      pending_changes.delete(attr.to_s)
    else
      pending_changes[attr.to_s] = new_value
    end
  end

  save!
end

private

def normalised(value)
  value.respond_to?(:downcase) ? value.downcase : value
end

What do you think?

@alistair-white-horne-tng alistair-white-horne-tng force-pushed the accept-import-caps-differences branch from aa5838b to a9148b3 Compare May 13, 2025 16:40
Copy link

@thomasleese thomasleese deleted the branch nhsuk:v2.2.2-wip May 14, 2025 20:39
@thomasleese
Copy link
Contributor

Hmm it seems like merging v2.2.2-wip in to main closed this, I think because it's a fork. You'll probably want to re-open it @alistair-white-horne-tng.

@alistair-white-horne-tng
Copy link
Contributor Author

New PR for this change: #3588

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

Successfully merging this pull request may close these issues.

3 participants