Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/docs #59

Open
wants to merge 129 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
ce1ee11
docs(d2dataresource): docs
tibendadavis Jun 18, 2024
39b059c
docs(d2categorycombo): docs
tibendadavis Jun 18, 2024
82db571
docs(d2categoryoptioncombo): docs
tibendadavis Jun 18, 2024
4fb0bc9
docs(d2categoryoption): docs
tibendadavis Jun 18, 2024
fb1b499
docs(d2category): docs
tibendadavis Jun 18, 2024
63544df
docs(d2compulsorydataelementoperand): docs
tibendadavis Jun 18, 2024
4eeef5f
docs(d2dataelement): docs
tibendadavis Jun 18, 2024
7a5828a
docs(d2dataset): docs
tibendadavis Jun 18, 2024
97d88e7
docs(d2basetrackerdatarepository): docs
tibendadavis Jun 18, 2024
162c57a
docs(d2categorycomborepository): docs
tibendadavis Jun 18, 2024
555ccaa
docs(d2categoryoptioncomborepository): docs
tibendadavis Jun 18, 2024
a947b1d
docs(d2categoryoptionrepository): docs
tibendadavis Jun 18, 2024
3782bf4
docs(d2categoryrepository): docs
tibendadavis Jun 18, 2024
3e27401
docs(d2compulsorydataelementoperandrepository): docs
tibendadavis Jun 18, 2024
81b6e40
docs(d2dataelementrepository): docs
tibendadavis Jun 18, 2024
6446b33
docs(d2clientservice): docs
tibendadavis Jun 18, 2024
ac15e6a
docs(d2appmodalutil): docs
tibendadavis Jun 18, 2024
b317fc3
docs(d2controlledform): docs
tibendadavis Jun 18, 2024
b91e30c
docs(d2baseorgunitselectorservice): docs
tibendadavis Jun 18, 2024
cce1a94
docs(d2ageinputfieldconfig): docs
tibendadavis Jun 18, 2024
4d6bdd4
docs(d2baseinputfieldconfig): docs
tibendadavis Jun 18, 2024
37dc306
docs(d2booleaninputfieldconfig): docs
tibendadavis Jun 18, 2024
ab3c945
refactor(d2basetrackerdatarepository): refactor
tibendadavis Jun 18, 2024
abc9283
docs(d2datasetstateformcontroller): docs
tibendadavis Jun 19, 2024
9ee9000
docs(d2datavalueset): docs
tibendadavis Jun 19, 2024
972f223
docs(d2datavalue): docs
tibendadavis Jun 19, 2024
d27aa42
docs(d2enrollment): docs
tibendadavis Jun 19, 2024
c846e4b
docs(d2importsummaryerror): docs
tibendadavis Jun 19, 2024
69e78ef
docs(d2datasetelement): docs
tibendadavis Jun 19, 2024
086f80e
docs(d2datastorerepository): docs
tibendadavis Jun 19, 2024
56862bd
docs(d2datavaluesetrepository): docs
tibendadavis Jun 19, 2024
643dffa
docs(d2datavaluerepository): docs
tibendadavis Jun 19, 2024
8fcc22e
docs(d2enrollmentrepository): docs
tibendadavis Jun 19, 2024
45f1cb5
docs(d2eventrepository): docs
tibendadavis Jun 19, 2024
31797b5
docs(d2importsummaryerrorrepository): docs
tibendadavis Jun 19, 2024
3c04c27
docs(d2datasetelementrepository): docs
tibendadavis Jun 19, 2024
b00c482
docs(d2datasetrepository): docs
tibendadavis Jun 19, 2024
3ac761d
docs(d2form): docs
tibendadavis Jun 19, 2024
d76871e
docs(d2formsection): docs
tibendadavis Jun 19, 2024
178d3f7
docs(d2formcontrolledinputfield): docs
tibendadavis Jun 19, 2024
2aa32b6
docs(d2geometryvalue): docs
tibendadavis Jun 19, 2024
e71fd17
refactor(d2formcontrolledinputfield): refactor
tibendadavis Jun 19, 2024
05535a6
docs(d2dateinputfieldconfig): docs
tibendadavis Jun 19, 2024
7189f62
docs(d2daterangeinputfieldconfig): docs
tibendadavis Jun 19, 2024
28bffb3
docs(d2formcontroller): docs
tibendadavis Jun 19, 2024
2d47b11
docs(d2datasetstateformcontroller): docs
tibendadavis Jun 19, 2024
f7bff18
docs(d2formutils): docs
tibendadavis Jun 19, 2024
670002e
docs(d2objectbox): docs
tibendadavis Jun 20, 2024
a1f6a86
docs(d2event): docs
tibendadavis Jun 20, 2024
0f45f65
docs(d2categorycombo): docs
tibendadavis Jun 20, 2024
228503b
docs(d2legendset): docs
tibendadavis Jun 20, 2024
78fffa8
docs(d2legend): docs
tibendadavis Jun 20, 2024
6b4ba46
docs(d2optionset): docs
tibendadavis Jun 20, 2024
207ca38
docs(d2option): docs
tibendadavis Jun 20, 2024
b0f5eb9
docs(d2orgunitgroup): docs
tibendadavis Jun 20, 2024
9b00597
docs(d2orgunit): docs
tibendadavis Jun 20, 2024
e9d0ae4
docs(d2legendsetrepository): docs
tibendadavis Jun 20, 2024
a1a12e0
docs(d2legendrepository): docs
tibendadavis Jun 20, 2024
54a6b74
docs(d2optionsetrepository): docs
tibendadavis Jun 20, 2024
1137341
docs(d2optionrepository): docs
tibendadavis Jun 20, 2024
d878b03
docs(d2metadatadownloadservice): docs
tibendadavis Jun 20, 2024
c3f41f1
docs(d2inputfieldcontainer): docs
tibendadavis Jun 20, 2024
bdb9281
docs(d2localorgunitselectorservice): docs
tibendadavis Jun 20, 2024
8f26eb6
docs(d2inputcontainercolorscheme): docs
tibendadavis Jun 20, 2024
9bdad86
docs(d2inputfieldlegend): docs
tibendadavis Jun 20, 2024
7c39445
docs(d2inputfieldoption): docs
tibendadavis Jun 20, 2024
0420a0b
docs(d2multiselectinputfieldconfig): docs
tibendadavis Jun 20, 2024
63b495f
docs(d2numberinputfieldconfig): docs
tibendadavis Jun 20, 2024
053ed06
docs(d2orgunitlevel): docs
tibendadavis Jun 21, 2024
295cde4
docs(d2programruleaction): docs
tibendadavis Jun 21, 2024
10790e3
docs(d2programrulevariable): docs
tibendadavis Jun 21, 2024
b2be98b
docs(d2programsection): docs
tibendadavis Jun 21, 2024
d24dbed
docs(d2program): docs
tibendadavis Jun 21, 2024
59cedb8
docs(d2orgunitgrouprepository): docs
tibendadavis Jun 21, 2024
e34fc0e
docs(d2orgunitlevelrepository): docs
tibendadavis Jun 21, 2024
ce9e6f3
docs(d2programruleactionrepository): docs
tibendadavis Jun 21, 2024
75f181d
docs(d2programrulevariablerepository): docs
tibendadavis Jun 21, 2024
0583c1c
docs(d2programrepository): docs
tibendadavis Jun 21, 2024
4aa877c
docs(d2orgunitinputfieldconfig): docs
tibendadavis Jun 21, 2024
2020925
docs(d2periodselector): docs
tibendadavis Jun 21, 2024
eaec58c
docs(d2periodselection): docs
tibendadavis Jun 21, 2024
dfddfd9
docs(d2programruleengine): docs
tibendadavis Jun 21, 2024
7f631e5
docs(d2programstagedataelement): docs
tibendadavis Jun 21, 2024
c18a21f
docs(d2programstagesection): docs
tibendadavis Jun 21, 2024
ccb9d05
docs(d2programstage): docs
tibendadavis Jun 21, 2024
f090d48
docs(d2programtrackedentityattribute): docs
tibendadavis Jun 21, 2024
d972ac1
docs(d2programsectionrepository): docs
tibendadavis Jun 21, 2024
d271b13
docs(d2programstagedataelementrepository): docs
tibendadavis Jun 21, 2024
5f03ab5
docs(d2programstagesectionrepository): docs
tibendadavis Jun 21, 2024
3163c6e
docs(d2programstagerepository): docs
tibendadavis Jun 21, 2024
a72d527
docs(d2programtrackedentityattributerepository): docs
tibendadavis Jun 21, 2024
789c4b1
docs(docs): docs
tibendadavis Jun 25, 2024
a7b9461
docs(d2objectbox): docs
tibendadavis Jun 25, 2024
f349ded
docs(d2trackedentityattributevalue): docs
tibendadavis Jun 25, 2024
7f4b05b
docs(d2trackedentitytypeattribute): docs
tibendadavis Jun 25, 2024
db3a02b
docs(d2trackedentitytype): docs
tibendadavis Jun 25, 2024
f8b8d2d
docs(d2trackedentityattributevaluerepository): docs
tibendadavis Jun 25, 2024
618fd25
docs(d2trackedentityrepository): docs
tibendadavis Jun 25, 2024
a1476c0
docs(d2trackedentityattributerepository): docs
tibendadavis Jun 25, 2024
9e53087
docs(d2trackedentitytypeattributerepository): docs
tibendadavis Jun 25, 2024
af2c6d3
docs(d2trackedentitytyperepository): docs
tibendadavis Jun 25, 2024
e4a4228
docs(d2trackerdatadownloadservice): docs
tibendadavis Jun 25, 2024
0e33476
docs(d2trackerdatauploadservice): docs
tibendadavis Jun 25, 2024
3a9e4f7
docs(d2trackereventform): docs
tibendadavis Jun 25, 2024
6f5f87b
docs(d2trackerregistrationform): docs
tibendadavis Jun 25, 2024
40aeeca
docs(d2trackerformoptions): docs
tibendadavis Jun 25, 2024
3fb4010
refactor(d2baseinputfieldconfig): refactor
tibendadavis Jun 25, 2024
04e8bfb
refactor(d2dateinputfieldconfig): docs
tibendadavis Jun 25, 2024
fc6828f
docs(d2trueonlyinputfieldcolorscheme): docs
tibendadavis Jun 25, 2024
fb53a89
docs(d2trackerenrollmentformcontroller): docs
tibendadavis Jun 25, 2024
9b105ba
docs(d2trackerenrollmentformcontroller): docs
tibendadavis Jun 25, 2024
6c904f3
docs(d2trackerenrollmentformutil): docs
tibendadavis Jun 25, 2024
34dd68c
docs(d2trackereventformutil): docs
tibendadavis Jun 25, 2024
a57eb29
docs(d2usergroup): docs
tibendadavis Jun 26, 2024
8c1000e
docs(d2userrole): docs
tibendadavis Jun 26, 2024
62dd458
docs(d2user): docs
tibendadavis Jun 26, 2024
3859964
docs(d2basetrackerdataquerymixin): docs
tibendadavis Jun 26, 2024
3828b4b
docs(d2usergrouprepository): docs
tibendadavis Jun 26, 2024
a2ad29d
docs(d2userrolerepository): docs
tibendadavis Jun 26, 2024
6ac63d8
docs(d2userrepository): doc
tibendadavis Jun 26, 2024
bdab69f
docs(d2usercredential): docs
tibendadavis Jun 26, 2024
08d2723
docs(formcontainer): docs
tibendadavis Jun 26, 2024
428e180
docs(formsectioncontainer): docs
tibendadavis Jun 26, 2024
764c710
refactor(d2ageinputfieldconfig): refactor
tibendadavis Jun 26, 2024
5bc1768
docs(d2inputfieldtype): docs
tibendadavis Jun 26, 2024
0561870
docs(d2uid): docs
tibendadavis Jun 26, 2024
1b49bc5
docs(d2usergroup): docs
tibendadavis Jun 27, 2024
73f6bc3
docs(d2orgunitrepository): docs
tibendadavis Jun 27, 2024
638b51c
Merge branches 'feature/docs' and 'develop' of github.com:hisptz/dhis…
ericchingalo Jul 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/objectbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,36 @@ import 'package:path_provider/path_provider.dart';
import 'objectbox.g.dart';
import 'src/services/entry.dart'; // created by `flutter pub run build_runner build`

