diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 5236c34..0c0c338 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -3,20 +3,7 @@ - - - - - - - - - - - - - - + diff --git a/app/src/main/java/Adapters/RecetaDataBaseHelper.kt b/app/src/main/java/Adapters/RecetaDataBaseHelper.kt index 8fd0807..b66b321 100644 --- a/app/src/main/java/Adapters/RecetaDataBaseHelper.kt +++ b/app/src/main/java/Adapters/RecetaDataBaseHelper.kt @@ -76,16 +76,16 @@ class RecetaDataBaseHelper(context: Context) : SQLiteOpenHelper(context, DATABAE fun obtenerRecetasPaciente(nombrePaciente : String): List{ val recetas = mutableListOf() val db = readableDatabase - val cursor = db.rawQuery("SELECT $COLUMN_NOMBRE_PACIENTE,$COLUMN_MEDICAMENTO, $COLUMN_FECHA FROM $TABLE_NAME WHERE $COLUMN_NOMBRE_PACIENTE = '$nombrePaciente'", null) + val cursor = db.rawQuery("SELECT * FROM $TABLE_NAME WHERE $COLUMN_NOMBRE_PACIENTE = '$nombrePaciente'", null) while (cursor.moveToNext()) { val nombrePaciente = cursor.getString(cursor.getColumnIndex(COLUMN_NOMBRE_PACIENTE)) - //val edadPaciente = cursor.getInt(cursor.getColumnIndex(COLUMN_EDAD_PACIENTE)) - //val pesoPaciente = cursor.getDouble(cursor.getColumnIndex(COLUMN_PESO_PACIENTE)) + val edadPaciente = cursor.getInt(cursor.getColumnIndex(COLUMN_EDAD_PACIENTE)) + val pesoPaciente = cursor.getDouble(cursor.getColumnIndex(COLUMN_PESO_PACIENTE)) val medicamento = cursor.getString(cursor.getColumnIndex(COLUMN_MEDICAMENTO)) val fecha = cursor.getString(cursor.getColumnIndex(COLUMN_FECHA)) - //val dosis = cursor.getString(cursor.getColumnIndex(COLUMN_DOSIS_PACIENTE)) - //val duracion = cursor.getString(cursor.getColumnIndex(DURACION_MEDICAMENTO)) - val receta = Receta(nombrePaciente, 0, 0.0, medicamento, fecha, "dosis", "duracion") + val dosis = cursor.getString(cursor.getColumnIndex(COLUMN_DOSIS_PACIENTE)) + val duracion = cursor.getString(cursor.getColumnIndex(DURACION_MEDICAMENTO)) + val receta = Receta(nombrePaciente, edadPaciente, pesoPaciente, medicamento, fecha, dosis, duracion) recetas.add(receta) } cursor.close() diff --git a/app/src/main/java/Adapters/RecetaViewAdapter.kt b/app/src/main/java/Adapters/RecetaViewAdapter.kt index 84607bf..324a3d8 100644 --- a/app/src/main/java/Adapters/RecetaViewAdapter.kt +++ b/app/src/main/java/Adapters/RecetaViewAdapter.kt @@ -17,7 +17,12 @@ class RecetaViewAdapter(private var notes : List, context: Context,val c class NoteViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView){ val tituloReceta : TextView = itemView.findViewById(R.id.tv_titulo_receta) val fechaReceta : TextView = itemView.findViewById(R.id.tv_fecha_receta) + val nombreReceta : TextView = itemView.findViewById(R.id.tv_nombre_paciente) val btnDescargar : Button = itemView.findViewById(R.id.btn_descargar_receta) + val pesoReceta : TextView = itemView.findViewById(R.id.tv_peso_paciente) + val edadReceta : TextView = itemView.findViewById(R.id.tv_edad_paciente) + val dosisReceta : TextView=itemView.findViewById(R.id.tv_dosis_medicamento) + val duracionReceta : TextView= itemView.findViewById(R.id.tv_duracion_receta) } @@ -34,6 +39,11 @@ class RecetaViewAdapter(private var notes : List, context: Context,val c val note = notes[position] holder.tituloReceta.text = note.nombreMedicamento holder.fechaReceta.text = note.fecha + holder.dosisReceta.text=note.dosis + holder.duracionReceta.text=note.duracion + holder.nombreReceta.text=note.NombrePaciente + holder.pesoReceta.text= note.pesoPaciente.toString() + holder.edadReceta.text=note.edadPaciente.toString() holder.btnDescargar.setOnClickListener{ cellClickListener.onCellClickListener(position) } diff --git a/app/src/main/java/com/terratenientes/medicalhealth/PacientePrincipalActivity.kt b/app/src/main/java/com/terratenientes/medicalhealth/PacientePrincipalActivity.kt index 4fb657f..b3cbd7c 100644 --- a/app/src/main/java/com/terratenientes/medicalhealth/PacientePrincipalActivity.kt +++ b/app/src/main/java/com/terratenientes/medicalhealth/PacientePrincipalActivity.kt @@ -50,14 +50,16 @@ class PacientePrincipalActivity : AppCompatActivity(), CellClickListener { } override fun onCellClickListener(position: Int) { + val datosPaciente = db.obtenerRecetasPaciente(idPaciente)//ARREGLO DE TODAS LAS RECETAS DEL PACIENTE + //Toast.makeText(this, "Peso : ${datosPaciente[position].pesoPaciente}+ edad: ${datosPaciente[position].edadPaciente} ", Toast.LENGTH_LONG).show() val receta = recetas[position] - val nombrePaciente = receta.NombrePaciente - val nombreMeciamento=receta.nombreMedicamento - val dosisMedicamento = receta.dosis - val duracionMedicamento = receta.duracion - val fechaReceta = receta.fecha - val pesoPaciente= receta.pesoPaciente - val edadPaciente = receta.edadPaciente + val nombrePaciente = recetas[position].NombrePaciente + val nombreMeciamento=recetas[position].nombreMedicamento + val dosisMedicamento = recetas[position].dosis + val duracionMedicamento = recetas[position].duracion + val fechaReceta = recetas[position].fecha + val pesoPaciente= recetas[position].pesoPaciente + val edadPaciente = recetas[position].edadPaciente val descripcionReceta ="Fecha de Consulta: ${fechaReceta}\n" + "Datos Generales del Paciente : \n " + "Peso del Paciente : ${pesoPaciente}\n" + @@ -65,9 +67,11 @@ class PacientePrincipalActivity : AppCompatActivity(), CellClickListener { "Medicamento a Recetar: ${nombreMeciamento}\n Dosis del Medicamento : ${dosisMedicamento}\n" + "Duración del Tratamiento ${duracionMedicamento} \n" + if(permisosPDF()){ + // Toast.makeText(this, "Peso : ${datosPaciente[position].pesoPaciente}+ edad: ${datosPaciente[position].edadPaciente} ", Toast.LENGTH_LONG).show() //Toast.makeText(this@PacientePrincipalActivity, "PERMISOS CONCEDIDOS", Toast.LENGTH_SHORT).show() - generarPDF(nombrePaciente, descripcionReceta) + generarPDF(nombrePaciente, descripcionReceta, nombreMeciamento) }else{ pedirPermisosPDF() } @@ -86,7 +90,7 @@ class PacientePrincipalActivity : AppCompatActivity(), CellClickListener { ),200) } - fun generarPDF(tituloReceta : String, contenidoReceta : String){ + fun generarPDF(tituloReceta : String, contenidoReceta : String, medicamento : String){ if (!permisosPDF()) { pedirPermisosPDF() return @@ -112,7 +116,7 @@ class PacientePrincipalActivity : AppCompatActivity(), CellClickListener { } pdfDoducment.finishPage(paginaReceta) val directory = getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS) - val file=File(directory,"Receta.pdf") + val file=File(directory,"Receta${medicamento}.pdf") try { pdfDoducment.writeTo(FileOutputStream(file)) Toast.makeText(this,"PDF CREADO CORRECTAMENTE",Toast.LENGTH_LONG).show() @@ -134,7 +138,7 @@ class PacientePrincipalActivity : AppCompatActivity(), CellClickListener { if(grantResults.isNotEmpty() && grantResults.all { it == PackageManager.PERMISSION_GRANTED }){ val writeStorage = grantResults[0]==PackageManager.PERMISSION_GRANTED val readStorage = grantResults[1]==PackageManager.PERMISSION_GRANTED - generarPDF("Título", "Contenido") + //generarPDF("Título", "Contenido") if(writeStorage && readStorage){ Toast.makeText(this@PacientePrincipalActivity, "PERMISOS CONCEDIDOS", Toast.LENGTH_SHORT).show() }else{ diff --git a/app/src/main/java/com/terratenientes/medicalhealth/RecetaActivity.kt b/app/src/main/java/com/terratenientes/medicalhealth/RecetaActivity.kt index 4a1f96f..a3d3d9d 100644 --- a/app/src/main/java/com/terratenientes/medicalhealth/RecetaActivity.kt +++ b/app/src/main/java/com/terratenientes/medicalhealth/RecetaActivity.kt @@ -27,7 +27,7 @@ class RecetaActivity : AppCompatActivity(), OnItemSelectedListener { db= RecetaDataBaseHelper(this@RecetaActivity) dbPaciente = DoctorDataBaseHelper(this@RecetaActivity) setContentView(view) - //db.crearTablaReceta() + // db.crearTablaReceta() cargarSpinnerPacientes() binding.spNombrePaciente.onItemSelectedListener=this binding.btnAgregarReceta.setOnClickListener { diff --git a/app/src/main/res/layout/rc_receta_item.xml b/app/src/main/res/layout/rc_receta_item.xml index 1c82905..d1c0dc4 100644 --- a/app/src/main/res/layout/rc_receta_item.xml +++ b/app/src/main/res/layout/rc_receta_item.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="100dp" + android:layout_height="110dp" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_marginEnd="12dp" android:layout_marginHorizontal="10dp" @@ -17,39 +17,51 @@ + android:layout_height="match_parent" + android:orientation="vertical"> + + + + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" />