Hello, everybody!
I am developing an application to display medical appointments and the data is brought in json from my database, like this:
I send all this data to a listview but it shows me for example doctor1 and his patient then doctor 2 and his patient then the same doctor again.
Here's my B4A script
I would like to group them by doctor. I mean, for example doctor 1 and all his patients then doctor 2 and also all his patients etc. should I modify the json ? or should I modify the B4A script ? and in either case how could I do it? Thanks in advance
I am developing an application to display medical appointments and the data is brought in json from my database, like this:
JSON:
[{"id_turno":"1","cal_id":"4","paciente_id":"31","dni":"112939","name":"WALKER","fecha":"2020-07-24","timeslot":"06:00-06:30","medico":"DOCTOR1","medico_id":"11","estado":"SIN CONFIRMAR"},{"id_turno":"2","cal_id":"5","paciente_id":"32","dni":"939","name":"CONERY","fecha":"2020-07-23","timeslot":"08:00-08:30","medico":"DOCTOR2","medico_id":"12","estado":"SIN CONFIRMAR"},{"id_turno":"3","cal_id":"5","paciente_id":"33","dni":"87333","name":"LOYD","fecha":"2020-08-13","timeslot":"11:00-11:30","medico":"DOCTOR2","medico_id":"12","estado":"SIN CONFIRMAR"},{"id_turno":"4","cal_id":"4","paciente_id":"34","dni":"3221","name":"SIMPSON","fecha":"2020-08-14","timeslot":"11:00-11:30","medico":"DOCTOR1","medico_id":"11","estado":"SIN CONFIRMAR"},{"id_turno":"5","cal_id":"6","paciente_id":"31","dni":"112939","name":"WALKER","fecha":"2020-09-04","timeslot":"18:30-19:15","medico":"DOCTOR3","medico_id":"13","estado":"SIN CONFIRMAR"},{"id_turno":"6","cal_id":"4","paciente_id":"32","dni":"939","name":"CONERY","fecha":"2020-09-02","timeslot":"10:00-10:30","medico":"DOCTOR1","medico_id":"11","estado":"SIN CONFIRMAR"},{"id_turno":"7","cal_id":"5","paciente_id":"33","dni":"87333","name":"LOYD","fecha":"2020-10-09","timeslot":"11:00-11:30","medico":"DOCTOR2","medico_id":"12","estado":"SIN CONFIRMAR"}]
I send all this data to a listview but it shows me for example doctor1 and his patient then doctor 2 and his patient then the same doctor again.
Here's my B4A script
B4X:
Sub ListarTurnos
lsvTurnos.Clear
lsvTurnos.SingleLineLayout.ItemHeight = 25dip
lsvTurnos.SingleLineLayout.Label.TextSize = 16
lsvTurnos.SingleLineLayout.Label.TextColor = Colors.White
lsvTurnos.SingleLineLayout.Label.Gravity = Gravity.LEFT
lsvTurnos.SingleLineLayout.Label.Gravity = Gravity.BOTTOM
lsvTurnos.TwoLinesLayout.ItemHeight = 60dip
lsvTurnos.TwoLinesLayout.Label.TextSize = 11
lsvTurnos.TwoLinesLayout.Label.TextColor = Colors.ARGB(150, 255, 255, 255)
lsvTurnos.TwoLinesLayout.Label.Gravity=Gravity.TOP
lsvTurnos.TwoLinesLayout.SecondLabel.TextSize = 11
lsvTurnos.TwoLinesLayout.SecondLabel.TextColor = Colors.ARGB(150, 255, 255, 255)
lsvTurnos.TwoLinesLayout.SecondLabel.Gravity=Gravity.TOP
Dim IDTURNO As Int
Dim TurnosPacientes As HttpJob
TurnosPacientes.Initialize("turnosinfo", Me)
TurnosPacientes.Download(sSrcAPI)
Wait For (TurnosPacientes) JobDone(TurnosPacientes As HttpJob)
ProgressDialogHide
If TurnosPacientes.Success Then
Dim parser As JSONParser
parser.Initialize(TurnosPacientes.GetString)
Dim root As List = parser.NextArray
For Each coolroot As Map In root
Dim IDNUMBER As String = coolroot.Get("dni")
Dim LASTNAME As String = coolroot.Get("name")
Dim DATE As String = coolroot.Get("fecha")
Dim TIMESLOT As String = coolroot.Get("timeslot")
Dim DOCTOR As String = coolroot.Get("medico")
Dim STATUS As String = coolroot.Get("estado")
Dim info As String = "PACIENTE: " & LASTNAME & _
" | DNI : " & IDNUMBER & _
" | FECHA: " & DATE & _
" | HORA : " & TIMESLOT & _
" | MEDICO: " & DOCTOR & _
" | ESTADO: " & STATUS
lsvTurnos.AddSingleLine(DOCTOR)
lsvTurnos.AddTwoLines(info, "")
Next
End If
TurnosPacientes.Release
End Sub
I would like to group them by doctor. I mean, for example doctor 1 and all his patients then doctor 2 and also all his patients etc. should I modify the json ? or should I modify the B4A script ? and in either case how could I do it? Thanks in advance