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