From 8b9daa4f2c46fb07e47f68bd3079d840ccbd1c39 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 25 Nov 2018 12:46:45 +0100 Subject: [PATCH] Dodano podstawowe modele i enumy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Podstawowe modele reprezentujące tabele w DB zostały dodane; - Podstawowe enumy zostały dodane --- basicModels.go | 68 ++++++++++++++++++++++++++++++++++++++++++++++ enums.go | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ index.go | 25 +++++++++++++++-- 3 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 basicModels.go create mode 100644 enums.go diff --git a/basicModels.go b/basicModels.go new file mode 100644 index 0000000..646ee78 --- /dev/null +++ b/basicModels.go @@ -0,0 +1,68 @@ +package main + +import "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 int + Name string + Surname string + AcademicDegree academicDegree + Specialization specialization + DateOfEmployment time.Time + JobPosition jobPosition +} + +type operation struct { + OperationID int + Name string + averageTime time.Time + operationType operationTypes + cost float32 + refoundation int +} + +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 diff --git a/enums.go b/enums.go new file mode 100644 index 0000000..d1570a7 --- /dev/null +++ b/enums.go @@ -0,0 +1,73 @@ +package main + +type patientStates string +type sex int +type surgeryField int +type academicDegree int +type specialization int +type jobPosition int +type operationTypes int + +const ( + critical patientStates = "KRYTYCZNY" //KRYTYCZNY + stable patientStates = "STABILNY" //Stabilny + endangered patientStates = "ZAGROŻONY" // ZAGROZONY + none patientStates = "NULL" //NULL + +) + +const ( + k sex = 0 + m sex = 1 +) + +const ( + ogolna surgeryField = 0 + klatkiPiersiowej surgeryField = 1 + sercowoNaczyniowa surgeryField = 2 + ukladuNerwowego surgeryField = 3 + urologia surgeryField = 4 + szczekowoTwarzowa surgeryField = 5 + urazowa surgeryField = 6 + inne surgeryField = 7 +) + +const ( + lekMed academicDegree = 0 + lekRez academicDegree = 1 + lekSpec academicDegree = 2 + dr academicDegree = 3 + drHab academicDegree = 4 + prof academicDegree = 5 +) + +const ( + chirOgolna specialization = 0 + chirKlatkiPiers specialization = 1 + chirSercowoNaczyn specialization = 2 + chirUkNerwowego specialization = 3 + chirUrologiczna specialization = 4 + chirSzczekTwarz specialization = 5 + chirUrazowa specialization = 6 +) + +const ( + generalPracticioner jobPosition = 0 + mainDoctor jobPosition = 1 + viceManager jobPosition = 2 + manager jobPosition = 3 + hospitalHead jobPosition = 4 +) + +const ( + szycie operationTypes = 0 + resekcja operationTypes = 1 + amputacja operationTypes = 2 + drenaz operationTypes = 3 + nastawienieZlaman operationTypes = 4 + operacjaKlatkiPiers operationTypes = 5 + operacjaSerca operationTypes = 6 + operacjaUkNerwow operationTypes = 7 + przeszczep operationTypes = 8 + inneOperacje operationTypes = 9 +) diff --git a/index.go b/index.go index eb48e4d..f828dc5 100644 --- a/index.go +++ b/index.go @@ -1,31 +1,52 @@ package main import ( + "encoding/json" "fmt" "html" "log" "net/http" + "time" "github.com/gorilla/mux" ) +// Zrobione ostatnio: +// Podstawowe struktury modeli; niezbędne enumy; +// Zrobione: +// Podstawowy serwer; +// +// Do zrobienia: +// Funkcje modeli; Interfejsy json; łączenie z bazą danych; Rozne metody do tworzenia komend sql; +// Komunikacja z aplikacja desktopowa; Walidacja danych!! ; func main() { - + xx := getXxx() + xx.Pesel = "ssss" muxRouter := mux.NewRouter().StrictSlash(true) muxRouter.HandleFunc("/", index) muxRouter.HandleFunc("/getfromdb", getAll) muxRouter.HandleFunc("/getfromdb/{primaryKey}", getIndex) log.Fatal(http.ListenAndServe(":8080", muxRouter)) + } func index(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) } func getAll(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, "Tutaj dostaniesz wyniki z bazy danych") + patientsList := patients{ + patient{"kss", "dasda", "asdasd a", time.Now(), patientStates(critical), sex(m), "xxx@yyy.zz"}, + patient{"00112245789", "Adam", "Marcel", time.Now(), patientStates(stable), sex(k), "xxxx@yyy.zz"}, + } + json.NewEncoder(w).Encode(patientsList) } func getIndex(w http.ResponseWriter, r *http.Request) { args := mux.Vars(r) pk := args["primaryKey"] fmt.Fprintf(w, "Tutaj bedzie wynik dla PK = %s", pk) } +func getXxx() patient { + pat := patient{"kss", "dasda", "asdasd a", time.Now(), patientStates(critical), sex(m), "xxx@yyy.zz"} + + return pat +}