From eada3633664c6dce1916e208fa658209c1a81055 Mon Sep 17 00:00:00 2001 From: sebastiancc27 Date: Wed, 24 Apr 2024 19:24:29 -0600 Subject: [PATCH] Agregar Receta Avance --- app/src/main/AndroidManifest.xml | 3 + .../terratenientes/medicalhealth/Receta.kt | 3 + .../medicalhealth/RecetaActivity.kt | 41 ++++++++ .../medicalhealth/RecetaDataBaseHelper.kt | 33 +++++++ app/src/main/res/layout/activity_receta.xml | 97 +++++++++++++++++++ app/src/main/res/values/strings.xml | 11 +++ 6 files changed, 188 insertions(+) create mode 100644 app/src/main/java/com/terratenientes/medicalhealth/Receta.kt create mode 100644 app/src/main/java/com/terratenientes/medicalhealth/RecetaActivity.kt create mode 100644 app/src/main/java/com/terratenientes/medicalhealth/RecetaDataBaseHelper.kt create mode 100644 app/src/main/res/layout/activity_receta.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b9a0973..49b5e78 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,6 +12,9 @@ android:supportsRtl="true" android:theme="@style/Theme.MedicalHealth" tools:targetApi="31"> + diff --git a/app/src/main/java/com/terratenientes/medicalhealth/Receta.kt b/app/src/main/java/com/terratenientes/medicalhealth/Receta.kt new file mode 100644 index 0000000..7d05d73 --- /dev/null +++ b/app/src/main/java/com/terratenientes/medicalhealth/Receta.kt @@ -0,0 +1,3 @@ +package com.terratenientes.medicalhealth + +data class Receta(val NombrePaciente : String, val edadPaciente : Int, val pesoPaciente: Double, val nombreMedicamento : String, val fecha : String, val dosis : String, val duracion :String) diff --git a/app/src/main/java/com/terratenientes/medicalhealth/RecetaActivity.kt b/app/src/main/java/com/terratenientes/medicalhealth/RecetaActivity.kt new file mode 100644 index 0000000..590c2ae --- /dev/null +++ b/app/src/main/java/com/terratenientes/medicalhealth/RecetaActivity.kt @@ -0,0 +1,41 @@ +package com.terratenientes.medicalhealth + +import android.annotation.SuppressLint +import android.database.sqlite.SQLiteOpenHelper +import android.os.Bundle +import androidx.activity.enableEdgeToEdge +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat +import com.terratenientes.medicalhealth.databinding.ActivityRecetaBinding + +class RecetaActivity : AppCompatActivity() { + private lateinit var binding : ActivityRecetaBinding + private lateinit var db : RecetaDataBaseHelper + private lateinit var dbPaciente : DoctorDataBaseHelper + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding=ActivityRecetaBinding.inflate(layoutInflater) + val view = binding.root + enableEdgeToEdge() + db= RecetaDataBaseHelper(this@RecetaActivity) + dbPaciente = DoctorDataBaseHelper(this@RecetaActivity) + + setContentView(view) + binding.btnAgregarReceta.setOnClickListener { + + } + } + @SuppressLint("Range") + private fun obtenerNombrePacientes() : MutableList{ + val nombresPacientes = mutableListOf() + val dbPaciente=db.readableDatabase + val cursor = dbPaciente.rawQuery("SELECT NombrePaciente FROM Pacientes", null) + while(cursor.moveToNext()){ + val nombre = cursor.getString(cursor.getColumnIndex(DoctorDataBaseHelper.COLUMN_NOMBRE_PACIENTE)).toString() + nombresPacientes.add(nombre) + } + cursor.close() + return nombresPacientes + } +} \ No newline at end of file diff --git a/app/src/main/java/com/terratenientes/medicalhealth/RecetaDataBaseHelper.kt b/app/src/main/java/com/terratenientes/medicalhealth/RecetaDataBaseHelper.kt new file mode 100644 index 0000000..716a64a --- /dev/null +++ b/app/src/main/java/com/terratenientes/medicalhealth/RecetaDataBaseHelper.kt @@ -0,0 +1,33 @@ +package com.terratenientes.medicalhealth + +import android.content.Context +import android.database.sqlite.SQLiteDatabase +import android.database.sqlite.SQLiteOpenHelper + +class RecetaDataBaseHelper(context: Context) : SQLiteOpenHelper(context, DATABAENAME, null, DATABASEVERSION){ + companion object{ + private val DATABAENAME ="MedicalHealth" + private val DATABASEVERSION=1 + //PRIMERO VA EL NOMBRE DE LA TABLA + private val TABLE_NAME="Recetas" + //LUEGO VAN LAS COLUMNAS DE ESA TABLA + private val COLUMN_NOMBRE_PACIENTE="NombrePaciente" + private val COLUMN_EDAD_PACIENTE="EdadPaciente" + private val COLUMN_MEDICAMENTO="NombreMedicamento" + private val COLUMN_FECHA="Fecha" + private val DURACION_MEDICAMENTO="Duracion" + private val COLUMN_PESO_PACIENTE="Peso" + private val COLUMN_DOSIS_PACIENTE="Dosis" + } + + override fun onCreate(p0: SQLiteDatabase?) { + val creatTabla="CREATE TABLE $TABLE_NAME ($COLUMN_NOMBRE_PACIENTE VARCHAR(30), $COLUMN_EDAD_PACIENTE INT, $COLUMN_PESO_PACIENTE INT, $COLUMN_FECHA VARCHAR(30), " + + "$COLUMN_MEDICAMENTO VARCHAR(30), $DURACION_MEDICAMENTO VARCHAR(20), $COLUMN_DOSIS_PACIENTE VARCHAR(30))" + p0?.execSQL(creatTabla) + } + + override fun onUpgrade(p0: SQLiteDatabase?, p1: Int, p2: Int) { + val dropTableReceta="DROP TABLE IF EXISTS $TABLE_NAME" + p0?.execSQL(dropTableReceta) + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_receta.xml b/app/src/main/res/layout/activity_receta.xml new file mode 100644 index 0000000..4215a46 --- /dev/null +++ b/app/src/main/res/layout/activity_receta.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + +