Skip to content

Commit

Permalink
Merge pull request #6 from CCC-MF/features/5-erstes_jahr_mtb
Browse files Browse the repository at this point in the history
Add first year with mtb as additional column
  • Loading branch information
pcvolkmer authored Jun 26, 2024
2 parents b4da9ed + b9c61c1 commit 161bbb9
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions patients.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,19 @@ func appendDiagnoseDaten(patientID string, data *PatientData, allTk bool) *Patie
icd10,
fernmetastasen,
pcve.shortdesc AS diagnose,
ROUND(DATEDIFF(IF(sterbedatum IS NULL, NOW(), sterbedatum),diagnosedatum) / 30) AS os_month
ROUND(DATEDIFF(IF(sterbedatum IS NULL, NOW(), sterbedatum),diagnosedatum) / 30) AS os_month,
sub.first_mtb_year
FROM prozedur
JOIN dk_diagnose ON prozedur.id = dk_diagnose.id
JOIN property_catalogue_version_entry pcve ON pcve.code = icd10 AND pcve.property_version_id = icd10_propcat_version
JOIN patient p on p.id = prozedur.patient_id
JOIN erkrankung_prozedur ep ON ep.prozedur_id = prozedur.id
LEFT OUTER JOIN (
SELECT erkrankung_id, MIN(YEAR(beginndatum)) AS first_mtb_year FROM prozedur p
JOIN dk_tumorkonferenz dt ON (p.id = dt.id AND dt.tk = '27')
JOIN erkrankung_prozedur ep ON (ep.prozedur_id = p.id)
GROUP BY erkrankung_id
) sub ON (sub.erkrankung_id = ep.erkrankung_id)
WHERE prozedur.geloescht = 0 AND p.patienten_id = ? AND ep.erkrankung_id IN (
SELECT ep.erkrankung_id FROM dk_tumorkonferenz
JOIN prozedur pro on dk_tumorkonferenz.id = pro.id
Expand All @@ -193,10 +200,11 @@ func appendDiagnoseDaten(patientID string, data *PatientData, allTk bool) *Patie
var fernmetastasen sql.NullString
var diagnose sql.NullString
var osMonth sql.NullInt16
var firstMtbYear sql.NullString

if row := db.QueryRow(query, patientID, patientID, allTk); row != nil {

if err := row.Scan(&icdo3histologie, &beginndatum, &icd10, &fernmetastasen, &diagnose, &osMonth); err == nil {
if err := row.Scan(&icdo3histologie, &beginndatum, &icd10, &fernmetastasen, &diagnose, &osMonth, &firstMtbYear); err == nil {
// OS_MONTH
// Aktuell nur ganze Monate als Kommazahl (Anzahl Tage / 30)
if osMonth, err := osMonth.Value(); err == nil && osMonth != nil {
Expand Down Expand Up @@ -227,6 +235,11 @@ func appendDiagnoseDaten(patientID string, data *PatientData, allTk bool) *Patie
data.SpreadOfDisease = "metastasiert"
}
}

// Erstes Jahr mit MTB
if firstMtbYear, err := firstMtbYear.Value(); err == nil && firstMtbYear != nil {
data.XFirstMtbYear = fmt.Sprint(firstMtbYear)
}
}
}

Expand Down Expand Up @@ -281,6 +294,7 @@ type PatientData struct {
OsMonths string `csv:"OS_MONTHS"`
DfsStatus string `csv:"DFS_STATUS"`
DfsMonths string `csv:"DFS_MONTHS"`
XFirstMtbYear string `csv:"x_first_mtb_year"`
}

func PatientDataHeaders() []string {
Expand All @@ -305,6 +319,7 @@ func PatientDataHeaders() []string {
"OS_MONTHS",
"DFS_STATUS",
"DFS_MONTHS",
"x_first_mtb_year",
}
}

Expand All @@ -331,5 +346,6 @@ func (data *PatientData) AsStringArray() []string {
data.OsMonths,
data.DfsStatus,
data.DfsMonths,
data.XFirstMtbYear,
}
}

0 comments on commit 161bbb9

Please sign in to comment.