fa9d4c0fc6
Dodano polimorficzny interfejs aby odpowiedzialność za pobranie danych leżała po stronie elementu zależnego, a nie nadrzędnego. Dodano metody rozszerzające do kolekcji modeli, które umożliwiają łatwe tworzenie modeli i dodawanie ich do kolekcji. Pobieranie modeli jeszcze do poprawki.
78 lines
1.4 KiB
Go
78 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"database/sql"
|
|
"time"
|
|
)
|
|
|
|
type patient struct {
|
|
Pesel string
|
|
Name string
|
|
Surname string
|
|
BirthDate time.Time
|
|
PatientState patientStates
|
|
PatientSex sex
|
|
PatientEmail string
|
|
}
|
|
|
|
type diagnosis struct {
|
|
IcdSymbol string
|
|
Name string
|
|
FieldOfSurgery surgeryField
|
|
Description string
|
|
}
|
|
|
|
type doctor struct {
|
|
DoctorID int64
|
|
Name string
|
|
Surname string
|
|
AcademicDegree academicDegree
|
|
Specialization specialization
|
|
DateOfEmployment time.Time
|
|
JobPosition jobPosition
|
|
}
|
|
|
|
type operation struct {
|
|
OperationID int64
|
|
Name string
|
|
averageTime string
|
|
operationType operationTypes
|
|
cost []uint8
|
|
refoundation int64
|
|
}
|
|
|
|
type room struct {
|
|
RoomNumber int
|
|
NumberOfBeds int
|
|
IncrasedCare bool
|
|
}
|
|
|
|
type admission struct {
|
|
AdmissionID int
|
|
AdmissionDate time.Time
|
|
EndDate time.Time
|
|
PatientPesel string
|
|
DiagnosisSymbol string
|
|
MainDoctor int
|
|
PlanedOperation int
|
|
RoomNumber int
|
|
IsPlanned bool
|
|
}
|
|
|
|
func (p patient) showPatient() string {
|
|
return p.Pesel
|
|
}
|
|
|
|
type patients []patient
|
|
type doctors []doctor
|
|
type diagnoses []diagnosis
|
|
type admissions []admission
|
|
type operations []operation
|
|
type rooms []room
|
|
|
|
type iDatabaseModel interface{}
|
|
type iDatabaseModels []iDatabaseModel
|
|
type iStoreModels interface {
|
|
readModels(rows *sql.Rows) iDatabaseModels
|
|
}
|