Go SDK for the Kenya Health Information System (KHIS / DHIS2), plus a self-hostable sync gateway
# mycelium
Go SDK for the Kenya Health Information System (KHIS / DHIS2), plus a self-hostable sync gateway with offline queuing, guaranteed report delivery, and SHA claims reconciliation exports.
## Install
```bash
go get
github.com
```
Requires Go 1.22+.
## Usage
```go
client, err := mycelium.NewClient(mycelium.Config{
BaseURL: os.Getenv("DHIS2_BASE_URL"), // e.g.
hiskenya.org
Username: os.Getenv("DHIS2_USERNAME"),
Password: os.Getenv("DHIS2_PASSWORD"),
Environment: mycelium.Production,
})
if err != nil {
log.Fatal(err)
}
// Submit aggregate data values for a reporting period
res, err := client.DataValues.Import(ctx, &mycelium.DataValueSet{
DataSet: "BfMAe6Itzgt",
Period: "202407",
OrgUnit: "KvRWAGAaHd2", // resolved from MFL code automatically
AttributeOptionCombo: "HllvX50cXC0",
DataValues: []mycelium.DataValue{
{DataElement: "fbfJHSPpUQD", Value: "143"},
{DataElement: "cYeuwXTCPkU", Value: "87"},
},
})
```
Token refresh, org unit resolution, retry backoff, and offline queue flush are handled automatically.
## Supported APIs
- [x] Data values — import, export, audit trail
- [x] Tracker — tracked entity instances, enrollments, events (patient records)
- [x] Org units — facility registry traversal + MFL code resolution
- [x] Metadata — data elements, indicators, category combos, option sets
- [x] Analytics — pivot table queries, aggregate indicators, period filters
- [x] Programs — program rules, program indicators, stage events
- [x] File resources — document attachments on tracked entities
- [x] Job notifications — async import status polling + webhook push
- [ ] FHIR R4 adapter _(planned)_
- [ ] mCSD facility registry sync _(planned)_
## Project Structure
```
mycelium/
├── cmd/
│ ├── gateway/ # sync gateway server entrypoint
│ └── scheduler/ # cron job runner entrypoint
├── internal/
│ ├── auth/ # basic auth + PAT manager (in-memory + Redis cac …