healthcrm

package module
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 11 Imported by: 3

README

healthcrm

Linting and Tests Coverage Status

healthcrm Library

healthcrm is a library that abstracts the interaction with SIL's health CRM service.

Installing it

healthcrm is compatible with modern Go releases in module mode, with Go installed:

go get -u github.com/savannahghi/healthcrm

will resolve and add the package to the current development module, along with its dependencies.

Alternatively the same can be achieved if you use import in a package:

import "github.com/savannahghi/healthcrm"

and run go get without parameters.

The package name is healthcrm

Developing

The default branch library is main

We try to follow semantic versioning ( https://semver.org/ ). For that reason, every major, minor and point release should be tagged.

git tag -m "v0.0.1" "v0.0.1"
git push --tags

Continuous integration tests must pass on Github CI. Our coverage threshold is >=80% i.e you must keep coverage above 80%.

Environment variables

In order to run tests, you need to have an env.sh file similar to this one:

# Application settings
export HEALTH_CRM_AUTH_SERVER_ENDPOINT=""
export HEALTH_CRM_CLIENT_ID=""
export HEALTH_CRM_CLIENT_SECRET=""
export HEALTH_CRM_GRANT_TYPE=""
export HEALTH_CRM_USERNAME=""
export HEALTH_CRM_PASSWORD=""

This file must not be committed to version control.

It is important to export the environment variables. If they are not exported, they will not be visible to child processes e.g go test ./....

These environment variables should also be set up on github CI environment variable section.

Contributing

I would like to cover the entire GitHub API and contributions are of course always welcome. The calling pattern is pretty well established, so adding new methods is relatively straightforward. See CONTRIBUTING.md for details.

Versioning

In general, enumutils follows semver as closely as we can for tagging releases of the package. For self-contained libraries, the application of semantic versioning is relatively straightforward and generally understood. We've adopted the following versioning policy:

  • We increment the major version with any incompatible change to non-preview functionality, including changes to the exported Go API surface or behavior of the API.
  • We increment the minor version with any backwards-compatible changes to functionality, as well as any changes to preview functionality in the GitHub API. GitHub makes no guarantee about the stability of preview functionality, so neither do we consider it a stable part of the go-github API.
  • We increment the patch version with any backwards-compatible bug fixes.

License

This library is distributed under the MIT license found in the LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// BaseURL represents the health CRM's base URL
	BaseURL = serverutils.MustGetEnvVar("HEALTH_CRM_BASE_URL")
)

Functions

This section is empty.

Types

type BusinessHours added in v1.0.3

type BusinessHours struct {
	Day         string `json:"day"`
	OpeningTime string `json:"opening_time"`
	ClosingTime string `json:"closing_time"`
}

BusinessHours models data to store business hours

type BusinessHoursOutput added in v1.0.1

type BusinessHoursOutput struct {
	ID          string `json:"id"`
	Day         string `json:"day"`
	OpeningTime string `json:"opening_time"`
	ClosingTime string `json:"closing_time"`
	FacilityID  string `json:"facility_id"`
}

BusinessHoursOutput models data that show facility's operational hours

type Contacts

type Contacts struct {
	ContactType  string `json:"contact_type,omitempty"`
	ContactValue string `json:"contact_value,omitempty"`
	Role         string `json:"role,omitempty"`
}

Contacts models facility's model data class

type ContactsOutput

type ContactsOutput struct {
	ID           string `json:"id"`
	ContactType  string `json:"contact_type"`
	ContactValue string `json:"contact_value"`
	Active       bool   `json:"active"`
	Role         string `json:"role"`
	FacilityID   string `json:"facility_id"`
}

ContactsOutput is used to show facility contacts

type Coordinates

type Coordinates struct {
	Latitude  string `json:"latitude,omitempty"`
	Longitude string `json:"longitude,omitempty"`
}

Coordinates models the geographical's location data class of a facility

type CoordinatesOutput

type CoordinatesOutput struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

CoordinatesOutput is used to show geographical coordinates

type Facility

type Facility struct {
	ID            string          `json:"id,omitempty"`
	Name          string          `json:"name,omitempty"`
	Description   string          `json:"description,omitempty"`
	FacilityType  string          `json:"facility_type,omitempty"`
	County        string          `json:"county,omitempty"`
	Country       string          `json:"country,omitempty"`
	Address       string          `json:"address,omitempty"`
	Coordinates   *Coordinates    `json:"coordinates,omitempty"`
	Contacts      []Contacts      `json:"contacts,omitempty"`
	Identifiers   []Identifiers   `json:"identifiers,omitempty"`
	BusinessHours []BusinessHours `json:"businesshours,omitempty"`
}

Facility is the hospitals data class

type FacilityOutput

