def fmedica(request): formulario2 = DatosEnfermeria() if request.method == 'POST': if 'num_historia' in request.POST: registros = Registro.objects.filter(datos__nro_historia__contains=request.POST['num_historia'], fmedica__isnull=True, enfermeria__atencion_medica=True) return render_to_response('fmedica.html', {'registros': registros, 'buscado': 'yes'}, context_instance=RequestContext(request)) formrm = FmedicaForm(request.POST) if formrm.is_valid(): formrm.save() return HttpResponseRedirect('/operaciones/') else: formrm = FmedicaForm() return render_to_response('fmedica.html', {'formrm': formrm, 'formulario_datos': formulario2}, context_instance=RequestContext(request))
def fmedica_buscado(request, historiac): registros = Registro.objects.filter(datos__nro_historia=historiac, fmedica__isnull=True) registro = registros.order_by('-fecha')[0] formulario2 = DatosEnfermeria(instance=registro.enfermeria) historia_c = get_object_or_404(Datos, pk=historiac) instancia = Fmedica(nro_historia=historia_c) formrr = RayxForm() if request.method == 'POST': formrm = FmedicaForm(request.POST) if formrm.is_valid(): formu_fmed = formrm.save() registros = Registro.objects.filter(datos__nro_historia=request.POST['nro_historia'], fmedica__isnull=True) registro = registros.order_by('-fecha')[0] registro.fmedica = formu_fmed registro.save() return HttpResponseRedirect('/operaciones/') else: formrm = FmedicaForm(instance=instancia) return render_to_response('fmedica.html', {'formrm': formrm, 'formulario_datos': formulario2, 'formrr': formrr}, context_instance=RequestContext(request))