/// This class represents a Objectbox store instance used throughout the application.
class D2ObjectBox {
/// The Store of this app.
/// The underlying store instance.
final Store store;

/// Identifier for the store instance.
final String storeId;

/// Private constructor for creating a [D2ObjectBox] instance.
///
/// Use [createTest] or [create] static methods to instantiate [D2ObjectBox].
D2ObjectBox._create(this.store, this.storeId) {
// Add any additional setup code, e.g. build queries.
}

/// Creates a test instance of [D2ObjectBox] with an in-memory store.
///
/// Returns a [Future] that completes with the created [D2ObjectBox] instance.
static Future<D2ObjectBox> createTest() async {
final store = await openStore(
directory: "memory:test-db",
);
return D2ObjectBox._create(store, "test");
}

/// Create an instance of ObjectBox to use throughout the app.
/// Creates an instance of [D2ObjectBox] for use throughout the application.
///
/// - Takes [credentials] of type [D2UserCredential] to identify the store.
///
/// Returns a [Future] that completes with the created [D2ObjectBox] instance.
static Future<D2ObjectBox> create(D2UserCredential credentials) async {
String storeId = credentials.id;
final docsDir = await getApplicationDocumentsDirectory();
Expand Down
9 changes: 9 additions & 0 deletions lib/src/models/data/base.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import 'upload_base.dart';

/// This is class represents a data resource in the DHIS2 system.
abstract class D2DataResource {
/// The ID of the data resource.
abstract int id;

/// The date and time when the data resource was created.
abstract DateTime createdAt;

/// The date and time when the data resource was last updated.
abstract DateTime updatedAt;

/// Creates a [D2DataResource] instance from a map.
static D2DataResource? fromMap() {
return null;
}
}

/// This class represents a synchronized data source.
abstract class SyncDataSource extends D2DataResource implements SyncableData {
/// The unique identifier (UID) of the sync data source.
abstract String uid;
}
18 changes: 18 additions & 0 deletions lib/src/models/data/data_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import '../../../objectbox.dart';
import '../../repositories/data/data_store.dart';

@Entity()

/// This class represents a data store in the DHIS2 system.
class D2DataStore {
int id = 0;

@Index()
String key;

Expand All @@ -19,15 +22,30 @@ class D2DataStore {

String value;

/// Constructs a new instance of [D2DataStore].
///
/// - [key] The key associated with the data store.
/// - [namespace] The namespace of the data store.
/// - [value] The value stored as a JSON encoded string.
/// - [uid] The unique identifier for the data store.
D2DataStore(this.key, this.namespace, this.value, this.uid);

/// Constructs a new instance of [D2DataStore] from a map.
///
/// - [db] The database reference for fetching related entities.
/// - [namespace] The namespace of the data store.
/// - [key] The key associated with the data store.
/// - [value] The value to be stored, which will be JSON encoded.
D2DataStore.fromMap(D2ObjectBox db,
{required this.namespace, required this.key, required Object value})
: value = jsonEncode(value),
uid = "$namespace-$key" {
id = D2DataStoreRepository(db).getIdByUid(uid) ?? 0;
}

/// Retrieves the value stored in the data store.
///
/// - Returns the decoded value.
getValue<T>() {
return jsonDecode(value) as T;
}
Expand Down
41 changes: 41 additions & 0 deletions lib/src/models/data/data_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import 'event.dart';
import 'upload_base.dart';

@Entity()

/// This class represents a data value in the DHIS2 system.
class D2DataValue extends D2DataResource
implements SyncableData, D2BaseEditable {
@override
Expand All @@ -30,9 +32,23 @@ class D2DataValue extends D2DataResource

final dataElement = ToOne<D2DataElement>();

/// Constructs a new instance of [D2DataValue].
///
/// - [uid] The unique identifier for the data value.
/// - [id] The ID of the data value.
/// - [createdAt] The creation timestamp of the data value.
/// - [updatedAt] The last updated timestamp of the data value.
/// - [value] The value stored.
/// - [providedElsewhere] Whether the value is provided elsewhere.
/// - [synced] Whether the value is synced.
D2DataValue(this.uid, this.id, this.createdAt, this.updatedAt, this.value,
this.providedElsewhere, this.synced);

/// Constructs a new instance of [D2DataValue] from a map.
///
/// - [db] The database reference for fetching related entities.
/// - [json] The JSON map containing data value information.
/// - [eventId] The event ID related to the data value.
D2DataValue.fromMap(D2ObjectBox db, Map json, String eventId)
: updatedAt = DateTime.parse(json["updatedAt"]),
createdAt = DateTime.parse(json["createdAt"]),
Expand All @@ -47,6 +63,11 @@ class D2DataValue extends D2DataResource
D2DataElementRepository(db).getByUid(json["dataElement"]);
}

/// Constructs a new instance of [D2DataValue] from form values.
///
/// - [value] The value to be stored.
/// - [event] The related event.
/// - [dataElement] The related data element.
D2DataValue.fromFormValues(this.value,
{required D2Event event, required D2DataElement dataElement})
: updatedAt = DateTime.now(),
Expand All @@ -60,6 +81,9 @@ class D2DataValue extends D2DataResource
@override
bool synced = true;

/// Retrieves the display value of the data element.
///
/// Returns the display value as [String].
String? getDisplayValue() {
if (dataElement.target!.optionSet.target == null) {
return value;
Expand All @@ -70,16 +94,30 @@ class D2DataValue extends D2DataResource
return valueOption?.displayName ?? valueOption?.name ?? value;
}

/// Converts the data value to a map.
///
/// - [db] The database reference, optional.
///
/// Returns a [Future] containing the map of data value information.
@override
Future<Map<String, dynamic>> toMap({D2ObjectBox? db}) async {
return {"dataElement": dataElement.target?.uid, "value": value};
}

/// Converts the data value to form values.
///
/// Returns a map of form values.
@override
Map<String, dynamic> toFormValues() {
return {dataElement.target!.uid: value};
}

/// Updates the data value from form values.
///
/// - [values] The map of form values.
/// - [db] The database reference.
/// - [program] The related program, optional.
/// - [orgUnit] The related organisation unit, optional.
@override
void updateFromFormValues(Map<String, dynamic> values,
{required D2ObjectBox db, D2Program? program, D2OrgUnit? orgUnit}) {
Expand All @@ -90,6 +128,9 @@ class D2DataValue extends D2DataResource
}
}

/// Saves the data value to the database.
///
/// - [db] The database reference.
@override
void save(D2ObjectBox db) {
D2DataValueRepository(db).saveEntity(this);
Expand Down
39 changes: 35 additions & 4 deletions lib/src/models/data/data_value_set.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import 'base.dart';
import 'base_deletable.dart';

@Entity()

/// This class represents a data value set in the DHIS2 system.
class D2DataValueSet extends SyncDataSource implements D2BaseDeletable {
@override
int id = 0;
Expand All @@ -16,15 +18,13 @@ class D2DataValueSet extends SyncDataSource implements D2BaseDeletable {
bool synced = true;

///For this to be unique, it has to include orgUnit, period, attributeOptionCombo, dataElement, and categoryOptionCombo. So it is generated with the format as listed separated by -

@Unique()
late String uid;

String value;

String period;

String? comment;

bool followup;

D2DataValueSet(this.uid, this.id, this.createdAt, this.updatedAt, this.value,
Expand All @@ -35,6 +35,10 @@ class D2DataValueSet extends SyncDataSource implements D2BaseDeletable {
final attributeOptionCombo = ToOne<D2CategoryOptionCombo>();
final organisationUnit = ToOne<D2OrgUnit>();

/// Creates an instance of [D2DataValueSet] from a JSON map.
///
/// - [db] The database reference.
/// - [json] The JSON map containing the data value set information.
D2DataValueSet.fromMap(D2ObjectBox db, Map json)
: updatedAt = DateTime.parse(json["lastUpdated"]),
createdAt = DateTime.parse(json["created"]),
Expand All @@ -56,6 +60,15 @@ class D2DataValueSet extends SyncDataSource implements D2BaseDeletable {
id = D2DataValueSetRepository(db).getIdByUid(uid) ?? 0;
}

/// Creates an instance of [D2DataValueSet] from form values.
///
/// - [db] The database reference.
/// - [orgUnit] The organization unit.
/// - [attributeOptionCombo] The attribute option combo.
/// - [period] The period.
/// - [value] The value.
/// - [dataElement] The data element.
/// - [categoryOptionCombo] The category option combo.
D2DataValueSet.fromForm(
{required D2ObjectBox db,
required D2OrgUnit orgUnit,
Expand All @@ -77,6 +90,11 @@ class D2DataValueSet extends SyncDataSource implements D2BaseDeletable {
synced = false;
}

/// Converts the data value set to a JSON map.
///
/// - [db] Optional database reference.
///
/// Returns a [Future<Map<String, dynamic>>] containing the JSON map.
@override
Future<Map<String, dynamic>> toMap({D2ObjectBox? db}) async {
return {
Expand All @@ -90,25 +108,38 @@ class D2DataValueSet extends SyncDataSource implements D2BaseDeletable {
};
}

/// Converts the data value set to form values.
///
/// Returns a [Map] containing the form values.
Map<String, dynamic> toFormValues() {
if (categoryOptionCombo.target != null) {
return {
'${dataElement.target!.uid}.${categoryOptionCombo.target!.uid}': value
};
}

return {dataElement.target!.uid: value};
}

/// Saves the data value set to the database.
///
/// - [db] The database reference.
void save(D2ObjectBox db) {
db.store.box<D2DataValueSet>().put(this);
}

/// Deletes the data value set from the database.
///
/// - [db] The database reference.
///
/// Returns a [bool] indicating the success of the operation.
@override
bool delete(D2ObjectBox db) {
return D2DataValueSetRepository(db).box.remove(id);
}

/// Soft deletes the data value set.
///
/// - [db] The database reference.
@override
void softDelete(db) {}
}
Loading