type FacilityOutput struct {
	ID            string                `json:"id"`
	Created       time.Time             `json:"created"`
	Name          string                `json:"name"`
	Description   string                `json:"description"`
	FacilityType  string                `json:"facility_type"`
	County        string                `json:"county"`
	Country       string                `json:"country"`
	Coordinates   CoordinatesOutput     `json:"coordinates"`
	Status        string                `json:"status"`
	Address       string                `json:"address"`
	Contacts      []ContactsOutput      `json:"contacts"`
	Identifiers   []IdentifiersOutput   `json:"identifiers"`
	BusinessHours []BusinessHoursOutput `json:"businesshours"`
	Services      []FacilityService     `json:"services"`
}

FacilityOutput is used to display facility(ies)

type FacilityPage

type FacilityPage struct {
	Count       int              `json:"count"`
	Next        string           `json:"next"`
	Previous    any              `json:"previous"`
	PageSize    int              `json:"page_size"`
	CurrentPage int              `json:"current_page"`
	TotalPages  int              `json:"total_pages"`
	StartIndex  int              `json:"start_index"`
	EndIndex    int              `json:"end_index"`
	Results     []FacilityOutput `json:"results"`
}

FacilityPage is the hospitals model used to show facility details

type FacilityService added in v1.0.1

type FacilityService struct {
	ID          string               `json:"id"`
	Name        string               `json:"name"`
	Description string               `json:"description"`
	Identifiers []*ServiceIdentifier `json:"identifiers"`
}

FacilityService models the data class that is used to show facility services

type FacilityServicePage added in v1.0.1

type FacilityServicePage struct {
	Results     []FacilityService `json:"results"`
	Count       int               `json:"count"`
	Next        string            `json:"next"`
	Previous    string            `json:"previous"`
	PageSize    int               `json:"page_size"`
	CurrentPage int               `json:"current_page"`
	TotalPages  int               `json:"total_pages"`
	StartIndex  int               `json:"start_index"`
	EndIndex    int               `json:"end_index"`
}

FacilityServicePage models the services offered in a facility

type HealthCRMLib

type HealthCRMLib struct {
	// contains filtered or unexported fields
}

HealthCRMLib interacts with the healthcrm APIs

func NewHealthCRMLib

func NewHealthCRMLib() (*HealthCRMLib, error)

NewHealthCRMLib initializes a new instance of healthCRM SDK

func (*HealthCRMLib) CreateFacility

func (h *HealthCRMLib) CreateFacility(ctx context.Context, facility *Facility) (*FacilityOutput, error)

CreateFacility is used to create facility in health CRM service

func (*HealthCRMLib) GetFacilities

func (h *HealthCRMLib) GetFacilities(ctx context.Context) (*FacilityPage, error)

GetFacilities is used to fetch facilities from health crm facility registry

func (*HealthCRMLib) GetFacilitiesOfferingAService added in v1.0.6

func (h *HealthCRMLib) GetFacilitiesOfferingAService(ctx context.Context, serviceID string) (*FacilityPage, error)

GetFacilitiesOfferingAService fetches the facilities that offer a particular service

func (*HealthCRMLib) GetFacilityByID

func (h *HealthCRMLib) GetFacilityByID(ctx context.Context, id string) (*FacilityOutput, error)

GetFacilityByID is used to fetch facilities from health crm facility registry using its ID

func (*HealthCRMLib) GetFacilityServices added in v1.0.1

func (h *HealthCRMLib) GetFacilityServices(ctx context.Context, facilityID string) (*FacilityServicePage, error)

GetFacilityServices fetches services associated with facility

func (*HealthCRMLib) UpdateFacility

func (h *HealthCRMLib) UpdateFacility(ctx context.Context, id string, updatePayload *Facility) (*FacilityOutput, error)

UpdateFacility is used to update facility's data

type Identifiers

type Identifiers struct {
	IdentifierType  string `json:"identifier_type,omitempty"`
	IdentifierValue string `json:"identifier_value,omitempty"`
	ValidFrom       string `json:"valid_from,omitempty"`
	ValidTo         string `json:"valid_to,omitempty"`
}

Identifiers models facility's identifiers; can be MFL Code, Slade Code etc...

type IdentifiersOutput

type IdentifiersOutput struct {
	ID              string `json:"id"`
	IdentifierType  string `json:"identifier_type"`
	IdentifierValue string `json:"identifier_value"`
	ValidFrom       string `json:"valid_from"`
	ValidTo         string `json:"valid_to"`
	FacilityID      string `json:"facility_id"`
}

IdentifiersOutput is used to display facility identifiers

type ServiceIdentifier added in v1.0.1

type ServiceIdentifier struct {
	ID              string `json:"id"`
	IdentifierType  string `json:"identifier_type"`
	IdentifierValue string `json:"identifier_value"`
	ServiceID       string `json:"service_id"`
}

ServiceIdentifier models the structure of facility's service identifiers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL