healthcrm

package module
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 15 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 ContactType added in v1.1.6

type ContactType string
const (
	ContactTypePhoneNumber ContactType = "PHONE_NUMBER"
	ContactTypeEmail       ContactType = "EMAIL"
)

func (ContactType) IsValid added in v1.1.6

func (f ContactType) IsValid() bool

IsValid returns true if a contact type is valid

func (ContactType) MarshalGQL added in v1.1.6

func (f ContactType) MarshalGQL(w io.Writer)

MarshalGQL writes the contact type to the supplied writer

func (ContactType) String added in v1.1.6

func (f ContactType) String() string

String converts the contact type enum to a string

func (*ContactType) UnmarshalGQL added in v1.1.6

func (f *ContactType) UnmarshalGQL(v interface{}) error

UnmarshalGQL converts the supplied value to a contact type.

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"`
	Radius    string `json:"radius,omitempty"`
}

Coordinates represents geographical coordinates using latitude and longitude. Latitude measures the north-south position, while longitude measures the east-west position.

func (Coordinates) ToString added in v1.0.10

func (c Coordinates) ToString() (string, error)

ToString returns the location in comma-separated values format. The order of values in the string is longitude,latitude. The latitude and longitude are formatted up to 5 decimal places. For example, if the Location has Latitude 36.79 and Longitude -1.29, the returned string will be "-1.29, 36.79".

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,omitempty"`
	Created       time.Time             `json:"created,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"`
	Coordinates   CoordinatesOutput     `json:"coordinates,omitempty"`
	Distance      float64               `json:"distance,omitempty"`
	Status        string                `json:"status,omitempty"`
	Address       string                `json:"address,omitempty"`
	Contacts      []ContactsOutput      `json:"contacts,omitempty"`
	Identifiers   []IdentifiersOutput   `json:"identifiers,omitempty"`
	BusinessHours []BusinessHoursOutput `json:"businesshours,omitempty"`
	Services      []FacilityService     `json:"services,omitempty"`
}

FacilityOutput is used to display facility(ies)

type FacilityOutputs added in v1.1.9

type FacilityOutputs struct {
	Results []*FacilityOutput `json:"results"`
}

FacilityOutputs is used to get a list of facilities

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 FacilityServiceInput added in v1.0.9

type FacilityServiceInput struct {
	Name        string                    `json:"name"`
	Description string                    `json:"description"`
	Identifiers []*ServiceIdentifierInput `json:"identifiers"`
}

FacilityServiceInput models is used to create a new service

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 FacilityServices added in v1.1.8

type FacilityServices struct {
	Results []*FacilityService `json:"results"`
}

FacilityServices is used to get a list of facility Services

type GenderType added in v1.2.0

type GenderType string
const (
	GenderTypeMale   GenderType = "MALE"
	GenderTypeFemale GenderType = "FEMALE"
	GenderTypeOther  GenderType = "OTHER"
	// GenderTypeASKU stands for Asked but Unknown
	GenderTypeASKU GenderType = "ASKU"
	// GenderTypeUNK stands for Unknown
	GenderTypeUNK GenderType = "UNK"
)

func ConvertEnumutilsGenderToCRMGender added in v1.2.3

func ConvertEnumutilsGenderToCRMGender(gender enumutils.Gender) GenderType

ConvertEnumutilsGenderToCRMGender converts an enumutils Gender to a CRM gender type

func (GenderType) IsValid added in v1.2.0

func (f GenderType) IsValid() bool

IsValid returns true if a Gender type is valid

func (GenderType) MarshalGQL added in v1.2.0

func (f GenderType) MarshalGQL(w io.Writer)

MarshalGQL writes the gender type to the supplied writer

func (GenderType) String added in v1.2.0

func (f GenderType) String() string

String converts the Gender type enum to a string

func (*GenderType) UnmarshalGQL added in v1.2.0

func (f *GenderType) UnmarshalGQL(v interface{}) error

UnmarshalGQL converts the supplied value to a Gender type.

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) CreateProfile added in v1.1.5

func (h *HealthCRMLib) CreateProfile(ctx context.Context, profile *ProfileInput) (*ProfileOutput, error)

