dhis2 2.3.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/PULL_REQUEST_TEMPLATE.md +11 -0
- data/Gemfile +2 -1
- data/README.md +208 -68
- data/Rakefile +4 -2
- data/bin/console +1 -0
- data/changelog.md +7 -0
- data/dhis2.gemspec +8 -8
- data/lib/dhis2/api/base.rb +5 -94
- data/lib/dhis2/api/bulk_creatable.rb +28 -0
- data/lib/dhis2/api/constants.rb +13 -0
- data/lib/dhis2/api/creatable.rb +47 -0
- data/lib/dhis2/api/deletable.rb +12 -0
- data/lib/dhis2/api/event_creation_status.rb +58 -0
- data/lib/dhis2/api/findable.rb +52 -0
- data/lib/dhis2/api/import_summary.rb +61 -0
- data/lib/dhis2/api/listable.rb +78 -0
- data/lib/dhis2/api/query_parameters_formatter.rb +50 -0
- data/lib/dhis2/api/shared/analytic.rb +20 -0
- data/lib/dhis2/api/shared/category_combo.rb +29 -0
- data/lib/dhis2/api/shared/category_option_combo.rb +23 -0
- data/lib/dhis2/api/shared/constants.rb +35 -0
- data/lib/dhis2/api/shared/data_element_group.rb +25 -0
- data/lib/dhis2/api/shared/data_set.rb +22 -0
- data/lib/dhis2/api/shared/data_value.rb +26 -0
- data/lib/dhis2/api/shared/data_value_set.rb +58 -0
- data/lib/dhis2/api/shared/event.rb +54 -0
- data/lib/dhis2/api/shared/organisation_unit.rb +17 -0
- data/lib/dhis2/api/shared/organisation_unit_group.rb +21 -0
- data/lib/dhis2/api/shared/report_tables.rb +32 -0
- data/lib/dhis2/api/shared/resource_table.rb +19 -0
- data/lib/dhis2/api/shared/save_validator.rb +47 -0
- data/lib/dhis2/api/shared/system_info.rb +19 -0
- data/lib/dhis2/api/updatable.rb +33 -0
- data/lib/dhis2/api/version224/analytic.rb +10 -0
- data/lib/dhis2/api/version224/attribute.rb +23 -0
- data/lib/dhis2/api/version224/category_combo.rb +25 -0
- data/lib/dhis2/api/version224/category_option_combo.rb +23 -0
- data/lib/dhis2/api/version224/constants.rb +22 -0
- data/lib/dhis2/api/version224/data_element.rb +45 -0
- data/lib/dhis2/api/version224/data_element_group.rb +22 -0
- data/lib/dhis2/api/version224/data_set.rb +53 -0
- data/lib/dhis2/api/version224/data_value.rb +11 -0
- data/lib/dhis2/api/version224/data_value_set.rb +25 -0
- data/lib/dhis2/api/version224/event.rb +31 -0
- data/lib/dhis2/api/version224/index.rb +27 -0
- data/lib/dhis2/api/version224/indicator.rb +24 -0
- data/lib/dhis2/api/version224/indicator_group.rb +20 -0
- data/lib/dhis2/api/version224/indicator_type.rb +20 -0
- data/lib/dhis2/api/version224/organisation_unit.rb +24 -0
- data/lib/dhis2/api/version224/organisation_unit_group.rb +22 -0
- data/lib/dhis2/api/version224/organisation_unit_group_set.rb +20 -0
- data/lib/dhis2/api/version224/organisation_unit_level.rb +21 -0
- data/lib/dhis2/api/version224/program.rb +26 -0
- data/lib/dhis2/api/version224/report.rb +20 -0
- data/lib/dhis2/api/version224/report_table.rb +21 -0
- data/lib/dhis2/api/version224/resource_table.rb +11 -0
- data/lib/dhis2/api/version224/save_validator.rb +48 -0
- data/lib/dhis2/api/version224/system_info.rb +11 -0
- data/lib/dhis2/api/version224/user.rb +15 -0
- data/lib/dhis2/api/version225/analytic.rb +10 -0
- data/lib/dhis2/api/version225/attribute.rb +23 -0
- data/lib/dhis2/api/version225/category_combo.rb +25 -0
- data/lib/dhis2/api/version225/category_option_combo.rb +23 -0
- data/lib/dhis2/api/version225/constants.rb +22 -0
- data/lib/dhis2/api/version225/data_element.rb +45 -0
- data/lib/dhis2/api/version225/data_element_group.rb +22 -0
- data/lib/dhis2/api/version225/data_set.rb +35 -0
- data/lib/dhis2/api/version225/data_value.rb +11 -0
- data/lib/dhis2/api/version225/data_value_set.rb +25 -0
- data/lib/dhis2/api/version225/event.rb +31 -0
- data/lib/dhis2/api/version225/index.rb +26 -0
- data/lib/dhis2/api/version225/indicator.rb +24 -0
- data/lib/dhis2/api/version225/indicator_group.rb +20 -0
- data/lib/dhis2/api/version225/indicator_type.rb +20 -0
- data/lib/dhis2/api/version225/organisation_unit.rb +24 -0
- data/lib/dhis2/api/version225/organisation_unit_group.rb +22 -0
- data/lib/dhis2/api/version225/organisation_unit_group_set.rb +20 -0
- data/lib/dhis2/api/version225/organisation_unit_level.rb +21 -0
- data/lib/dhis2/api/version225/program.rb +26 -0
- data/lib/dhis2/api/version225/report.rb +20 -0
- data/lib/dhis2/api/version225/report_table.rb +21 -0
- data/lib/dhis2/api/version225/resource_table.rb +11 -0
- data/lib/dhis2/api/version225/system_info.rb +11 -0
- data/lib/dhis2/api/version225/user.rb +15 -0
- data/lib/dhis2/api/version226/analytic.rb +10 -0
- data/lib/dhis2/api/version226/attribute.rb +23 -0
- data/lib/dhis2/api/version226/category_combo.rb +25 -0
- data/lib/dhis2/api/version226/category_option_combo.rb +23 -0
- data/lib/dhis2/api/version226/constants.rb +22 -0
- data/lib/dhis2/api/version226/data_element.rb +42 -0
- data/lib/dhis2/api/version226/data_element_group.rb +22 -0
- data/lib/dhis2/api/version226/data_set.rb +32 -0
- data/lib/dhis2/api/version226/data_value.rb +11 -0
- data/lib/dhis2/api/version226/data_value_set.rb +25 -0
- data/lib/dhis2/api/version226/event.rb +31 -0
- data/lib/dhis2/api/version226/index.rb +26 -0
- data/lib/dhis2/api/version226/indicator.rb +24 -0
- data/lib/dhis2/api/version226/indicator_group.rb +20 -0
- data/lib/dhis2/api/version226/indicator_type.rb +20 -0
- data/lib/dhis2/api/version226/organisation_unit.rb +24 -0
- data/lib/dhis2/api/version226/organisation_unit_group.rb +22 -0
- data/lib/dhis2/api/version226/organisation_unit_group_set.rb +20 -0
- data/lib/dhis2/api/version226/organisation_unit_level.rb +21 -0
- data/lib/dhis2/api/version226/program.rb +24 -0
- data/lib/dhis2/api/version226/report.rb +20 -0
- data/lib/dhis2/api/version226/report_table.rb +21 -0
- data/lib/dhis2/api/version226/resource_table.rb +11 -0
- data/lib/dhis2/api/version226/system_info.rb +11 -0
- data/lib/dhis2/api/version226/user.rb +15 -0
- data/lib/dhis2/api/version227/analytic.rb +10 -0
- data/lib/dhis2/api/version227/attribute.rb +23 -0
- data/lib/dhis2/api/version227/category_combo.rb +25 -0
- data/lib/dhis2/api/version227/category_option_combo.rb +23 -0
- data/lib/dhis2/api/version227/constants.rb +22 -0
- data/lib/dhis2/api/version227/data_element.rb +42 -0
- data/lib/dhis2/api/version227/data_element_group.rb +22 -0
- data/lib/dhis2/api/version227/data_set.rb +32 -0
- data/lib/dhis2/api/version227/data_value.rb +11 -0
- data/lib/dhis2/api/version227/data_value_set.rb +25 -0
- data/lib/dhis2/api/version227/event.rb +31 -0
- data/lib/dhis2/api/version227/index.rb +26 -0
- data/lib/dhis2/api/version227/indicator.rb +24 -0
- data/lib/dhis2/api/version227/indicator_group.rb +20 -0
- data/lib/dhis2/api/version227/indicator_type.rb +20 -0
- data/lib/dhis2/api/version227/organisation_unit.rb +24 -0
- data/lib/dhis2/api/version227/organisation_unit_group.rb +22 -0
- data/lib/dhis2/api/version227/organisation_unit_group_set.rb +20 -0
- data/lib/dhis2/api/version227/organisation_unit_level.rb +21 -0
- data/lib/dhis2/api/version227/program.rb +24 -0
- data/lib/dhis2/api/version227/report.rb +20 -0
- data/lib/dhis2/api/version227/report_table.rb +21 -0
- data/lib/dhis2/api/version227/resource_table.rb +11 -0
- data/lib/dhis2/api/version227/system_info.rb +11 -0
- data/lib/dhis2/api/version227/user.rb +15 -0
- data/lib/dhis2/api/version228/analytic.rb +10 -0
- data/lib/dhis2/api/version228/attribute.rb +23 -0
- data/lib/dhis2/api/version228/category_combo.rb +25 -0
- data/lib/dhis2/api/version228/category_option_combo.rb +23 -0
- data/lib/dhis2/api/version228/constants.rb +22 -0
- data/lib/dhis2/api/version228/data_element.rb +41 -0
- data/lib/dhis2/api/version228/data_element_group.rb +22 -0
- data/lib/dhis2/api/version228/data_set.rb +32 -0
- data/lib/dhis2/api/version228/data_value.rb +11 -0
- data/lib/dhis2/api/version228/data_value_set.rb +25 -0
- data/lib/dhis2/api/version228/event.rb +31 -0
- data/lib/dhis2/api/version228/index.rb +26 -0
- data/lib/dhis2/api/version228/indicator.rb +24 -0
- data/lib/dhis2/api/version228/indicator_group.rb +20 -0
- data/lib/dhis2/api/version228/indicator_type.rb +20 -0
- data/lib/dhis2/api/version228/organisation_unit.rb +24 -0
- data/lib/dhis2/api/version228/organisation_unit_group.rb +22 -0
- data/lib/dhis2/api/version228/organisation_unit_group_set.rb +20 -0
- data/lib/dhis2/api/version228/organisation_unit_level.rb +21 -0
- data/lib/dhis2/api/version228/program.rb +24 -0
- data/lib/dhis2/api/version228/report.rb +20 -0
- data/lib/dhis2/api/version228/report_table.rb +21 -0
- data/lib/dhis2/api/version228/resource_table.rb +11 -0
- data/lib/dhis2/api/version228/system_info.rb +11 -0
- data/lib/dhis2/api/version228/user.rb +15 -0
- data/lib/dhis2/case.rb +46 -0
- data/lib/dhis2/classes.rb +44 -0
- data/lib/dhis2/client.rb +152 -89
- data/lib/dhis2/collection_wrapper.rb +13 -3
- data/lib/dhis2/configuration.rb +55 -1
- data/lib/dhis2/error.rb +19 -0
- data/lib/dhis2/pager.rb +8 -3
- data/lib/dhis2/version.rb +1 -1
- data/lib/dhis2.rb +51 -42
- metadata +168 -50
- data/lib/dhis2/api/analytic.rb +0 -20
- data/lib/dhis2/api/attribute.rb +0 -8
- data/lib/dhis2/api/category_combo.rb +0 -28
- data/lib/dhis2/api/category_option_combo.rb +0 -8
- data/lib/dhis2/api/data_element.rb +0 -34
- data/lib/dhis2/api/data_element_group.rb +0 -32
- data/lib/dhis2/api/data_set.rb +0 -33
- data/lib/dhis2/api/data_value.rb +0 -15
- data/lib/dhis2/api/data_value_set.rb +0 -71
- data/lib/dhis2/api/event.rb +0 -36
- data/lib/dhis2/api/indicator.rb +0 -8
- data/lib/dhis2/api/indicator_group.rb +0 -8
- data/lib/dhis2/api/organisation_unit.rb +0 -66
- data/lib/dhis2/api/organisation_unit_group.rb +0 -38
- data/lib/dhis2/api/organisation_unit_group_set.rb +0 -6
- data/lib/dhis2/api/organisation_unit_level.rb +0 -8
- data/lib/dhis2/api/program.rb +0 -8
- data/lib/dhis2/api/report.rb +0 -8
- data/lib/dhis2/api/report_table.rb +0 -8
- data/lib/dhis2/api/resource_table.rb +0 -14
- data/lib/dhis2/api/system_info.rb +0 -13
- data/lib/dhis2/api/user.rb +0 -8
- data/lib/dhis2/import_error.rb +0 -6
- data/lib/dhis2/status.rb +0 -42
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Shared
|
|
6
|
+
module OrganisationUnitGroup
|
|
7
|
+
def organisation_unit_ids
|
|
8
|
+
organisation_units.map do |organisation_unit|
|
|
9
|
+
organisation_unit["id"]
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def group_set_ids
|
|
14
|
+
[organisation_unit_group_set, group_sets].flatten.compact.map do |group_set|
|
|
15
|
+
group_set["id"]
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Shared
|
|
6
|
+
module ReportTable
|
|
7
|
+
def self.included(base)
|
|
8
|
+
base.extend(ClassMethods)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def instance_update_success?(_response)
|
|
14
|
+
# response is empty so...
|
|
15
|
+
true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
module ClassMethods
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def created_instance_id(_response)
|
|
22
|
+
nil
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def instance_creation_success?(response)
|
|
26
|
+
response["status"] == "OK"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Shared
|
|
6
|
+
module ResourceTable
|
|
7
|
+
def self.included(base)
|
|
8
|
+
base.extend(ClassMethods)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
module ClassMethods
|
|
12
|
+
def analytics(client)
|
|
13
|
+
client.post(path: "resourceTables/analytics")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Shared
|
|
6
|
+
module SaveValidator
|
|
7
|
+
def self.included(base)
|
|
8
|
+
base.extend(ClassMethods)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def validate_instance_update(response)
|
|
14
|
+
unless instance_update_success?(response)
|
|
15
|
+
raise Dhis2::UpdateError, "Update error. #{response}"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def instance_update_success?(response)
|
|
20
|
+
self.class.base_response_check(response) &&
|
|
21
|
+
response["http_status"] == "OK"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
module ClassMethods
|
|
25
|
+
def validate_instance_creation(response)
|
|
26
|
+
unless instance_creation_success?(response)
|
|
27
|
+
raise Dhis2::CreationError, "Creation error. #{response}"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def instance_creation_success?(response)
|
|
32
|
+
base_response_check(response) &&
|
|
33
|
+
response["http_status"] == "Created"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def created_instance_id(response)
|
|
37
|
+
response["response"]["uid"]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def base_response_check(response)
|
|
41
|
+
response["status"] == "OK"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Shared
|
|
6
|
+
module SystemInfo
|
|
7
|
+
def self.included(base)
|
|
8
|
+
base.extend(ClassMethods)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
module ClassMethods
|
|
12
|
+
def get(client)
|
|
13
|
+
client.get(path: "/system/info")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Updatable
|
|
6
|
+
def update_attributes(attributes)
|
|
7
|
+
client.patch(
|
|
8
|
+
path: "#{self.class.resource_name}/#{id}",
|
|
9
|
+
payload: attributes
|
|
10
|
+
)
|
|
11
|
+
attributes.each do |key, value|
|
|
12
|
+
public_send("#{key}=", value)
|
|
13
|
+
end
|
|
14
|
+
self
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def update
|
|
18
|
+
client.put(
|
|
19
|
+
path: "#{self.class.resource_name}/#{id}",
|
|
20
|
+
payload: update_args
|
|
21
|
+
).tap do |response|
|
|
22
|
+
validate_instance_update(response)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def update_args
|
|
29
|
+
to_h.reject { |k, _| k == :client }
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
class Attribute < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Listable
|
|
8
|
+
include ::Dhis2::Api::Findable
|
|
9
|
+
include ::Dhis2::Api::Creatable
|
|
10
|
+
include ::Dhis2::Api::Updatable
|
|
11
|
+
include ::Dhis2::Api::Deletable
|
|
12
|
+
include ::Dhis2::Api::Version224::SaveValidator
|
|
13
|
+
|
|
14
|
+
Schema = Dry::Validation.Schema do
|
|
15
|
+
required(:name).filled
|
|
16
|
+
required(:value_type).value(
|
|
17
|
+
included_in?: ::Dhis2::Api::Version224::Constants.value_types
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
class CategoryCombo < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Listable
|
|
8
|
+
include ::Dhis2::Api::Findable
|
|
9
|
+
include ::Dhis2::Api::Creatable
|
|
10
|
+
include ::Dhis2::Api::BulkCreatable
|
|
11
|
+
include ::Dhis2::Api::Updatable
|
|
12
|
+
include ::Dhis2::Api::Deletable
|
|
13
|
+
include ::Dhis2::Api::Version224::SaveValidator
|
|
14
|
+
include ::Dhis2::Api::Shared::CategoryCombo
|
|
15
|
+
|
|
16
|
+
Schema = Dry::Validation.Schema do
|
|
17
|
+
required(:name).filled
|
|
18
|
+
required(:data_dimension_type).value(
|
|
19
|
+
included_in?: ::Dhis2::Api::Version224::Constants.data_dimension_types
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
class CategoryOptionCombo < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Listable
|
|
8
|
+
include ::Dhis2::Api::Findable
|
|
9
|
+
include ::Dhis2::Api::Creatable
|
|
10
|
+
include ::Dhis2::Api::Updatable
|
|
11
|
+
include ::Dhis2::Api::Deletable
|
|
12
|
+
include ::Dhis2::Api::Version224::SaveValidator
|
|
13
|
+
include ::Dhis2::Api::Shared::CategoryOptionCombo
|
|
14
|
+
|
|
15
|
+
Schema = Dry::Validation.Schema do
|
|
16
|
+
required(:category_combo).schema do
|
|
17
|
+
required(:id).filled
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
module Constants
|
|
7
|
+
include ::Dhis2::Api::Shared::Constants
|
|
8
|
+
|
|
9
|
+
VALUE_TYPES = %w(UNIT_INTERVAL LETTER BOOLEAN NUMBER TEXT DATE LONG_TEXT FILE_RESOURCE USERNAME TRACKER_ASSOCIATE COORDINATE INTEGER_POSITIVE DATETIME EMAIL TRUE_ONLY INTEGER INTEGER_ZERO_OR_POSITIVE TIME INTEGER_NEGATIVE PERCENTAGE PHONE_NUMBER).freeze
|
|
10
|
+
AGGREGATION_TYPES = %w(DEFAULT MAX AVERAGE_INT_DISAGGREGATION SUM AVERAGE_BOOL AVERAGE_INT COUNT CUSTOM STDDEV AVERAGE_SUM_ORG_UNIT NONE AVERAGE_SUM_INT AVERAGE_SUM_INT_DISAGGREGATION AVERAGE VARIANCE MIN).freeze
|
|
11
|
+
|
|
12
|
+
def self.value_types
|
|
13
|
+
VALUE_TYPES
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.aggregation_types
|
|
17
|
+
AGGREGATION_TYPES
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
class DataElement < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Listable
|
|
8
|
+
include ::Dhis2::Api::Findable
|
|
9
|
+
include ::Dhis2::Api::Creatable
|
|
10
|
+
include ::Dhis2::Api::BulkCreatable
|
|
11
|
+
include ::Dhis2::Api::Updatable
|
|
12
|
+
include ::Dhis2::Api::Deletable
|
|
13
|
+
include ::Dhis2::Api::Version224::SaveValidator
|
|
14
|
+
|
|
15
|
+
Schema = Dry::Validation.Schema do
|
|
16
|
+
required(:name).filled
|
|
17
|
+
required(:short_name).filled
|
|
18
|
+
required(:aggregation_type).value(
|
|
19
|
+
included_in?: ::Dhis2::Api::Version224::Constants.aggregation_types
|
|
20
|
+
)
|
|
21
|
+
required(:domain_type).value(
|
|
22
|
+
included_in?: ::Dhis2::Api::Version224::Constants.domain_types
|
|
23
|
+
)
|
|
24
|
+
required(:value_type).value(
|
|
25
|
+
included_in?: ::Dhis2::Api::Version224::Constants.value_types
|
|
26
|
+
)
|
|
27
|
+
required(:category_combo).schema do
|
|
28
|
+
required(:id).filled
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.creation_defaults(args)
|
|
33
|
+
{
|
|
34
|
+
aggregation_type: "SUM",
|
|
35
|
+
code: args[:short_name],
|
|
36
|
+
domain_type: "AGGREGATE",
|
|
37
|
+
type: "int",
|
|
38
|
+
value_type: "NUMBER",
|
|
39
|
+
zero_is_significant: true
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
class DataElementGroup < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Listable
|
|
8
|
+
include ::Dhis2::Api::Findable
|
|
9
|
+
include ::Dhis2::Api::Creatable
|
|
10
|
+
include ::Dhis2::Api::BulkCreatable
|
|
11
|
+
include ::Dhis2::Api::Updatable
|
|
12
|
+
include ::Dhis2::Api::Deletable
|
|
13
|
+
include ::Dhis2::Api::Version224::SaveValidator
|
|
14
|
+
include ::Dhis2::Api::Shared::DataElementGroup
|
|
15
|
+
|
|
16
|
+
Schema = Dry::Validation.Schema do
|
|
17
|
+
required(:name).filled
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
class DataSet < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Listable
|
|
8
|
+
include ::Dhis2::Api::Findable
|
|
9
|
+
include ::Dhis2::Api::Creatable
|
|
10
|
+
include ::Dhis2::Api::BulkCreatable
|
|
11
|
+
include ::Dhis2::Api::Updatable
|
|
12
|
+
include ::Dhis2::Api::Deletable
|
|
13
|
+
include ::Dhis2::Api::Version224::SaveValidator
|
|
14
|
+
|
|
15
|
+
Schema = Dry::Validation.Schema do
|
|
16
|
+
required(:name).filled
|
|
17
|
+
required(:period_type).value(
|
|
18
|
+
included_in?: ::Dhis2::Api::Version224::Constants.period_types
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def add_data_elements(new_data_element_ids)
|
|
23
|
+
(new_data_element_ids - data_element_ids).each do |data_element_id|
|
|
24
|
+
add_data_element(data_element_id, check: true)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def add_data_element(data_element_id, check: true)
|
|
29
|
+
# this returns 204 on success and failure...
|
|
30
|
+
client.post(path: "dataSets/#{id}/dataElements/#{data_element_id}", payload: {})
|
|
31
|
+
return unless check
|
|
32
|
+
updated_set = self.class.find(client, id)
|
|
33
|
+
if updated_set.data_element_ids.include?(data_element_id)
|
|
34
|
+
self.data_elements = updated_set.data_elements
|
|
35
|
+
else
|
|
36
|
+
raise Dhis2::DataElementAdditionError, "Could not add dataElement #{data_element_id}"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def data_element_ids
|
|
41
|
+
data_elements.map { |de| de["id"] }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def self.creation_defaults(args)
|
|
45
|
+
{
|
|
46
|
+
code: args[:short_name],
|
|
47
|
+
period_type: "Monthly"
|
|
48
|
+
}
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
class DataValueSet < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Creatable
|
|
8
|
+
include ::Dhis2::Api::Listable
|
|
9
|
+
include ::Dhis2::Api::Version224::SaveValidator
|
|
10
|
+
include ::Dhis2::Api::Shared::DataValueSet
|
|
11
|
+
|
|
12
|
+
Schema = Dry::Validation.Schema do
|
|
13
|
+
required(:data_values).each do
|
|
14
|
+
schema do
|
|
15
|
+
required(:value).filled
|
|
16
|
+
required(:period).filled
|
|
17
|
+
required(:org_unit).filled
|
|
18
|
+
required(:data_element).filled
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
class Event < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Listable
|
|
8
|
+
include ::Dhis2::Api::Findable
|
|
9
|
+
include ::Dhis2::Api::BulkCreatable
|
|
10
|
+
include ::Dhis2::Api::Creatable
|
|
11
|
+
include ::Dhis2::Api::Deletable
|
|
12
|
+
include ::Dhis2::Api::Version224::SaveValidator
|
|
13
|
+
include ::Dhis2::Api::Shared::Event
|
|
14
|
+
|
|
15
|
+
BulkCreationStatusClass = ::Dhis2::Api::EventCreationStatus
|
|
16
|
+
|
|
17
|
+
# args for a program without registration
|
|
18
|
+
# and a program with a program_stage
|
|
19
|
+
Schema = Dry::Validation.Schema do
|
|
20
|
+
required(:program).filled # program must be linked to the org unit
|
|
21
|
+
required(:org_unit).filled
|
|
22
|
+
required(:event_date).filled
|
|
23
|
+
required(:data_values).each do
|
|
24
|
+
required(:data_element).filled
|
|
25
|
+
required(:value).filled
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "save_validator"
|
|
4
|
+
require_relative "constants"
|
|
5
|
+
require_relative "analytic"
|
|
6
|
+
require_relative "attribute"
|
|
7
|
+
require_relative "category_combo"
|
|
8
|
+
require_relative "category_option_combo"
|
|
9
|
+
require_relative "data_element"
|
|
10
|
+
require_relative "data_element_group"
|
|
11
|
+
require_relative "data_set"
|
|
12
|
+
require_relative "data_value"
|
|
13
|
+
require_relative "data_value_set"
|
|
14
|
+
require_relative "event"
|
|
15
|
+
require_relative "indicator"
|
|
16
|
+
require_relative "indicator_group"
|
|
17
|
+
require_relative "indicator_type"
|
|
18
|
+
require_relative "organisation_unit"
|
|
19
|
+
require_relative "organisation_unit_group"
|
|
20
|
+
require_relative "organisation_unit_group_set"
|
|
21
|
+
require_relative "organisation_unit_level"
|
|
22
|
+
require_relative "program"
|
|
23
|
+
require_relative "report_table"
|
|
24
|
+
require_relative "resource_table"
|
|
25
|
+
require_relative "report"
|
|
26
|
+
require_relative "system_info"
|
|
27
|
+
require_relative "user"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
class Indicator < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Listable
|
|
8
|
+
include ::Dhis2::Api::Findable
|
|
9
|
+
include ::Dhis2::Api::Creatable
|
|
10
|
+
include ::Dhis2::Api::Updatable
|
|
11
|
+
include ::Dhis2::Api::Deletable
|
|
12
|
+
include ::Dhis2::Api::Version224::SaveValidator
|
|
13
|
+
|
|
14
|
+
Schema = Dry::Validation.Schema do
|
|
15
|
+
required(:name).filled
|
|
16
|
+
required(:short_name).filled
|
|
17
|
+
required(:numerator).filled
|
|
18
|
+
required(:denominator).filled
|
|
19
|
+
required(:indicator_type).filled
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
class IndicatorGroup < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Listable
|
|
8
|
+
include ::Dhis2::Api::Findable
|
|
9
|
+
include ::Dhis2::Api::Creatable
|
|
10
|
+
include ::Dhis2::Api::Updatable
|
|
11
|
+
include ::Dhis2::Api::Deletable
|
|
12
|
+
include ::Dhis2::Api::Version224::SaveValidator
|
|
13
|
+
|
|
14
|
+
Schema = Dry::Validation.Schema do
|
|
15
|
+
required(:name).filled
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
class IndicatorType < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Listable
|
|
8
|
+
include ::Dhis2::Api::Findable
|
|
9
|
+
include ::Dhis2::Api::Creatable
|
|
10
|
+
include ::Dhis2::Api::Updatable
|
|
11
|
+
include ::Dhis2::Api::Deletable
|
|
12
|
+
include ::Dhis2::Api::Version224::SaveValidator
|
|
13
|
+
|
|
14
|
+
Schema = Dry::Validation.Schema do
|
|
15
|
+
required(:name).filled
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
class OrganisationUnit < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Listable
|
|
8
|
+
include ::Dhis2::Api::Findable
|
|
9
|
+
include ::Dhis2::Api::Creatable
|
|
10
|
+
include ::Dhis2::Api::BulkCreatable
|
|
11
|
+
include ::Dhis2::Api::Updatable
|
|
12
|
+
include ::Dhis2::Api::Deletable
|
|
13
|
+
include ::Dhis2::Api::Version224::SaveValidator
|
|
14
|
+
include ::Dhis2::Api::Shared::OrganisationUnit
|
|
15
|
+
|
|
16
|
+
Schema = Dry::Validation.Schema do
|
|
17
|
+
required(:name).filled
|
|
18
|
+
required(:short_name).filled
|
|
19
|
+
required(:opening_date).filled
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
class OrganisationUnitGroup < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Listable
|
|
8
|
+
include ::Dhis2::Api::Findable
|
|
9
|
+
include ::Dhis2::Api::Creatable
|
|
10
|
+
include ::Dhis2::Api::BulkCreatable
|
|
11
|
+
include ::Dhis2::Api::Updatable
|
|
12
|
+
include ::Dhis2::Api::Deletable
|
|
13
|
+
include ::Dhis2::Api::Version224::SaveValidator
|
|
14
|
+
include ::Dhis2::Api::Shared::OrganisationUnitGroup
|
|
15
|
+
|
|
16
|
+
Schema = Dry::Validation.Schema do
|
|
17
|
+
required(:name).filled
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
class OrganisationUnitGroupSet < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Listable
|
|
8
|
+
include ::Dhis2::Api::Findable
|
|
9
|
+
include ::Dhis2::Api::Creatable
|
|
10
|
+
include ::Dhis2::Api::Updatable
|
|
11
|
+
include ::Dhis2::Api::Deletable
|
|
12
|
+
include ::Dhis2::Api::Version224::SaveValidator
|
|
13
|
+
|
|
14
|
+
Schema = Dry::Validation.Schema do
|
|
15
|
+
required(:name).filled
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version224
|
|
6
|
+
class OrganisationUnitLevel < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Listable
|
|
8
|
+
include ::Dhis2::Api::Findable
|
|
9
|
+
include ::Dhis2::Api::Creatable
|
|
10
|
+
include ::Dhis2::Api::Updatable
|
|
11
|
+
include ::Dhis2::Api::Deletable
|
|
12
|
+
include ::Dhis2::Api::Version224::SaveValidator
|
|
13
|
+
|
|
14
|
+
Schema = Dry::Validation.Schema do
|
|
15
|
+
required(:name).filled
|
|
16
|
+
required(:level).filled
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|