2018-12-08 18:01:33 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
2018-12-22 15:56:43 +01:00
|
|
|
"database/sql/driver"
|
2018-12-08 18:01:33 +01:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2018-12-18 22:09:23 +01:00
|
|
|
// DOCTOR:
|
2018-12-08 18:01:33 +01:00
|
|
|
func (doc doctors) readModels(rows *sql.Rows) iDatabaseModels {
|
|
|
|
var models iDatabaseModels
|
|
|
|
for rows.Next() {
|
|
|
|
var valueList [7]iHasValue
|
|
|
|
rows.Scan(&valueList[0], &valueList[1], &valueList[2], &valueList[3], &valueList[4],
|
|
|
|
&valueList[5], &valueList[6])
|
|
|
|
|
|
|
|
models = append(models, doctor{
|
|
|
|
valueList[0].(int64), valueList[1].(string), valueList[2].(string), academicDegree(valueList[3].(string)),
|
|
|
|
specialization(valueList[4].(string)), valueList[5].(time.Time), jobPosition(valueList[6].(string))})
|
|
|
|
}
|
|
|
|
return models
|
|
|
|
}
|
2018-12-18 22:09:23 +01:00
|
|
|
|
|
|
|
//DO POPRAWY:
|
2018-12-08 18:01:33 +01:00
|
|
|
func (pat patients) readModels(rows *sql.Rows) iDatabaseModels {
|
|
|
|
var models iDatabaseModels
|
2018-12-18 22:09:23 +01:00
|
|
|
var pati patient
|
2018-12-08 18:01:33 +01:00
|
|
|
for rows.Next() {
|
2018-12-18 22:09:23 +01:00
|
|
|
//var valueList [7]iHasValue
|
|
|
|
pati = patient{}
|
|
|
|
rows.Scan(&pati.Pesel, &pati.Name, &pati.Surname, &pati.BirthDate, &pati.PatientState,
|
|
|
|
&pati.PatientSex)
|
|
|
|
/*rows.Scan(&valueList[0], &valueList[1], &valueList[2], &valueList[3], &valueList[4],
|
|
|
|
&valueList[5])*/
|
|
|
|
//var patientSta patientStates
|
|
|
|
models = append(models, pati)
|
|
|
|
/*if valueList[4] == nil {
|
2018-12-08 18:01:33 +01:00
|
|
|
patientSta = patientStates("NULL")
|
|
|
|
} else {
|
|
|
|
patientSta = patientStates(valueList[4].(string))
|
|
|
|
}
|
|
|
|
var se sex
|
|
|
|
if valueList[5] == nil {
|
|
|
|
se = sex("M")
|
|
|
|
} else {
|
|
|
|
se = sex(valueList[5].(string))
|
|
|
|
}
|
|
|
|
models = append(models, patient{
|
|
|
|
valueList[0].(string), valueList[1].(string), valueList[2].(string), valueList[3].(time.Time),
|
2018-12-18 22:09:23 +01:00
|
|
|
patientSta, se, ""})*/
|
2018-12-08 18:01:33 +01:00
|
|
|
}
|
|
|
|
return models
|
|
|
|
}
|
|
|
|
func (dia diagnoses) readModels(rows *sql.Rows) iDatabaseModels {
|
|
|
|
var models iDatabaseModels
|
2018-12-18 22:09:23 +01:00
|
|
|
var diag diagnosis
|
2018-12-08 18:01:33 +01:00
|
|
|
for rows.Next() {
|
2018-12-18 22:09:23 +01:00
|
|
|
diag = diagnosis{}
|
|
|
|
rows.Scan(&diag.IcdSymbol, &diag.Name, &diag.FieldOfSurgery, &diag.Description)
|
|
|
|
models = append(models, diag)
|
2018-12-08 18:01:33 +01:00
|
|
|
}
|
|
|
|
return models
|
|
|
|
}
|
|
|
|
func (ope operations) readModels(rows *sql.Rows) iDatabaseModels {
|
|
|
|
var models iDatabaseModels
|
2018-12-18 22:09:23 +01:00
|
|
|
var oper operation
|
2018-12-08 18:01:33 +01:00
|
|
|
for rows.Next() {
|
2018-12-18 22:09:23 +01:00
|
|
|
oper = operation{}
|
2018-12-22 15:56:43 +01:00
|
|
|
rows.Scan(&oper.OperationID, &oper.Name, &oper.averageTime, &oper.operationType,
|
2018-12-18 22:09:23 +01:00
|
|
|
&oper.cost, &oper.refoundation)
|
|
|
|
models = append(models, oper)
|
2018-12-08 18:01:33 +01:00
|
|
|
}
|
|
|
|
return models
|
|
|
|
}
|
|
|
|
|
2018-12-18 22:09:23 +01:00
|
|
|
func (doc admissions) readModels(rows *sql.Rows) iDatabaseModels {
|
2018-12-08 18:01:33 +01:00
|
|
|
var models iDatabaseModels
|
2018-12-18 22:09:23 +01:00
|
|
|
var admiss admission
|
2018-12-08 18:01:33 +01:00
|
|
|
for rows.Next() {
|
2018-12-18 22:09:23 +01:00
|
|
|
admiss = admission{}
|
2018-12-22 15:56:43 +01:00
|
|
|
//var dummy interface{}
|
|
|
|
/*var valueList [9]iHasValue
|
|
|
|
rows.Scan(&valueList[0], &valueList[1], &valueList[2], &valueList[3], &valueList[4],
|
|
|
|
&valueList[5], &valueList[6], &valueList[7], &valueList[8])
|
|
|
|
timex := NullTime{}
|
|
|
|
stri, strix := sql.NullString{}, sql.NullString{}
|
|
|
|
if valueList[2] == nil {
|
|
|
|
timex.Valid = false
|
|
|
|
} else {
|
|
|
|
timex.Time = valueList[2].(time.Time)
|
|
|
|
timex.Valid = true
|
|
|
|
}
|
|
|
|
if valueList[3] == nil {
|
|
|
|
strix.Valid = false
|
|
|
|
} else {
|
|
|
|
strix.String = valueList[4].(string)
|
|
|
|
strix.Valid = true
|
|
|
|
}
|
|
|
|
if valueList[4] == nil {
|
|
|
|
stri.Valid = false
|
|
|
|
} else {
|
|
|
|
stri.String = valueList[4].(string)
|
|
|
|
stri.Valid = true
|
|
|
|
}
|
|
|
|
models = append(models, admission{
|
|
|
|
valueList[0].(int64), valueList[1].(time.Time), timex, strix,
|
|
|
|
stri, valueList[5].(int64), valueList[6].(int64), valueList[7].(int64),
|
|
|
|
valueList[8].(bool)})*/
|
2018-12-18 22:09:23 +01:00
|
|
|
rows.Scan(&admiss.AdmissionID, &admiss.AdmissionDate, &admiss.EndDate,
|
|
|
|
&admiss.PatientPesel, &admiss.MainDoctor, &admiss.PlanedOperation,
|
|
|
|
&admiss.RoomNumber, &admiss.IsPlanned)
|
|
|
|
models = append(models, admiss)
|
2018-12-08 18:01:33 +01:00
|
|
|
}
|
|
|
|
return models
|
2018-12-18 22:09:23 +01:00
|
|
|
}
|
|
|
|
|
2018-12-22 15:56:43 +01:00
|
|
|
type NullTime struct {
|
|
|
|
Time time.Time
|
|
|
|
Valid bool // Valid is true if Time is not NULL
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scan implements the Scanner interface.
|
|
|
|
func (nt *NullTime) Scan(value interface{}) error {
|
|
|
|
nt.Time, nt.Valid = value.(time.Time)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Value implements the driver Valuer interface.
|
|
|
|
func (nt NullTime) Value() (driver.Value, error) {
|
|
|
|
if !nt.Valid {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return nt.Time, nil
|
|
|
|
}
|
2018-12-18 22:09:23 +01:00
|
|
|
func (ro rooms) readModels(rows *sql.Rows) iDatabaseModels {
|
|
|
|
var models iDatabaseModels
|
|
|
|
var rom room
|
|
|
|
for rows.Next() {
|
|
|
|
rom = room{}
|
|
|
|
rows.Scan(&rom.RoomNumber, &rom.NumberOfBeds, &rom.IncrasedCare)
|
|
|
|
models = append(models, rom)
|
|
|
|
}
|
|
|
|
return models
|
|
|
|
}
|