CreateProfile is used to create profile in health CRM service

func (*HealthCRMLib) CreateService added in v1.0.9

func (h *HealthCRMLib) CreateService(ctx context.Context, input FacilityServiceInput) (*FacilityService, error)

CreateService is used to create a new service in health crm

func (*HealthCRMLib) GetFacilities

func (h *HealthCRMLib) GetFacilities(ctx context.Context, location *Coordinates, serviceIDs []string, searchParameter string, pagination *Pagination, crmServiceCode string) (*FacilityPage, error)

GetFacilities retrieves a list of facilities associated with MyCareHub stored in HealthCRM. The method allows for filtering facilities by location proximity and services offered.

Parameters:

  • location: A Location struct that represents the reference location. If provided, facilities will be filtered based on proximity to this location.
  • pagination: A Pagination struct containing options for paginating the results.
  • serviceIDs: A parameter that allows specifying one or more service IDs. Facilities offering these services will be included in the results. You can pass multiple service IDs as separate arguments (e.g., GetFacilities(ctx, location, pagination, []string{"1234", "178"})).
  • searchParameter: A parameter used to search a facility by the facility name or a service name Note that this parameter cannot be passed together with the serviceIDs

Usage: Example 1: Retrieve facilities by location and service IDs: --> E.g If we are searching with service ID that represents Chemotherapy, the response will be a list of facilities that offer Chemotherapy and it will be ordered with proximity

Example 2: Retrieve facilities by location without specifying services: This will return a list of all facilities ordered by the proximity

Example 3: Retrieve all facilities without specifying location or services:

func (*HealthCRMLib) GetFacilitiesOfferingAService added in v1.0.6

func (h *HealthCRMLib) GetFacilitiesOfferingAService(ctx context.Context, serviceID string, pagination *Pagination) (*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) GetMultipleFacilities added in v1.1.9

func (h *HealthCRMLib) GetMultipleFacilities(ctx context.Context, facilityIDs []string) ([]*FacilityOutput, error)

GetMultipleFacilities is used to fetch multiple facilities

Parameters:

  • facilityIDs: A parameter that is a list of IDs specifying one or more facility IDs. Facility identifiers, contacts, services and business hours linked to a facility will be included in the results. You can **ONLY** pass a single or multiple facility IDs which should be of type **UUID** (e.g., GetMultipleFacilities(ctx, []string{"0fee2792-dffc-40d3-a744-2a70732b1053", "56c62083-c7b4-4055-8d44-6cc7446ac1d0", "8474ea55-8ede-4bc6-aa67-f53ed5456a03"})).

func (*HealthCRMLib) GetMultipleServices added in v1.1.8

func (h *HealthCRMLib) GetMultipleServices(ctx context.Context, servicesIDs []string) ([]*FacilityService, error)

GetMultipleServices is used to fetch multiple services

Parameters:

  • serviceIDs: A parameter that is a list of IDs specifying one or more service IDs. Service identifiers identifying these services will be included in the results. You can **ONLY** pass a single or multiple service IDs which should be of type **UUID** (e.g., GetMultipleServices(ctx, []string{"0fee2792-dffc-40d3-a744-2a70732b1053", "56c62083-c7b4-4055-8d44-6cc7446ac1d0", "8474ea55-8ede-4bc6-aa67-f53ed5456a03"})).

func (*HealthCRMLib) GetPersonContacts added in v1.2.5

func (h *HealthCRMLib) GetPersonContacts(ctx context.Context, healthID string) ([]*ProfileContactOutput, error)

GetPersonContacts fetches a persons Contacts using their HealthID

func (*HealthCRMLib) GetPersonIdentifiers added in v1.2.5

func (h *HealthCRMLib) GetPersonIdentifiers(ctx context.Context, healthID string, identifierTypes []*IdentifierType) ([]*ProfileIdentifierOutput, error)

GetPersonIdentifiers fetches a persons identifiers using their HealthID, a filter for identifier_type can be passed

func (*HealthCRMLib) GetService added in v1.1.1

func (h *HealthCRMLib) GetService(ctx context.Context, serviceID string) (*FacilityService, error)

