Skip to content
Snippets Groups Projects
Commit e68595ba authored by Piotr Gawron's avatar Piotr Gawron
Browse files

data from tns should be separated by address

parent d816fc8b
No related branches found
No related tags found
1 merge request!240Redcap sync
...@@ -4,6 +4,7 @@ import datetime ...@@ -4,6 +4,7 @@ import datetime
import logging import logging
import sys import sys
import traceback import traceback
import codecs
import pytz import pytz
from django.conf import settings from django.conf import settings
...@@ -38,7 +39,7 @@ class TnsCsvVisitImportReader: ...@@ -38,7 +39,7 @@ class TnsCsvVisitImportReader:
result = [] result = []
with open(filename) as csv_file: with open(filename) as csv_file:
reader = csv.reader(csv_file, delimiter=';') reader = csv.reader((remove_bom(line) for line in csv_file), delimiter=';')
headers = next(reader, None) headers = next(reader, None)
for row in reader: for row in reader:
try: try:
...@@ -134,12 +135,75 @@ class TnsCsvVisitImportReader: ...@@ -134,12 +135,75 @@ class TnsCsvVisitImportReader:
text = data.get('adressofvisit', None) text = data.get('adressofvisit', None)
if text is None: if text is None:
text = data['lab_id'] text = data['lab_id']
if text.startswith('lab-reunis'):
text = u"Laboratoires réunis" if text.startswith('lab-reunis-1'):
if text.startswith('lab-ketterthill'): text='Laboratoires réunis, 23 Route de Diekirch, 6555, Bollendorf-Pont'
text = u"Ketterthill" if text.startswith('lab-reunis-2'):
if text.startswith('lab-bionex'): text='Laboratoires réunis, 38 Rue Hiehl, 6131, Junglinster'
text = u"BioneXt" if text.startswith('lab-reunis-3'):
text='Laboratoires réunis, 16 Rue de la Gare, 6117, Junglinster'
if text.startswith('lab-reunis-4'):
text='Laboratoires réunis, 456 Rue de Neudorf, 2222, Luxembourg'
if text.startswith('lab-reunis-5'):
text='Laboratoires réunis, 14 Place St Michel, 7556, Mersch'
if text.startswith('lab-reunis-6'):
text='Laboratoires réunis, 2 Avenue des Bains, 5610, Mondorf-les-Bains'
if text.startswith('lab-reunis-7'):
text='Laboratoires réunis, 239 Route d\'Arlon, 8011, Strassen'
if text.startswith('lab-reunis-8'):
text='Laboratoires réunis, 123 Route de Diekirch, 7220, Walferdange'
if text.startswith('lab-reunis-9'):
text='Laboratoires réunis, 20 Rue de Luxembourg, 4220, Esch-sur-Alzette'
if text.startswith('lab-reunis-10'):
text='Laboratoires réunis, 124 Avenue de Luxembourg, 4940, Bascharage'
if text.startswith('lab-reunis-11'):
text='Laboratoires réunis, 1 Marbuergerstrooss, 9764, Marnach'
if text.startswith('lab-reunis-12'):
text='Laboratoires réunis, 51 Avenue Lucien Salentiny, 9080, Ettelbruck'
if text.startswith('lab-reunis-13'):
text='Laboratoires réunis, 14 route de l\'Europe, 5531, Remich'
if text.startswith('lab-reunis-14'):
text='Laboratoires réunis, 27, rue Principale, 5240, Sandweiler'
if text.startswith('lab-reunis-15'):
text='Laboratoires réunis, booking by phone 780 290-1, , '
if text.startswith('lab-bionext-16'):
text='BioneXt, 2 Rue du Chateau d\'Eau, 3364, Leudelange'
if text.startswith('lab-bionextpd-17'):
text='BioneXt, PickenDoheem'
if text.startswith('lab-ketterthill-18'):
text='Ketterthill, 11, rue Schwaarze Wee , 3474, Dudelange'
if text.startswith('lab-ketterthill-19'):
text='Ketterthill, 52, bd J.-F. Kennedy , 4170, Esch-sur-Alzette'
if text.startswith('lab-ketterthill-20'):
text='Ketterthill, 7, route de Bettembourg , 5810, Hesperange'
if text.startswith('lab-ketterthill-21'):
text='Ketterthill, Avenue des Bains (Dom. Thermal) , 5601, Mondorf-les-Bains'
if text.startswith('lab-ketterthill-22'):
text='Ketterthill, 8, avenue du Swing , 4367, Belvaux'
if text.startswith('lab-ketterthill-23'):
text='Ketterthill, 1-3, rue de la Continentale , 4917, Bascharage'
if text.startswith('lab-ketterthill-24'):
text='Ketterthill, 14, rue d\'Esch, 3920, Mondercange'
if text.startswith('lab-ketterthill-25'):
text='Ketterthill, 21, rue d\'Orval , 2270, Luxembourg'
if text.startswith('lab-ketterthill-26'):
text='Ketterthill, 24, rue Glesener , 1630, Luxembourg'
if text.startswith('lab-ketterthill-27'):
text='Ketterthill, 36, avenue Victor Hugo , 1750, Luxembourg'
if text.startswith('lab-ketterthill-28'):
text='Ketterthill, 70, rue de Luxembourg , 8140, Bridel'
if text.startswith('lab-ketterthill-29'):
text='Ketterthill, 15, rue Edward Steichen , 2540, Luxembourg'
if text.startswith('lab-ketterthill-30'):
text='Ketterthill, 29, rue Cents , 1319, Luxembourg'
if text.startswith('lab-ketterthill-31'):
text='Ketterthill, 155, rue Lucien Salentiny , 9080, Ettelbruck'
if text.startswith('lab-ketterthill-32'):
text='Ketterthill, 12, rue G.-D. Charlotte , 7520, Mersch'
if text.startswith('lab-ketterthill-33'):
text='Ketterthill, 18, rue de la Piscine , 8508, Redange-sur-Atert'
if text.startswith('lab-ketterthill-34'):
text='Ketterthill, 19, rue Grande-Duchesse Charlotte , 9515, Wiltz'
locations = Location.objects.filter(name=text) locations = Location.objects.filter(name=text)
if len(locations) > 0: if len(locations) > 0:
return locations[0] return locations[0]
...@@ -159,3 +223,6 @@ class TnsCsvVisitImportReader: ...@@ -159,3 +223,6 @@ class TnsCsvVisitImportReader:
style = ' color="brown" ' style = ' color="brown" '
result += "<p><font " + style + ">Number of raised warnings: <b>" + str(self.warning_count) + "</b></font></p>" result += "<p><font " + style + ">Number of raised warnings: <b>" + str(self.warning_count) + "</b></font></p>"
return result return result
def remove_bom(line):
return line[3:] if line.startswith(codecs.BOM_UTF8) else line
...@@ -139,15 +139,15 @@ class TestTnsCsvSubjectReader(TestCase): ...@@ -139,15 +139,15 @@ class TestTnsCsvSubjectReader(TestCase):
visit = Visit.objects.filter(id=visits[0].id)[0] visit = Visit.objects.filter(id=visits[0].id)[0]
appointment = Appointment.objects.filter(visit=visit)[0] appointment = Appointment.objects.filter(visit=visit)[0]
self.assertEqual(u"Laboratoires réunis", appointment.location.name) self.assertTrue(u"Laboratoires réunis" in appointment.location.name)
visit = Visit.objects.filter(id=visits[1].id)[0] visit = Visit.objects.filter(id=visits[1].id)[0]
appointment = Appointment.objects.filter(visit=visit)[0] appointment = Appointment.objects.filter(visit=visit)[0]
self.assertEqual(u"Ketterthill", appointment.location.name) self.assertTrue(u"Ketterthill" in appointment.location.name)
visit = Visit.objects.filter(id=visits[2].id)[0] visit = Visit.objects.filter(id=visits[2].id)[0]
appointment = Appointment.objects.filter(visit=visit)[0] appointment = Appointment.objects.filter(visit=visit)[0]
self.assertEqual(u"BioneXt", appointment.location.name) self.assertTrue(u"BioneXt" in appointment.location.name)
self.assertEquals(3, self.get_warnings_count()) self.assertEquals(3, self.get_warnings_count())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment