admissionServer/databaseRead.go

100 lines
2.7 KiB
Go
Raw Normal View History

package main
import (
"database/sql"
"time"
)
// DOCTOR:
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
}
//DO POPRAWY:
func (pat patients) readModels(rows *sql.Rows) iDatabaseModels {
var models iDatabaseModels
var pati patient
for rows.Next() {
//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 {
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
var diag diagnosis
for rows.Next() {
diag = diagnosis{}
rows.Scan(&diag.IcdSymbol, &diag.Name, &diag.FieldOfSurgery, &diag.Description)
models = append(models, diag)
}
return models
}
func (ope operations) readModels(rows *sql.Rows) iDatabaseModels {
var models iDatabaseModels
var oper operation
for rows.Next() {
oper = operation{}
var dummy interface{}
rows.Scan(&oper.OperationID, &oper.Name, &dummy, &oper.operationType,
&oper.cost, &oper.refoundation)
models = append(models, oper)
}
return models
}
func (doc admissions) readModels(rows *sql.Rows) iDatabaseModels {
var models iDatabaseModels
var admiss admission
for rows.Next() {
admiss = admission{}
rows.Scan(&admiss.AdmissionID, &admiss.AdmissionDate, &admiss.EndDate,
&admiss.PatientPesel, &admiss.MainDoctor, &admiss.PlanedOperation,
&admiss.RoomNumber, &admiss.IsPlanned)
models = append(models, admiss)
}
return models
}
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
}