Compare commits
No commits in common. "cbe7bc5caa8e7a17f2f8c2906d8f0d20357697b7" and "b49828a221c14ddb2effdcfd1eea186edc42b997" have entirely different histories.
cbe7bc5caa
...
b49828a221
|
@ -3,20 +3,7 @@
|
|||
<component name="deploymentTargetDropDown">
|
||||
<value>
|
||||
<entry key="app">
|
||||
<State>
|
||||
<targetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="C:\Users\Hp\.android\avd\Pixel_3a_API_34.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2024-05-10T04:34:58.235157600Z" />
|
||||
</State>
|
||||
<State />
|
||||
</entry>
|
||||
</value>
|
||||
</component>
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.database.sqlite.SQLiteOpenHelper
|
|||
import Data.Doctor
|
||||
import Data.Paciente
|
||||
import android.database.Cursor
|
||||
import android.widget.Toast
|
||||
|
||||
class DoctorDataBaseHelper (context: Context) : SQLiteOpenHelper(context, DATABASE_NAME,null,
|
||||
DATABASE_VERSION
|
||||
|
@ -86,7 +85,6 @@ class DoctorDataBaseHelper (context: Context) : SQLiteOpenHelper(context, DATABA
|
|||
put(COLUMN_DOMICILIO, paciente.domicilio)
|
||||
}
|
||||
db.insert(TABLE_PACIENTES, null, values)
|
||||
print("ID DEL PACIENTE AGREGADO: "+COLUMN_ID_PACIENTE)
|
||||
db.close()
|
||||
}
|
||||
|
||||
|
@ -120,7 +118,7 @@ class DoctorDataBaseHelper (context: Context) : SQLiteOpenHelper(context, DATABA
|
|||
|
||||
fun validarDatos(usuario :String , contrasena : String): Boolean{
|
||||
val db = readableDatabase
|
||||
val validarQuery = "SELECT $COLUMN_CEDULA,$COLUMN_CONTRASENA FROM $TABLE_NAME WHERE $COLUMN_CEDULA = '$usuario' AND $COLUMN_CONTRASENA = '$contrasena' "
|
||||
val validarQuery = "SELECT $COLUMN_CEDULA,$COLUMN_CONTRASENA FROM $TABLE_NAME, $TABLE_PACIENTES WHERE $COLUMN_CEDULA = '$usuario' AND $COLUMN_CONTRASENA = '$contrasena' "
|
||||
val cursor = db.rawQuery(validarQuery, null)
|
||||
val isValid = cursor.count > 0
|
||||
cursor.close()
|
||||
|
|
|
@ -6,9 +6,6 @@ import Adapters.RecetaViewAdapter
|
|||
import Data.Receta
|
||||
import android.Manifest
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Typeface
|
||||
import android.graphics.pdf.PdfDocument
|
||||
import android.os.Bundle
|
||||
|
@ -37,7 +34,6 @@ class PacientePrincipalActivity : AppCompatActivity(), CellClickListener {
|
|||
idPaciente= intent.getStringExtra("IDPaciente")!!
|
||||
db= RecetaDataBaseHelper(this)
|
||||
recetas=db.obtenerRecetasPaciente(idPaciente)
|
||||
|
||||
recycleAdapter = RecetaViewAdapter(db.obtenerRecetasPaciente(idPaciente), this, this@PacientePrincipalActivity)
|
||||
|
||||
binding.rvRecetasPaciente.layoutManager=LinearLayoutManager(this)
|
||||
|
@ -58,12 +54,7 @@ class PacientePrincipalActivity : AppCompatActivity(), CellClickListener {
|
|||
val fechaReceta = receta.fecha
|
||||
val pesoPaciente= receta.pesoPaciente
|
||||
val edadPaciente = receta.edadPaciente
|
||||
val descripcionReceta ="Fecha de Consulta: ${fechaReceta}\n" +
|
||||
"Datos Generales del Paciente : \n " +
|
||||
"Peso del Paciente : ${pesoPaciente}\n" +
|
||||
"Edad del Paciente : ${edadPaciente}" +
|
||||
"Medicamento a Recetar: ${nombreMeciamento}\n Dosis del Medicamento : ${dosisMedicamento}\n" +
|
||||
"Duración del Tratamiento ${duracionMedicamento} \n"
|
||||
val descripcionReceta ="Ejemplo de descripcion"
|
||||
|
||||
if(permisosPDF()){
|
||||
//Toast.makeText(this@PacientePrincipalActivity, "PERMISOS CONCEDIDOS", Toast.LENGTH_SHORT).show()
|
||||
|
@ -74,8 +65,8 @@ class PacientePrincipalActivity : AppCompatActivity(), CellClickListener {
|
|||
}
|
||||
// función que valida si los permisos ya estan garantizados por parte del usuario
|
||||
fun permisosPDF() : Boolean{
|
||||
val permission1= ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
val permission2= ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
val permission1= ContextCompat.checkSelfPermission(applicationContext, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
val permission2= ContextCompat.checkSelfPermission(applicationContext, Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
|
||||
return permission1 == PackageManager.PERMISSION_GRANTED && permission2 == PackageManager.PERMISSION_GRANTED
|
||||
}
|
||||
|
@ -85,12 +76,7 @@ class PacientePrincipalActivity : AppCompatActivity(), CellClickListener {
|
|||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
),200)
|
||||
}
|
||||
|
||||
fun generarPDF(tituloReceta : String, contenidoReceta : String){
|
||||
if (!permisosPDF()) {
|
||||
pedirPermisosPDF()
|
||||
return
|
||||
}
|
||||
val pdfDoducment = PdfDocument()
|
||||
val tituloPDF = TextPaint()
|
||||
val contenido = TextPaint()
|
||||
|
@ -111,8 +97,7 @@ class PacientePrincipalActivity : AppCompatActivity(), CellClickListener {
|
|||
y=y+15
|
||||
}
|
||||
pdfDoducment.finishPage(paginaReceta)
|
||||
val directory = getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS)
|
||||
val file=File(directory,"Receta.pdf")
|
||||
val file=File(Environment.getExternalStorageDirectory(),"Receta.pdf")
|
||||
try {
|
||||
pdfDoducment.writeTo(FileOutputStream(file))
|
||||
Toast.makeText(this,"PDF CREADO CORRECTAMENTE",Toast.LENGTH_LONG).show()
|
||||
|
@ -123,7 +108,6 @@ class PacientePrincipalActivity : AppCompatActivity(), CellClickListener {
|
|||
pdfDoducment.close()
|
||||
}
|
||||
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<out String>,
|
||||
|
@ -131,10 +115,9 @@ class PacientePrincipalActivity : AppCompatActivity(), CellClickListener {
|
|||
) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
if(requestCode==200){
|
||||
if(grantResults.isNotEmpty() && grantResults.all { it == PackageManager.PERMISSION_GRANTED }){
|
||||
if(grantResults.isNotEmpty()){
|
||||
val writeStorage = grantResults[0]==PackageManager.PERMISSION_GRANTED
|
||||
val readStorage = grantResults[1]==PackageManager.PERMISSION_GRANTED
|
||||
generarPDF("Título", "Contenido")
|
||||
if(writeStorage && readStorage){
|
||||
Toast.makeText(this@PacientePrincipalActivity, "PERMISOS CONCEDIDOS", Toast.LENGTH_SHORT).show()
|
||||
}else{
|
||||
|
|
Loading…
Reference in New Issue