enumutils

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: MIT Imports: 3 Imported by: 35

README

Linting and Tests Coverage Status

Enum Utils Library

enumutils are utilities used by several backend services. These includes various method implementations

Installing it

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

go get -u github.com/savannahghi/enumutils

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/enumutils"

and run go get without parameters.

The package name is enumutils

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 Travis CI. Our coverage threshold is 90% i.e you must keep coverage above 90%.

Environment variables

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

# Application settings
export DEBUG=true
export IS_RUNNING_TESTS=true
export SENTRY_DSN=<a Sentry Data Source Name>
export GOOGLE_CLOUD_PROJECT="Google Cloud project id"

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 Travis 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

View Source
const LanguageCodingSystem = "urn:ietf:bcp:47"

LanguageCodingSystem is the FHIR language coding system

View Source
const LanguageCodingVersion = ""

LanguageCodingVersion is the FHIR language value

Variables

AllAddressType contains a slice of all addresses types

AllCalendarView is a list of calendar views

AllContentType is a list of all acceptable content types

AllFieldType is a list of all field types, used to simulate/map to a GraphQL enum

AllGender is a list of known genders

AllIdentificationDocType contains a slice of all IdentificationDocTypes

View Source
var AllLanguage = []Language{
	LanguageEn,
	LanguageSw,
}

AllLanguage is a list of all allowed languages

AllOperation is a list of all valid operations for filter parameters

AllPractitionerSpecialty is the set of known practitioner specialties

AllSenderID defines a list of the sender IDs

View Source
var AllSortOrder = []SortOrder{
	SortOrderAsc,
	SortOrderDesc,
}

AllSortOrder is a list of all valid sort orders

View Source
var LanguageNames = map[Language]string{
	LanguageEn: "English",
	LanguageSw: "Swahili",
}

LanguageNames is a map of language codes to language names

Functions

This section is empty.

Types

type AddressType

type AddressType string

AddressType represents the types of addresses we have

const (
	AddressTypeHome AddressType = "HOME"
	AddressTypeWork AddressType = "WORK"
)

AddressTypeHome is an example of an address type

func (AddressType) IsValid

func (e AddressType) IsValid() bool

IsValid checks if the address type is valid

func (AddressType) MarshalGQL

func (e AddressType) MarshalGQL(w io.Writer)

MarshalGQL converts address type into a valid JSON string

func (AddressType) String

func (e AddressType) String() string

func (*AddressType) UnmarshalGQL

func (e *AddressType) UnmarshalGQL(v interface{}) error

UnmarshalGQL converts the input, if valid, into an address type value

type CalendarView

type CalendarView string

CalendarView is used to determine what view of a calendar to render

const (
	// CalendarViewDay ...
	CalendarViewDay CalendarView = "DAY"
	// CalendarViewWeek ...
	CalendarViewWeek CalendarView = "WEEK"
)

calendar view constants

func (CalendarView) IsValid

func (e CalendarView) IsValid() bool

IsValid returns true if a calendar view is valid

func (CalendarView) MarshalGQL

func (e CalendarView) MarshalGQL(w io.Writer)

MarshalGQL writes the calendar view value to the supplied writer

func (CalendarView) String

func (e CalendarView) String() string

String ...

func (*CalendarView) UnmarshalGQL

func (e *CalendarView) UnmarshalGQL(v interface{}) error

UnmarshalGQL converts the input value into a calendar view

type ContentType

type ContentType string

ContentType defines accepted content types

const (
	ContentTypePng ContentType = "PNG"
	ContentTypeJpg ContentType = "JPG"
	ContentTypePdf ContentType = "PDF"
)

Constants used to map to allowed MIME types

func (ContentType) IsValid

func (e ContentType) IsValid() bool

IsValid ensures that the content type value is valid

func (ContentType) MarshalGQL

func (e ContentType) MarshalGQL(w io.Writer)

MarshalGQL writes the value of this enum to the supplied writer

func (ContentType) String

func (e ContentType) String() string

func (*ContentType) UnmarshalGQL

func (e *ContentType) UnmarshalGQL(v interface{}) error

UnmarshalGQL turns the supplied value into a content type value

type FieldType

type FieldType string

