From f24981d04447205e6151f130d578c6e5fab80b4f Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Fri, 3 Mar 2017 11:16:48 +0100
Subject: [PATCH] appoointment list contains visit number and nd number

---
 smash/web/models.py                         |  7 ++-----
 smash/web/templates/appointments/index.html | 15 +++++++++++----
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/smash/web/models.py b/smash/web/models.py
index 44487b7f..df643b52 100644
--- a/smash/web/models.py
+++ b/smash/web/models.py
@@ -205,11 +205,8 @@ class Visit(models.Model):
         return "%s %s" % (self.subject.first_name, self.subject.last_name)
 
     def follow_up_title(self):
-        visits = Visit.objects.filter(subject=self.subject, datetime_begin__lt =self.datetime_begin)
-        if len(visits)==0:
-            return "First visit"
-        else:
-            return "Follow up "+str(len(visits))
+        count = Visit.objects.filter(subject=self.subject, datetime_begin__lt =self.datetime_begin).count()
+        return "Visit " + str(count + 1)
 
     def mark_as_finished(self):
         self.is_finished = True
diff --git a/smash/web/templates/appointments/index.html b/smash/web/templates/appointments/index.html
index c440bab2..624a8797 100644
--- a/smash/web/templates/appointments/index.html
+++ b/smash/web/templates/appointments/index.html
@@ -67,6 +67,7 @@
 				<thead>
 					<tr>
             <th>Subject</th>
+            <th>Visit</th>
             <th>Type</th>
 						<th>Date</th>
 						<th>Details</th>
@@ -76,13 +77,19 @@
 
       			{% for approach in approaching_list %}
   				<tr>
-  					<td>
               {% if approach.visit.subject.screening_number == "---" %}
-                N/A
+                <td>
+                </td>
+                <td>
+                </td>
               {% else %}
-                {{ approach.visit.subject.first_name }} {{ approach.visit.subject.last_name }}
+                <td>
+                  {{ approach.visit.subject.first_name }} {{ approach.visit.subject.last_name }} ({{ approach.visit.subject.nd_number }})
+                </td>
+                <td>
+                  {{ approach.visit.follow_up_title }}
+                </td>
               {% endif %}
-  					</td>
             <td>
               {% for type in approach.appointment_types.all %}
                 {{ type.code }},
-- 
GitLab