Skip to content

Commit

Permalink
Replace Umlaute in diagnosis with matching ligature
Browse files Browse the repository at this point in the history
  • Loading branch information
pcvolkmer committed Jun 3, 2024
1 parent e5e1ec2 commit ea4dd77
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
13 changes: 12 additions & 1 deletion patients.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ import (
"strings"
)

func sanitizeUmlaute(s string) string {
s = strings.ReplaceAll(s, "Ä", "Ae")
s = strings.ReplaceAll(s, "Ö", "Oe")
s = strings.ReplaceAll(s, "Ü", "Ue")
s = strings.ReplaceAll(s, "ä", "ae")
s = strings.ReplaceAll(s, "ö", "oe")
s = strings.ReplaceAll(s, "ü", "ue")
s = strings.ReplaceAll(s, "ß", "ss")
return s
}

type Patients struct {
db *sql.DB
}
Expand Down Expand Up @@ -204,7 +215,7 @@ func appendDiagnoseDaten(patientID string, data *PatientData, allTk bool) *Patie

// DIAGNOSIS
if diagnose, err := diagnose.Value(); err == nil && diagnose != nil {
data.Diagnosis = fmt.Sprint(diagnose)
data.Diagnosis = sanitizeUmlaute(fmt.Sprint(diagnose))
}

// ONKOTREE_CODE
Expand Down
9 changes: 9 additions & 0 deletions patients_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,12 @@ func TestShouldReturnEcogForKarnofsky0(t *testing.T) {
t.Fail()
}
}

func TestShouldSanitizeUmlaute(t *testing.T) {
actual := sanitizeUmlaute("Bösartige Neubildung")
expected := "Boesartige Neubildung"
if actual != expected {
t.Logf("wrong value: Expected %s, got %s", expected, actual)
t.Fail()
}
}

0 comments on commit ea4dd77

Please sign in to comment.