I’ve developed a type system and constructors in Go for working with HSDS (Human Services Data Specification) data. This implementation makes it easy for organizations to transform their existing data into HSDS-compliant formats using Go’s high-performance capabilities.
Key Features
The system provides a standardized way to map various data sources to the HSDS API schema using Go. It includes:
- Type definitions aligned with HSDS specifications
- Constructor functions for creating valid HSDS objects
- GORM compatibility for simplified SQL interactions
Usage Example
Here’s a practical example showing how to map legacy hospital service data to HSDS:
func mapLegacyHospitalService(legacyService LegacyHospitalService) (*Service, *Schedule, error) {
// Create service
svcOpts := &ServiceOptions{
Description: &legacyService.Description,
}
svc, err := NewService(hospitalOrgID, legacyService.Title, ServiceStatusActive, svcOpts)
if err != nil {
return nil, nil, err
}
// Create schedule
schedOpts := &ScheduleOptions{
ServiceID: &svc.ID,
DTStart: &legacyService.StartTime,
ValidTo: &legacyService.EndTime,
Freq: (*ScheduleFreqEnum)(&legacyService.Frequency),
}
sched, err := NewSchedule(schedOpts)
if err != nil {
return nil, nil, err
}
return svc, sched, nil
}
This code demonstrates how organizations can easily map their existing data structures to the HSDS schema using the provided constructors.
Use this Code
You can add this to your Go project with:
go get github.com/david-botos/hsds-types/
I am not certain I did this the right way, I have never made a go package, but the code is in that repo.
I’ve opened a GitHub issue to propose adding this to the HSDS repository: https://github.com/openreferral/specification/issues/536
This would allow other developers to leverage these tools when their organizations need to share or consume HSDS data.