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,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version228
|
|
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::Updatable
|
|
11
|
+
include ::Dhis2::Api::Deletable
|
|
12
|
+
include ::Dhis2::Api::Shared::SaveValidator
|
|
13
|
+
|
|
14
|
+
Schema = Dry::Validation.Schema do
|
|
15
|
+
required(:name).filled
|
|
16
|
+
required(:short_name).filled
|
|
17
|
+
required(:aggregation_type).value(
|
|
18
|
+
included_in?: ::Dhis2::Api::Version228::Constants.aggregation_types
|
|
19
|
+
)
|
|
20
|
+
required(:domain_type).value(
|
|
21
|
+
included_in?: ::Dhis2::Api::Version228::Constants.domain_types
|
|
22
|
+
)
|
|
23
|
+
required(:value_type).value(
|
|
24
|
+
included_in?: ::Dhis2::Api::Version228::Constants.value_types
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.creation_defaults(args)
|
|
29
|
+
{
|
|
30
|
+
aggregation_type: "SUM",
|
|
31
|
+
code: args[:short_name],
|
|
32
|
+
domain_type: "AGGREGATE",
|
|
33
|
+
type: "int",
|
|
34
|
+
value_type: "NUMBER",
|
|
35
|
+
zero_is_significant: true
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version228
|
|
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::Shared::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,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version228
|
|
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::Shared::SaveValidator
|
|
14
|
+
include ::Dhis2::Api::Shared::DataSet
|
|
15
|
+
|
|
16
|
+
Schema = Dry::Validation.Schema do
|
|
17
|
+
required(:name).filled
|
|
18
|
+
required(:period_type).value(
|
|
19
|
+
included_in?: ::Dhis2::Api::Version228::Constants.period_types
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.creation_defaults(args)
|
|
24
|
+
{
|
|
25
|
+
code: args[:short_name],
|
|
26
|
+
period_type: "Monthly"
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version228
|
|
6
|
+
class DataValueSet < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Creatable
|
|
8
|
+
include ::Dhis2::Api::Listable
|
|
9
|
+
include ::Dhis2::Api::Shared::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 Version228
|
|
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::Shared::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,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "constants"
|
|
4
|
+
require_relative "analytic"
|
|
5
|
+
require_relative "attribute"
|
|
6
|
+
require_relative "category_combo"
|
|
7
|
+
require_relative "category_option_combo"
|
|
8
|
+
require_relative "data_element"
|
|
9
|
+
require_relative "data_element_group"
|
|
10
|
+
require_relative "data_set"
|
|
11
|
+
require_relative "data_value"
|
|
12
|
+
require_relative "data_value_set"
|
|
13
|
+
require_relative "event"
|
|
14
|
+
require_relative "indicator"
|
|
15
|
+
require_relative "indicator_group"
|
|
16
|
+
require_relative "indicator_type"
|
|
17
|
+
require_relative "organisation_unit"
|
|
18
|
+
require_relative "organisation_unit_group"
|
|
19
|
+
require_relative "organisation_unit_group_set"
|
|
20
|
+
require_relative "organisation_unit_level"
|
|
21
|
+
require_relative "program"
|
|
22
|
+
require_relative "report_table"
|
|
23
|
+
require_relative "resource_table"
|
|
24
|
+
require_relative "report"
|
|
25
|
+
require_relative "system_info"
|
|
26
|
+
require_relative "user"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version228
|
|
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::Shared::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 Version228
|
|
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::Shared::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 Version228
|
|
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::Shared::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 Version228
|
|
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::Shared::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 Version228
|
|
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::Shared::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 Version228
|
|
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::Shared::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 Version228
|
|
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::Shared::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
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version228
|
|
6
|
+
class Program < ::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::Shared::SaveValidator
|
|
13
|
+
|
|
14
|
+
Schema = Dry::Validation.Schema do
|
|
15
|
+
required(:name).filled
|
|
16
|
+
required(:short_name).filled
|
|
17
|
+
required(:program_type).value(
|
|
18
|
+
included_in?: ::Dhis2::Api::Version228::Constants.program_types
|
|
19
|
+
)
|
|
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 Version228
|
|
6
|
+
class Report < ::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::Shared::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 Version228
|
|
6
|
+
class ReportTable < ::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::Shared::SaveValidator
|
|
13
|
+
include ::Dhis2::Api::Shared::ReportTable
|
|
14
|
+
|
|
15
|
+
Schema = Dry::Validation.Schema do
|
|
16
|
+
required(:name).filled
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Api
|
|
5
|
+
module Version228
|
|
6
|
+
class User < ::Dhis2::Api::Base
|
|
7
|
+
include ::Dhis2::Api::Listable
|
|
8
|
+
include ::Dhis2::Api::Findable
|
|
9
|
+
include ::Dhis2::Api::Updatable
|
|
10
|
+
include ::Dhis2::Api::Deletable
|
|
11
|
+
include ::Dhis2::Api::Shared::SaveValidator
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/dhis2/case.rb
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
module Case
|
|
5
|
+
SUPPORTER_CASE_CHANGES = %i(underscore camelize).freeze
|
|
6
|
+
|
|
7
|
+
def self.deep_change(obj, type)
|
|
8
|
+
raise CaseError, deep_change_error(type) unless SUPPORTER_CASE_CHANGES.include?(type)
|
|
9
|
+
case obj
|
|
10
|
+
when Array then obj.map { |v| deep_change(v, type) }
|
|
11
|
+
when Hash
|
|
12
|
+
obj.each_with_object({}) do |(k, v), new_hash|
|
|
13
|
+
new_key = type == :underscore ? underscore(k.to_s) : camelize(k.to_s, false)
|
|
14
|
+
new_hash[new_key] = deep_change(v, type)
|
|
15
|
+
end
|
|
16
|
+
else obj
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.camelize(string, uppercase_first_letter = true)
|
|
21
|
+
string = if uppercase_first_letter
|
|
22
|
+
string.sub(/^[a-z\d]*/) { $&.capitalize }
|
|
23
|
+
else
|
|
24
|
+
string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { $&.downcase }
|
|
25
|
+
end
|
|
26
|
+
string
|
|
27
|
+
.gsub(/(?:_|(\/))([a-z\d]*)/) do
|
|
28
|
+
"#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}"
|
|
29
|
+
end
|
|
30
|
+
.gsub("/", "::")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.underscore(camel_cased_word)
|
|
34
|
+
return camel_cased_word unless camel_cased_word =~ /[A-Z-]|::/
|
|
35
|
+
camel_cased_word.to_s.gsub(/::/, "/")
|
|
36
|
+
.gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
|
|
37
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
|
38
|
+
.tr("-", "_")
|
|
39
|
+
.downcase
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def deep_change_error(type)
|
|
43
|
+
"unsupported case changes #{type} vs #{SUPPORTER_CASE_CHANGES}"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dhis2
|
|
4
|
+
class Versioned
|
|
5
|
+
MAPPING = {
|
|
6
|
+
"2.24" => "Version224",
|
|
7
|
+
"2.25" => "Version225",
|
|
8
|
+
"2.26" => "Version226",
|
|
9
|
+
"2.27" => "Version227",
|
|
10
|
+
"2.28" => "Version228"
|
|
11
|
+
}.freeze
|
|
12
|
+
|
|
13
|
+
def self.[](version)
|
|
14
|
+
Object.const_get "Dhis2::Api::#{MAPPING[version]}::#{basename}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.basename
|
|
18
|
+
name.split("::").last
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class Analytic < Versioned; end
|
|
23
|
+
class Attribute < Versioned; end
|
|
24
|
+
class CategoryCombo < Versioned; end
|
|
25
|
+
class CategoryOptionCombo < Versioned; end
|
|
26
|
+
class DataElement < Versioned; end
|
|
27
|
+
class DataElementGroup < Versioned; end
|
|
28
|
+
class DataSet < Versioned; end
|
|
29
|
+
class DataValueSet < Versioned; end
|
|
30
|
+
class Event < Versioned; end
|
|
31
|
+
class Indicator < Versioned; end
|
|
32
|
+
class IndicatorGroup < Versioned; end
|
|
33
|
+
class IndicatorType < Versioned; end
|
|
34
|
+
class OrganisationUnit < Versioned; end
|
|
35
|
+
class OrganisationUnitGroup < Versioned; end
|
|
36
|
+
class OrganisationUnitGroupSet < Versioned; end
|
|
37
|
+
class OrganisationUnitLevel < Versioned; end
|
|
38
|
+
class Program < Versioned; end
|
|
39
|
+
class Report < Versioned; end
|
|
40
|
+
class ReportTable < Versioned; end
|
|
41
|
+
class ResourceTable < Versioned; end
|
|
42
|
+
class SystemInfo < Versioned; end
|
|
43
|
+
class User < Versioned; end
|
|
44
|
+
end
|