Skip to content

Commit 181d7bd

Browse files
committed
Remove requirement for clinic to have a team
This helps to keep the clinic model similar to the school model, allowing for two separate CLI tools: one which creates clinics and another which adds them to organisations.
1 parent e9e1016 commit 181d7bd

3 files changed

Lines changed: 6 additions & 11 deletions

File tree

app/models/location.rb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,13 @@ class Location < ApplicationRecord
6464
validates :url, url: true, allow_nil: true
6565
validates :urn, uniqueness: true, allow_nil: true
6666

67-
with_options if: :clinic? do
68-
validates :team, presence: true
69-
end
70-
7167
with_options if: :community_clinic? do
7268
validates :ods_code, exclusion: { in: :organisation_ods_code }
7369
end
7470

7571
with_options if: :generic_clinic? do
7672
validates :ods_code, inclusion: { in: :organisation_ods_code }
73+
validates :team, presence: true
7774
end
7875

7976
with_options if: :gp_practice? do
@@ -121,9 +118,9 @@ def create_default_programme_year_groups!(programmes)
121118

122119
private
123120

124-
def organisation_ods_code
125-
[team&.organisation&.ods_code]
126-
end
121+
def organisation_ods_code = [team&.organisation&.ods_code].compact
127122

128-
def fhir_mapper = @fhir_mapper ||= FHIRMapper::Location.new(self)
123+
def fhir_mapper
124+
@fhir_mapper ||= FHIRMapper::Location.new(self)
125+
end
129126
end

spec/factories/locations.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@
6565
name { "#{Faker::University.name} Clinic" }
6666

6767
sequence(:ods_code, 100) { "CL#{_1}" }
68-
69-
organisation
7068
end
7169

7270
factory :generic_clinic do

spec/models/location_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
"gias_establishment_number" => nil,
176176
"gias_local_authority_code" => nil,
177177
"id" => location.id,
178-
"is_attached_to_organisation" => true,
178+
"is_attached_to_organisation" => false,
179179
"name" => location.name,
180180
"ods_code" => location.ods_code,
181181
"status" => "unknown",

0 commit comments

Comments
 (0)