admissionServer/modelsMethods.go

88 lines
2.7 KiB
Go
Raw Normal View History

package main
import (
"database/sql"
"time"
)
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
}
func (pat patients) 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])
var patientSta patientStates
if valueList[4] == nil {
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),
patientSta, se, ""})
}
return models
}
func (dia diagnoses) readModels(rows *sql.Rows) iDatabaseModels {
var models iDatabaseModels
for rows.Next() {
var valueList [4]iHasValue
rows.Scan(&valueList[0], &valueList[1], &valueList[2], &valueList[3])
var opis string
if valueList[3] == nil {
opis = "Brak"
} else {
opis = valueList[3].(string)
}
models = append(models, diagnosis{
valueList[0].(string), valueList[1].(string), surgeryField(valueList[2].(string)), opis})
}
return models
}
func (ope operations) readModels(rows *sql.Rows) iDatabaseModels {
var models iDatabaseModels
for rows.Next() {
var valueList [6]iHasValue
rows.Scan(&valueList[0], &valueList[1], &valueList[2], &valueList[3], &valueList[4],
&valueList[5])
models = append(models, operation{
valueList[0].(int64), valueList[1].(string), "5:00", operationTypes(valueList[3].(string)),
valueList[4].([]uint8), valueList[5].(int64)})
}
return models
}
/*func (doc admissions) 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, admission{
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
}*/