62 lines
1.6 KiB
Plaintext
62 lines
1.6 KiB
Plaintext
Structure Person
|
|
Name$
|
|
EndStructure
|
|
|
|
Structure Visits
|
|
Datum$
|
|
Score$
|
|
EndStructure
|
|
|
|
Structure Merge
|
|
Patient.Person
|
|
List PVisit.Visits()
|
|
EndStructure
|
|
|
|
NewMap P.Merge()
|
|
NewList ID$()
|
|
|
|
If ReadFile(1,"./Data/patients.csv")=0 : End 1 : EndIf
|
|
header=1
|
|
While Not Eof(1)
|
|
buf1$=ReadString(1)
|
|
If header=1 : header=0 : Continue : EndIf
|
|
bufId$=StringField(buf1$,1,",")
|
|
P(bufId$)\Patient\Name$=StringField(buf1$,2,",")
|
|
AddElement(ID$()) : ID$()=bufId$
|
|
Wend
|
|
CloseFile(1)
|
|
|
|
If ReadFile(2,"./Data/visits.csv")=0 : End 2 : EndIf
|
|
header=1
|
|
While Not Eof(2)
|
|
buf1$=ReadString(2)
|
|
If header=1 : header=0 : Continue : EndIf
|
|
bufId$=StringField(buf1$,1,",")
|
|
AddElement(P(bufId$)\PVisit())
|
|
P(bufId$)\PVisit()\Datum$=StringField(buf1$,2,",")
|
|
P(bufId$)\PVisit()\Score$=StringField(buf1$,3,",")
|
|
Wend
|
|
CloseFile(2)
|
|
|
|
If OpenConsole()=0 : End 3 : EndIf
|
|
SortList(ID$(),#PB_Sort_Ascending)
|
|
PrintN("| PATIENT_ID | LASTNAME | LAST_VISIT | SCORE_SUM | SCORE_AVG |")
|
|
ForEach ID$()
|
|
Print("| "+LSet(ID$(),11))
|
|
Print("| "+LSet(P(ID$())\Patient\Name$,9)+"|")
|
|
SortStructuredList(P(ID$())\PVisit(),#PB_Sort_Ascending,OffsetOf(Visits\Datum$),TypeOf(Visits\Datum$))
|
|
ForEach P(ID$())\PVisit()
|
|
scs.f+ValF(p(ID$())\PVisit()\Score$) : c+Bool(ValF(p(ID$())\PVisit()\Score$))
|
|
Next
|
|
If LastElement(P(ID$())\PVisit())
|
|
sca.f=scs/c
|
|
Print(" "+LSet(P(ID$())\PVisit()\Datum$,10)+" |")
|
|
Print(RSet(StrF(scs,1),10)+" |")
|
|
If Not IsNAN(sca) : Print(RSet(StrF(sca,2),10)+" |") : Else : Print(Space(11)+"|") : EndIf
|
|
Else
|
|
Print(Space(12)+"|"+Space(11)+"|"+Space(11)+"|")
|
|
EndIf
|
|
PrintN("") : scs=0 : c=0
|
|
Next
|
|
Input()
|