Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diversos Cambios #19

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
6 changes: 6 additions & 0 deletions CentroAsist/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models
from django.utils.timezone import now



Expand Down Expand Up @@ -31,6 +32,11 @@ class Paciente(models.Model):
null=True, blank=True,
help_text='Numero historia clinica en archivo físico')


def edad(self):
return int((now().date() - self.fecha_nacimiento). days / 365.25)


def __str__(self):
return "{} {}".format(self.nombre, self.apellido)

Expand Down
11 changes: 8 additions & 3 deletions CentroAsist/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{% block css %}

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
<link rel="stylesheet" href="{% static "bootstrap.min.css" %}">

<link href="{% static 'css/styles.css' %}" rel="stylesheet">
{% endblock %}
Expand All @@ -32,13 +32,18 @@
<a class="navbar-brand" href="/">Centro Asistencial</a>
<ul class="nav navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="/">Nuevo Paciente<span class="sr-only">(current)</span></a>
<a class="nav-link" href="/paciente/nuevo">Nuevo Paciente<span class="sr-only">(current)</span></a>
</li>
{% if request.user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="#">Paciente</a>
<a class="nav-link" href="/logout">Salir</a>
</li>
{% endif %}
</ul>
</nav>
<div class="row"><div class="col-md-12" style="margin-top: 30px">
<center><img src ="{% static "imagen/centro.png" %}" WIDTH=980></center>
</div></div>

<div class="container">
{% block content %}
Expand Down
24 changes: 24 additions & 0 deletions CentroAsist/templates/buscador.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% extends "base.html" %}
{% load staticfiles %}



{% block content %}




<form method="post" action="">
{% csrf_token %}
{{ form }}
<input type="submit" value="Buscar" />
</form>

{% if pacientes %}
<ul>
{% for paciente in pacientes %}
<li><a href="/paciente/{{ paciente.id }}">{{ paciente }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endblock content %}
28 changes: 3 additions & 25 deletions CentroAsist/templates/login.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
{% load staticfiles %}
<!DOCTYPE html>
<html lang="{{ LANGUAGE_CODE }}">
<head>
<script LANGUAGE="Javascript">
var txt=" Centro Asistencial";
var espera=300;
var refresco=null;
function rotulo_title() {
document.title=txt;
txt=txt.substring(1,txt.length)+txt.charAt(0);
refresco=setTimeout("rotulo_title()",espera);
}
rotulo_title();
</script>
</head>
<body>
<center><img src ="{% static "imagen/centro.png" %}" WIDTH=980></center>
<br>
{% extends "base.html" %}

{% block body %}
{% block content %}


<FORM name=form method="post">
Expand All @@ -30,8 +12,4 @@
</FORM>


{% endblock body %}


</body>
</html>
{% endblock content %}
12 changes: 9 additions & 3 deletions CentroAsist/templates/paciente.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% extends "login.html" %}
{% extends "base.html" %}
{% load staticfiles %}



{% block body %}
{% block content %}


<h1>{{ paciente }}</h1>
Expand All @@ -13,6 +13,12 @@ <h1>{{ paciente }}</h1>
<dd>{{ paciente.dni }}</dd>
<dt>Sexo</dt>
<dd>{{ paciente.sexo }}</dd>
<dt>Fecha Nacimiento</dt>
<dd>{{ paciente.fecha_nacimiento }}</dd>
<dt>Edad</dt>
<dd>{{ paciente.edad }}</dd>
<dt>Domicilio</dt>
<dd>{{ paciente.domicilio }}</dd>
</dl>


Expand Down Expand Up @@ -40,4 +46,4 @@ <h5>{{ registro.consulta }}</h5>



{% endblock body %}
{% endblock content %}
59 changes: 58 additions & 1 deletion CentroAsist/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


from django.shortcuts import render, redirect,get_object_or_404
from CentroAsistencial.forms import (LoginForm, PacienteForm, buscar, RegistroHCForm)
from CentroAsistencial.forms import (LoginForm, PacienteForm, RegistroHCForm, BuscadorForm)
from django.core.urlresolvers import reverse
from django.template import RequestContext
from django.http import HttpResponseRedirect
Expand All @@ -11,6 +11,7 @@
from CentroAsist.models import Paciente, Profesional, RegistroHC, Adjuntos, PalabrasClave
from django.template.response import TemplateResponse
from django.contrib.auth.decorators import login_required
from django.db.models import Q


def login_view(request):
Expand Down Expand Up @@ -46,6 +47,7 @@ def home(request):
return render_to_response('login.html')



@login_required
def registro_hc(request, id_paciente):
paciente = get_object_or_404(Paciente, id=id_paciente)
Expand Down Expand Up @@ -80,10 +82,65 @@ def registro_paciente(request, id_paciente=None):
# check whether it's valid:
if form.is_valid():
paciente = form.save()
paciente.edad ()
return redirect('/paciente/{}'.format(paciente.id))

# if a GET (or any other method) we'll create a blank form
else:

form = PacienteForm()

return render(request, 'login.html', {'form': form})


@login_required
def buscar_paciente(request):

pacientes = []
if request.method == 'POST' :
form = BuscadorForm(request.POST)
if form.is_valid():
pacientes = Paciente.objects.filter(Q(
apellido__icontains=form.cleaned_data['buscador']) | Q( dni__icontains=form.cleaned_data['buscador']))


else:
form = BuscadorForm()

return render(request, 'buscador.html', {'form': form, 'pacientes': pacientes})




































2 changes: 1 addition & 1 deletion CentroAsistencial/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class LoginForm(Form):



class buscar(ModelForm):
class BuscadorForm(Form):
buscador = forms.CharField(max_length=40)


Expand Down
3 changes: 2 additions & 1 deletion CentroAsistencial/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from django.contrib import admin

urlpatterns = [

url(r'^$', 'CentroAsist.views.buscar_paciente', name= 'buscar_paciente'),

url(r'^admin/', include(admin.site.urls)),
url(r'^paciente/nuevo','CentroAsist.views.registro_paciente', name='registro_paciente'),

Expand Down