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

Change handling of legacy occurrence point data #5022

Merged
merged 8 commits into from
Feb 5, 2025

Conversation

gigxz
Copy link
Contributor

@gigxz gigxz commented Dec 29, 2024

Merging this PR

  • use the squash-merge strategy

Description

Issue: https://github.com/open-path/Green-River/issues/7236

This is walking back a previous assumption which said "you would only have one Occurrence Point form per field you're collecting". So only ONE move-in form, ONE unit assignment form, etc. If you want to customize it it can be done with custom_rule values.

Proposed approach is to only show the enabled forms, PLUS special logic to show Move-in Date, DOE, and PATH status if there is data that would otherwise be hidden.

"Bug" Reproduction:

  • Add and publish second form that collects Move-in Date. Don't add any rules to enable it.
  • Previous Behavior Move-in date is duplicated on all Enrollment Dashboards. It shows up once per form.
  • New Behavior the new move-in date form doesn't appear unless specified
Screenshot 2024-12-29 at 2 36 30 PM

Scenarios requiring this change:

  • Multiple move-in forms (hypothetical)
    • Project type X collects Move-in Date using form A which has a required move-in address on it
    • Project type Y collects Move-in Date using form B which does not have move-in address on it
  • Multiple occurrence point forms that collect/display current_unit (https://github.com/open-path/Green-River/issues/7093)
    • One form is read-only, used for most projects
    • One form allows anyone to edit, used for certain projects

Type of change

Bug fix

Checklist before requesting review

  • I have performed a self-review of my code
  • I have run the code that is being changed under ideal conditions, and it doesn't fail
  • If adding a new endpoint / exposing data in a new way, I have:
  • Any major architectural changes are supported by an approved ADR (Architectural Decision Record)
  • I have updated the documentation (or not applicable)
  • I have added spec tests (or not applicable)
  • I have provided testing instructions in this PR or the related issue (or not applicable)

@gigxz gigxz changed the base branch from stable to release-146 December 29, 2024 19:30
@gigxz gigxz changed the title Gig/7093 fix duplicate occurrence point bug Change handling of legacy occurrence point data Dec 29, 2024
@gigxz gigxz requested review from martha and ttoomey December 30, 2024 19:01
Copy link
Contributor

@ttoomey ttoomey left a comment

Choose a reason for hiding this comment

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

looks reasonable to me, thanks!

@@ -339,49 +339,51 @@ def data_collection_features
end.compact
end

# Occurrence Point Forms that are enabled for this Enrollment.
# Returns array of OpenStructs, which are resolved by the HmisSchema::OccurrencePointForm GQL type.
def occurrence_point_forms
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine; it's consistent with how the other models. But the Enrollment class is getting kind of big (550 lines). I wonder if this might be an opportunity to extract this into some kind of single-purpose service class

class Enrollment 
  #...
  def occurrence_point_forms
    OccurrencePointFormCollection.new(self).all
  end
end

class OccurrencePointFormCollection
  def initialize(enrollment)
    @enrollment = enrollment
  end

  def all =  active_forms + legacy_forms

  def active_forms
    definitions = Hmis::Form::Definition
      .with_role(:OCCURRENCE_POINT)
      .published_or_retired
      .latest_versions
    # definitions.map ...
  end

  def legacy_forms
    #...
  end
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion and snippet @ttoomey, I updated this to use a class. Both the Enrollment and Project occurrence point form function logic are moved into it

Base automatically changed from release-146 to stable January 23, 2025 18:14
@gigxz gigxz changed the base branch from stable to release-151 February 3, 2025 22:10
@gigxz gigxz marked this pull request as ready for review February 4, 2025 22:09
Copy link
Contributor

@ttoomey ttoomey left a comment

Choose a reason for hiding this comment

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

This looks great, thanks for the restructure!

@gigxz gigxz merged commit e284a34 into release-151 Feb 5, 2025
53 checks passed
@gigxz gigxz deleted the gig/7093-fix-duplicate-occurrence-point-bug branch February 5, 2025 12:54
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

Successfully merging this pull request may close these issues.

3 participants