FieldType is used to represent the GraphQL enum that is used for filter parameters

const (
	// FieldTypeBoolean represents a boolean filter parameter
	FieldTypeBoolean FieldType = "BOOLEAN"

	// FieldTypeTimestamp represents a timestamp filter parameter
	FieldTypeTimestamp FieldType = "TIMESTAMP"

	// FieldTypeNumber represents a numeric (decimal or float) filter parameter
	FieldTypeNumber FieldType = "NUMBER"

	// FieldTypeInteger represents an integer filter parameter
	FieldTypeInteger FieldType = "INTEGER"

	// FieldTypeString represents a string filter parameter
	FieldTypeString FieldType = "STRING"
)

func (FieldType) IsValid

func (e FieldType) IsValid() bool

IsValid returns True if the supplied value is a valid field type

func (FieldType) MarshalGQL

func (e FieldType) MarshalGQL(w io.Writer)

MarshalGQL serializes the enum value to the supplied writer

func (FieldType) String

func (e FieldType) String() string

String represents a GraphQL enum as a string

func (*FieldType) UnmarshalGQL

func (e *FieldType) UnmarshalGQL(v interface{}) error

UnmarshalGQL checks whether the supplied value is a valid gqlgen enum and returns an error if it is not

type Gender

type Gender string

Gender is a code system for administrative gender.

See: https://www.hl7.org/fhir/valueset-administrative-gender.html

const (
	GenderMale           Gender = "male"
	GenderFemale         Gender = "female"
	GenderOther          Gender = "other"
	GenderUnknown        Gender = "unknown"
	GenderNonBinary      Gender = "nonbinary"
	GenderGenderQueer    Gender = "genderqueer"
	GenderTransGender    Gender = "transgender"
	GenderAgender        Gender = "agender"
	GenderBigender       Gender = "bigender"
	GenderTwoSpirit      Gender = "twospirit"
	GenderPreferNotToSay Gender = "prefer_not_to_say"
)

gender constants

func (Gender) IsValid

func (e Gender) IsValid() bool

IsValid returns True if the enum value is valid

func (Gender) MarshalGQL

func (e Gender) MarshalGQL(w io.Writer)

MarshalGQL writes the enum value to the supplied writer

func (Gender) String

func (e Gender) String() string

func (Gender) ToAdvantageGender added in v0.0.6

func (e Gender) ToAdvantageGender() string

ToAdvantageGender converts the `male` and `female` genders to `MALE` and `FEMALE` respectively. This is used in support of advantage wrapper service and also ensure consistency of known gender types in go services.

func (*Gender) UnmarshalGQL

func (e *Gender) UnmarshalGQL(v interface{}) error

UnmarshalGQL translates from the supplied value to a valid enum value

type IdentificationDocType

type IdentificationDocType string

IdentificationDocType defines the various supplier IdentificationDocTypes

const (
	IdentificationDocTypeNationalid IdentificationDocType = "NATIONALID"
	IdentificationDocTypePassport   IdentificationDocType = "PASSPORT"
	IdentificationDocTypeMilitary   IdentificationDocType = "MILITARY"
)

IdentificationDocTypeNationalid is an example of a IdentificationDocType

func (IdentificationDocType) IsValid

func (e IdentificationDocType) IsValid() bool

IsValid checks if the IdentificationDocType is valid

func (IdentificationDocType) MarshalGQL

func (e IdentificationDocType) MarshalGQL(w io.Writer)

MarshalGQL converts IdentificationDocType into a valid JSON string

func (IdentificationDocType) String

func (e IdentificationDocType) String() string

func (*IdentificationDocType) UnmarshalGQL

func (e *IdentificationDocType) UnmarshalGQL(v interface{}) error

UnmarshalGQL converts the input, if valid, into an IdentificationDocType value

type Language

type Language string

Language defines allowed languages for uploads

const (
	LanguageEn Language = "en"
	LanguageSw Language = "sw"
)

Constants used to map to allowed languages

func (Language) IsValid

func (e Language) IsValid() bool

IsValid ensures that the supplied language value is correct

func (Language) MarshalGQL

func (e Language) MarshalGQL(w io.Writer)

MarshalGQL writes the value of this enum to the supplied writer

