Skip to content

BlueCodeSystems/opensrp-client-growth-monitoring

 
 

Repository files navigation

JitPack Latest master-SNAPSHOT

opensrp-client-growth-monitoring

Android library that powers growth monitoring within OpenSRP deployments, providing reusable UI flows, repositories, and z-score utilities for weight, height, and weight-for-height tracking.

Project Status

  • Toolchain: Gradle 8.7, Android Gradle Plugin 8.6.0, Java 17 (library is Java-based; Kotlin is optional)
  • CI: GitHub Actions builds (ci.yml) and snapshot publishing (release.yml)
  • Default branch: master; tagged releases: not yet published

Features

  • Capture current or historical weight and height measurements with built-in dialogs
  • Render WHO-aligned growth charts with weight-for-age, height-for-age, and weight-for-height indicators
  • Calculate z-scores and derive color-coded status thresholds for quick assessments
  • Provide repositories and intent services for synchronizing growth data with OpenSRP backends

Requirements

  • JDK 17+
  • Android Studio/Gradle using AGP 8.6.0 and Gradle 8.7
  • (Optional) Kotlin 1.9.x if your host app uses Kotlin
  • Android minSdk 28
  • Android compileSdk/targetSdk 35

Install

Add the dependency from Maven Central (coordinates from gradle.properties). Replace <version> with the desired release (see Releases).

Groovy DSL
repositories {
  mavenCentral()
}

dependencies {
  implementation 'org.smartregister:opensrp-growth-monitoring:<version>'
}
Kotlin DSL
dependencies {
  implementation("org.smartregister:opensrp-growth-monitoring:<version>")
}

Initialize

GrowthMonitoringLibrary must be initialized once from your Application class after the OpenSRP core has been bootstrapped.

public class MyOpensrpApp extends Application {
  private static final int DATABASE_VERSION = 1;

  @Override
  public void onCreate() {
    super.onCreate();

    org.smartregister.Context opensrp = org.smartregister.Context.getInstance();
    Repository repository = opensrp.updateApplicationContext(this).getRepository();

    GrowthMonitoringLibrary.init(
        opensrp,
        repository,
        BuildConfig.VERSION_CODE,
        BuildConfig.VERSION_NAME,
        DATABASE_VERSION,
        new GrowthMonitoringConfig()
    );
  }
}

Usage examples

// Launch the record-growth dialog for the selected child
WeightWrapper wrapper = new WeightWrapper();
wrapper.setId(baseEntityId);
wrapper.setDob(childDobIsoString);
RecordGrowthDialogFragment dialog = RecordGrowthDialogFragment
    .newInstance(childDob, wrapper, null);
dialog.show(getSupportFragmentManager(), "record_growth");
// Display the weight monitoring fragment inside an activity or host fragment
List<Weight> weights = GrowthMonitoringLibrary.getInstance()
    .weightRepository()
    .findByEntityId(baseEntityId);
Fragment fragment = WeightMonitoringFragment
    .createInstance(childDobIsoString, Gender.FEMALE, weights);
getSupportFragmentManager()
    .beginTransaction()
    .replace(R.id.content_frame, fragment)
    .commit();
// Calculate a z-score for the most recent weight entry
Double z = WeightZScore.calculate(
    Gender.FEMALE,
    childDob,
    latestWeighingDate,
    latestWeightKg
);
if (z != null) {
  int colorRes = WeightZScore.getZScoreColor(z);
  // apply color-coded status to your UI
}

Sample app

A demo client lives in the sample/ module.

  • Install on a connected device/emulator: ./gradlew :sample:installDebug
  • Alternatively, open the project in Android Studio and run the sample configuration.

Build & test

./gradlew clean assemble
./gradlew test

Releases

See GitHub Releases for published versions, release notes, and change logs.

Contributing

We welcome issues and pull requests. Please build with the toolchain noted above and run the unit tests before submitting patches. (If your organization has additional contribution guidelines, follow those as well.)

License

Licensed under the Apache License 2.0.

About

OpenSRP Client Growth Monitoring Library

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Java 100.0%