hospitals

package
v0.0.0-...-c7f2103 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2018 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeListAllDepartmentsEndpoint

func MakeListAllDepartmentsEndpoint(component Component) endpoint.Endpoint

MakeListAllDepartmentsEndpoint makes the ListAllDepartmentsEndpoint.

func MakeListAllDoctorsEndpoint

func MakeListAllDoctorsEndpoint(component Component) endpoint.Endpoint

MakeListAllDoctorsEndpoint makes the ListAllDoctorsEndpoint.

func MakeListAllHospitalsEndpoint

func MakeListAllHospitalsEndpoint(component Component) endpoint.Endpoint

MakeListAllHospitalsEndpoint makes the ListAllHospitalsEndpoint.

Types

type Component

type Component interface {
	ListAllHospitals(context.Context) ([]Hospital, error)
	ListAllDepartments(context.Context) ([]Department, error)
	ListAllDoctors(context.Context) ([]Doctor, error)
}

Component is the hospital business component interface.

func NewComponent

func NewComponent(hospDepModule HospDepModule, doctorsModule DoctorsModule) Component

NewComponent returns a patient business component

type Department

type Department struct {
	ID       int32    `json:"id,omitempty"`
	Name     string   `json:"name,omitempty"`
	Hospital Hospital `json:"hospital,omitempty"`
	Doctors  []Doctor `json:"doctors,omitempty"`
}

Department represents the department of a hospital

type Doctor

type Doctor struct {
	ID          int32        `json:"id,omitempty"`
	FirstName   string       `json:"firstName,omitempty"`
	LastName    string       `json:"lastName,omitempty"`
	Departments []Department `json:"departments,omitempty"`
	PatientsIds []int32      `json:"patients,omitempty"`
}

Doctor represents a doctor

type DoctorsDatabase

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

DoctorsDatabase deals with the communication with CockroachDB.

func InitDoctorsDatabase

func InitDoctorsDatabase(db cockroachDB) (*DoctorsDatabase, error)

InitDoctorsDatabase initializes the database

func (*DoctorsDatabase) ReadFromDb

func (c *DoctorsDatabase) ReadFromDb() ([]Doctor, error)

ReadFromDb returns all the hospitals from the database

type DoctorsModule

type DoctorsModule interface {
	ListAll(ctx context.Context) ([]Doctor, error)
}

DoctorsModule contains the business logic for the doctors.

func NewDoctorModule

func NewDoctorModule(doctorsDatabase DoctorsDatabase) DoctorsModule

NewDoctorModule returns a hospital/departments module

type Endpoints

type Endpoints struct {
	ListAllHospitalsEndpoint   endpoint.Endpoint
	ListAllDepartmentsEndpoint endpoint.Endpoint
	ListAllDoctorsEndpoint     endpoint.Endpoint
}

Endpoints wraps a service behind a set of endpoints.

type HospDepDatabase

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

HospDepDatabase deals with the communication with CockroachDB.

func InitHospDepDatabase

func InitHospDepDatabase(db cockroachDB) (*HospDepDatabase, error)

InitHospDepDatabase initializes the database

func (*HospDepDatabase) ReadDepartmentsFromDb

func (c *HospDepDatabase) ReadDepartmentsFromDb() ([]Department, error)

ReadDepartmentsFromDb returns all the departments from the database

func (*HospDepDatabase) ReadHospitalsFromDb

func (c *HospDepDatabase) ReadHospitalsFromDb() ([]Hospital, error)

ReadHospitalsFromDb returns all the hospitals from the database

type HospDepModule

type HospDepModule interface {
	ListAllHospitals(ctx context.Context) ([]Hospital, error)
	ListAllDepartments(ctx context.Context) ([]Department, error)
}

HospDepModule contains the business logic for the hospitals/departments.

func NewHospDepModule

func NewHospDepModule(hospDepDatabase HospDepDatabase) HospDepModule

NewHospDepModule returns a hospital/departments module

type Hospital

type Hospital struct {
	ID          int32        `json:"id,omitempty"`
	Name        string       `json:"name,omitempty"`
	City        string       `json:"city,omitempty"`
	Departments []Department `json:"departments,omitempty"`
}

Hospital represents a hospital

Jump to

Keyboard shortcuts

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