func (Language) String

func (e Language) String() string

func (*Language) UnmarshalGQL

func (e *Language) UnmarshalGQL(v interface{}) error

UnmarshalGQL translates the input to a language type value

type Operation

type Operation string

Operation is used to map to a gqlgen (GraphQL) enum that defines filter/comparison operations

const (
	// OperationLessThan represents < in a GraphQL enum
	OperationLessThan Operation = "LESS_THAN"

	// OperationLessThanOrEqualTo represents <= in a GraphQL enum
	OperationLessThanOrEqualTo Operation = "LESS_THAN_OR_EQUAL_TO"

	// OperationEqual represents = in a GraphQL enum
	OperationEqual Operation = "EQUAL"

	// OperationGreaterThan represents > in a GraphQL enum
	OperationGreaterThan Operation = "GREATER_THAN"

	// OperationGreaterThanOrEqualTo represents >= in a GraphQL enum
	OperationGreaterThanOrEqualTo Operation = "GREATER_THAN_OR_EQUAL_TO"

	// OperationIn represents "in" (for queries that supply a list of parameters)
	// in a GraphQL enum
	OperationIn Operation = "IN"

	// OperationContains represents "contains" (for queries that check that a fragment is contained)
	// in a field(s) in a GraphQL enum
	OperationContains Operation = "CONTAINS"
)

func (Operation) IsValid

func (e Operation) IsValid() bool

IsValid returns true if the operation is valid

func (Operation) MarshalGQL

func (e Operation) MarshalGQL(w io.Writer)

MarshalGQL writes the enum value to the supplied writer

func (Operation) String

func (e Operation) String() string

String renders an operation enum value as a string

func (*Operation) UnmarshalGQL

func (e *Operation) UnmarshalGQL(v interface{}) error

UnmarshalGQL confirms that an enum value is valid and returns an error if it is not

type PractitionerSpecialty

type PractitionerSpecialty string

PractitionerSpecialty is a list of recognised health worker specialties.

See: https://medicalboard.co.ke/resources_page/gazetted-specialties/

const (
	PractitionerSpecialtyUnspecified                     PractitionerSpecialty = "UNSPECIFIED"
	PractitionerSpecialtyAnaesthesia                     PractitionerSpecialty = "ANAESTHESIA"
	PractitionerSpecialtyCardiothoracicSurgery           PractitionerSpecialty = "CARDIOTHORACIC_SURGERY"
	PractitionerSpecialtyClinicalMedicalGenetics         PractitionerSpecialty = "CLINICAL_MEDICAL_GENETICS"
	PractitionerSpecialtyClincicalPathology              PractitionerSpecialty = "CLINCICAL_PATHOLOGY"
	PractitionerSpecialtyGeneralPathology                PractitionerSpecialty = "GENERAL_PATHOLOGY"
	PractitionerSpecialtyAnatomicPathology               PractitionerSpecialty = "ANATOMIC_PATHOLOGY"
	PractitionerSpecialtyClinicalOncology                PractitionerSpecialty = "CLINICAL_ONCOLOGY"
	PractitionerSpecialtyDermatology                     PractitionerSpecialty = "DERMATOLOGY"
	PractitionerSpecialtyEarNoseAndThroat                PractitionerSpecialty = "EAR_NOSE_AND_THROAT"
	PractitionerSpecialtyEmergencyMedicine               PractitionerSpecialty = "EMERGENCY_MEDICINE"
	PractitionerSpecialtyFamilyMedicine                  PractitionerSpecialty = "FAMILY_MEDICINE"
	PractitionerSpecialtyGeneralSurgery                  PractitionerSpecialty = "GENERAL_SURGERY"
	PractitionerSpecialtyGeriatrics                      PractitionerSpecialty = "GERIATRICS"
	PractitionerSpecialtyImmunology                      PractitionerSpecialty = "IMMUNOLOGY"
	PractitionerSpecialtyInfectiousDisease               PractitionerSpecialty = "INFECTIOUS_DISEASE"
	PractitionerSpecialtyInternalMedicine                PractitionerSpecialty = "INTERNAL_MEDICINE"
	PractitionerSpecialtyMicrobiology                    PractitionerSpecialty = "MICROBIOLOGY"
	PractitionerSpecialtyNeurosurgery                    PractitionerSpecialty = "NEUROSURGERY"
	PractitionerSpecialtyObstetricsAndGynaecology        PractitionerSpecialty = "OBSTETRICS_AND_GYNAECOLOGY"
	PractitionerSpecialtyOccupationalMedicine            PractitionerSpecialty = "OCCUPATIONAL_MEDICINE"
	PractitionerSpecialtyOphthalmology                   PractitionerSpecialty = "OPGTHALMOLOGY"
	PractitionerSpecialtyOrthopaedicSurgery              PractitionerSpecialty = "ORTHOPAEDIC_SURGERY"
	PractitionerSpecialtyOncology                        PractitionerSpecialty = "ONCOLOGY"
	PractitionerSpecialtyOncologyRadiotherapy            PractitionerSpecialty = "ONCOLOGY_RADIOTHERAPY"
	PractitionerSpecialtyPaediatricsAndChildHealth       PractitionerSpecialty = "PAEDIATRICS_AND_CHILD_HEALTH"
	PractitionerSpecialtyPalliativeMedicine              PractitionerSpecialty = "PALLIATIVE_MEDICINE"
	PractitionerSpecialtyPlasticAndReconstructiveSurgery PractitionerSpecialty = "PLASTIC_AND_RECONSTRUCTIVE_SURGERY"
	PractitionerSpecialtyPsychiatry                      PractitionerSpecialty = "PSYCHIATRY"
	PractitionerSpecialtyPublicHealth                    PractitionerSpecialty = "PUBLIC_HEALTH"
	PractitionerSpecialtyRadiology                       PractitionerSpecialty = "RADIOLOGY"
	PractitionerSpecialtyUrology                         PractitionerSpecialty = "UROLOGY"
)

