0001-dossiers-quotations-table-refactored.patch
calebasse/dossiers/templates/dossiers/quotations.html | ||
---|---|---|
52 | 52 |
<th colspan="2">N° dossier |
53 | 53 |
</th><th rowspan="2">Nom</th> |
54 | 54 |
<th rowspan="2">Prénom</th> |
55 |
<th rowspan="2">Date de naissance</th> |
|
55 | 56 |
<th rowspan="2">État du dossier</th> |
56 |
<th rowspan="2">Mises 1</th>
|
|
57 |
<th rowspan="2">Mises 2</th>
|
|
58 |
<th rowspan="2">Mises 3</th>
|
|
57 |
<th rowspan="2">Date du prochain rendez-vou</th>
|
|
58 |
<th rowspan="2">Date du dernier rendez-vous</th>
|
|
59 |
<th rowspan="2">Mises</th> |
|
59 | 60 |
<th rowspan="2">ANAP</th> |
60 | 61 |
</tr> |
61 | 62 |
<tr> |
... | ... | |
71 | 72 |
<td>{{ patient_record.object.id }}</td> |
72 | 73 |
<td><span class="lastname">{{ patient_record.object.last_name }}</span></td> |
73 | 74 |
<td>{{ patient_record.object.first_name }}</td> |
75 |
<td>{{ patient_record.object.birthdate|date:"SHORT_DATE_FORMAT" }}</td> |
|
74 | 76 |
<td class="{{ patient_record.state_class }}">{{ patient_record.state }}</td> |
75 |
<td>{% for mise in patient_record.object.mises_1.all %}{{ mise }}<br/>{% endfor %}</td> |
|
76 |
<td>{% for mise in patient_record.object.mises_2.all %}{{ mise }}<br/>{% endfor %}</td> |
|
77 |
<td>{% for mise in patient_record.object.mises_3.all %}{{ mise }}<br/>{% endfor %}</td> |
|
77 |
<td>{% if patient_record.next_rdv_date %} |
|
78 |
{{ patient_record.next_rdv_date|date:"DATETIME_FORMAT" }} |
|
79 |
{% endif %} |
|
80 |
</td> |
|
81 |
<td>{% if patient_record.last_rdv_date %} |
|
82 |
{{ patient_record.last_rdv_date|date:"DATETIME_FORMAT" }} |
|
83 |
{% endif %}</td> |
|
84 |
<td>{% if patient_record.mises %}<span class="icon-ok"></span>{% endif %}</td> |
|
78 | 85 |
<td>{% if patient_record.anap %}<span class="icon-ok"></span>{% endif %}</td> |
79 | 86 |
</tr> |
80 | 87 |
{% endfor %} |
calebasse/dossiers/views.py | ||
---|---|---|
851 | 851 |
deficiencies = [getattr(patient_record, field) \ |
852 | 852 |
for field in self.deficience_fields] |
853 | 853 |
anap = reduce(lambda f1, f2: f1 or f2, deficiencies) |
854 |
mises = reduce(lambda m1, m2: m1+m2, [list(getattr(patient_record, field).all()) for field in self.mises_fields]) |
|
855 |
next_rdv = get_next_rdv(patient_record) |
|
856 |
last_rdv = get_last_rdv(patient_record) |
|
857 | ||
858 |
if next_rdv: |
|
859 |
next_rdv_datetime = next_rdv.start_datetime |
|
860 |
else: |
|
861 |
next_rdv_datetime = None |
|
862 |
if last_rdv: |
|
863 |
last_rdv_datetime = last_rdv['start_datetime'] |
|
864 |
else: |
|
865 |
last_rdv_datetime = None |
|
854 | 866 |
patient_records.append( |
855 | 867 |
{ |
856 | 868 |
'object': patient_record, |
857 | 869 |
'state': state, |
858 | 870 |
'state_class': state_class, |
859 |
'anap': anap |
|
871 |
'anap': anap, |
|
872 |
'mises': mises, |
|
873 |
'next_rdv_date': next_rdv_datetime, |
|
874 |
'last_rdv_date': last_rdv_datetime |
|
860 | 875 |
} |
861 | 876 |
) |
862 | 877 |
return patient_records |
... | ... | |
864 | 879 |
def get_queryset(self): |
865 | 880 |
form = forms.QuotationsForm(data=self.request.GET or None) |
866 | 881 |
qs = super(PatientRecordsQuotationsView, self).get_queryset() |
867 |
self.deficience_fields = [field for field in self.model._meta.get_all_field_names() if field.startswith('deficiency_')] |
|
882 |
all_field_names = self.model._meta.get_all_field_names() |
|
883 |
self.deficience_fields = [field for field in all_field_names if field.startswith('deficiency_')] |
|
884 |
self.mises_fields = [field for field in all_field_names if field.startswith('mises_')] |
|
868 | 885 | |
869 | 886 |
without_quotations = self.request.GET.get('without_quotations') |
870 | 887 |
without_anap_quotations = self.request.GET.get('without_anap_quotations') |
871 | 888 |
if without_quotations: |
872 |
qs = qs.filter(mises_1__isnull=True).filter(mises_2__isnull=True).filter(mises_3__isnull=True) |
|
889 |
for field in self.mises_fields: |
|
890 |
mise_field = {'%s__isnull' % field: True} |
|
891 |
qs = qs.filter(**mise_field) |
|
873 | 892 | |
874 | 893 |
if without_anap_quotations: |
875 | 894 |
for field in self.deficience_fields: |
876 |
- |