From 055fce482a17b030d8ebf685982a23f077b99526 Mon Sep 17 00:00:00 2001 From: haraldnilsen Date: Sun, 14 Jan 2024 20:39:43 +0100 Subject: [PATCH] :ambulance: critical changes before deployment Co-authored-by: Sindre Kjelsrud --- backend/cmd/db/db.go | 1 + backend/cmd/db/get_user_questions.go | 2 +- backend/cmd/db/insert_user_data.go | 8 ++++---- backend/cmd/main.go | 7 ++++--- frontend/src/api/postUserformData.ts | 3 +++ .../src/components/form/answerbox/AnswerBox.svelte | 4 ++-- frontend/src/routes/+page.svelte | 4 ++-- frontend/src/routes/personvern/+page.svelte | 2 +- frontend/src/routes/userform/+page.svelte | 10 ++++++---- 9 files changed, 24 insertions(+), 17 deletions(-) diff --git a/backend/cmd/db/db.go b/backend/cmd/db/db.go index dae6c39..fe501d8 100644 --- a/backend/cmd/db/db.go +++ b/backend/cmd/db/db.go @@ -54,6 +54,7 @@ func SetupDb() { alder TEXT NOT NULL, utdanningsgrad TEXT NOT NULL, helsepersonell BOOL NOT NULL, + harlisens BOOL NOT NULL, kjønn TEXT NOT NULL, svartfør BOOL NOT NULL, fylke TEXT NOT NULL, diff --git a/backend/cmd/db/get_user_questions.go b/backend/cmd/db/get_user_questions.go index 209307c..5bba8c7 100644 --- a/backend/cmd/db/get_user_questions.go +++ b/backend/cmd/db/get_user_questions.go @@ -53,7 +53,7 @@ func GetUserQuestions(respondentID int) ([]UserQuestions, error) { FROM Spørsmålsvar ss LEFT JOIN SvarVurdering sv ON ss.svarID = sv.svarID GROUP BY ss.spørsmålID - HAVING COUNT(sv.vurderingID) < 10 + HAVING COUNT(sv.vurderingID) < 3 ) AS subquery ON s.spørsmålID = subquery.spørsmålID WHERE subquery.spørsmålID IS NOT NULL LIMIT 5 diff --git a/backend/cmd/db/insert_user_data.go b/backend/cmd/db/insert_user_data.go index 313d4e0..25c342b 100644 --- a/backend/cmd/db/insert_user_data.go +++ b/backend/cmd/db/insert_user_data.go @@ -8,7 +8,7 @@ import ( _ "github.com/lib/pq" ) -func InsertUserData(age string, education string, healthcarepersonell bool, gender string, answeredbefore bool, county string, submitdate string) (int, error) { +func InsertUserData(age string, education string, healthcarepersonell bool, islicensed bool, gender string, answeredbefore bool, county string, submitdate string) (int, error) { // Connection string psqlInfo := fmt.Sprintf("host=%s port=%d user=%s "+ "password=%s dbname=%s sslmode=disable", @@ -28,8 +28,8 @@ func InsertUserData(age string, education string, healthcarepersonell bool, gend } insertStatement := ` - INSERT INTO Respondent (alder, utdanningsgrad, helsepersonell, kjønn, svartfør, fylke, dato) - VALUES ($1, $2, $3, $4, $5, $6, $7) + INSERT INTO Respondent (alder, utdanningsgrad, helsepersonell, harlisens, kjønn, svartfør, fylke, dato) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING respondentID ` @@ -40,7 +40,7 @@ func InsertUserData(age string, education string, healthcarepersonell bool, gend defer stmt.Close() var respondentID int - err = stmt.QueryRow(age, education, healthcarepersonell, gender, answeredbefore, county, submitdate).Scan(&respondentID) + err = stmt.QueryRow(age, education, healthcarepersonell, islicensed, gender, answeredbefore, county, submitdate).Scan(&respondentID) if err != nil { log.Fatalf("Error inserting userdata: %v\n", err) } diff --git a/backend/cmd/main.go b/backend/cmd/main.go index 71d84b6..889ba5f 100644 --- a/backend/cmd/main.go +++ b/backend/cmd/main.go @@ -14,6 +14,7 @@ type UserformData struct { Age string `json:"age"` Education string `json:"education"` HealthcarePersonnel bool `json:"healthcare_personnel"` + IsLicensed bool `json:"is_licensed"` Gender string `json:"gender"` AnsweredBefore bool `json:"answered_before"` County string `json:"county"` @@ -35,7 +36,7 @@ type Evaluation struct { func main() { router := gin.Default() - //router.Use(cors.Default()) + // router.Use(cors.Default()) router.GET("/hello", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"hello":"world"}) @@ -51,7 +52,7 @@ func main() { } // Capture both the ID and error returned from InsertData - respondentId, err := db.InsertUserData(requestBody.Age, requestBody.Education, requestBody.HealthcarePersonnel, requestBody.Gender, requestBody.AnsweredBefore, requestBody.County, requestBody.SubmitDate) + respondentId, err := db.InsertUserData(requestBody.Age, requestBody.Education, requestBody.HealthcarePersonnel, requestBody.IsLicensed, requestBody.Gender, requestBody.AnsweredBefore, requestBody.County, requestBody.SubmitDate) if err != nil { fmt.Print(err) @@ -148,6 +149,6 @@ func main() { }) // Run the server on port 8080 - //db.SetupDb() + // db.SetupDb() router.Run(":8080") } diff --git a/frontend/src/api/postUserformData.ts b/frontend/src/api/postUserformData.ts index 5288945..bcfa05b 100644 --- a/frontend/src/api/postUserformData.ts +++ b/frontend/src/api/postUserformData.ts @@ -6,6 +6,7 @@ export const postUserformData = async ( age: string, education: string, healthcare_personnel: string, + is_licensed: string, gender: string, has_answered_before: string, county: string, @@ -13,6 +14,7 @@ export const postUserformData = async ( ): Promise => { let url = "https://helseundersokelsen.online/submituserform"; let personnel = healthcare_personnel == "Ja" ? true : false; + let licensed = is_licensed == "Ja" ? true : false; let answered_before = has_answered_before == "Ja" ? true : false; const response = fetch(url, { @@ -21,6 +23,7 @@ export const postUserformData = async ( age: age, education: education, healthcare_personnel: personnel, + is_licensed: licensed, gender: gender, answered_before: answered_before, county: county, diff --git a/frontend/src/components/form/answerbox/AnswerBox.svelte b/frontend/src/components/form/answerbox/AnswerBox.svelte index a7f7c8e..433b708 100644 --- a/frontend/src/components/form/answerbox/AnswerBox.svelte +++ b/frontend/src/components/form/answerbox/AnswerBox.svelte @@ -76,8 +76,8 @@
- {knowledge = e.detail; handleFormUpdate()}} inputType="radio" label="Kunnskap" options={["Veldig dårlig", "Dårlig", "Nøytral", "Bra", "Veldig bra"]}/> + {knowledge = e.detail; handleFormUpdate()}} inputType="radio" label="Kunnskap" options={["Veldig dårlig", "Dårlig", "Nøytral", "Bra", "Veldig bra", "Vet ikke"]}/> {empathy = e.detail; handleFormUpdate()}} inputType="radio" label="Empati" options={["Veldig dårlig", "Dårlig", "Nøytral", "Bra", "Veldig bra"]}/> - {helpfulness = e.detail; handleFormUpdate()}} inputType="radio" label="Hjelpsomhet" options={["Veldig dårlig", "Dårlig", "Nøytral", "Bra", "Veldig bra", "Vet ikke"]}/> + {helpfulness = e.detail; handleFormUpdate()}} inputType="radio" label="Hjelpsomhet" options={["Veldig dårlig", "Dårlig", "Nøytral", "Bra", "Veldig bra"]}/>
\ No newline at end of file diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index e5d0a66..c7ec0b9 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -6,14 +6,14 @@