list of known practitioner specialties

func (PractitionerSpecialty) IsValid

func (e PractitionerSpecialty) IsValid() bool

IsValid returns True if the practitioner specialty is valid

func (PractitionerSpecialty) MarshalGQL

func (e PractitionerSpecialty) MarshalGQL(w io.Writer)

MarshalGQL writes the practitioner specialty to the supplied writer

func (PractitionerSpecialty) String

func (e PractitionerSpecialty) String() string

func (*PractitionerSpecialty) UnmarshalGQL

func (e *PractitionerSpecialty) UnmarshalGQL(v interface{}) error

UnmarshalGQL converts the supplied value to a practitioner specialty

type SenderID

type SenderID string

SenderID defines the various AT Sender IDs that we have and can use

const (
	SenderIDSLADE360 SenderID = "SLADE360"
	SenderIDBewell   SenderID = "BEWELL"
)

SenderIDSLADE360 is an example of a sender ID

func (SenderID) IsValid

func (e SenderID) IsValid() bool

IsValid checks if a Sender ID is valid

func (SenderID) MarshalGQL

func (e SenderID) MarshalGQL(w io.Writer)

MarshalGQL converts SenderID into a valid JSON string

func (SenderID) String

func (e SenderID) String() string

func (*SenderID) UnmarshalGQL

func (e *SenderID) UnmarshalGQL(v interface{}) error

UnmarshalGQL converts the input, if valid, into a Sender ID value

type SortOrder

type SortOrder string

SortOrder is used to represent map sort directions to a GraphQl enum

const (
	// SortOrderAsc is for ascending sorts
	SortOrderAsc SortOrder = "ASC"

	// SortOrderDesc is for descending sorts
	SortOrderDesc SortOrder = "DESC"
)

func (SortOrder) IsValid

func (e SortOrder) IsValid() bool

IsValid returns true if the sort order is valid

func (SortOrder) MarshalGQL

func (e SortOrder) MarshalGQL(w io.Writer)

MarshalGQL writes the sort order to the supplied writer as a quoted string

func (SortOrder) String

func (e SortOrder) String() string

String renders the sort order as a plain string

func (*SortOrder) UnmarshalGQL

func (e *SortOrder) UnmarshalGQL(v interface{}) error

UnmarshalGQL confirms that the supplied value is a valid sort order and returns an error if it is not

Jump to

Keyboard shortcuts

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