@@ -19,8 +19,10 @@ def __init__(self, connection: DHIS2Connection = None, cache_dir: Union[str, Pat
19
19
20
20
Parameters
21
21
----------
22
- connection : openhexa DHIS2Connection
22
+ connection : openhexa DHIS2Connection, optional
23
23
An initialized openhexa dhis2 connection
24
+ kwargs:
25
+ Additional arguments to pass to initialize openhexa dhis2 connection, such as `url`, `username`, `password`
24
26
cache_dir : str, optional
25
27
Cache directory. Actual cache data will be stored under a sub-directory
26
28
named after the DHIS2 instance domain.
@@ -69,7 +71,7 @@ def organisation_unit_levels(self) -> List[dict]:
69
71
)
70
72
return levels
71
73
72
- def organisation_units (self , fields :str = "id,name,level,path,geometry" , filter : str = None ) -> List [dict ]:
74
+ def organisation_units (self , fields : str = "id,name,level,path,geometry" , filter : str = None ) -> List [dict ]:
73
75
"""Get organisation units metadata.
74
76
75
77
Parameters
@@ -95,13 +97,17 @@ def organisation_units(self, fields:str = "id,name,level,path,geometry", filter:
95
97
for ou in page ["organisationUnits" ]:
96
98
org_units .append (
97
99
{
98
- key : ou .get (key ) if key != "geometry" else json .dumps (ou .get ("geometry" )) if ou .get ("geometry" ) else None
100
+ key : ou .get (key )
101
+ if key != "geometry"
102
+ else json .dumps (ou .get ("geometry" ))
103
+ if ou .get ("geometry" )
104
+ else None
99
105
for key in fields .split ("," )
100
106
}
101
107
)
102
108
return org_units
103
109
104
- def organisation_unit_groups (self , fields :str = "id,name,organisationUnits" ) -> List [dict ]:
110
+ def organisation_unit_groups (self , fields : str = "id,name,organisationUnits" ) -> List [dict ]:
105
111
"""Get organisation unit groups metadata.
106
112
Parameters
107
113
----------
@@ -121,20 +127,23 @@ def organisation_unit_groups(self, fields:str = "id,name,organisationUnits") ->
121
127
for group in page .get ("organisationUnitGroups" ):
122
128
groups .append (
123
129
{
124
- key : group .get (key ) if key != "organisationUnits" else [ou .get ("id" ) for ou in group ["organisationUnits" ]]
130
+ key : group .get (key )
131
+ if key != "organisationUnits"
132
+ else [ou .get ("id" ) for ou in group ["organisationUnits" ]]
125
133
for key in fields .split ("," )
126
134
}
127
135
)
128
136
org_unit_groups += groups
129
137
return groups
130
138
131
- def datasets (self , fields :str = "id,name,dataSetElements,indicators,organisationUnits" ) -> List [dict ]:
139
+ def datasets (self , fields : str = "id,name,dataSetElements,indicators,organisationUnits" ) -> List [dict ]:
132
140
"""Get datasets metadata.
133
141
134
142
Parameters
135
143
----------
136
144
fields: str, optional
137
- DHIS2 fields to include in the response, where default value is "id,name,dataSetElements,indicators,organisationUnits"
145
+ DHIS2 fields to include in the response, where default value is
146
+ "id,name,dataSetElements,indicators,organisationUnits"
138
147
Return
139
148
------
140
149
list of dict
@@ -164,7 +173,9 @@ def datasets(self, fields:str ="id,name,dataSetElements,indicators,organisationU
164
173
datasets .append (row )
165
174
return datasets
166
175
167
- def data_elements (self , fields :str = "id,name,aggregationType,zeroIsSignificant" ,filter : str = None ) -> List [dict ]:
176
+ def data_elements (
177
+ self , fields : str = "id,name,aggregationType,zeroIsSignificant" , filter : str = None
178
+ ) -> List [dict ]:
168
179
"""Get data elements metadata.
169
180
170
181
Parameters
@@ -184,14 +195,14 @@ def data_elements(self, fields:str = "id,name,aggregationType,zeroIsSignificant"
184
195
params ["filter" ] = filter
185
196
elements = []
186
197
for page in self .client .api .get_paged (
187
- "dataElements" ,
188
- params = params ,
198
+ "dataElements" ,
199
+ params = params ,
189
200
):
190
201
for element in page ["dataElements" ]:
191
202
elements .append ({key : element .get (key ) for key in params ["fields" ].split ("," )})
192
203
return elements
193
204
194
- def data_element_groups (self , fields :str = "id,name,dataElements" ) -> List [dict ]:
205
+ def data_element_groups (self , fields : str = "id,name,dataElements" ) -> List [dict ]:
195
206
"""Get data element groups metadata.
196
207
Parameters
197
208
----------
@@ -231,7 +242,7 @@ def category_option_combos(self) -> List[dict]:
231
242
combos += page .get ("categoryOptionCombos" )
232
243
return combos
233
244
234
- def indicators (self , fields :str = "id,name,numerator,denominator" , filter : str = None ) -> List [dict ]:
245
+ def indicators (self , fields : str = "id,name,numerator,denominator" , filter : str = None ) -> List [dict ]:
235
246
"""Get indicators metadata.
236
247
237
248
Parameters
@@ -257,7 +268,7 @@ def indicators(self, fields:str="id,name,numerator,denominator", filter: str = N
257
268
indicators += page ["indicators" ]
258
269
return indicators
259
270
260
- def indicator_groups (self , fields :str = None ) -> List [dict ]:
271
+ def indicator_groups (self , fields : str = "id,name,indicators" ) -> List [dict ]:
261
272
"""Get indicator groups metadata.
262
273
263
274
Return
@@ -274,7 +285,9 @@ def indicator_groups(self, fields:str=None) -> List[dict]:
274
285
for group in page .get ("indicatorGroups" ):
275
286
groups .append (
276
287
{
277
- key : group .get (key ) if key != "indicators" else [indicator .get ("id" ) for indicator in group ["indicators" ]]
288
+ key : group .get (key )
289
+ if key != "indicators"
290
+ else [indicator .get ("id" ) for indicator in group ["indicators" ]]
278
291
for key in fields .split ("," )
279
292
}
280
293
)
0 commit comments