GetService is used to fetch a single service given its ID

func (*HealthCRMLib) GetServices added in v1.0.11

func (h *HealthCRMLib) GetServices(ctx context.Context, pagination *Pagination, crmServiceCode string) (*FacilityServicePage, error)

GetServices retrieves a list of healthcare services provided by facilities that are owned by a specific SIL service, such as Mycarehub or Advantage.

func (*HealthCRMLib) LinkServiceToFacility added in v1.0.9

func (h *HealthCRMLib) LinkServiceToFacility(ctx context.Context, facilityID string, input []*FacilityServiceInput) (*FacilityService, error)

LinkServiceToFacility is used to link a service to a facility

func (*HealthCRMLib) MatchProfile added in v1.3.2

func (h *HealthCRMLib) MatchProfile(ctx context.Context, profile *ProfileInput) (*ProfileOutput, error)

MatchProfile is used to create profile in health CRM service

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 IdentifierType added in v1.1.6

type IdentifierType string
const (
	// Identifier types
	IdentifierTypeNationalID         IdentifierType = "NATIONAL_ID"
	IdentifierTypePassportNo         IdentifierType = "PASSPORT_NO"
	IdentifierTypeMilitaryID         IdentifierType = "MILITARY_ID"
	IdentifierTypeAlienID            IdentifierType = "ALIEN_ID"
	IdentifierTypeNHIFNo             IdentifierType = "NHIF_NO"
	IdentifierTypePatientNo          IdentifierType = "PATIENT_NO"
	IdentifierTypePayerMemberNo      IdentifierType = "PAYER_MEMBER_NO"
	IdentifierTypeSmartMemberNo      IdentifierType = "SMART_MEMBER_NO"
	IdentifierTypeFHIRPatientID      IdentifierType = "FHIR_PATIENT_ID"
	IdentifierTypeERPCustomerID      IdentifierType = "ERP_CUSTOMER_ID"
	IdentifierTypeCCCNumber          IdentifierType = "CCC_NUMBER"
	IdentifierTypeRefugeeID          IdentifierType = "REFUGEE_ID"
	IdentifierTypeBirthCertificateNo IdentifierType = "BIRTH_CERTIFICATE_NO"
	IdentifierTypeMandateNo          IdentifierType = "MANDATE_NO"
	IdentifierTypeClientRegistryNo   IdentifierType = "CLIENT_REGISTRY_NO"
)

func (IdentifierType) IsValid added in v1.1.6

func (f IdentifierType) IsValid() bool

IsValid returns true if an identifier type is valid

func (IdentifierType) MarshalGQL added in v1.1.6

func (f IdentifierType) MarshalGQL(w io.Writer)

MarshalGQL writes the identifier type to the supplied writer

func (IdentifierType) String added in v1.1.6

func (f IdentifierType) String() string

String converts the identifier type enum to a string

func (*IdentifierType) UnmarshalGQL added in v1.1.6

func (f *IdentifierType) UnmarshalGQL(v interface{}) error

UnmarshalGQL converts the supplied value to an identifier type.

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 MatchResult added in v1.3.2

type MatchResult string
const (
	MatchResultMatch         MatchResult = "MATCH"
	MatchResultPossibleMatch MatchResult = "POSSIBLE_MATCH"
	MatchResultNoMatch       MatchResult = "NO_MATCH"
)

func (MatchResult) IsValid added in v1.3.2

func (m MatchResult) IsValid() bool

IsValid returns true if a match result is valid

func (MatchResult) String added in v1.3.2

func (m MatchResult) String() string

String converts the match result enum to a string

type Pagination added in v1.0.8

type Pagination struct {
	Page     string `json:"page"`
	PageSize string `json:"page_size"`
}

Pagination is used to hold pagination values

type Profile added in v1.2.7

type Profile struct {
	Service    Service `json:"service"`
	Name       string  `json:"full_name"`
	SladeCode  string  `json:"slade_code"`
	ExternalID string  `json:"external_id"`
}

Profile models how a profile from a service is modelled.

type ProfileContactInput added in v1.1.5

