5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/roles/services/sltc_registration_completer.rb', line 5
def complete(params)
configure_only = params[:configure_only].present? && params[:configure_only] == 'true'
am = find_or_create_account_mapping(params[:third_party_id], params[:account_id])
ca = find_or_create_configured_account(params[:service_definition_id], params[:account_id], configure_only)
return if configure_only
si = ca.service_definition.service_implementation
si.identify_providers(ca)
uploaded_before = Time.now
uploaded_after = uploaded_before - (params[:baseline_days].present? ? params[:baseline_days].to_i : 90).days
abaqis_facility_ids = ApplicationApi.api_impl.enabled_facilities_for_account_id(params[:account_id]).pluck(:id)
ca.service_definition.third_party.facility_mappings.where(facility_id: abaqis_facility_ids).each do | facility_mapping |
si.request_baseline(ca, facility_mapping.facility_code, uploaded_after, uploaded_before)
end
update_attributes(status: Services::SltcRegistration::STATUS_REGISTERED)
end
|