Helseveileder

Vi utfører en undersøkelse om kunstig intelligens (AI) i medisin. Vi ønsker å forstå hvordan AI kan fungere som en copilot for leger og pasienter.

-

Undersøkelsen er helt anonym.

+

Undersøkelsen er helt anonym. Spørsmålene er helserettet innenfor et spekter av kategorier. Det er mulig å gå videre til neste spørsmål, hvis man er ukomfortabel med spørsmålet eller ikke ønsker å vurdere et spørsmål.

    I denne undersøkelsen vil vi at du skal vurdere empati, kunnskap og hjelpsomhet i ulike svar på medisinske spørsmål.

  • Empati: Evnen til å oppdage og erkjenne andres følelser og tanker.
  • Kunnskap: Nøyaktighet og relevans av den medisinske informasjonen gitt.
  • Hjelpsomhet: Evnen til å gi nyttig og praktisk råd eller støtte.
- +
diff --git a/frontend/src/routes/userform/+page.svelte b/frontend/src/routes/userform/+page.svelte index cdecd8e..13f97e5 100644 --- a/frontend/src/routes/userform/+page.svelte +++ b/frontend/src/routes/userform/+page.svelte @@ -10,6 +10,7 @@ let age: string = "18-20" let education: string = "PhD" let healthcare_personnel: string = "Ja" + let is_licensed: string = "Nei" let gender: string = "Mann" let has_answered_before: string = "Nei" let county: string = "Vestland" @@ -21,7 +22,7 @@ const submitDate = new Date().toISOString() - const response = await postUserformData(age, education, healthcare_personnel, gender, has_answered_before, county, submitDate) + const response = await postUserformData(age, education, healthcare_personnel, is_licensed, gender, has_answered_before, county, submitDate) const userQuestions = await getUserQuestions(response.respondentID) goto("form/0") @@ -35,14 +36,15 @@
age = e.detail} inputType="radio" label="Alder" options={["18-20", "20-30", "30-40", "40-50", "50-60"]}/> - education = e.detail} inputType="select" label="Utdanningsgrad" options={["PhD", "Master", "Fagbrev", "Bachelor"]}/> county = e.detail} inputType="select" label="Fylke" options={["Vestland", "Rogaland", "Møre og Romsdal", "Oslo", "Viken", "Nordland", "Trøndelag", "Innlandet", "Troms og Finnmark", "Vestfold og Telemark", "Agder"]}/> - healthcare_personnel = e.detail} inputType="radio" label="Helsepersonell" options={["Ja", "Nei"]}/> + education = e.detail} inputType="select" label="Utdanningsgrad" options={["VGS", "Bachelor", "Master", "PhD"]}/> + healthcare_personnel = e.detail} inputType="radio" label="Jobber/studerer du innen helse?" options={["Ja", "Nei"]}/> + is_licensed = e.detail} inputType="radio" label="Er du lege eller medisinstudent med lisens?" options={["Ja", "Nei"]}/> gender = e.detail} inputType="radio" label="Kjønn" options={["Mann", "Kvinne", "Annet"]}/> has_answered_before = e.detail} inputType="radio" label="Jeg har svart på denne undersøkelsen tidligere" options={["Ja", "Nei"]}/>