type ProfileContactInput struct {
	ContactType  ContactType       `json:"contact_type"`
	ContactValue string            `json:"contact_value"`
	Verified     bool              `json:"verified"`
	ValidFrom    *scalarutils.Date `json:"valid_from,omitempty"`
	ValidTo      *scalarutils.Date `json:"valid_to,omitempty"`
}

ProfileContanctInput is used to create profile(s) contact(s)

type ProfileContactOutput added in v1.2.5

type ProfileContactOutput struct {
	ContactType  ContactType       `json:"contact_type"`
	ContactValue string            `json:"contact_value"`
	Verified     bool              `json:"verified"`
	ValidFrom    *scalarutils.Date `json:"valid_from,omitempty"`
	ValidTo      *scalarutils.Date `json:"valid_to,omitempty"`
	Profile      Profile           `json:"profile"`
}

ProfileContactOutput is used to display profile(s) contact(s)

type ProfileContactOutputs added in v1.2.5

type ProfileContactOutputs struct {
	Results []*ProfileContactOutput `json:"results"`
}

ProfileContactOutputs is used to get a list of contacts

type ProfileIdentifierInput added in v1.1.5

type ProfileIdentifierInput struct {
	IdentifierType  IdentifierType    `json:"identifier_type"`
	IdentifierValue string            `json:"identifier_value"`
	Verified        bool              `json:"verified"`
	ValidFrom       *scalarutils.Date `json:"valid_from,omitempty"`
	ValidTo         *scalarutils.Date `json:"valid_to,omitempty"`
}

ProfileIdentifierInput is used to create profile(s) identifier(s)

type ProfileIdentifierOutput added in v1.2.5

type ProfileIdentifierOutput struct {
	IdentifierType  IdentifierType    `json:"identifier_type"`
	IdentifierValue string            `json:"identifier_value"`
	Verified        bool              `json:"verified"`
	ValidFrom       *scalarutils.Date `json:"valid_from,omitempty"`
	ValidTo         *scalarutils.Date `json:"valid_to,omitempty"`
	Profile         Profile           `json:"profile"`
}

ProfileIdentifierOutput is used to display profile(s) identifier(s)

type ProfileIdentifierOutputs added in v1.2.5

type ProfileIdentifierOutputs struct {
	Results []*ProfileIdentifierOutput `json:"results"`
}

ProfileIdentifierOutputs is used to get a list of identifiers

type ProfileInput added in v1.1.5

type ProfileInput struct {
	ProfileID     string                    `json:"profile_id"`
	HealthID      string                    `json:"health_id,omitempty"`
	FirstName     string                    `json:"first_name"`
	LastName      string                    `json:"last_name"`
	OtherName     string                    `json:"other_name,omitempty"`
	DateOfBirth   string                    `json:"date_of_birth,omitempty"`
	Gender        GenderType                `json:"gender"`
	EnrolmentDate string                    `json:"enrolment_date,omitempty"`
	SladeCode     string                    `json:"slade_code"`
	ServiceCode   string                    `json:"service_code"`
	Contacts      []*ProfileContactInput    `json:"contacts,omitempty"`
	Identifiers   []*ProfileIdentifierInput `json:"identifiers,omitempty"`
}

ProfileInput is the host of users data or a brief description of a person

type ProfileOutput added in v1.1.5

type ProfileOutput struct {
	ID             string      `json:"id"`
	ProfileID      string      `json:"profile_id"`
	HealthID       string      `json:"health_id,omitempty"`
	Classification MatchResult `json:"classification,omitempty"`
	SladeCode      string      `json:"slade_code"`
}

ProfileOutput is used to display profile(s)

type Service added in v1.2.7

type Service struct {
	Name string `json:"name"`
	Code string `json:"code"`
}

Service is used get a service from HealthCRM. These are services such as advantage, edi , consumer etc

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

type ServiceIdentifierInput added in v1.0.9

type ServiceIdentifierInput struct {
	IdentifierType  string `json:"identifier_type"`
	IdentifierValue string `json:"identifier_value"`
}

ServiceIdentifierInput is used to create an identifier

Jump to

Keyboard shortcuts

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