admissionServer/databaseRead.go

78 lines
2.2 KiB
Go

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
var pati patient
for rows.Next() {
pati = patient{}
rows.Scan(&pati.Pesel, &pati.Name, &pati.Surname, &pati.BirthDate, &pati.PatientState,
&pati.PatientSex, &pati.PatientEmail)
models = append(models, pati)
}
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{}
rows.Scan(&oper.OperationID, &oper.Name, &oper.AverageTime, &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.DiagnosisSymbol, &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.IncreasedCare)
models = append(models, rom)
}
return models
}