Index: /tags/v1.0.23rc1/opentrials/repository/admin.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/admin.py (revision 839)
+++ /tags/v1.0.23rc1/opentrials/repository/admin.py (revision 839)
@@ -0,0 +1,218 @@
+# -*- coding: utf-8 -*-
+
+from django.contrib import admin
+from django.utils.translation import ugettext as _
+from django.utils.functional import update_wrapper
+from django.http import HttpResponseRedirect
+from django.db import models
+from django.template.defaultfilters import yesno
+
+from repository.models import *
+from fossil.models import FossilIndexer
+
+from polyglot.admin import TranslationInline, TranslationAdmin
+
+tabular_inline_models = [Descriptor, TrialNumber, PublicContact, ScientificContact,
+                         TrialSecondarySponsor, TrialSupportSource]
+tabular_inlines = []
+for model in tabular_inline_models:
+    cls_name = model.__name__+'line'
+    cls = type(cls_name, (admin.TabularInline,), {'model':model})
+    tabular_inlines.append(cls)
+
+class OutcomeInline(admin.StackedInline):
+    model = Outcome
+
+class ClinicalTrialTranslationInline(TranslationInline):
+    model = ClinicalTrialTranslation
+
+class ClinicalTrialAdmin(admin.ModelAdmin):
+    inlines = tabular_inlines + [OutcomeInline, ClinicalTrialTranslationInline]
+    list_display = ('updated_str','identifier','short_title','recruitment_status',)
+    list_display_links = ('identifier','short_title',)
+    search_fields = ('scientific_title', 'public_title', 'i_freetext',)
+    list_filter = ('updated', 'study_type', 'phase', 'recruitment_status', 'status',)
+    date_hierarchy = 'updated'
+    save_on_top = True
+    actions = ['publish_action']
+    
+    def publish_action(self, request, queryset):
+        rows_updated = 0
+        
+        for obj in queryset:
+            if obj.status != 'published':
+                obj.status = 'published'
+                obj.save()
+                rows_updated += 1
+                
+        if rows_updated == 0:
+            message = _("No clinical trial was published.") 
+        elif rows_updated == 1:
+            message = "1 %s" % _("clinical trial was published.")
+        else:
+            message = "%s %s" % (rows_updated, _("clinical trials were published."))
+        self.message_user(request, message)
+
+    publish_action.short_description = _("Publish the selected clinical trials")
+
+class DescriptorAdmin(admin.ModelAdmin):
+    list_display = ('trial_identifier','vocabulary','code', 'text')
+
+class InlineFossilIndexer(admin.TabularInline):
+    model = FossilIndexer
+
+class PublishedTrialAdmin(admin.ModelAdmin):
+    list_display = ('display_text','creation','trial_id','is_most_recent','revision_sequential')
+    list_filter = ('creation','is_most_recent','revision_sequential')
+    search_fields = ('display_text','serialized')
+    inlines = [InlineFossilIndexer]
+
+    def get_urls(self):
+        from django.conf.urls.defaults import patterns, url
+
+        default_urls = super(PublishedTrialAdmin, self).get_urls()
+
+        def wrap(view):
+            def wrapper(*args, **kwargs):
+                return self.admin_site.admin_view(view)(*args, **kwargs)
+            return update_wrapper(wrapper, view)
+
+        urlpatterns = patterns('',
+                url(r'^(.+)/display-off/$', wrap(self.set_display_off), name='fossil_set_display_off'),
+                url(r'^(.+)/display-on/$', wrap(self.set_display_on), name='fossil_set_display_on'),
+                )
+        
+        return urlpatterns + default_urls
+
+    def set_display_off(self, request, object_id):
+        obj = self.get_object(request, object_id)
+        obj.set_indexer('display', False)
+
+        self.message_user(request, _('Published Trial set display to off.'))
+        return HttpResponseRedirect(request.META.get('HTTP_REFERER', '../'))
+
+    def set_display_on(self, request, object_id):
+        obj = self.get_object(request, object_id)
+        obj.set_indexer('display', True)
+
+        self.message_user(request, _('Published Trial set display to on.'))
+        return HttpResponseRedirect(request.META.get('HTTP_REFERER', '../'))
+
+    def change_view(self, request, object_id, extra_context=None):
+        if request.method == 'POST':
+            self.message_user(request, _('This model is only for query porpuses.'))
+            return HttpResponseRedirect(request.META.get('HTTP_REFERER',
+                reverse('admin:repository_publishedtrial_change', args=(object_id,))))
+
+        fossil = self.get_object(request, object_id)
+
+        extra_context = extra_context or {}
+        extra_context['vocabulary_fields'] = ('study_type','purpose','intervention_assignment',
+                'masking','allocation','recruitment_status','phase')
+        extra_context['outcome_fields'] = ('primary_outcomes','secondary_outcomes')
+        extra_context['description_fields'] = ('hc_code','hc_keyword','intervention_keyword')
+        extra_context['trial_fields'] = []
+
+        values_dict = fossil.trial.fossil.copy()
+
+        # Ordinary fields
+        for field in ClinicalTrial._meta.fields:
+            if field.name in ('_deleted',):
+                continue
+
+            d_field = {
+                'name': field.name,
+                'label': field.verbose_name,
+                }
+
+            value = values_dict.pop(field.name, None)
+           
+            #print field.name, type(field)
+            if isinstance(field, (models.BooleanField, models.NullBooleanField)):
+                d_field['value'] = yesno(value)
+            elif field.choices:
+                d_field['value'] = dict(field.choices).get(value, value)
+            else:
+                d_field['value'] = value
+
+            extra_context['trial_fields'].append(d_field)
+
+        # Many to many fields
+        for field in ClinicalTrial._meta.many_to_many:
+            extra_context['trial_fields'].append({
+                'name': field.name,
+                'label': field.verbose_name,
+                'value': values_dict.pop(field.name, None),
+                })
+
+        # Other children objects
+        for name, value in values_dict.items():
+            if name in ('__model__','scientific_acronym_display','acronym_display','pk',
+                    '__unicode__','date_enrollment_start',):
+                continue
+
+            extra_context['trial_fields'].append({
+                'name': name,
+                'label': name,
+                'value': values_dict.pop(name, None),
+                })
+
+        # Fossil meta fields
+        extra_context['trial_fields'].append({
+            'name': 'is_most_recent',
+            'label': _('Is the most recent'),
+            'value': yesno(fossil.is_most_recent),
+            })
+        extra_context['trial_fields'].append({
+            'name': 'revision_sequential',
+            'label': _('Revision Sequential'),
+            'value': yesno(fossil.revision_sequential),
+            })
+        extra_context['trial_fields'].append({
+            'name': 'status',
+            'label': _('Status'),
+            'value': fossil.status,
+            })
+        extra_context['trial_fields'].append({
+            'name': 'display',
+            'label': _('Displaying'),
+            'value': yesno(fossil.display == 'True'),
+            })
+
+        return super(PublishedTrialAdmin, self).change_view(request, object_id, extra_context)
+
+    def delete_view(self, request, object_id, extra_context=None):
+        self.message_user(request, _('This model is only for query porpuses.'))
+        return HttpResponseRedirect(request.META.get('HTTP_REFERER',
+            reverse('admin:repository_publishedtrial_change', args=(object_id,))))
+
+    def add_view(self, request, form_url='', extra_context=None):
+        self.message_user(request, _('This model is only for query porpuses.'))
+        return HttpResponseRedirect(request.META.get('HTTP_REFERER',
+            reverse('admin:repository_publishedtrial_changelist')))
+
+    def get_actions(self, request):
+        return []
+
+    def get_model_perms(self, request):
+        perms = super(PublishedTrialAdmin, self).get_model_perms(request)
+        perms['add'] = perms['delete'] = False
+        
+        return perms
+    
+
+if ClinicalTrial not in admin.site._registry:
+    admin.site.register(ClinicalTrial, ClinicalTrialAdmin)
+
+if Descriptor not in admin.site._registry:
+    admin.site.register(Descriptor, DescriptorAdmin)
+
+if Institution not in admin.site._registry:
+    admin.site.register(Institution)
+
+if Contact not in admin.site._registry:
+    admin.site.register(Contact)
+
+if PublishedTrial not in admin.site._registry:
+    admin.site.register(PublishedTrial, PublishedTrialAdmin)
+
Index: /tags/v1.0.23rc1/opentrials/repository/serializers.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/serializers.py (revision 839)
+++ /tags/v1.0.23rc1/opentrials/repository/serializers.py (revision 839)
@@ -0,0 +1,638 @@
+import datetime
+
+from django.utils import simplejson
+from django.db import models
+from django.contrib.auth.models import User
+from django.contrib.contenttypes.models import ContentType
+from django.core.exceptions import ObjectDoesNotExist
+
+from fossil.fields import FossilProxy, DictKeyAttribute
+from polyglot.models import lang_format
+from utilities import safe_truncate
+
+def serialize_trial(trial, as_string=True, attrs_to_ignore=None):
+    """
+    Serialize a given ClinicalTrial and its dependencies in once trunk.
+
+    This function is used for djang-fossil to fossilize this object and
+    make possible to generate other formats (i.e: opentrials.dtd) and
+    keep revisions of a trial in denormalized mode in database.
+
+    Returns a text JSON to be used anywhere.
+
+    The argument 'as_string' sets to return serialized as String. If False,
+    it will return a dict.
+    """
+    attrs_to_ignore = attrs_to_ignore or []
+
+    json = {}
+
+    # Common fields
+    for field in trial._meta.fields:
+        if field.name in attrs_to_ignore:
+            continue
+
+        try:
+            value = getattr(trial, field.name)
+        except AttributeError:
+            continue
+        except ObjectDoesNotExist:
+            value = None
+
+        if isinstance(value, datetime.datetime):
+            value = value.strftime('%Y-%m-%d %H:%M:%S')
+        elif isinstance(value, datetime.date):
+            value = value.strftime('%Y-%m-%d')
+        elif isinstance(value, User):
+            value = serialize_user(value, as_string=False)
+        elif isinstance(value, models.Model):
+            value = value.serialize_for_fossil(as_string=False)
+        
+        json[field.name] = value
+
+    # Many to many fields
+    for field in trial._meta.many_to_many:
+        if field.name in attrs_to_ignore:
+            continue
+
+        try:
+            objects = getattr(trial, field.name).all()
+        except AttributeError:
+            continue
+
+        json[field.name] = [item.serialize_for_fossil(as_string=False) for item in objects.all()]
+
+    # Other attributes
+    if hasattr(trial, 'secondary_sponsors'):
+        json['secondary_sponsors'] = [item.serialize_for_fossil(as_string=False) for item in trial.secondary_sponsors()]
+    if hasattr(trial, 'hc_code'):
+        json['hc_code'] = [item.serialize_for_fossil(as_string=False) for item in trial.hc_code()]
+    if hasattr(trial, 'hc_keyword'):
+        json['hc_keyword'] = [item.serialize_for_fossil(as_string=False) for item in trial.hc_keyword()]
+    if hasattr(trial, 'intervention_keyword'):
+        json['intervention_keyword'] = [item.serialize_for_fossil(as_string=False) for item in trial.intervention_keyword()]
+    if hasattr(trial, 'primary_outcomes'):
+        json['primary_outcomes'] = [item.serialize_for_fossil(as_string=False) for item in trial.primary_outcomes()]
+    if hasattr(trial, 'secondary_outcomes'):
+        json['secondary_outcomes'] = [item.serialize_for_fossil(as_string=False) for item in trial.secondary_outcomes()]
+    if hasattr(trial, 'trial_number'):
+        json['trial_number'] = [item.serialize_for_fossil(as_string=False) for item in trial.trial_number()]
+    if hasattr(trial, 'support_sources'):
+        json['support_sources'] = [item.serialize_for_fossil(as_string=False) for item in trial.support_sources()]
+    if hasattr(trial, 'acronym_display'):
+        json['acronym_display'] = trial.acronym_display()
+    if hasattr(trial, 'scientific_acronym_display'):
+        json['scientific_acronym_display'] = trial.scientific_acronym_display()
+    if hasattr(trial, 'enrollment_start_planned'):
+        date = trial.enrollment_start_actual or trial.enrollment_start_planned
+        if date:
+            date = date.split('-')
+            date.reverse()
+            json['date_enrollment_start'] = '/'.join(date)
+
+    # Meta or auxiliar attributes
+    json['__unicode__'] = unicode(trial)
+    json['__model__'] = trial.__class__.__name__
+    json['pk'] = trial.pk
+
+    if as_string:
+        json = simplejson.dumps(json)
+
+    return json
+
+def deserialize_trial(data, persistent=False, persistency_class=None, commit=True):
+    """
+    Gets a JSON text data and converts to an instance of ClinicalTrial model class.
+    TODO: confirm if this must be a proxy class
+    """
+    if isinstance(data, basestring):
+        json = simplejson.loads(data)
+    elif isinstance(data, dict):
+        json = data
+    else:
+        raise Exception('Invalid trial serialized data.')
+
+    if not persistent:
+        return FossilClinicalTrial(data)
+
+    else:
+        if persistency_class is None:
+            raise Exception('Persistent deserialization of a trial must inform the persistency class.')
+
+        from repository.models import ClinicalTrialTranslation, PublicContact, ScientificContact
+        from repository.models import SiteContact
+        from vocabulary.models import StudyType, StudyPurpose, InterventionAssigment
+        from vocabulary.models import StudyMasking, StudyAllocation, StudyPhase
+        from vocabulary.models import RecruitmentStatus, InterventionCode, CountryCode
+
+        obj_fossil = DictKeyAttribute(json)
+
+        trial = persistency_class()
+
+        # Simple fields
+        for field in persistency_class._meta.fields:
+            if field.name in ('id','trial_id','status'):
+                continue
+
+            try:
+                value = getattr(obj_fossil, field.name)
+            except AttributeError:
+                continue
+
+            if isinstance(field, (models.CharField, models.TextField, models.IntegerField,
+                models.PositiveIntegerField, models.DateTimeField, models.DateField,
+                models.NullBooleanField, models.BooleanField)):
+                setattr(trial, field.name, value)
+
+            elif isinstance(field, models.ForeignKey) and value is not None:
+                if field.name == 'primary_sponsor':
+                    trial.primary_sponsor = deserialize_institution(value, True)
+                elif field.name == 'study_type':
+                    trial.study_type = deserialize_vocabulary(value, True, StudyType)
+                elif field.name == 'purpose':
+                    trial.purpose = deserialize_vocabulary(value, True, StudyPurpose)
+                elif field.name == 'intervention_assignment':
+                    trial.intervention_assignment = deserialize_vocabulary(value, True, InterventionAssigment)
+                elif field.name == 'masking':
+                    trial.masking = deserialize_vocabulary(value, True, StudyMasking)
+                elif field.name == 'allocation':
+                    trial.allocation = deserialize_vocabulary(value, True, StudyAllocation)
+                elif field.name == 'phase':
+                    trial.phase = deserialize_vocabulary(value, True, StudyPhase)
+                elif field.name == 'recruitment_status':
+                    trial.recruitment_status = deserialize_vocabulary(value, True, RecruitmentStatus)
+
+        if not commit:
+            return trial
+
+        trial.save()
+
+        # Many to many fields
+        for contact_fossil in obj_fossil.public_contact:
+            contact = deserialize_contact(contact_fossil, True)
+
+            PublicContact.objects.create(trial=trial, contact=contact)
+
+        for contact_fossil in obj_fossil.scientific_contact:
+            contact = deserialize_contact(contact_fossil, True)
+
+            ScientificContact.objects.create(trial=trial, contact=contact)
+
+        for contact_fossil in obj_fossil.site_contact:
+            contact = deserialize_contact(contact_fossil, True)
+
+            SiteContact.objects.create(trial=trial, contact=contact)
+
+        for icode_fossil in obj_fossil.i_code:
+            icode = deserialize_vocabulary(icode_fossil, True, InterventionCode)
+
+            trial.i_code.add(icode)
+
+        for country_fossil in obj_fossil.recruitment_country:
+            country = deserialize_vocabulary(country_fossil, True, CountryCode)
+
+            trial.recruitment_country.add(country)
+
+        # Translations
+        for trans_fossil in obj_fossil.translations:
+            trans = deserialize_trial(trans_fossil, True, ClinicalTrialTranslation, False)
+            trans.content_object = trial
+            trans.save()
+
+        # Saves trial again to force fields validation
+        trial.save()
+
+        return trial
+
+def serialize_institution(institution, as_string=True):
+    """
+    Serializes a given institution object to JSON
+    """
+    json = {
+        'pk': institution.pk,
+        'name': institution.name,
+        'address': institution.address,
+        'country': institution.country.serialize_for_fossil(as_string=False),
+        'creator': serialize_user(institution.creator, as_string=False),
+        }
+
+    if institution.i_type:
+        json['i_type'] = institution.i_type.serialize_for_fossil(as_string=False)
+
+    if as_string:
+        json = simplejson.dumps(json)
+
+    return json
+
+def deserialize_institution(data, persistent=False):
+    """
+    Transforms data (as JSON string or a dict) to an institution
+    """
+    if not data:
+        return None
+
+    if not persistent:
+        pass # TODO if necessary
+
+    else:
+        from repository.models import Institution
+        from vocabulary.models import CountryCode, InstitutionType
+
+        if isinstance(data, basestring):
+            data = DictKeyAttribute(simplejson.loads(data))
+        elif isinstance(data, dict):
+            data = DictKeyAttribute(data)
+
+        try:
+            institution = Institution.objects.get(pk=data.pk)
+        except Institution.DoesNotExist:
+            institution = Institution()
+            institution.id = data.pk
+            institution.name = data.name
+            institution.address = data.address
+            institution.country = deserialize_vocabulary(data.country, True, CountryCode)
+            institution.creator = deserialize_user(data.creator, True)
+            institution.i_type = deserialize_vocabulary(data.i_type, True, InstitutionType)
+            institution.save()
+
+        return institution
+
+def deserialize_vocabulary(data, persistent=False, persistency_class=None):
+    """
+    Transforms data (as JSON string or a dict) to a vocabulary instance of
+    the given class
+    """
+    if not data:
+        return None
+
+    if not persistent:
+        pass # TODO if necessary
+
+    else:
+        if persistency_class is None:
+            raise Exception('Persistent deserialization of a vocabulary object must inform the persistency class.')
+
+        if isinstance(data, basestring):
+            data = DictKeyAttribute(simplejson.loads(data))
+        elif isinstance(data, dict):
+            data = DictKeyAttribute(data)
+
+        try:
+            obj = persistency_class.objects.get(label=data.label)
+        except persistency_class.DoesNotExist:
+            obj = persistency_class()
+            obj.label = data.label
+            obj.description = data.description
+            obj.save()
+
+        return obj
+
+def serialize_contact(contact, as_string=True):
+    """
+    Serializes a given contact object to JSON
+    """
+    json = {
+        'pk': contact.pk,
+        'firstname': contact.firstname,
+        'middlename': contact.middlename,
+        'lastname': contact.lastname,
+        'email': contact.email,
+        'affiliation': serialize_institution(contact.affiliation, as_string=False) if contact.affiliation else None,
+        'address': contact.address,
+        'city': contact.city,
+        'country': contact.country.serialize_for_fossil(as_string=False) if contact.country else None,
+        'zip': contact.zip,
+        'telephone': contact.telephone,
+        'creator': serialize_user(contact.creator, as_string=False) if contact.creator else None,
+        }
+
+    if as_string:
+        json = simplejson.dumps(json)
+
+    return json
+
+def deserialize_contact(data, persistent=False):
+    """
+    Transforms data (as JSON string or a dict) to a contact object
+    """
+    if not data:
+        return None
+
+    if not persistent:
+        pass # TODO if necessary
+
+    else:
+        from repository.models import Contact
+        from vocabulary.models import CountryCode
+
+        if isinstance(data, basestring):
+            data = DictKeyAttribute(simplejson.loads(data))
+        elif isinstance(data, dict):
+            data = DictKeyAttribute(data)
+
+        try:
+            obj = Contact.objects.get(pk=data.pk)
+        except Contact.DoesNotExist:
+            obj = Contact()
+            obj.id = data.pk
+            obj.firstname = data.firstname
+            obj.middlename = data.middlename
+            obj.lastname = data.lastname
+            obj.email = data.email
+            obj.affiliation = deserialize_institution(data.affiliation, True)
+            obj.address = data.address
+            obj.city = data.city
+            obj.country = deserialize_vocabulary(data.country, True, CountryCode)
+            obj.zip = data.zip
+            obj.telephone = data.telephone
+            obj.creator = deserialize_user(data.creator, True)
+            obj.save()
+
+        return obj
+
+def serialize_user(user, as_string=True):
+    """
+    Serializes a given user object to JSON
+    """
+    json = {
+        'username': user.username,
+        'email': user.email,
+        }
+
+    if as_string:
+        json = simplejson.dumps(json)
+
+    return json
+
+def deserialize_user(data, persistent=False):
+    """
+    Transforms data (as JSON string or a dict) to a Django user
+    """
+    if not data:
+        return None
+
+    if not persistent:
+        pass # TODO if necessary
+
+    else:
+        if isinstance(data, basestring):
+            data = DictKeyAttribute(simplejson.loads(data))
+        elif isinstance(data, dict):
+            data = DictKeyAttribute(data)
+
+        try:
+            obj = User.objects.get(username=data.username)
+        except User.DoesNotExist:
+            obj = User()
+            obj.username = data.username
+            obj.email = data.email
+            obj.save()
+
+        return obj
+
+def serialize_trialnumber(trialnumber, as_string=True):
+    """
+    Serializes a given trial number object to JSON
+    """
+    json = {
+            'issuing_authority': trialnumber.issuing_authority,
+            'id_number': trialnumber.id_number,
+        }
+
+    if as_string:
+        json = simplejson.dumps(json)
+
+    return json
+
+def serialize_trialsupportsource(source, as_string=True):
+    """
+    Serializes a given trial support source object to JSON
+    """
+    json = {
+            'institution': serialize_institution(source.institution, as_string=False),
+        }
+
+    if as_string:
+        json = simplejson.dumps(json)
+
+    return json
+
+def serialize_trialsecondarysponsor(sponsor, as_string=True):
+    """
+    Serializes a given trial number object to JSON
+    """
+    json = {
+            'institution': serialize_institution(sponsor.institution, as_string=False),
+        }
+
+    if as_string:
+        json = simplejson.dumps(json)
+
+    return json
+
+def serialize_outcome(outcome, as_string=True):
+    """
+    Serializes a given trial outcome object to JSON
+    """
+    json = {
+            'description': outcome.description,
+        }
+
+    if hasattr(outcome, 'interest'):
+        json['interest'] = outcome.interest
+
+    if hasattr(outcome, 'language'):
+        json['language'] = outcome.language
+
+    if hasattr(outcome, 'translations'):
+        json['translations'] = [serialize_outcome(trans, as_string=False)
+                for trans in outcome.translations.all()]
+
+    if as_string:
+        json = simplejson.dumps(json)
+
+    return json
+
+def serialize_descriptor(descriptor, as_string=True):
+    """
+    Serializes a given trial descriptor object to JSON
+    """
+    json = {
+            'text': descriptor.text,
+        }
+
+    if hasattr(descriptor, 'aspect'):
+        json['aspect'] = descriptor.aspect
+
+    if hasattr(descriptor, 'vocabulary'):
+        json['vocabulary'] = descriptor.vocabulary
+
+    if hasattr(descriptor, 'version'):
+        json['version'] = descriptor.version
+
+    if hasattr(descriptor, 'level'):
+        json['level'] = descriptor.level
+
+    if hasattr(descriptor, 'code'):
+        json['code'] = descriptor.code
+
+    if hasattr(descriptor, 'language'):
+        json['language'] = descriptor.language
+
+    if hasattr(descriptor, 'translations'):
+        json['translations'] = [serialize_descriptor(trans, as_string=False)
+                for trans in descriptor.translations.all()]
+
+    if as_string:
+        json = simplejson.dumps(json)
+
+    return json
+
+class FossilClinicalTrial(FossilProxy):
+    """
+    This class has the same interface of a ClinicalTrial object, but its behaviour
+    is to be a proxy of deserialized fossilized version of a trial.
+
+    The instance of this class is not persistent.
+    """
+    _language = None
+    _translations = None
+
+    def _load_translations(self):
+        if self._translations is None:
+            self._translations = dict([(lang_format(t.get('language', '').lower()), t)
+                for t in self.object_fossil.translations])
+    
+    def __getattr__(self, name):
+        value = super(FossilClinicalTrial, self).__getattr__(name)
+
+        def filter_by_language(item):
+            lang1 = (item.get('language', None) or '').lower()
+            lang2 = (self._language or '').lower()
+            return lang1 == lang2
+
+        if name in ('date_registration','created','updated','exported'):
+            if isinstance(value, basestring):
+                try:
+                    value = datetime.datetime.strptime(value, '%Y-%m-%d %H:%M:%S')
+                except ValueError:
+                    value = datetime.datetime.strptime(value, '%Y-%m-%d')
+
+        elif isinstance(value, dict) and value.get('translations', None):
+            try:
+                value = filter(filter_by_language, value['translations'])[0]
+                #value = [t for t in value['translations'] if t.get('language', '').lower() == self._language.lower()][0]
+            except IndexError:
+                pass
+
+        elif self._language:
+            self._load_translations()
+
+            try:
+                value_trans = self._translations[lang_format(self._language)][name]
+                if value_trans:
+                    value = value_trans
+            except KeyError:
+                pass
+
+        return value
+
+    def main_title(self):
+        if self.public_title:
+            return self.public_title
+        else:
+            return self.scientific_title
+
+    def rec_status(self):
+        self._load_translations()
+
+        try:
+            value = self._translations[lang_format(self._language)]['recruitment_status']
+        except KeyError:
+            value = self.recruitment_status
+
+        # FIXME This should be serialized with right translation, so the following code
+        # would be unnecessary
+        if value:
+            from vocabulary.models import RecruitmentStatus
+            try:
+                rec_status = RecruitmentStatus.objects.get(label=value['label'])
+                trans = rec_status.translations.get(language=lang_format(self._language))
+                return trans.label
+            except ObjectDoesNotExist:
+                return value['label']
+
+        return value
+
+    def short_title(self):
+        return safe_truncate(self.main_title(), 120)
+
+    @property
+    def recruitment_country(self):
+        countries = super(FossilClinicalTrial, self).__getattr__('recruitment_country')
+
+        def get_trans(item):
+            try:
+                return [t for t in item['translations'] if t.get('language', '').lower() == self._language.lower()][0]
+            except IndexError:
+                return item
+
+        return map(get_trans, countries)
+
+    @property
+    def i_code(self):
+        codes = super(FossilClinicalTrial, self).__getattr__('i_code')
+
+        def get_trans(item):
+            try:
+                return [t for t in item['translations'] if t.get('language', '').lower() == self._language.lower()][0]
+            except IndexError:
+                return item
+
+        return map(get_trans, codes)
+
+    @property
+    def public_contact(self):
+        contacts = super(FossilClinicalTrial, self).__getattr__('public_contact')
+
+        contacts = [FossilContact(contact, language=self._language) for contact in contacts]
+
+        return contacts
+
+    @property
+    def scientific_contact(self):
+        contacts = super(FossilClinicalTrial, self).__getattr__('scientific_contact')
+
+        contacts = [FossilContact(contact, language=self._language) for contact in contacts]
+
+        return contacts
+
+    @property
+    def site_contact(self):
+        try:
+            contacts = super(FossilClinicalTrial, self).__getattr__('site_contact')
+            contacts = [FossilContact(contact, language=self._language) for contact in contacts]
+        except AttributeError:
+            contacts = []
+
+        return contacts
+
+class FossilContact(FossilProxy):
+    _language = None
+
+    def __init__(self, contact, language):
+        contact['__model__'] = 'Contact'
+
+        super(FossilContact, self).__init__(contact)
+
+        self._language = language
+
+    @property
+    def country(self):
+        country = super(FossilContact, self).__getattr__('country')
+
+        try:
+            return [t for t in country['translations'] if t.get('language', '').lower() == self._language.lower()][0]
+        except IndexError:
+            return country
+
Index: /tags/v1.0.23rc1/opentrials/repository/views.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/views.py (revision 994)
+++ /tags/v1.0.23rc1/opentrials/repository/views.py (revision 994)
@@ -0,0 +1,1118 @@
+# coding: utf-8
+
+try:
+    set
+except:
+    from sets import Set as set
+
+from django.core import serializers
+from django.core.exceptions import ObjectDoesNotExist
+from django.http import HttpResponseRedirect, HttpResponse, Http404
+from django.shortcuts import render_to_response, get_object_or_404
+from django.utils.translation import ugettext_lazy as _
+from django.forms.models import inlineformset_factory
+from django.core.urlresolvers import reverse
+from django.contrib.auth.decorators import login_required
+from django.template import loader
+from django.db.models import Q
+from django.views.generic.list_detail import object_list
+from django.conf import settings
+from django.template.defaultfilters import slugify
+from django.template.context import RequestContext
+from django.contrib.sites.models import Site
+from django.core.paginator import Paginator, InvalidPage, EmptyPage
+from django.contrib import messages
+from django.utils.translation import get_language
+
+from reviewapp.models import Attachment, Submission, Remark
+from reviewapp.models import STATUS_PENDING, STATUS_RESUBMIT, STATUS_DRAFT, STATUS_APPROVED
+from reviewapp.forms import ExistingAttachmentForm,NewAttachmentForm
+from reviewapp.consts import STEP_STATES, REMARK, MISSING, PARTIAL, COMPLETE
+
+from repository.trial_validation import trial_validator
+from repository.models import ClinicalTrial, Descriptor, TrialNumber
+from repository.models import TrialSecondarySponsor, TrialSupportSource, Outcome
+from repository.models import PublicContact, ScientificContact, SiteContact, Contact, Institution
+from repository.models import ClinicalTrialTranslation
+from repository.trds_forms import MultilingualBaseFormSet
+from repository.trds_forms import GeneralHealthDescriptorForm, PrimarySponsorForm
+from repository.trds_forms import SecondaryIdForm, make_secondary_sponsor_form
+from repository.trds_forms import make_support_source_form, TrialIdentificationForm
+from repository.trds_forms import SpecificHealthDescriptorForm, HealthConditionsForm
+from repository.trds_forms import InterventionDescriptorForm, InterventionForm
+from repository.trds_forms import RecruitmentForm, StudyTypeForm, PrimaryOutcomesForm
+from repository.trds_forms import SecondaryOutcomesForm, make_public_contact_form
+from repository.trds_forms import make_scientifc_contact_form, make_contact_form, NewInstitution
+from repository.trds_forms import make_site_contact_form, TRIAL_FORMS
+from vocabulary.models import RecruitmentStatus, VocabularyTranslation, CountryCode, InterventionCode
+from vocabulary.models import StudyPurpose, InterventionAssigment, StudyMasking, StudyAllocation
+
+from polyglot.multilingual_forms import modelformset_factory
+
+from fossil.fields import DictKeyAttribute
+from fossil.models import Fossil
+
+from utilities import user_in_group
+import datetime
+
+import choices
+import settings
+
+EXTRA_FORMS = 1
+
+MENU_SHORT_TITLE = [_('Trial Identif.'),
+                    _('Spons.'),
+                    _('Health Cond.'),
+                    _('Interv.'),
+                    _('Recruit.'),
+                    _('Study Type'),
+                    _('Outcomes'),
+                    _('Contacts'),
+                    _('Attachs')]
+
+def check_user_can_edit_trial(func):
+    """
+    Decorator to check if current user has permission to edit a given clinical trial
+    """
+    def _inner(request, trial_pk, *args, **kwargs):
+        request.ct = get_object_or_404(ClinicalTrial, id=int(trial_pk))
+        request.can_change_trial = True
+
+        if request.ct.submission.status == STATUS_APPROVED:
+            request.can_change_trial = False
+            messages.warning(request, unicode(_('This trial cannot be modified because it has already been approved.')))
+
+        # Creator can edit in statuses draft and resubmited but can view on other statuses
+        elif request.user == request.ct.submission.creator:
+            if request.ct.submission.status not in (STATUS_DRAFT, STATUS_RESUBMIT):
+                request.can_change_trial = False
+                messages.warning(request, unicode(_('You cannot modify this trial because it is being revised.')))
+
+        elif not request.user.is_staff: # If this is a staff member...
+            request.can_change_trial = False
+            messages.warning(request, unicode(_('Only the creator can modify a trial.')))
+
+            # A reviewer in status pending
+            if not( request.ct.submission.status == STATUS_PENDING and
+                    user_in_group(request.user, 'reviewers') ):
+
+                resp = render_to_response(
+                        '403.html',
+                        {'site': Site.objects.get_current()},
+                        context_instance=RequestContext(request),
+                        )
+                resp.status_code = 403
+
+                return resp
+
+        return func(request, trial_pk, *args, **kwargs)
+
+    return _inner
+
+@login_required
+@check_user_can_edit_trial
+def edit_trial_index(request, trial_pk):
+    ct = request.ct
+
+    status = ct.submission.get_status()
+
+    if status in [REMARK, MISSING]:
+        submit = False
+    else:
+        submit = request.can_change_trial
+
+    if request.method == 'POST' and submit:
+        sub = ct.submission
+        sub.status = STATUS_PENDING
+
+        sub.save()
+        return HttpResponseRedirect(reverse('reviewapp.dashboard'))
+    else:
+        ''' start view '''
+
+        # Changes status from "resubmit" to "draft" if user is the creator
+        sub = ct.submission
+        if sub.status == STATUS_RESUBMIT and request.user == sub.creator:
+            sub.status = STATUS_DRAFT
+            sub.save()
+
+        fields_status = ct.submission.get_fields_status()
+
+        links = []
+        for i, name in enumerate(TRIAL_FORMS):
+            data = dict(label=_(name))
+            data['url'] = reverse('step_' + str(i + 1), args=[trial_pk])
+
+            trans_list = []
+            for lang in ct.submission.get_mandatory_languages():
+                trans = {}
+                lang = lang.lower()
+                step_status = fields_status.get(lang, {}).get(name, None)
+                if step_status == MISSING:
+                    trans['icon'] = settings.MEDIA_URL + 'images/form-status-missing.png'
+                    trans['msg'] = STEP_STATES[MISSING-1][1].title()
+                    trans['leg'] = _("There are required fields missing.")
+                elif step_status == PARTIAL:
+                    trans['icon'] = settings.MEDIA_URL + 'images/form-status-partial.png'
+                    trans['msg'] = STEP_STATES[PARTIAL-1][1].title()
+                    trans['leg'] = _("All required fields were filled.")
+                elif step_status == COMPLETE:
+                    trans['icon'] = settings.MEDIA_URL + 'images/form-status-complete.png'
+                    trans['msg'] = STEP_STATES[COMPLETE-1][1].title()
+                    trans['leg'] = _("All fields were filled.")
+                elif step_status == REMARK:
+                    trans['icon'] = settings.MEDIA_URL + 'images/form-status-remark.png'
+                    trans['msg'] = STEP_STATES[REMARK-1][1].title()
+                    trans['leg'] = _("There are fields with remarks.")
+                else:
+                    trans['icon'] = settings.MEDIA_URL + 'media/img/admin/icon_error.gif'
+                    trans['msg'] = _('Error')
+                    trans['leg'] = _('Error')
+
+                trans_list.append(trans)
+            data['trans'] = trans_list
+            links.append(data)
+
+        status_message = {}
+        if status == REMARK:
+            status_message['icon'] = settings.MEDIA_URL + 'images/form-status-remark.png'
+            status_message['msg'] = _("There are fields with remarks.")
+        elif status == MISSING:
+            status_message['icon'] = settings.MEDIA_URL + 'images/form-status-missing.png'
+            status_message['msg'] = _("There are required fields missing.")
+        elif status == PARTIAL:
+            status_message['icon'] = settings.MEDIA_URL + 'images/form-status-partial.png'
+            status_message['msg'] = _("All required fields were filled.")
+        elif status == COMPLETE:
+            status_message['icon'] = settings.MEDIA_URL + 'images/form-status-complete.png'
+            status_message['msg'] = _("All fields were filled.")
+        else:
+            status_message['icon'] = settings.MEDIA_URL + 'media/img/admin/icon_error.gif'
+            status_message['msg'] = _("Error")
+
+        return render_to_response('repository/trial_index.html',
+                                  {'trial_pk':trial_pk,
+                                   'submission':ct.submission,
+                                   'links':links,
+                                   'status': status,
+                                   'submit': submit,
+                                   'status_message': status_message,},
+                                   context_instance=RequestContext(request))
+
+def full_view(request, trial_pk):
+    ''' full view '''
+    ct = get_object_or_404(ClinicalTrial, id=int(trial_pk))
+    return render_to_response('repository/trds.html',
+                              {'fieldtable':ct.html_dump()},
+                               context_instance=RequestContext(request))
+
+
+def recruiting(request):
+    ''' List all registered trials with recruitment_status = recruiting
+    '''
+    object_list = ClinicalTrial.fossils.recruiting()
+    object_list = object_list.proxies(language=request.LANGUAGE_CODE)
+
+    """
+    recruitments = RecruitmentStatus.objects.filter(label__exact='recruiting')
+    if len(recruitments) > 0:
+        object_list = ClinicalTrial.published.filter(recruitment_status=recruitments[0])
+    else:
+        object_list = None
+
+    for obj in object_list:
+        try:
+            trans = obj.translations.get(language__iexact=request.LANGUAGE_CODE)
+        except ClinicalTrialTranslation.DoesNotExist:
+            trans = None
+
+        if trans:
+            if trans.public_title:
+                obj.public_title = trans.public_title
+            if trans.public_title:
+                obj.scientific_title = trans.scientific_title
+
+        if obj.recruitment_status:
+            try:
+                rec_status_trans = obj.recruitment_status.translations.get(language__iexact=request.LANGUAGE_CODE)
+            except VocabularyTranslation.DoesNotExist:
+                rec_status_trans = obj.recruitment_status
+            obj.rec_status = rec_status_trans.label
+    """
+
+    # pagination
+    paginator = Paginator(object_list, getattr(settings, 'PAGINATOR_CT_PER_PAGE', 10))
+
+    try:
+        page = int(request.GET.get('page', '1'))
+    except ValueError:
+        page = 1
+
+    try:
+        objects = paginator.page(page)
+    except (EmptyPage, InvalidPage):
+        objects = paginator.page(paginator.num_pages)
+
+
+    return render_to_response('repository/clinicaltrial_recruiting.html',
+                              {'objects': objects,
+                               'page': page,
+                               'paginator': paginator},
+                               context_instance=RequestContext(request))
+
+
+def index(request):
+    ''' List all registered trials
+        If you use a search term, the result is filtered
+    '''
+    q = request.GET.get('q', '').strip()
+
+    object_list = ClinicalTrial.fossils.published(q=q)
+
+    object_list = object_list.proxies(language=request.LANGUAGE_CODE)
+
+    # pagination
+    paginator = Paginator(object_list, getattr(settings, 'PAGINATOR_CT_PER_PAGE', 10))
+
+    try:
+        page = int(request.GET.get('page', '1'))
+    except ValueError:
+        page = 1
+
+    try:
+        objects = paginator.page(page)
+    except (EmptyPage, InvalidPage):
+        objects = paginator.page(paginator.num_pages)
+
+    return render_to_response('repository/clinicaltrial_list.html',
+                              {'objects': objects,
+                               'page': page,
+                               'paginator': paginator,
+                               'q': q},
+                               context_instance=RequestContext(request))
+
+@login_required
+def trial_view(request, trial_pk):
+    ''' show details of a trial of a user logged '''
+    ct = get_object_or_404(ClinicalTrial, id=int(trial_pk))
+    review_mode = True
+    if not request.user.is_staff and not user_in_group(request.user, 'reviewers'):
+        review_mode = False
+        if request.user != ct.submission.creator:
+            return render_to_response('403.html', {'site': Site.objects.get_current(),},
+                            context_instance=RequestContext(request))
+
+    if review_mode:
+        can_approve = ct.submission.status == STATUS_PENDING and ct.submission.remark_set.exclude(status='closed').count() == 0
+        can_resubmit = ct.submission.status == STATUS_PENDING
+    else:
+        can_approve = False
+        can_resubmit = False
+
+    translations = [t for t in ct.translations.all()]
+    remark_list = []
+    for tf in TRIAL_FORMS:
+         remarks = ct.submission.remark_set.filter(context=slugify(tf))
+         if remarks:
+            remark_list.append(remarks)
+
+    # get translation for recruitment status
+    recruitment_status = ct.recruitment_status
+    if recruitment_status:
+        recruitment_label = recruitment_status.label
+        try:
+            t = VocabularyTranslation.objects.get_translation_for_object(
+                                request.LANGUAGE_CODE.lower(), model=RecruitmentStatus,
+                                object_id=recruitment_status.id)
+            if t.label:
+                recruitment_label = t.label
+        except ObjectDoesNotExist:
+            pass
+    else:
+        recruitment_label = ""
+
+    # get translations for recruitment country
+    recruitment_country = ct.recruitment_country.all()
+    recruitment_country_list = recruitment_country.values('pk', 'description')
+    for obj in recruitment_country_list:
+        try:
+            t = VocabularyTranslation.objects.get_translation_for_object(
+                                request.LANGUAGE_CODE.lower(), model=CountryCode,
+                                object_id=obj['pk'])
+            if t.description:
+                obj['description'] = t.description
+        except ObjectDoesNotExist:
+            pass
+
+    # get translations for scientific contacts country
+    scientific_contacts = ct.scientific_contacts()
+    scientific_contacts_list = scientific_contacts.values('pk', 'firstname', 'middlename',
+                            'lastname', 'address', 'city', 'zip', 'country_id', 'telephone',
+                            'email', 'affiliation__name')
+
+    for obj in scientific_contacts_list:
+        try:
+            country = CountryCode.objects.get(pk=obj['country_id'])
+            obj['country_description'] = country.description
+        except CountryCode.DoesNotExist:
+            obj['country_description'] = ""
+
+        try:
+            t = VocabularyTranslation.objects.get_translation_for_object(
+                                request.LANGUAGE_CODE.lower(), model=CountryCode,
+                                object_id=obj['country_id'])
+            if t.description:
+                obj['country_description'] = t.description
+        except ObjectDoesNotExist:
+            pass
+
+    # get translations for public contacts country
+    public_contacts = ct.public_contacts()
+    public_contacts_list = public_contacts.values('pk', 'firstname', 'middlename',
+                            'lastname', 'address', 'city', 'zip', 'country_id', 'telephone',
+                            'email', 'affiliation__name')
+
+    for obj in public_contacts_list:
+        try:
+            country = CountryCode.objects.get(pk=obj['country_id'])
+            obj['country_description'] = country.description
+        except CountryCode.DoesNotExist:
+            obj['country_description'] = ""
+
+        try:
+            t = VocabularyTranslation.objects.get_translation_for_object(
+                                request.LANGUAGE_CODE.lower(), model=CountryCode,
+                                object_id=obj['country_id'])
+            if t.description:
+                obj['country_description'] = t.description
+        except ObjectDoesNotExist:
+            pass
+
+    # get translations for site contacts country
+    site_contacts = ct.site_contact.all().select_related()
+    site_contacts_list = site_contacts.values('pk', 'firstname', 'middlename',
+                            'lastname', 'address', 'city', 'zip', 'country_id', 'telephone',
+                            'email', 'affiliation__name')
+
+    for obj in site_contacts_list:
+        try:
+            country = CountryCode.objects.get(pk=obj['country_id'])
+            obj['country_description'] = country.description
+        except CountryCode.DoesNotExist:
+            obj['country_description'] = ""
+
+        try:
+            t = VocabularyTranslation.objects.get_translation_for_object(
+                                request.LANGUAGE_CODE.lower(), model=CountryCode,
+                                object_id=obj['country_id'])
+            if t.description:
+                obj['country_description'] = t.description
+        except ObjectDoesNotExist:
+            pass
+
+    enrollment_start_date = ct.enrollment_start_actual if \
+        ct.enrollment_start_actual is not None else ct.enrollment_start_planned
+    enrollment_end_date = ct.enrollment_end_actual if \
+        ct.enrollment_end_actual is not None else ct.enrollment_end_planned
+
+    return render_to_response('repository/clinicaltrial_detail_user.html',
+                                {'object': ct,
+                                'translations': translations,
+                                'host': request.get_host(),
+                                'remark_list': remark_list,
+                                'review_mode': review_mode,
+                                'can_approve': can_approve,
+                                'can_resubmit': can_resubmit,
+                                'languages': get_sorted_languages(request),
+                                'recruitment_label': recruitment_label,
+                                'recruitment_country': recruitment_country_list,
+                                'scientific_contacts': scientific_contacts_list,
+                                'public_contacts': public_contacts_list,
+                                'site_contacts': site_contacts_list,
+                                'enrollment_start_date': enrollment_start_date,
+                                'enrollment_end_date': enrollment_end_date,
+                                },
+                                context_instance=RequestContext(request))
+
+def get_sorted_languages(request):
+    # This just copy managed languages to sorte with main language first
+    languages = [lang.lower() for lang in settings.MANAGED_LANGUAGES]
+    languages.sort(lambda a,b: -1 if a == request.trials_language else cmp(a,b))
+    return languages
+
+def trial_registered(request, trial_fossil_id, trial_version=None):
+    ''' show details of a trial registered '''
+    try:
+        fossil = Fossil.objects.get(pk=trial_fossil_id)
+    except Fossil.DoesNotExist:
+        try:
+            qs = Fossil.objects.indexed(trial_id=trial_fossil_id)
+            if trial_version:
+                fossil = qs.get(revision_sequential=trial_version)
+            else:
+                fossil = qs.get(is_most_recent=True)
+        except Fossil.DoesNotExist:
+            raise Http404
+
+    ct = fossil.get_object_fossil()
+    ct.fossil['language'] = ct.fossil.get('language', settings.DEFAULT_SUBMISSION_LANGUAGE)
+    ct._language = ct.language
+    ct.hash_code = fossil.pk
+    ct.previous_revision = fossil.previous_revision
+    ct.version = fossil.revision_sequential
+
+    translations = [ct.fossil] # the Fossil dictionary must be one of the translations
+    translations.extend(ct.translations)
+    try:
+        scientific_title = [t['scientific_title'] for t in translations
+                if t['language'] == get_language() and t['scientific_title'].strip()][0]
+    except IndexError:
+        scientific_title = ct.scientific_title
+
+    created = datetime.datetime.strptime(ct.fossil['created'], "%Y-%m-%d %H:%M:%S")
+
+    trial = get_object_or_404(ClinicalTrial, trial_id=trial_fossil_id)
+    attachs = [attach for attach in trial.trial_attach() if attach.public]
+    
+    try:
+        time_perspective = trial.time_perspective
+    except ObjectDoesNotExist: 
+        time_perspective = None
+    observational_study_design = trial.observational_study_design
+
+    return render_to_response('repository/clinicaltrial_detail_published.html',
+                                {'object': ct,
+                                'attachs': attachs,
+                                'translations': translations,
+                                'time_perspective':time_perspective,
+                                'observational_study_design':observational_study_design,
+                                'host': request.get_host(),
+                                'fossil_created': created,
+                                'register_number': trial_fossil_id,
+                                'scientific_title': scientific_title,
+                                'languages': get_sorted_languages(request)},
+                                context_instance=RequestContext(request))
+
+@login_required
+def new_institution(request):
+
+    if request.method == 'POST':
+        new_institution = NewInstitution(request.POST)
+        if new_institution.is_valid():
+            institution = new_institution.save(commit=False)
+            institution.creator = request.user
+            institution.save()
+            json = serializers.serialize('json',[institution])
+            return HttpResponse(json, mimetype='application/json')
+        else:
+            return HttpResponse(new_institution.as_table(), mimetype='text/html')
+
+    else:
+        new_institution = NewInstitution()
+
+    return render_to_response('repository/new_institution.html',
+                             {'form':new_institution},
+                               context_instance=RequestContext(request))
+
+def step_list(trial_pk):
+    import sys
+    current_step = int( sys._getframe(1).f_code.co_name.replace('step_','') )
+    steps = []
+    for i in range(1,10):
+        steps.append({'link': reverse('step_%d'%i,args=[trial_pk]),
+                      'is_current': (i == current_step),
+                      'name': MENU_SHORT_TITLE[i-1]})
+    return steps
+
+@login_required
+@check_user_can_edit_trial
+def step_1(request, trial_pk):
+    ct = request.ct
+
+    if not request.user.is_staff and not user_in_group(request.user, 'reviewers'):
+        if request.user != ct.submission.creator:
+            return render_to_response('403.html', {'site': Site.objects.get_current(),},
+                            context_instance=RequestContext(request))
+
+    if request.method == 'POST' and request.can_change_trial:
+        form = TrialIdentificationForm(request.POST, instance=ct,
+                                       display_language=request.user.get_profile().preferred_language)
+        SecondaryIdSet = inlineformset_factory(ClinicalTrial, TrialNumber,
+                                               form=SecondaryIdForm,
+                                               extra=EXTRA_FORMS)
+        secondary_forms = SecondaryIdSet(request.POST, instance=ct)
+
+        if form.is_valid() and secondary_forms.is_valid():
+            secondary_forms.save()
+            form.save()
+            return HttpResponseRedirect(reverse('step_1',args=[trial_pk]))
+    else:
+        form = TrialIdentificationForm(instance=ct,
+                                       default_second_language=ct.submission.get_secondary_language(),
+                                       display_language=request.user.get_profile().preferred_language,
+                                       )
+        SecondaryIdSet = inlineformset_factory(ClinicalTrial, TrialNumber,
+                                               form=SecondaryIdForm,
+                                               extra=EXTRA_FORMS, can_delete=True)
+        secondary_forms = SecondaryIdSet(instance=ct)
+
+    forms = [form]
+    formsets = [secondary_forms]
+    return render_to_response('repository/trial_form.html',
+                              {'forms':forms,'formsets':formsets,
+                               'trial_pk':trial_pk,
+                               'title':TRIAL_FORMS[0],
+                               'steps': step_list(trial_pk),
+                               'remarks':Remark.status_open.filter(submission=ct.submission,context=slugify(TRIAL_FORMS[0])),
+                               'default_second_language': ct.submission.get_secondary_language(),
+                               'available_languages': [lang.lower() for lang in ct.submission.get_mandatory_languages()],
+                               },
+                               context_instance=RequestContext(request))
+
+
+@login_required
+@check_user_can_edit_trial
+def step_2(request, trial_pk):
+    ct = request.ct
+
+    if not request.user.is_staff and not user_in_group(request.user, 'reviewers'):
+        if request.user != ct.submission.creator:
+            return render_to_response('403.html', {'site': Site.objects.get_current(),},
+                            context_instance=RequestContext(request))
+
+    qs_primary_sponsor = Institution.objects.filter(creator=request.user).order_by('name')
+
+    if request.method == 'POST' and request.can_change_trial:
+        form = PrimarySponsorForm(request.POST, instance=ct, queryset=qs_primary_sponsor,
+                                  display_language=request.user.get_profile().preferred_language)
+        SecondarySponsorSet = inlineformset_factory(ClinicalTrial, TrialSecondarySponsor,
+                           form=make_secondary_sponsor_form(request.user),extra=EXTRA_FORMS)
+        SupportSourceSet = inlineformset_factory(ClinicalTrial, TrialSupportSource,
+                           form=make_support_source_form(request.user),extra=EXTRA_FORMS)
+
+        secondary_forms = SecondarySponsorSet(request.POST, instance=ct)
+        sources_form = SupportSourceSet(request.POST, instance=ct)
+
+        if form.is_valid() and secondary_forms.is_valid() and sources_form.is_valid():
+            secondary_forms.save()
+            sources_form.save()
+            form.save()
+        return HttpResponseRedirect(reverse('step_2',args=[trial_pk]))
+    else:
+        form = PrimarySponsorForm(instance=ct, queryset=qs_primary_sponsor,
+                                  default_second_language=ct.submission.get_secondary_language(),
+                                  display_language=request.user.get_profile().preferred_language)
+        SecondarySponsorSet = inlineformset_factory(ClinicalTrial, TrialSecondarySponsor,
+            form=make_secondary_sponsor_form(request.user),extra=EXTRA_FORMS, can_delete=True)
+        SupportSourceSet = inlineformset_factory(ClinicalTrial, TrialSupportSource,
+               form=make_support_source_form(request.user),extra=EXTRA_FORMS,can_delete=True)
+
+        secondary_forms = SecondarySponsorSet(instance=ct)
+        sources_form = SupportSourceSet(instance=ct)
+
+    forms = [form]
+    formsets = [secondary_forms,sources_form]
+    return render_to_response('repository/step_2.html',
+                              {'forms':forms,'formsets':formsets,
+                               'trial_pk':trial_pk,
+                               'title':TRIAL_FORMS[1],
+                               'steps': step_list(trial_pk),
+                               'remarks':Remark.status_open.filter(submission=ct.submission,context=slugify(TRIAL_FORMS[1])),
+                               'default_second_language': ct.submission.get_secondary_language(),
+                               'available_languages': [lang.lower() for lang in ct.submission.get_mandatory_languages()],},
+                               context_instance=RequestContext(request))
+
+
+@login_required
+@check_user_can_edit_trial
+def step_3(request, trial_pk):
+    ct = request.ct
+
+    if not request.user.is_staff and not user_in_group(request.user, 'reviewers'):
+        if request.user != ct.submission.creator:
+            return render_to_response('403.html', {'site': Site.objects.get_current(),},
+                            context_instance=RequestContext(request))
+
+    GeneralDescriptorSet = modelformset_factory(Descriptor,
+                                                formset=MultilingualBaseFormSet,
+                                                form=GeneralHealthDescriptorForm,
+                                                can_delete=True,
+                                                extra=EXTRA_FORMS,
+                                                extra_formset_attrs={
+                                                    'default_second_language':ct.submission.get_secondary_language(),
+                                                    'available_languages':[lang.lower() for lang in ct.submission.get_mandatory_languages()],
+                                                    'display_language':request.user.get_profile().preferred_language,
+                                                    },
+                                                )
+
+    SpecificDescriptorSet = modelformset_factory(Descriptor,
+                                                formset=MultilingualBaseFormSet,
+                                                form=SpecificHealthDescriptorForm,
+                                                can_delete=True,
+                                                extra=EXTRA_FORMS,
+                                                extra_formset_attrs={
+                                                    'default_second_language':ct.submission.get_secondary_language(),
+                                                    'available_languages':[lang.lower() for lang in ct.submission.get_mandatory_languages()],
+                                                    'display_language':request.user.get_profile().preferred_language,
+                                                    },
+                                                )
+
+    general_qs = Descriptor.objects.filter(trial=trial_pk,
+                                           aspect=choices.TRIAL_ASPECT[0][0],
+                                           level=choices.DESCRIPTOR_LEVEL[0][0])
+
+    specific_qs = Descriptor.objects.filter(trial=trial_pk,
+                                           aspect=choices.TRIAL_ASPECT[0][0],
+                                           level=choices.DESCRIPTOR_LEVEL[1][0])
+
+    if request.method == 'POST' and request.can_change_trial:
+        form = HealthConditionsForm(request.POST, instance=ct,
+                                    display_language=request.user.get_profile().preferred_language)
+        general_desc_formset = GeneralDescriptorSet(request.POST,queryset=general_qs,prefix='g')
+        specific_desc_formset = SpecificDescriptorSet(request.POST,queryset=specific_qs,prefix='s')
+
+        if form.is_valid() and general_desc_formset.is_valid() and specific_desc_formset.is_valid():
+            descriptors = general_desc_formset.save(commit=False)
+            descriptors += specific_desc_formset.save(commit=False)
+
+
+            for descriptor in descriptors:
+                descriptor.trial = ct
+
+            general_desc_formset.save()
+            specific_desc_formset.save()
+            form.save()
+
+            return HttpResponseRedirect(reverse('step_3',args=[trial_pk]))
+    else:
+        form = HealthConditionsForm(instance=ct,
+                                    default_second_language=ct.submission.get_secondary_language(),
+                                    display_language=request.user.get_profile().preferred_language)
+        general_desc_formset = GeneralDescriptorSet(queryset=general_qs,prefix='g')
+        specific_desc_formset = SpecificDescriptorSet(queryset=specific_qs,prefix='s')
+
+
+    forms = [form]
+    formsets = [general_desc_formset, specific_desc_formset]
+    return render_to_response('repository/step_3.html',
+                              {'forms':forms,'formsets':formsets,
+                               'trial_pk':trial_pk,
+                               'title':TRIAL_FORMS[2],
+                               'steps': step_list(trial_pk),
+                               'remarks':Remark.status_open.filter(submission=ct.submission,context=slugify(TRIAL_FORMS[2])),
+                               'default_second_language': ct.submission.get_secondary_language(),
+                               'available_languages': [lang.lower() for lang in ct.submission.get_mandatory_languages()],},
+                               context_instance=RequestContext(request))
+
+
+@login_required
+@check_user_can_edit_trial
+def step_4(request, trial_pk):
+    ct = request.ct
+
+    if not request.user.is_staff and not user_in_group(request.user, 'reviewers'):
+        if request.user != ct.submission.creator:
+            return render_to_response('403.html', {'site': Site.objects.get_current(),},
+                            context_instance=RequestContext(request))
+
+    DescriptorFormSet = modelformset_factory(Descriptor,
+                                          formset=MultilingualBaseFormSet,
+                                          form=InterventionDescriptorForm,
+                                          can_delete=True,
+                                          extra=EXTRA_FORMS,
+                                          extra_formset_attrs={
+                                            'default_second_language':ct.submission.get_secondary_language(),
+                                            'available_languages':[lang.lower() for lang in ct.submission.get_mandatory_languages()],
+                                            'display_language':request.user.get_profile().preferred_language,
+                                            },
+                                          )
+
+    queryset = Descriptor.objects.filter(trial=trial_pk,
+                                           aspect=choices.TRIAL_ASPECT[1][0],
+                                           level=choices.DESCRIPTOR_LEVEL[0][0])
+    if request.method == 'POST' and request.can_change_trial:
+        form = InterventionForm(request.POST, instance=ct,
+                                display_language=request.user.get_profile().preferred_language)
+        specific_desc_formset = DescriptorFormSet(request.POST, queryset=queryset)
+
+        if form.is_valid() and specific_desc_formset.is_valid():
+            descriptors = specific_desc_formset.save(commit=False)
+
+
+            for descriptor in descriptors:
+                descriptor.trial = ct
+
+            specific_desc_formset.save()
+            form.save()
+            return HttpResponseRedirect(reverse('step_4',args=[trial_pk]))
+    else:
+        form = InterventionForm(instance=ct,
+                                default_second_language=ct.submission.get_secondary_language(),
+                                display_language=request.trials_language)
+        specific_desc_formset = DescriptorFormSet(queryset=queryset)
+
+    forms = [form]
+    formsets = [specific_desc_formset]
+    return render_to_response('repository/step_4.html',
+                              {'forms':forms,'formsets':formsets,
+                               'trial_pk':trial_pk,
+                               'title':TRIAL_FORMS[3],
+                               'steps': step_list(trial_pk),
+                               'remarks':Remark.status_open.filter(submission=ct.submission,context=slugify(TRIAL_FORMS[3])),
+                               'default_second_language': ct.submission.get_secondary_language(),
+                               'available_languages': [lang.lower() for lang in ct.submission.get_mandatory_languages()],},
+                               context_instance=RequestContext(request))
+
+
+@login_required
+@check_user_can_edit_trial
+def step_5(request, trial_pk):
+    ct = request.ct
+
+    if not request.user.is_staff and not user_in_group(request.user, 'reviewers'):
+        if request.user != ct.submission.creator:
+            return render_to_response('403.html', {'site': Site.objects.get_current(),},
+                            context_instance=RequestContext(request))
+
+    if request.method == 'POST' and request.can_change_trial:
+        form = RecruitmentForm(request.POST, instance=ct,
+                               display_language=request.user.get_profile().preferred_language)
+
+        if form.is_valid():
+            form.save()
+            return HttpResponseRedirect(reverse('step_5',args=[trial_pk]))
+    else:
+        form = RecruitmentForm(instance=ct,
+                               default_second_language=ct.submission.get_secondary_language(),
+                               display_language=request.trials_language)
+
+    forms = [form]
+
+    return render_to_response('repository/trial_form.html',
+                              {'forms':forms,
+                               'trial_pk':trial_pk,
+                               'title':TRIAL_FORMS[4],
+                               'steps': step_list(trial_pk),
+                               'remarks':Remark.status_open.filter(submission=ct.submission,context=slugify(TRIAL_FORMS[4])),
+                               'default_second_language': ct.submission.get_secondary_language(),
+                               'available_languages': [lang.lower() for lang in ct.submission.get_mandatory_languages()],
+                               },
+                               context_instance=RequestContext(request))
+
+
+@login_required
+@check_user_can_edit_trial
+def step_6(request, trial_pk):
+    ct = request.ct
+
+    if not request.user.is_staff and not user_in_group(request.user, 'reviewers'):
+        if request.user != ct.submission.creator:
+            return render_to_response('403.html', {'site': Site.objects.get_current(),},
+                            context_instance=RequestContext(request))
+
+    if request.method == 'POST' and request.can_change_trial:
+        form = StudyTypeForm(request.POST, instance=ct,
+                             display_language=request.user.get_profile().preferred_language)
+
+        if form.is_valid():
+            form.save()
+            return HttpResponseRedirect(reverse('step_6',args=[trial_pk]))
+    else:
+        form = StudyTypeForm(instance=ct,
+                             default_second_language=ct.submission.get_secondary_language(),
+                             display_language=request.trials_language)
+
+    forms = [form]
+    return render_to_response('repository/trial_form.html',
+                              {'forms':forms,
+                               'trial_pk':trial_pk,
+                               'title':TRIAL_FORMS[5],
+                               'steps': step_list(trial_pk),
+                               'remarks':Remark.status_open.filter(submission=ct.submission,context=slugify(TRIAL_FORMS[5])),
+                               'default_second_language': ct.submission.get_secondary_language(),
+                               'available_languages': [lang.lower() for lang in ct.submission.get_mandatory_languages()],},
+                               context_instance=RequestContext(request))
+
+
+@login_required
+@check_user_can_edit_trial
+def step_7(request, trial_pk):
+    ct = request.ct
+
+    if not request.user.is_staff and not user_in_group(request.user, 'reviewers'):
+        if request.user != ct.submission.creator:
+            return render_to_response('403.html', {'site': Site.objects.get_current(),},
+                            context_instance=RequestContext(request))
+
+    PrimaryOutcomesSet = modelformset_factory( Outcome,
+                                formset=MultilingualBaseFormSet,
+                                form=PrimaryOutcomesForm,extra=EXTRA_FORMS,
+                                can_delete=True,
+                                extra_formset_attrs={
+                                    'default_second_language':ct.submission.get_secondary_language(),
+                                    'available_languages':[lang.lower() for lang in ct.submission.get_mandatory_languages()],
+                                    'display_language':request.user.get_profile().preferred_language,
+                                    },
+                                )
+    SecondaryOutcomesSet = modelformset_factory(Outcome,
+                                formset=MultilingualBaseFormSet,
+                                form=SecondaryOutcomesForm,extra=EXTRA_FORMS,
+                                can_delete=True,
+                                extra_formset_attrs={
+                                    'default_second_language':ct.submission.get_secondary_language(),
+                                    'available_languages':[lang.lower() for lang in ct.submission.get_mandatory_languages()],
+                                    'display_language':request.user.get_profile().preferred_language,
+                                    },
+                                )
+
+    primary_qs = Outcome.objects.filter(trial=ct, interest=choices.OUTCOME_INTEREST[0][0])
+    secondary_qs = Outcome.objects.filter(trial=ct, interest=choices.OUTCOME_INTEREST[1][0])
+
+    if request.method == 'POST' and request.can_change_trial:
+        primary_outcomes_formset = PrimaryOutcomesSet(request.POST, queryset=primary_qs, prefix='primary')
+        secondary_outcomes_formset = SecondaryOutcomesSet(request.POST, queryset=secondary_qs, prefix='secondary')
+
+        if primary_outcomes_formset.is_valid() and secondary_outcomes_formset.is_valid():
+            outcomes = primary_outcomes_formset.save(commit=False)
+            outcomes += secondary_outcomes_formset.save(commit=False)
+
+            for outcome in outcomes:
+                outcome.trial = ct
+
+            primary_outcomes_formset.save()
+            secondary_outcomes_formset.save()
+
+            # Executes validation of current trial submission (for mandatory fields)
+            trial_validator.validate(ct)
+
+            return HttpResponseRedirect(reverse('step_7',args=[trial_pk]))
+    else:
+        primary_outcomes_formset = PrimaryOutcomesSet(queryset=primary_qs, prefix='primary')
+        secondary_outcomes_formset = SecondaryOutcomesSet(queryset=secondary_qs, prefix='secondary')
+
+    formsets = [primary_outcomes_formset,secondary_outcomes_formset]
+    return render_to_response('repository/trial_form.html',
+                              {'formsets':formsets,
+                               'trial_pk':trial_pk,
+                               'title':TRIAL_FORMS[6],
+                               'steps': step_list(trial_pk),
+                               'remarks':Remark.status_open.filter(submission=ct.submission,context=slugify(TRIAL_FORMS[6])),
+                               'default_second_language': ct.submission.get_secondary_language(),
+                               'available_languages': [lang.lower() for lang in ct.submission.get_mandatory_languages()],},
+                               context_instance=RequestContext(request))
+
+
+@login_required
+@check_user_can_edit_trial
+def step_8(request, trial_pk):
+    ct = request.ct
+
+    if not request.user.is_staff and not user_in_group(request.user, 'reviewers'):
+        if request.user != ct.submission.creator:
+            return render_to_response('403.html', {'site': Site.objects.get_current(),},
+                            context_instance=RequestContext(request))
+
+    contact_type = {
+        'PublicContact': (PublicContact,make_public_contact_form(request.user)),
+        'ScientificContact': (ScientificContact,make_scientifc_contact_form(request.user)),
+        'SiteContact': (SiteContact,make_site_contact_form(request.user))
+    }
+
+    InlineFormSetClasses = []
+    for model,form in contact_type.values():
+        InlineFormSetClasses.append(
+            inlineformset_factory(ClinicalTrial,model,form=form,can_delete=True,extra=EXTRA_FORMS)
+        )
+
+    ContactFormSet = modelformset_factory(Contact,
+                                          form=make_contact_form(request.user,formset_prefix='new_contact'),
+                                          extra=1)
+
+    contact_qs = Contact.objects.none()
+
+    if request.method == 'POST' and request.can_change_trial:
+        inlineformsets = [fs(request.POST,instance=ct) for fs in InlineFormSetClasses]
+        new_contact_formset = ContactFormSet(request.POST,queryset=contact_qs,prefix='new_contact')
+
+        if not False in [fs.is_valid() for fs in inlineformsets] \
+                and new_contact_formset.is_valid():
+
+            for contactform in new_contact_formset.forms:
+                if contactform.cleaned_data:
+                    Relation = contact_type[contactform.cleaned_data.pop('relation')][0]
+                    new_contact = contactform.save(commit=False)
+                    new_contact.creator = request.user
+                    new_contact.save()
+                    Relation.objects.create(trial=ct,contact=new_contact)
+
+            for fs in inlineformsets:
+                fs.save()
+
+            # Executes validation of current trial submission (for mandatory fields)
+            trial_validator.validate(ct)
+
+            return HttpResponseRedirect(reverse('step_8',args=[trial_pk]))
+    else:
+        inlineformsets = [fs(instance=ct) for fs in InlineFormSetClasses]
+        new_contact_formset = ContactFormSet(queryset=contact_qs,prefix='new_contact')
+
+    formsets = inlineformsets + [new_contact_formset]
+    return render_to_response('repository/step_8.html',
+                              {'formsets':formsets,
+                               'trial_pk':trial_pk,
+                               'title':TRIAL_FORMS[7],
+                               'steps': step_list(trial_pk),
+                               'remarks':Remark.status_open.filter(submission=ct.submission,context=slugify(TRIAL_FORMS[7])),
+                               'default_second_language': ct.submission.get_secondary_language(),
+                               'available_languages': [lang.lower() for lang in ct.submission.get_mandatory_languages()],},
+                               context_instance=RequestContext(request))
+
+@login_required
+@check_user_can_edit_trial
+def step_9(request, trial_pk):
+    # TODO: this function should be on another place
+    ct = request.ct
+
+    if not request.user.is_staff and not user_in_group(request.user, 'reviewers'):
+        if request.user != ct.submission.creator:
+            return render_to_response('403.html', {'site': Site.objects.get_current(),},
+                            context_instance=RequestContext(request))
+
+    su = Submission.objects.get(trial=ct)
+
+    NewAttachmentFormSet = modelformset_factory(Attachment,
+                                             extra=1,
+                                             can_delete=False,
+                                             form=NewAttachmentForm)
+
+    existing_attachments = Attachment.objects.filter(submission=su)
+    
+    if request.method == 'POST' and request.can_change_trial:
+
+        if 'remove' in request.POST:
+            attach = Attachment.objects.get(id=request.POST.get('remove'))
+            attach.delete()
+
+            return HttpResponseRedirect(reverse('step_9',args=[trial_pk]))
+
+        else:
+
+            new_attachment_formset = NewAttachmentFormSet(request.POST,
+                                                          request.FILES,
+                                                          prefix='new')
+
+            if new_attachment_formset.is_valid():
+                new_attachments = new_attachment_formset.save(commit=False)
+
+                for attachment in new_attachments:
+                    attachment.submission = su
+
+                new_attachment_formset.save()
+                return HttpResponseRedirect(reverse('step_9',args=[trial_pk]))
+
+    else:
+        new_attachment_formset = NewAttachmentFormSet(queryset=Attachment.objects.none(),
+                                                      prefix='new')
+
+    formsets = [new_attachment_formset]
+
+    return render_to_response('repository/attachments.html',
+                              {'formsets':formsets,
+                               'existing_attachments':existing_attachments,
+                               'trial_pk':trial_pk,
+                               'title':TRIAL_FORMS[8],
+                               'host': request.get_host(),
+                               'steps': step_list(trial_pk),
+                               'remarks':Remark.status_open.filter(submission=ct.submission,context=slugify(TRIAL_FORMS[8])),
+                               'default_second_language': ct.submission.get_secondary_language(),
+                               'available_languages': [lang.lower() for lang in ct.submission.get_mandatory_languages()],},
+                               context_instance=RequestContext(request))
+
+from repository.xml.generate import xml_ictrp, xml_opentrials
+
+def trial_ictrp(request, trial_fossil_id, trial_version=None):
+    """
+    Returns a XML content structured on ICTRP standard, you can find more details
+    about it on:
+
+    - http://reddes.bvsalud.org/projects/clinical-trials/wiki/RegistrationDataModel
+    - http://reddes.bvsalud.org/projects/clinical-trials/attachment/wiki/RegistrationDataModel/who_ictrp_dtd.txt
+    - http://reddes.bvsalud.org/projects/clinical-trials/attachment/wiki/RegistrationDataModel/ICTRP%20Data%20format%201.1%20.doc
+    - http://reddes.bvsalud.org/projects/clinical-trials/attachment/wiki/RegistrationDataModel/xmlsample.xml
+    - http://reddes.bvsalud.org/projects/clinical-trials/attachment/wiki/RegistrationDataModel/ICTRPTrials.xml
+    """
+
+    try:
+        fossil = Fossil.objects.get(pk=trial_fossil_id)
+    except Fossil.DoesNotExist:
+        try:
+            qs = Fossil.objects.indexed(trial_id=trial_fossil_id)
+            if trial_version:
+                fossil = qs.get(revision_sequential=trial_version)
+            else:
+                fossil = qs.get(is_most_recent=True)
+        except Fossil.DoesNotExist:
+            raise Http404
+
+    ct = fossil.get_object_fossil()
+    xml = xml_ictrp([fossil])
+
+    resp = HttpResponse(xml,
+            mimetype = 'text/xml'
+            )
+
+    resp['Content-Disposition'] = 'attachment; filename=%s-ictrp.xml' % ct.trial_id
+
+    return resp
+
+def all_trials_ictrp(request):
+
+    trials = ClinicalTrial.fossils.published()
+    xml = xml_ictrp(trials)
+
+    resp = HttpResponse(xml,
+            mimetype = 'text/xml'
+            )
+
+    resp['Content-Disposition'] = 'attachment; filename=%s-ictrp.xml' % settings.TRIAL_ID_PREFIX
+
+    return resp
+
+
+def trial_otxml(request, trial_fossil_id, trial_version=None):
+    """
+    Returns a XML content structured on OpenTrials standard, you can find more details
+    about it on:
+
+    - ToDo
+    """
+
+    try:
+        fossil = Fossil.objects.get(pk=trial_fossil_id)
+    except Fossil.DoesNotExist:
+        try:
+            qs = Fossil.objects.indexed(trial_id=trial_fossil_id)
+            if trial_version:
+                fossil = qs.get(revision_sequential=trial_version)
+            else:
+                fossil = qs.get(is_most_recent=True)
+        except Fossil.DoesNotExist:
+            raise Http404
+
+    ct = fossil.get_object_fossil()
+    ct.hash_code = fossil.pk
+    ct.previous_revision = fossil.previous_revision
+    ct.version = fossil.revision_sequential
+    ct.status = fossil.indexers.key('status', fail_silent=True).value
+
+    persons = set(ct.scientific_contact + ct.public_contact + ct.site_contact)
+
+    xml = xml_opentrials(ct, persons)
+
+    resp = HttpResponse(xml,
+            mimetype = 'text/xml'
+            )
+
+    resp['Content-Disposition'] = 'attachment; filename=%s-ot.xml' % ct.trial_id
+
+    return resp
Index: /tags/v1.0.23rc1/opentrials/repository/templatetags/recruiting_trials.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templatetags/recruiting_trials.py (revision 716)
+++ /tags/v1.0.23rc1/opentrials/repository/templatetags/recruiting_trials.py (revision 716)
@@ -0,0 +1,46 @@
+from repository.models import ClinicalTrial, ClinicalTrialTranslation
+from django.template import Library, Node, TemplateSyntaxError
+
+register = Library()
+
+def get_latest_recruiting_trials(parser, token):
+    bits = token.contents.split()
+    if len(bits) != 4:
+        raise TemplateSyntaxError, "get_latest_recruiting_trials tag takes exactly three arguments"
+    if bits[2] != 'as':
+        raise TemplateSyntaxError, "second argument to the get_latest_recruiting_trials tag must be 'as'"
+
+    return LatestRecruitingTrialsNode(bits[1], bits[3])
+
+class LatestRecruitingTrialsNode(Node):
+    def __init__(self, num, varname):
+        self.num = num
+        self.varname = varname
+    
+    def render(self, context):
+        request = context['request']
+
+        object_list = ClinicalTrial.fossils.recruiting()
+        object_list = object_list.proxies(language=request.LANGUAGE_CODE)
+
+        """
+        object_list = ClinicalTrial.published.filter(recruitment_status__label='recruiting').order_by('-date_registration',)[:self.num]
+    
+        for obj in object_list:
+            try:
+                trans = obj.translations.get(language__iexact=request.LANGUAGE_CODE)
+            except ClinicalTrialTranslation.DoesNotExist:
+                trans = None
+            
+            if trans:
+                if trans.public_title:
+                    obj.public_title = trans.public_title
+                if trans.public_title:
+                    obj.scientific_title = trans.scientific_title
+        """
+            
+        context[self.varname] = object_list
+        return ''
+
+get_latest_recruiting_trials = register.tag(get_latest_recruiting_trials)
+
Index: /tags/v1.0.23rc1/opentrials/repository/templatetags/repository_tags.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templatetags/repository_tags.py (revision 891)
+++ /tags/v1.0.23rc1/opentrials/repository/templatetags/repository_tags.py (revision 891)
@@ -0,0 +1,111 @@
+from django import template
+from django.template.defaultfilters import slugify
+
+register = template.Library()
+
+class ForTranslationNode(template.Node):
+    def __init__(self, trans, var, nodelist):
+        if '.' in trans:
+            parts = trans.split('.')
+            obj = '.'.join(parts[:-1])
+            self.translations = parts[-1]
+            self.obj = template.Variable(obj)
+        else:
+            self.obj = None
+            self.translations = template.Variable(trans)
+        self.var = var
+        self.nodelist = nodelist
+
+    def render(self, context):
+        output = []
+        languages = context['languages']
+
+        if self.obj:
+            done_languages = []
+            obj = self.obj.resolve(context)
+
+            if obj:
+                for lang in languages:
+                    try:
+                        context[self.var] = [t for t in self.get_translations(self.get_value(obj, 'translations'))
+                                if self.get_value(t, 'language') == lang][0]
+                    except IndexError:
+                        context[self.var] = obj
+                        self.set_language(obj, lang)
+
+                    if self.get_value(context[self.var], 'language') not in done_languages:
+                        output.append(self.nodelist.render(context))
+                        done_languages.append(self.get_value(context[self.var], 'language'))
+        else:
+            translations = self.translations.resolve(context)
+            for lang in languages:
+                context[self.var] = [t for t in translations if self.get_value(t, 'language').lower() == lang.lower()][0]
+
+                output.append(self.nodelist.render(context))
+
+        return u'\n'.join(output)
+
+    def get_value(self, obj, key):
+        try:
+            return obj[key]
+        except TypeError:
+            return None
+
+    def get_translations(self, obj):
+        return obj
+
+    def set_language(self, obj, lang):
+        obj.setdefault('language', lang)
+
+class ForTranslationNodeObj(ForTranslationNode):
+    def get_value(self, obj, key):
+        return getattr(obj, key)
+
+    def get_translations(self, obj):
+        return obj.all()
+
+    def set_language(self, obj, lang):
+        obj.language = getattr(obj, 'language', lang)
+
+#@register.tag
+def do_for_trans(parser, token):
+    """
+    Usage example:
+
+        {% for_trans translations as t %}
+            <div class="title">
+                <h2>{{ t.language }}</h2>
+                <p>{{ t.scientific_title }}</p>
+            </div>
+        {% endfor_trans %}
+    """
+    bits = token.split_contents()
+    nodelist = parser.parse(('end'+bits[0],))
+    parser.delete_first_token()    
+
+    if bits[0] == 'for_trans_obj':
+        return ForTranslationNodeObj(bits[1], bits[3], nodelist)
+    else:
+        return ForTranslationNode(bits[1], bits[3], nodelist)
+
+for_trans = register.tag('for_trans', do_for_trans)
+for_trans_obj = register.tag('for_trans_obj', do_for_trans)
+
+@register.filter
+def switch(value, key_labels):
+    """
+    Returns the equivalent label for a given key value.
+    
+    The example below will return "months":
+
+        {{ "M"|switch:"-=null,Y=years,M=months,W=weeks,D=days,H=hours" }}
+    """
+    key_labels = dict([item.split('=') for item in key_labels.split(',')])
+    return key_labels.get(value, value)
+
+@register.filter
+def prep_label_for_xml(label):
+    """Returns a label replacing whitespaces for underlines because XML validation
+    doesn't support white spaces."""
+    return 'null' if label == 'N/A' else slugify(label.replace(' ', '_'))
+
Index: /tags/v1.0.23rc1/opentrials/repository/templatetags/remark.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templatetags/remark.py (revision 411)
+++ /tags/v1.0.23rc1/opentrials/repository/templatetags/remark.py (revision 411)
@@ -0,0 +1,23 @@
+from reviewapp.models import Remark
+from django.template import Library, Node
+
+register = Library()
+
+@register.tag
+def get_remarks(parser, token):
+    bits = token.contents.split()
+    if len(bits) != 4:
+        raise TemplateSyntaxError, "get_remarks tag takes exactly three arguments"
+    if bits[2] != 'as':
+        raise TemplateSyntaxError, "second argument to the get_remarks tag must be 'as'"
+    return RemarkList(parser.compile_filter(bits[1]), bits[3])
+
+class RemarkList(Node):
+    def __init__(self, subject, varname):
+        self.subject = subject
+        self.varname = varname
+    
+    def render(self, context):
+        subject = self.subject.resolve(context,True)
+        context[self.varname] = Remark.objects.filter(context=subject)
+        return ''
Index: /tags/v1.0.23rc1/opentrials/repository/templatetags/scoreboard.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templatetags/scoreboard.py (revision 979)
+++ /tags/v1.0.23rc1/opentrials/repository/templatetags/scoreboard.py (revision 979)
@@ -0,0 +1,33 @@
+from repository.models import ClinicalTrial, ClinicalTrialTranslation
+from django.template import Library, Node, TemplateSyntaxError
+from django.utils.translation import ugettext as _
+
+register = Library()
+
+def get_score_numbers(parser, token):
+    bits = token.contents.split()
+    if len(bits) != 3:
+        raise TemplateSyntaxError, "get_score_numbers tag takes exactly two arguments"
+    if bits[1] != 'as':
+        raise TemplateSyntaxError, "second argument to the get_score_numbers tag must be 'as'"
+
+    return GetScoresNode(bits[2])
+
+class GetScoresNode(Node):
+    def __init__(self, varname):
+        self.varname = varname
+
+    def render(self, context):
+        request = context['request']
+
+        number_recruiting_trials = len(ClinicalTrial.fossils.recruiting())
+        number_registered_trials = len(ClinicalTrial.fossils.published())
+        scoreboard_text = "Deprecated!"
+
+        scoreboard_result = {'number_recruiting_trials': number_recruiting_trials,
+                             'number_registered_trials': number_registered_trials}
+
+        context[self.varname] = scoreboard_result #scoreboard_text
+        return ''
+
+get_score_numbers = register.tag(get_score_numbers)
Index: /tags/v1.0.23rc1/opentrials/repository/widgets.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/widgets.py (revision 892)
+++ /tags/v1.0.23rc1/opentrials/repository/widgets.py (revision 892)
@@ -0,0 +1,93 @@
+from django import forms
+from django.forms.util import flatatt
+from django.utils.safestring import mark_safe
+from django.utils.translation import ugettext_lazy as _
+from django.utils.dates import MONTHS
+
+from datetime import date, datetime
+
+class SelectWithLink(forms.widgets.Select):
+    def __init__(self, attrs=None, choices=(), **kwargs):
+        self.text = kwargs.pop('text', 'Link')
+        self.link = kwargs.pop('link', '#')
+        super(SelectWithLink, self).__init__(attrs)
+        
+    def render(self, name, value, attrs=None, choices=()):
+        if value is None: 
+            value = ''
+        final_attrs = self.build_attrs(attrs, name=name)
+        output = [u'<select%s>' % flatatt(final_attrs)]
+        options = self.render_options(choices, [value])
+        if options:
+            output.append(options)
+        output.append(u'</select>')
+        output.append(u'<span><a href="%s" id="%s-link" style="display: inline;">%s</a></span>' % (self.link, name, self.text))
+        return mark_safe(u'\n'.join(output))
+        
+        
+class SelectInstitution(forms.widgets.Select):
+    def __init__(self, attrs=None, choices=(), **kwargs):
+        self.button_label = kwargs.pop('button_label', _("New Institution"))
+        self.formset_prefix = kwargs.pop('formset_prefix', 'new_contact')
+        self.func = "new_institution('%s')" % self.formset_prefix
+        super(SelectInstitution, self).__init__(attrs)
+        
+    def render(self, name, value, attrs=None, choices=()):
+        if value is None: 
+            value = ''
+        final_attrs = self.build_attrs(attrs, name=name)
+        output = [u'<select%s>' % flatatt(final_attrs)]
+        options = self.render_options(choices, [value])
+        if options:
+            output.append(options)
+        output.append(u'</select>')
+        output.append(u'<span><input id="button_new_institution" onclick="%s" type="button" value="%s"/><span>' % (self.func, self.button_label))
+        return mark_safe(u'\n'.join(output))
+        
+class YearMonthWidget(forms.MultiWidget):
+    """
+    This widget shows two combos with year and month and returns as a date of first day
+    of that month
+    """
+
+    def __init__(self, *args, **kwargs):
+        MONTHS_CHOICES = [('','-------')] + MONTHS.items()
+        year = date.today().year
+        YEARS_CHOICES = [('','-------')] + [(y,y) for y in range(year-1, year+50)]
+        widgets = [
+                forms.Select(choices=MONTHS_CHOICES),
+                forms.Select(choices=YEARS_CHOICES),
+                ]
+
+        super(YearMonthWidget, self).__init__(widgets=widgets, *args, **kwargs)
+
+    def decompress(self, value):
+        if not value:
+            ret = ['', '']
+        else:
+            value = value.strftime('%Y-%m-%d') if isinstance(value, (datetime, date)) else value
+            if '-' in value:
+                # format YYYY-mm-dd
+                ret = map(int, value.split('-')[:2])
+                ret.reverse()
+            elif '/' in value:
+                # This was implemented to maintain compatibility (the fields 
+                # enrollment_start_planned, enrollment_start_actual, enrollment_end_planned and 
+                # enrollment_end_actual were open for typing)
+                # format dd/mm/YYYY
+                ret = map(int, value.split('/')[-2:])
+            else:
+                ret = ['', '']
+        return ret
+
+    def value_from_datadict(self, data, files, name):
+        month, year = data[name+'_0'], data[name+'_1']
+        
+        if bool(month) ^ bool(year):
+            return False
+        
+        try:
+            return date(int(year), int(month), 1)
+        except ValueError:
+            return None
+
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/trds.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/trds.html (revision 186)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/trds.html (revision 186)
@@ -0,0 +1,10 @@
+{% extends "base.html" %}
+{% load i18n %}
+{% block title %}{% trans "Trial Registration Data Set" %}{% endblock %}
+{% block body_title %}{% trans "Trial Registration Data Set" %}{% endblock %}
+
+{% block body %}
+<table border="1">
+{{ fieldtable|safe }}
+</table>
+{% endblock %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/trial_outcomes_form.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/trial_outcomes_form.html (revision 345)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/trial_outcomes_form.html (revision 345)
@@ -0,0 +1,24 @@
+{% extends "base.html" %}
+{% load i18n %}
+{% block body_title %}{{ forms.form_main.title }}{% endblock %}
+
+{% block body %}
+
+    <form action="./" method="POST">{% csrf_token %}
+        <table><caption>{% trans "Primary Outcomes" %}</caption>
+        {{forms.form_main.as_table}}
+        </table>
+        <table><caption>{% trans "Secondary Outcomes" %}</caption>
+        {{forms.form_main.as_table}}
+        </table>
+        <input name="submit_go" type="submit" 
+                     value="{% trans "Save and continue later" %}"><br/>
+        
+        {% if next_form_title %}
+        <input name="submit_next" type="submit"
+             value="{% trans "Save and go to" %} '{{next_form_title}}'">
+        {% endif %}
+    </form>
+
+
+{% endblock %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/new-clinicaltrial_detail_user.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/new-clinicaltrial_detail_user.html (revision 809)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/new-clinicaltrial_detail_user.html (revision 809)
@@ -0,0 +1,849 @@
+{% extends "base.html" %}
+
+{% load i18n adminmedia repository_tags %}
+
+{% block body_title %}{% trans 'Clinical Trial' %}{% endblock %}
+
+{% block extrahead %}
+<style type="text/css">
+    span.label, span.legend {
+        font-weight: bold;
+    }
+    span.legend {
+        display: block;
+        margin: 0.5em 0;
+        text-decoration: underline;
+    }
+    .mainContent ul li {
+        margin-bottom: 1em;
+    }
+    .mainContent li.subset {
+        border: 1px solid silver;
+        padding: 0.5em;
+        clear: both;
+    }
+    .mainContent li.subset ul {
+        padding: 0em;
+    }
+    .mainContent li.subset .odd {
+        background-color: #F4F9FD;
+    }
+    .mainContent li.subset ul.vcard {
+        float: left;
+        width: 33%;
+        margin: 1.5em 0 1em;
+    }
+    div.title {
+      margin-left: 1%;
+      border: 4px solid #CCC;
+      border-radius: 16px;
+      -moz-border-radius: 16px;
+      -webkit-border-radius: 16px;
+      margin-bottom: 2em;
+      background: #EEE;
+      overflow: hidden;
+      padding: 0;
+      width: 31%;
+      float: left;
+    }
+    
+    div.title h2 {
+      color: #CCC;
+      font-size: 18pt;
+      line-height: 54pt;
+      margin-top: -16px;
+      margin-right: 10px;
+      font-variant: small-caps;
+      letter-spacing: -1pt;
+      text-align: right;
+    }
+
+    html > body div.title h2 {
+      margin-bottom: -30pt;
+    }
+
+    div.title p {
+      margin-left: 14pt;
+      line-height: 200%;
+      margin-right: 14pt;
+    }
+</style>
+{% endblock %}
+
+{% block stepmenu_top %}
+    <small>
+        <a href="{% url reviewapp.home %}">{% trans 'Home' %}</a>
+    </small>
+    <small>
+        / <a href="{% url reviewapp.submissionlist %}">{% trans 'Submissions' %}</a>
+    </small>
+    <small>
+        / <a href="{% url repository.edittrial object.pk %}">{% trans "Summary" %}</a>
+    </small>
+    <big>/ Trial {{ object }}</big>
+{% endblock %}
+
+{% block body %}
+
+    <div class="review_buttons" {% if not review_mode %}style="display:none;"{% endif %}>
+          <form action="{% url reviewapp.change_submission_status object.submission.pk 'approved' %}" method="POST" style="display:inline;">
+          {% csrf_token %}
+          <input id="approve_review" type="submit" style="font-size: 80%;" value="{% trans 'Approve Submission' %}" title="{% trans 'Approve Submission' %}" {% if not can_approve %} disabled="disabled" {% endif %} />
+          </form>
+          <form action="{% url reviewapp.change_submission_status object.submission.pk 'resubmit' %}" method="POST" style="display:inline;">
+          {% csrf_token %}
+          <input id="resubmit_review" type="submit" style="font-size: 80%;" value="{% trans 'Resubmit Submission' %}" title="{% trans 'Resubmit Submission' %}" {% if not can_resubmit %} disabled="disabled" {% endif %} />
+          </form>
+      </div>
+
+    {% if remark_list %}
+    <div class="warning">
+        <a class="minimize button" onclick="$(this.parentNode).toggleClass('warning-minimized').find('ul').toggle('slow')"><img src="{{MEDIA_URL}}media/img/admin/arrow-down.gif"/></a>
+        <a class="maximize button" onclick="$(this.parentNode).toggleClass('warning-minimized').find('ul').toggle('slow')"><img src="{{MEDIA_URL}}media/img/admin/arrow-up.gif"/></a>
+        <h2>{% trans 'Remarks' %}</h2>
+        <ul>
+            {% for remarks in remark_list %}
+                {% for remark in remarks %}
+                <li id="remark_{{ remark.id }}"><b>{% trans remark.context_title %}:</b> {{ remark.text }}
+                {% if review_mode %}
+                    {% if remark.status == 'open' %}
+                        <br />{% trans 'Status' %}: {% trans "Open (awaiting revision)" %}
+                        
+                        <form action="{% url reviewapp.delete_remark remark.pk %}" method="POST">
+                        {% csrf_token %}
+                        <input id="remark-delete" type="submit" style="font-size: 80%;" value="{% trans 'Delete' %}" title="{% trans 'Delete' %}" />
+                        </form>
+                        
+                    {% endif %}
+                    {% if remark.status == 'acknowledged' %}
+                        <br />{% trans 'Status' %}: {% trans "Revised" %}
+                        <br />
+                        <form action="{% url reviewapp.changeremarkstatus remark.pk 'closed' %}" method="POST" style="display:inline;">
+                        {% csrf_token %}
+                        <input id="remark-approve" type="submit" style="font-size: 80%;" value="{% trans 'Approve' %}" title="{% trans 'Approve' %}" />
+                        </form>
+                        <form action="{% url reviewapp.changeremarkstatus remark.pk 'open' %}" method="POST" style="display:inline;">
+                        {% csrf_token %}
+                        <input id="remark-reopen" type="submit" style="font-size: 80%;" value="{% trans 'Reopen' %}" title="{% trans 'Reopen' %}" />
+                        </form>
+                    {% endif %}
+                {% else %}
+                    {% if remark.status == 'open' %}
+                        <br />{% trans 'Status' %}: {% trans "Mark as reviewed" %}
+                        <br />
+                        <form action="{% url reviewapp.changeremarkstatus remark.pk 'acknowledged' %}" method="POST" style="display:inline;">
+                        {% csrf_token %}
+                        <input id="remark-acknowledged" type="submit" style="font-size: 80%;" value="{% trans 'Mark as reviewed' %}" title="{% trans 'Mark as reviewed' %}" />
+                        </form>
+                    {% endif %}
+                    {% if remark.status == 'acknowledged' %}
+                        <br />{% trans 'Status' %}: {% trans "Revised (awaiting approval)" %}
+                    {% endif %}
+                {% endif %}
+                {% if remark.status == 'closed' %}
+                    <br />{% trans 'Status' %}: {% trans "Closed" %}
+                {% endif %}
+                </li>
+                {% endfor %}
+            {% endfor %}
+        </ul>
+    </div>
+    {% endif %}
+    
+    <h2>{{ object.scientific_title }}</h2>
+
+    
+    <h3>{% trans 'Scientific Title' %}:</h3>
+        {% for t in translations|dictsortreversed:"language" %}
+            {% if t.scientific_title %}
+            <div class="title">
+                <h2>{{ t.language }}</h2>
+                <p>{{ t.scientific_title }}</p>
+            </div>
+            {% endif %}
+        {% endfor %}
+        {% if object.scientific_title %}
+            <div class="title">
+
+                <h2>en</h2>
+                <p>{{ object.scientific_title }}</p>
+            </div>
+        {% endif %}
+        <div class="spacer"> </div>
+    <h3>{% trans 'Trial Identification' %}</h3>
+    <ul>
+
+        <li>
+            <p><span class="label">{% trans 'Public Title' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.public_title %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.public_title }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.public_title %}
+                <div class="title">
+
+                    <h2>en</h2>
+                    <p>{{ object.public_title }}</p>
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Scientific Acronym' %}:</span></p>
+
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.scientific_acronym %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.scientific_acronym }}: {{ t.scientific_acronym_expansion }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.scientific_acronym %}
+                <div class="title">
+                    <h2>en</h2>
+
+                    <p>{{ object.scientific_acronym_display }}</p>
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Public Acronym' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.acronym %}
+                <div class="title">
+
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.acronym }}: {{ t.acronym_expansion }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.acronym %}
+                <div class="title">
+                    <h2>en</h2>
+                    <p>{{ object.acronym_display }}</p>
+
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+        <li class="subset">
+            <span class="legend">{% trans 'Secondary Identifying Numbers' %}:</span>
+            {% for secid in object.trial_number %}
+            <ul class="{% cycle 'even' 'odd' %}">
+                <li>
+
+                    <span class="label">{{ secid.id_number }}</span><br />
+                    <span class="value">{% trans 'Issuing Authority' %}:</span>
+                    <span class="value">{{ secid.issuing_authority }}</span>
+                </li>
+            </ul>
+            {% endfor %}
+        </li>
+        
+        {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Trial Identification'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+        
+    </ul>
+
+    <h3>{% trans 'Sponsors' %}</h3>
+    <ul>
+        <li>
+            <span class="label">{% trans 'Primary Sponsor' %}:</span>
+            <span class="value">{{ object.primary_sponsor.name }}</span>
+        </li>
+        {% if object.secondary_sponsors %}
+        <li class="subset">
+
+            <span class="legend">{% trans 'Secondary Sponsors' %}:</span>
+            <ul>
+            {%  for sponsors in object.secondary_sponsors %}
+                <li class="{% cycle 'even' 'odd' %}">
+                    <span class="label">{% trans 'Institution' %}:</span>
+                    <span class="value">{{ sponsors.institution.name }}</span>
+                </li>
+            {% endfor %}
+            </ul>
+
+        </li>
+        {% endif %}
+        <li class="subset">
+            <span class="legend">{% trans 'Source(s) of Monetary or Material Support' %}:</span>
+            <ul>
+            {%  for source_support in object.support_sources %}
+                <li class="{% cycle 'even' 'odd' %}">
+                    <span class="label">{% trans 'Institution' %}:</span>
+                    <span class="value">{{ source_support.institution }}</span>
+
+                </li>
+            {% endfor %}
+            </ul>
+        </li>
+        
+        {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Sponsors'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+        
+    </ul>
+    
+    <h3>{% trans 'Health Conditions' %}</h3>
+    <ul>
+        <li>
+
+        <p><span class="label">{% trans 'Health Condition(s) or Problem(s)' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.hc_freetext %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.hc_freetext }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.hc_freetext %}
+                <div class="title">
+
+                    <h2>en</h2>
+                    <p>{{ object.hc_freetext }}</p>
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'General Descriptors for Health Condition(s)' %}:</span></p>
+
+            {% for hc in object.hc_code %}
+                {% for hc_trans in hc.translations_all|dictsortreversed:"language" %}
+                    {% if hc_trans.text %}
+                    <div class="title">
+                        <h2>{{ hc_trans.language }}</h2>
+                        <p>
+                            <span class="label">{{ hc.code }}:</span>
+                            <span class="value">{{ hc_trans.text }}</span>
+                        </p>
+                    </div>
+
+                    {% endif %}
+                {% endfor %}
+                {% if hc.text %}
+                    <div class="title">
+                        <h2>en</h2>
+                        <p>
+                            <span class="label">{{ hc.code }}:</span>
+                            <span class="value">{{ hc.text }}</span>
+                        </p>
+                    </div>
+
+                {% endif %}
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+        <li>
+            <p><span class="label">{% trans 'Specific Descriptors for Health Condition(s)' %}:</span></p>
+            {% for hc in object.hc_keyword %}
+                {% for hc_trans in hc.translations_all|dictsortreversed:"language" %}
+                    {% if hc_trans.text %}
+                    <div class="title">
+                        <h2>{{ hc_trans.language }}</h2>
+
+                        <p>
+                            <span class="label">{{ hc.code }}:</span>
+                            <span class="value">{{ hc_trans.text }}</span>
+                        </p>
+                    </div>
+                    {% endif %}
+                {% endfor %}
+                {% if hc.text %}
+                    <div class="title">
+                        <h2>en</h2>
+
+                        <p>
+                            <span class="label">{{ hc.code }}:</span>
+                            <span class="value">{{ hc.text }}</span>
+                        </p>
+                    </div>
+                {% endif %}
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+
+        {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Health Conditions'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+        
+    </ul>
+    
+    <h3>{% trans 'Interventions' %}</h3>
+    <ul>
+        <li class="subset">
+            <span class="legend">{% trans 'Intervention Code(s)' %}</span>
+            <ul>
+            {% for iv in object.intervention_code %}
+                <li>
+
+                    <span class="label">{{ iv.label }}</span>
+                </li>
+            {% endfor %}
+            </ul>
+        </li>
+        <li>
+        <p><span class="label">{% trans 'Interventions' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.i_freetext %}
+                <div class="title">
+
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.i_freetext|linebreaksbr }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.i_freetext %}
+                <div class="title">
+                    <h2>en</h2>
+                    <p>{{ object.i_freetext|linebreaksbr }}</p>
+
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Descriptor for Intervention(s)' %}:</span></p>
+            {% for intervention in object.intervention_keyword %}
+                {% for i_trans in intervention.translations_all|dictsortreversed:"language" %}
+                    {% if i_trans.text %}
+                    <div class="title">
+                        <h2>{{ i_trans.language }}</h2>
+
+                        <p>
+                            <span class="label">{{ intervention.code }}:</span>
+                            <span class="value">{{ i_trans.text }}</span>
+                        </p>
+                    </div>
+                    {% endif %}
+                {% endfor %}
+                {% if intervention.text %}
+                    <div class="title">
+                        <h2>en</h2>
+                        <p>
+                            <span class="label">{{ intervention.code }}:</span>
+                            <span class="value">{{ intervention.text }}</span>
+                        </p>
+                    </div>
+                {% endif %}
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+
+        {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Interventions'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+        
+    </ul>
+    
+    <h3>{% trans 'Recruitment' %}</h3>
+    <ul>
+        <li>
+            <span class="label">{% trans 'Recruitment Status' %}:</span>
+            <span class="value">{{ object.recruitment_status.label }}</span>
+        </li>
+
+        <li class="subset">
+            <span class="legend">{% trans 'Recruitment Country' %}</span>
+            <ul>
+            {% for recruitment in object.trial_recruitment_country %}
+                <li>{{ recruitment.description }}{% if not forloop.last %}, {% endif %}</li>
+            {% endfor %}
+            </ul>
+        </li>
+        <li>
+
+            <span class="label">{% trans 'Planned Date of First Enrollment' %}:</span>
+            <span class="value">{{ object.enrollment_start_planned }}</span>
+        </li>
+        <li>
+            <table class="dataTable">
+                <tr>
+                    <th>{% trans 'Target Sample Size' %}:</th>
+
+                    <th>{% trans 'Gender (inclusion sex)' %}:</th>
+                    <th>{% trans 'Inclusion Minimum Age' %}:</th>
+                    <th>{% trans 'Inclusion Maximum Age' %}:</th>
+                </tr>
+                <tr>
+                    <td>{{ object.target_sample_size }}</td>
+                    <td>{{ object.gender }}</td>
+
+                    <td>{{ object.agemin_value }} {{ object.agemin_unit }}</td>
+                    <td>{{ object.agemax_value }} {{ object.agemax_unit }}</td>
+                </tr>
+            </table>
+        </li>
+        <li>
+            <p><span class="label">{% trans 'Inclusion Criteria' %}:</span></p>
+
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.inclusion_criteria %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.inclusion_criteria|linebreaksbr }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.inclusion_criteria %}
+                <div class="title">
+                    <h2>en</h2>
+
+                    <p>{{ object.inclusion_criteria|linebreaksbr }}</p>
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Exclusion Criteria' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.exclusion_criteria %}
+                <div class="title">
+
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.exclusion_criteria|linebreaksbr }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.exclusion_criteria %}
+                <div class="title">
+                    <h2>en</h2>
+                    <p>{{ object.exclusion_criteria|linebreaksbr }}</p>
+
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+        
+        {% if perms.reviewapp.add_remark %}  
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Recruitment'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+        
+    </ul>
+
+    <h3>{% trans 'Study Type' %}</h3>
+    <ul>
+
+        <li>
+            <p><span class="label">{% trans 'Study Design' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.study_design %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.study_design }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.study_design|linebreaksbr %}
+                <div class="title">
+
+                    <h2>en</h2>
+                    <p>{{ object.study_design|linebreaksbr }}</p>
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <table class="dataTable">
+
+                <tr>
+                    <th><span class="label">{% trans 'Expanded access program' %}</span></th>
+                    <th><span class="label">{% trans 'Study Purpose' %}</span></th>
+                    <th><span class="label">{% trans 'Intervention Assignment' %}</span></th>
+                    <th><span class="label">{% trans 'Number of arms' %}</span></th>
+                    <th><span class="label">{% trans 'Masking type' %}</span></th>
+
+                    <th><span class="label">{% trans 'Allocation type' %}</span></th>
+                    <th><span class="label">{% trans 'Study Phase' %}</span></th>
+                </tr>
+                <tr>
+                    <td><span class="value">
+                        <img src="{% admin_media_prefix %}img/admin/icon-{% if object.expanded_access_program %}yes{% else %}{% if object.expanded_access_program == None %}unknown{% else %}no{% endif %}{% endif %}.gif"
+                            alt="{{ object.expanded_access_program|yesno }}"/> {{ object.expanded_access_program|yesno }}
+                    </span></td>
+                    <td><span class="value">
+                        {% for_trans_obj object.purpose.translations as t %}
+                        {{ t.language }}: {{ t.label }}<br/>
+                        {% endfor_trans_obj %}
+                    </span></td>
+                    <td><span class="value">
+                        {% for_trans_obj object.intervention_assignment.translations as t %}
+                        {{ t.language }}: {{ t.label }}<br/>
+                        {% endfor_trans_obj %}
+                    </span></td>
+
+                    <td><span class="value">{{ object.number_of_arms }}</span></td>
+                    <td><span class="value">
+                        {% for_trans_obj object.masking.translations as t %}
+                        {{ t.language }}: {{ t.label }}<br/>
+                        {% endfor_trans_obj %}
+                    </span></td>
+                    <td><span class="value">
+                        {% for_trans_obj object.allocation.translations as t %}
+                        {{ t.language }}: {{ t.label }}<br/>
+                        {% endfor_trans_obj %}
+                    </span></td>
+                    <td><span class="value">
+                        {% for_trans_obj object.phase.translations as t %}
+                        {{ t.language }}: {{ t.label }}<br/>
+                        {% endfor_trans_obj %}
+                    </span></td>
+                </tr>
+            </table>
+        </li>
+
+        {% if perms.reviewapp.add_remark %}   
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Study Type'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+        
+    </ul>
+    
+    <h3>{% trans 'Outcomes' %}</h3>
+    <ul>
+        <li>
+            <p><span class="label">{% trans 'Primary Outcomes' %}:</span></p>
+            {% for outcome in object.primary_outcomes %}
+                {% for out_trans in outcome.translations_all|dictsortreversed:"language" %}
+                    {% if out_trans.description %}
+                    <div class="title">
+                        <h2>{{ out_trans.language }}</h2>
+
+                        <p>{{ out_trans.description|linebreaksbr }}</p>
+                    </div>
+                    {% endif %}
+                {% endfor %}
+                {% if outcome.description %}
+                    <div class="title">
+                        <h2>en</h2>
+                        <p>{{ outcome.description|linebreaksbr }}</p>
+                    </div>
+                {% endif %}
+                <div class="spacer"> </div>
+
+            {% endfor %}
+        </li>
+        <li>
+            <p><span class="label">{% trans 'Secondary Outcomes' %}:</span></p>
+            {% for outcome in object.secondary_outcomes %}
+                {% for out_trans in outcome.translations_all|dictsortreversed:"language" %}
+                    {% if out_trans.description %}
+                    <div class="title">
+                        <h2>{{ out_trans.language }}</h2>
+                        <p>{{ out_trans.description|linebreaksbr }}</p>
+
+                    </div>
+                    {% endif %}
+                {% endfor %}
+                {% if outcome.description %}
+                    <div class="title">
+                        <h2>en</h2>
+                        <p>{{ outcome.description|linebreaksbr }}</p>
+                    </div>
+                {% endif %}
+                <div class="spacer"> </div>
+
+            {% endfor %}
+        </li>
+        
+        {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Outcomes'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+    </ul>
+    
+    <h3>{% trans 'Contacts' %}</h3>
+    <ul>
+        {% if object.public_contacts %}
+        <li class="subset">
+            <span class="legend">{% trans 'Contacts for Public Queries' %}</span>
+
+            {% for contact in object.public_contacts %}
+            <ul class="vcard">
+                <li>
+                    <b>{% trans 'Full Name' %}:</b>
+                    <span class="fn">{{ contact.firstname }} {{ contact.middlename }} {{ contact.lastname }}</span>
+                </li>
+                <li>
+                    <ul class="adr">
+
+                        <li>
+                            <b>{% trans 'Address' %}:</b>
+                            <span class="street-address">{{ contact.address }}</span>
+                        </li>
+                        <li>
+                            <b>{% trans 'City' %}: </b>
+                            <span><span class="locality">{{ contact.city }}</span> / <span class="country-name">{{ contact.country }}</span></span>
+
+                        </li>
+                        <li>
+                            <b>{% trans 'Zip Code' %}:</b>
+                            <span class="postal-code">{{ contact.zip }}</span>
+                        </li>
+                    </ul>
+                </li>
+                <li>
+
+                    <b>{% trans 'Telephone' %}:</b>
+                    <span class="tel">{{ contact.telephone }}</span>
+                </li>
+                <li>
+                    <b>E-mail:</b>
+                    <span class="email">{{ contact.email }}</span>
+                </li>
+
+                <li>
+                    <b>{% trans 'Affiliation' %}:</b>
+                    <span class="org">{{ contact.affiliation }}</span>
+                </li>
+            </ul>
+            {% if forloop.counter|divisibleby:3 and not forloop.last %}
+                <hr class="spacer" size="1"/>
+            {% endif %}
+            {% if forloop.last %}
+                <div class="spacer">&nbsp;</div>
+
+            {% endif %}
+            {% endfor %}
+        </li>
+        {% endif %}
+        
+        {% if object.scientific_contacts %}
+        <li class="subset">
+            <span class="legend">{% trans 'Contacts for Scientific Queries' %}</span>
+            {% for contact in object.scientific_contacts %}
+            <ul class="vcard">
+                <li>
+                    <b>{% trans 'Full Name' %}:</b>
+
+                    <span class="fn">{{ contact.firstname }} {{ contact.middlename }} {{ contact.lastname }}</span>
+                </li>
+                <li>
+                    <ul class="adr">
+                        <li>
+                            <b>{% trans 'Address' %}:</b>
+                            <span class="street-address">{{ contact.address }}</span>
+
+                        </li>
+                        <li>
+                            <b>{% trans 'City' %}: </b>
+                            <span><span class="locality">{{ contact.city }}</span> / <span class="country-name">{{ contact.country }}</span></span>
+                        </li>
+                        <li>
+
+                            <b>{% trans 'Zip Code' %}:</b>
+                            <span class="postal-code">{{ contact.zip }}</span>
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    <b>{% trans 'Telephone' %}:</b>
+
+                    <span class="tel">{{ contact.telephone }}</span>
+                </li>
+                <li>
+                    <b>E-mail:</b>
+                    <span class="email">{{ contact.email }}</span>
+                </li>
+                <li>
+
+                    <b>{% trans 'Affiliation' %}:</b>
+                    <span class="org">{{ contact.affiliation }}</span>
+                </li>
+            </ul>
+            {% if forloop.counter|divisibleby:3 and not forloop.last %}
+                <hr class="spacer" size="1"/>
+            {% endif %}
+            {% if forloop.last %}
+                <div class="spacer">&nbsp;</div>
+            {% endif %}
+            {% endfor %}
+        </li>
+
+        {% endif %}
+
+
+        {% if object.site_contacts %}
+        <li class="subset">
+            <span class="legend">{% trans 'Contact(s) for Site Queries' %}</span>
+            {% for contact in object.site_contacts %}
+            <ul class="vcard">
+                <li>
+                    <b>{% trans 'Full Name' %}:</b>
+                    <span class="fn">{{ contact.firstname }} {{ contact.middlename }} {{ contact.lastname }}</span>
+
+                </li>
+                <li>
+                    <ul class="adr">
+                        <li>
+                            <b>{% trans 'Address' %}:</b>
+                            <span class="street-address">{{ contact.address }}</span>
+                        </li>
+                        <li>
+
+                            <b>{% trans 'City' %}: </b>
+                            <span><span class="locality">{{ contact.city }}</span> / <span class="country-name">{{ contact.country }}</span></span>
+                        </li>
+                        <li>
+                            <b>{% trans 'Zip Code' %}:</b>
+                            <span class="postal-code">{{ contact.zip }}</span>
+
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    <b>{% trans 'Telephone' %}:</b>
+                    <span class="tel">{{ contact.telephone }}</span>
+                </li>
+                <li>
+
+                    <b>E-mail:</b>
+                    <span class="email">{{ contact.email }}</span>
+                </li>
+                <li>
+                    <b>{% trans 'Affiliation' %}:</b>
+                    <span class="org">{{ contact.affiliation }}</span>
+                </li>
+
+            </ul>
+            {% if forloop.counter|divisibleby:3 and not forloop.last %}
+                <hr class="spacer" size="1"/>
+            {% endif %}
+            {% if forloop.last %}
+                <div class="spacer">&nbsp;</div>
+            {% endif %}
+            {% endfor %}
+        </li>
+        {% endif %}
+        
+        {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Contacts'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+        
+    </ul>
+
+    {% if object.trial_attach %}
+        <h3>{% trans 'Attachments' %}</h3>
+        <ul>
+            {%  for attach in object.trial_attach %}
+                <li>
+                <a href="http://{{host}}{{attach.get_relative_url}}">
+                http://{{host}}{{attach.get_relative_url}}</a>
+                ({{ attach.description }})
+                </li>
+            {% endfor %}
+            {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Attachments'|slugify %}">{% trans 'Remark' %}</a></li>
+            {% endif %}
+        </ul>
+    {% endif %}
+    
+{% endblock %}
+
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/new-clinicaltrial_detail_published.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/new-clinicaltrial_detail_published.html (revision 902)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/new-clinicaltrial_detail_published.html (revision 902)
@@ -0,0 +1,598 @@
+{% extends "base.html" %}
+
+{% load i18n repository_tags adminmedia %}
+
+{% block body_title %}{% trans 'Clinical Trial' %}{% endblock %}
+
+{% block extrahead %}
+<style type="text/css">
+    span.label, span.legend {
+        font-weight: bold;
+    }
+    span.legend {
+        display: block;
+        margin: 0.5em 0;
+        text-decoration: underline;
+    }
+    .mainContent ul li {
+        margin-bottom: 1em;
+    }
+    .mainContent li.subset {
+        border: 1px solid silver;
+        padding: 0.5em;
+        clear: both;
+    }
+    .mainContent li.subset ul {
+        padding: 0em;
+    }
+    .mainContent li.subset .odd {
+        background-color: #F4F9FD;
+    }
+    .mainContent li.subset ul.vcard {
+        float: left;
+        width: 33%;
+        margin: 1.5em 0 1em;
+    }
+    div.title {
+      margin-left: 1%;
+      border: 4px solid #CCC;
+      border-radius: 16px;
+      -moz-border-radius: 16px;
+      -webkit-border-radius: 16px;
+      margin-bottom: 2em;
+      background: #EEE;
+      overflow: hidden;
+      padding: 0;
+      width: 31%;
+      float: left;
+    }
+    
+    div.title h2 {
+      color: #CCC;
+      font-size: 18pt;
+      line-height: 54pt;
+      margin-top: -16px;
+      margin-right: 10px;
+      font-variant: small-caps;
+      letter-spacing: -1pt;
+      text-align: right;
+    }
+
+    html > body div.title h2 {
+      margin-bottom: -30pt;
+    }
+
+    div.title p {
+      margin-left: 14pt;
+      line-height: 200%;
+      margin-right: 14pt;
+    }
+</style>
+{% endblock %}
+
+{% block stepmenu_top %}
+    {{ block.super }}
+    <small>
+        / <a href="{% url repository.index %}">{% trans 'Registered Trials' %}</a>
+    </small>
+    <big>/ {{ object.identifier }}</big>
+{% endblock %}
+
+{% block body %}
+
+    <h2>{{ scientific_title }} - {{register_number}}</h2>
+    
+    <h3>{% trans 'Scientific Title' %}:</h3>
+        {% for_trans translations as t %}
+            {% if t.scientific_title %}
+            <div class="title">
+                <h2>{{ t.language }}</h2>
+                <p>{{ t.scientific_title }}</p>
+            </div>
+            {% endif %}
+        {% endfor_trans %}
+        <div class="spacer"> </div>
+    <h3>{% trans 'Trial Identification' %}</h3>
+    <ul>
+        <li>
+            <p><span class="label">{% trans 'Public Title' %}:</span></p>
+            {% for_trans translations as t %}
+                {% if t.public_title %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.public_title }}</p>
+                </div>
+                {% endif %}
+            {% endfor_trans %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Scientific Acronym' %}:</span></p>
+            {% for_trans translations as t %}
+                {% if t.scientific_acronym %} 
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.scientific_acronym }}: {{ t.scientific_acronym_expansion }}</p>
+                </div>
+                {% endif %}
+            {% endfor_trans %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Public Acronym' %}:</span></p>
+            {% for_trans translations as t %}
+                {% if t.acronym %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.acronym }}: {{ t.acronym_expansion }}</p>
+                </div>
+                {% endif %}
+            {% endfor_trans %}
+        </li>
+        <div class="spacer"> </div>
+        <li class="subset">
+            <span class="legend">{% trans 'Secondary Identifying Numbers' %}:</span>
+            {% for secid in object.trial_number %}
+            <ul class="{% cycle 'even' 'odd' %}">
+                <li>
+                    <span class="label">{{ secid.id_number }}</span><br />
+                    <span class="value">{% trans 'Issuing Authority' %}:</span>
+                    <span class="value">{{ secid.issuing_authority }}</span>
+                </li>
+            </ul>
+            {% endfor %}
+        </li>
+    </ul>
+
+    <h3>{% trans 'Sponsors' %}</h3>
+    <ul>
+        <li>
+            <span class="label">{% trans 'Primary Sponsor' %}:</span>
+            <span class="value">{{ object.primary_sponsor.name }}</span>
+        </li>
+        {% if object.secondary_sponsors %}
+        <li class="subset">
+            <span class="legend">{% trans 'Secondary Sponsors' %}:</span>
+            <ul>
+            {%  for sponsors in object.secondary_sponsors %}
+                <li class="{% cycle 'even' 'odd' %}">
+                    <span class="label">{% trans 'Institution' %}:</span>
+                    <span class="value">{{ sponsors.institution.name }}</span>
+                </li>
+            {% endfor %}
+            </ul>
+        </li>
+        {% endif %}
+        
+        {% if object.support_sources %}
+        <li class="subset">
+            <span class="legend">{% trans 'Source(s) of Monetary or Material Support' %}:</span>
+            <ul>
+            {%  for source_support in object.support_sources %}
+                <li class="{% cycle 'even' 'odd' %}">
+                    <span class="label">{% trans 'Institution' %}:</span>
+                    <span class="value">{{ source_support.institution.name }}</span>
+                </li>
+            {% endfor %}
+            </ul>
+        </li>
+        {% endif %}
+    </ul>
+    
+    <h3>{% trans 'Health Conditions' %}</h3>
+    <ul>
+        <li>
+        <p><span class="label">{% trans 'Health Condition(s) or Problem(s)' %}:</span></p>
+            {% for_trans translations as t %}
+                {% if t.hc_freetext %} 
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.hc_freetext }}</p>
+                </div>
+                {% endif %}
+            {% endfor_trans %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'General Descriptors for Health Condition(s)' %}:</span></p>
+            {% for hc in object.hc_code %}
+                {% for_trans hc.translations as hc_trans %}
+                    {% if hc_trans.text %}
+                    <div class="title">
+                        <h2>{{ hc_trans.language }}</h2>
+                        <p>
+                            <span class="label">{{ hc.code }}:</span>
+                            <span class="value">{{ hc_trans.text }}</span>
+                        </p>
+                    </div>
+                    {% endif %}
+                {% endfor_trans %}
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+        <li>
+            <p><span class="label">{% trans 'Specific Descriptors for Health Condition(s)' %}:</span></p>
+            {% for hc in object.hc_keyword %}
+                {% for_trans hc.translations as hc_trans %}
+                    {% if hc_trans.text %}
+                    <div class="title">
+                        <h2>{{ hc_trans.language }}</h2>
+                        <p>
+                            <span class="label">{{ hc.code }}:</span>
+                            <span class="value">{{ hc_trans.text }}</span>
+                        </p>
+                    </div>
+                    {% endif %}
+                {% endfor_trans %}
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+    </ul>
+    
+    <h3>{% trans 'Interventions' %}</h3>
+    <ul>
+        <li class="subset">
+            <span class="legend">{% trans 'Intervention Code(s)' %}</span>
+            <ul>
+            {% for iv in object.i_code %}
+                <li>
+                    <span class="label">{{ iv.description|default:iv.label }}</span>
+                </li>
+            {% endfor %}
+            </ul>
+        </li>
+        <li>
+        <p><span class="label">{% trans 'Interventions' %}:</span></p>
+            {% for_trans translations as t %}
+                {% if t.i_freetext %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.i_freetext|linebreaksbr }}</p>
+                </div>
+                {% endif %}
+            {% endfor_trans %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Descriptor for Intervention(s)' %}:</span></p>
+            {% for intervention in object.intervention_keyword %}
+                {% for_trans intervention.translations as i_trans %}
+                    {% if i_trans.text %}
+                    <div class="title">
+                        <h2>{{ i_trans.language }}</h2>
+                        <p>
+                            <span class="label">{{ intervention.code }}:</span>
+                            <span class="value">{{ i_trans.text }}</span>
+                        </p>
+                    </div>
+                    {% endif %}
+                {% endfor_trans %}
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+    </ul>
+    
+    <h3>{% trans 'Recruitment' %}</h3>
+    <ul>
+        <li>
+            <span class="label">{% trans 'Recruitment Status' %}:</span>
+            <span class="value">{{ object.rec_status }}</span>
+        </li>
+        <li class="subset">
+            <span class="legend">{% trans 'Recruitment Country' %}</span>
+            <ul>
+            {% for recruitment in object.recruitment_country %}
+                <li>{{ recruitment.description }}{% if not forloop.last %}, {% endif %}</li>
+            {% endfor %}
+            </ul>
+        </li>
+        <li>
+            <span class="label">{% trans 'Planned Date of First Enrollment' %}:</span>
+            {% if object.enrollment_start_actual %}
+                <span class="value">{{ object.enrollment_start_actual }}</span>
+            {% else %}
+                <span class="value">{{ object.enrollment_start_planned }}</span>
+            {% endif %}
+        </li>
+        <li>
+            <table class="dataTable">
+                <tr>
+                    <th>{% trans 'Target Sample Size' %}:</th>
+                    <th>{% trans 'Gender (inclusion sex)' %}:</th>
+                    <th>{% trans 'Inclusion Minimum Age' %}:</th>
+                    <th>{% trans 'Inclusion Maximum Age' %}:</th>
+                </tr>
+                <tr>
+                    <td>{{ object.target_sample_size }}</td>
+                    <td>{{ object.gender }}</td>
+                    <td>{{ object.agemin_value }} {{ object.agemin_unit }}</td>
+                    <td>{{ object.agemax_value }} {{ object.agemax_unit }}</td>
+                </tr>
+            </table>
+        </li>
+        <li>
+            <p><span class="label">{% trans 'Inclusion Criteria' %}:</span></p>
+            {% for_trans translations as t %}
+                {% if t.inclusion_criteria %} 
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.inclusion_criteria|linebreaksbr }}</p>
+                </div>
+                {% endif %}
+            {% endfor_trans %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Exclusion Criteria' %}:</span></p>
+            {% for_trans translations as t %}
+                {% if t.exclusion_criteria %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.exclusion_criteria|linebreaksbr }}</p>
+                </div>
+                {% endif %}
+            {% endfor_trans %}
+        </li>
+        <div class="spacer"> </div>
+    </ul>
+
+    <h3>{% trans 'Study Type' %}</h3>
+    <ul>
+        <li>
+            <p><span class="label">{% trans 'Study Design' %}:</span></p>
+            {% for_trans translations as t %}
+                {% if t.study_design %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.study_design }}</p>
+                </div>
+                {% endif %}
+            {% endfor_trans %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <table class="dataTable">
+                <tr>
+                    <th><span class="label">{% trans 'Expanded access program' %}</span></th>
+                    <th><span class="label">{% trans 'Study Purpose' %}</span></th>
+                    <th><span class="label">{% trans 'Intervention Assignment' %}</span></th>
+                    <th><span class="label">{% trans 'Number of arms' %}</span></th>
+                    <th><span class="label">{% trans 'Masking type' %}</span></th>
+                    <th><span class="label">{% trans 'Allocation type' %}</span></th>
+                    <th><span class="label">{% trans 'Study Phase' %}</span></th>
+                </tr>
+                <tr>
+                    <td><span class="value">
+                        <img src="{% admin_media_prefix %}img/admin/icon-{% if object.expanded_access_program %}yes{% else %}{% if object.expanded_access_program == None %}unknown{% else %}no{% endif %}{% endif %}.gif"
+                            alt="{{ object.expanded_access_program|yesno }}"/> {{ object.expanded_access_program|yesno }}
+                    </span></td>
+                    <td><span class="value">
+                        {% for_trans object.purpose.translations as t %}
+                        {{ t.language }}: {{ t.label }}<br/>
+                        {% endfor_trans %}
+                    </span></td>
+                    <td><span class="value">
+                        {% for_trans object.intervention_assignment.translations as t %}
+                        {{ t.language }}: {{ t.label }}<br/>
+                        {% endfor_trans %}
+                    </span></td>
+                    <td><span class="value">{{ object.number_of_arms }}</span></td>
+                    <td><span class="value">
+                        {% for_trans object.masking.translations as t %}
+                        {{ t.language }}: {{ t.label }}<br/>
+                        {% endfor_trans %}
+                    </span></td>
+                    <td><span class="value">
+                        {% for_trans object.allocation.translations as t %}
+                        {{ t.language }}: {{ t.label }}<br/>
+                        {% endfor_trans %}
+                    </span></td>
+                    <td><span class="value">
+                        {% for_trans object.phase.translations as t %}
+                        {{ t.language }}: {{ t.label }}<br/>
+                        {% endfor_trans %}
+                    </span></td>
+                </tr>
+            </table>
+        </li>
+    </ul>
+    
+    <h3>{% trans 'Outcomes' %}</h3>
+    <ul>
+        <li>
+            <p><span class="label">{% trans 'Primary Outcomes' %}:</span></p>
+            {% for outcome in object.primary_outcomes %}
+                {% for_trans outcome.translations as out_trans %}
+                    {% if out_trans.description %} 
+                    <div class="title">
+                        <h2>{{ out_trans.language }}</h2>
+                        <p>{{ out_trans.description|linebreaksbr }}</p>
+                    </div>
+                    {% endif %}
+                {% endfor_trans %}
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+        <li>
+            <p><span class="label">{% trans 'Secondary Outcomes' %}:</span></p>
+            {% for outcome in object.secondary_outcomes %}
+                {% for_trans outcome.translations as out_trans %}
+                    {% if out_trans.description %}
+                    <div class="title">
+                        <h2>{{ out_trans.language }}</h2>
+                        <p>{{ out_trans.description|linebreaksbr }}</p>
+                    </div>
+                    {% endif %}
+                {% endfor_trans %}
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+    </ul>
+    
+    <h3>{% trans 'Contacts' %}</h3>
+    <ul>
+        {% if object.public_contact %}
+        <li class="subset">
+            <span class="legend">{% trans 'Contacts for Public Queries' %}</span>
+            {% for contact in object.public_contact %}
+            <ul class="vcard">
+                <li>
+                    <b>{% trans 'Full Name' %}:</b>
+                    <span class="fn">{{ contact.firstname }} {{ contact.middlename }} {{ contact.lastname }}</span>
+                </li>
+                <li>
+                    <ul class="adr">
+                        <li>
+                            <b>{% trans 'Address' %}:</b>
+                            <span class="street-address">{{ contact.address }}</span>
+                        </li>
+                        <li>
+                            <b>{% trans 'City' %}: </b>
+                            <span><span class="locality">{{ contact.city }}</span> /
+                                <span class="country-name">{{ contact.country.description }}</span></span>
+                        </li>
+                        <li>
+                            <b>{% trans 'Zip Code' %}:</b>
+                            <span class="postal-code">{{ contact.zip }}</span>
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    <b>{% trans 'Telephone' %}:</b>
+                    <span class="tel">{{ contact.telephone }}</span>
+                </li>
+                <li>
+                    <b>E-mail:</b>
+                    <span class="email">{{ contact.email }}</span>
+                </li>
+                <li>
+                    <b>{% trans 'Affiliation' %}:</b>
+                    <span class="org">{{ contact.affiliation.name }}</span>
+                </li>
+            </ul>
+            {% if forloop.counter|divisibleby:3 and not forloop.last %}
+                <hr class="spacer" size="1"/>
+            {% endif %}
+            {% if forloop.last %}
+                <div class="spacer">&nbsp;</div>
+            {% endif %}
+            {% endfor %}
+        </li>
+        {% endif %}
+        
+        {% if object.scientific_contact %}
+        <li class="subset">
+            <span class="legend">{% trans 'Contacts for Scientific Queries' %}</span>
+            {% for contact in object.scientific_contact %}
+            <ul class="vcard">
+                <li>
+                    <b>{% trans 'Full Name' %}:</b>
+                    <span class="fn">{{ contact.firstname }} {{ contact.middlename }} {{ contact.lastname }}</span>
+                </li>
+                <li>
+                    <ul class="adr">
+                        <li>
+                            <b>{% trans 'Address' %}:</b>
+                            <span class="street-address">{{ contact.address }}</span>
+                        </li>
+                        <li>
+                            <b>{% trans 'City' %}: </b>
+                            <span><span class="locality">{{ contact.city }}</span> / <span class="country-name">{{ contact.country.description }}</span></span>
+                        </li>
+                        <li>
+                            <b>{% trans 'Zip Code' %}:</b>
+                            <span class="postal-code">{{ contact.zip }}</span>
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    <b>{% trans 'Telephone' %}:</b>
+                    <span class="tel">{{ contact.telephone }}</span>
+                </li>
+                <li>
+                    <b>E-mail:</b>
+                    <span class="email">{{ contact.email }}</span>
+                </li>
+                <li>
+                    <b>{% trans 'Affiliation' %}:</b>
+                    <span class="org">{{ contact.affiliation.name }}</span>
+                </li>
+            </ul>
+            {% if forloop.counter|divisibleby:3 and not forloop.last %}
+                <hr class="spacer" size="1"/>
+            {% endif %}
+            {% if forloop.last %}
+                <div class="spacer">&nbsp;</div>
+            {% endif %}
+            {% endfor %}
+        </li>
+        {% endif %}
+
+
+        {% if object.site_contact %}
+        <li class="subset">
+            <span class="legend">{% trans 'Contact(s) for Site Queries' %}</span>
+            {% for contact in object.site_contact %}
+            <ul class="vcard">
+                <li>
+                    <b>{% trans 'Full Name' %}:</b>
+                    <span class="fn">{{ contact.firstname }} {{ contact.middlename }} {{ contact.lastname }}</span>
+                </li>
+                <li>
+                    <ul class="adr">
+                        <li>
+                            <b>{% trans 'Address' %}:</b>
+                            <span class="street-address">{{ contact.address }}</span>
+                        </li>
+                        <li>
+                            <b>{% trans 'City' %}: </b>
+                            <span><span class="locality">{{ contact.city }}</span> / <span class="country-name">{{ contact.country.description }}</span></span>
+                        </li>
+                        <li>
+                            <b>{% trans 'Zip Code' %}:</b>
+                            <span class="postal-code">{{ contact.zip }}</span>
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    <b>{% trans 'Telephone' %}:</b>
+                    <span class="tel">{{ contact.telephone }}</span>
+                </li>
+                <li>
+                    <b>E-mail:</b>
+                    <span class="email">{{ contact.email }}</span>
+                </li>
+                <li>
+                    <b>{% trans 'Affiliation' %}:</b>
+                    <span class="org">{{ contact.affiliation }}</span>
+                </li>
+            </ul>
+            {% if forloop.counter|divisibleby:3 and not forloop.last %}
+                <hr class="spacer" size="1"/>
+            {% endif %}
+            {% if forloop.last %}
+                <div class="spacer">&nbsp;</div>
+            {% endif %}
+            {% endfor %}
+        </li>
+        {% endif %}
+    </ul>
+
+    {% if object.previous_revision %}
+    <div>
+        <a href="{% url repository.trial_registered trial_fossil_id=object.previous_revision.pk %}">
+            {% trans 'Previous Revision' %}</a>
+    </div>
+    {% endif %}
+
+    {% block attachs %}{% endblock %}
+
+    {% block additional_links %}
+    <h3>{% trans 'Additional Links' %}:</h3>
+    <ul>
+        <li><a href="{% url repository.trial_ictrp_version trial_fossil_id=object.trial_id,trial_version=object.version %}">
+            {% trans "Download as ICTRP format" %}</a></li>
+    </ul>
+    {% endblock %}
+    
+{% endblock %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/submission_step.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/submission_step.html (revision 564)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/submission_step.html (revision 564)
@@ -0,0 +1,36 @@
+{% extends "base.html" %}
+{% load i18n %}
+{% block body_title %}{% trans forms.form_main.title %}{% endblock %}
+
+{% block extrahead %}
+    {# Shows forms scripts and css #}
+    {% for form in forms %}{{ form.media }}{% endfor %}
+{% endblock extrahead %}
+
+{% block stepmenu_top %}
+    <small>
+        <a href="{% url repository.edittrial trial_pk %}">{% trans "Summary" %}</a>
+    </small>
+    {% for step in steps %}
+    <span> | </span>
+    <small{% if step.is_current %} class="current"{% endif %}>
+        <a href="{{ step.link }}">{% trans step.name %}</a>
+    </small>
+    {% endfor %}
+    <div style="float:right; margin-right:20px;">
+        <small><a href="{% url repository.trialview trial_pk %}">{% trans 'Preview' %}</a></small>
+    </div>
+{% endblock %}
+
+{% block stepmenu_bottom %}
+<div class="stepmenu stepmenu-bottom">
+    <ul>
+        <li><a href="{% url repository.edittrial trial_pk %}">{% trans "Summary" %}</a></li>
+        {% for step in steps %}
+        <li{% if step.is_current %} class="current"{% endif %}>
+            <a href="{{ step.link }}">{% trans step.name %}</a>
+        </li>
+        {% endfor %}
+    </ul>
+</div>
+{% endblock %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/clinicaltrial_detail_user.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/clinicaltrial_detail_user.html (revision 994)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/clinicaltrial_detail_user.html (revision 994)
@@ -0,0 +1,877 @@
+{% extends "base.html" %}
+
+{% load i18n %}
+
+{% block body_title %}{% trans 'Clinical Trial' %}{% endblock %}
+
+{% block extrahead %}
+<style type="text/css">
+    span.label, span.legend {
+        font-weight: bold;
+    }
+    span.legend {
+        display: block;
+        margin: 0.5em 0;
+        text-decoration: underline;
+    }
+    .mainContent ul li {
+        margin-bottom: 1em;
+    }
+    .mainContent li.subset {
+        border: 1px solid silver;
+        padding: 0.5em;
+        clear: both;
+    }
+    .mainContent li.subset ul {
+        padding: 0em;
+    }
+    .mainContent li.subset .odd {
+        background-color: #F4F9FD;
+    }
+    .mainContent li.subset ul.vcard {
+        float: left;
+        width: 33%;
+        margin: 1.5em 0 1em;
+    }
+    div.title {
+      margin-left: 1%;
+      border: 4px solid #CCC;
+      border-radius: 16px;
+      -moz-border-radius: 16px;
+      -webkit-border-radius: 16px;
+      margin-bottom: 2em;
+      background: #EEE;
+      overflow: hidden;
+      padding: 0;
+      width: 31%;
+      float: left;
+    }
+
+    div.title h2 {
+      color: #CCC;
+      font-size: 18pt;
+      line-height: 54pt;
+      margin-top: -16px;
+      margin-right: 10px;
+      font-variant: small-caps;
+      letter-spacing: -1pt;
+      text-align: right;
+    }
+
+    html > body div.title h2 {
+      margin-bottom: -30pt;
+    }
+
+    div.title p {
+      margin-left: 14pt;
+      line-height: 200%;
+      margin-right: 14pt;
+    }
+</style>
+{% endblock %}
+
+{% block stepmenu_top %}
+    <small>
+        <a href="{% url reviewapp.home %}">{% trans 'Home' %}</a>
+    </small>
+    <small>
+        / <a href="{% url reviewapp.submissionlist %}">{% trans 'Submissions' %}</a>
+    </small>
+    <small>
+        / <a href="{% url repository.edittrial object.pk %}">{% trans "Summary" %}</a>
+    </small>
+    <big>/ Trial {{ object }}</big>
+{% endblock %}
+
+{% block body %}
+
+    <div class="review_buttons" {% if not review_mode %}style="display:none;"{% endif %}>
+          <form action="{% url reviewapp.change_submission_status object.submission.pk 'approved' %}" method="POST" style="display:inline;">
+          {% csrf_token %}
+          <input id="approve_review" type="submit" style="font-size: 80%;" value="{% trans 'Approve Submission' %}" title="{% trans 'Approve Submission' %}" {% if not can_approve %} disabled="disabled" {% endif %} />
+          </form>
+          <form action="{% url reviewapp.change_submission_status object.submission.pk 'resubmit' %}" method="POST" style="display:inline;">
+          {% csrf_token %}
+          <input id="resubmit_review" type="submit" style="font-size: 80%;" value="{% trans 'Resubmit Submission' %}" title="{% trans 'Resubmit Submission' %}" {% if not can_resubmit %} disabled="disabled" {% endif %} />
+          </form>
+      </div>
+
+    {% if remark_list %}
+    <div class="warning">
+        <a class="minimize button" onclick="$(this.parentNode).toggleClass('warning-minimized').find('ul').toggle('slow')"><img src="{{MEDIA_URL}}media/img/admin/arrow-down.gif"/></a>
+        <a class="maximize button" onclick="$(this.parentNode).toggleClass('warning-minimized').find('ul').toggle('slow')"><img src="{{MEDIA_URL}}media/img/admin/arrow-up.gif"/></a>
+        <h2>{% trans 'Remarks' %}</h2>
+        <ul>
+            {% for remarks in remark_list %}
+                {% for remark in remarks %}
+                <li id="remark_{{ remark.id }}"><b>{% trans remark.context_title %}:</b> {{ remark.text }}
+                {% if review_mode %}
+                    {% if remark.status == 'open' %}
+                        <br />{% trans 'Status' %}: {% trans "Open (awaiting revision)" %}
+
+                        <form action="{% url reviewapp.delete_remark remark.pk %}" method="POST">
+                        {% csrf_token %}
+                        <input id="remark-delete" type="submit" style="font-size: 80%;" value="{% trans 'Delete' %}" title="{% trans 'Delete' %}" />
+                        </form>
+
+                    {% endif %}
+                    {% if remark.status == 'acknowledged' %}
+                        <br />{% trans 'Status' %}: {% trans "Revised" %}
+                        <br />
+                        <form action="{% url reviewapp.changeremarkstatus remark.pk 'closed' %}" method="POST" style="display:inline;">
+                        {% csrf_token %}
+                        <input id="remark-approve" type="submit" style="font-size: 80%;" value="{% trans 'Approve' %}" title="{% trans 'Approve' %}" />
+                        </form>
+                        <form action="{% url reviewapp.changeremarkstatus remark.pk 'open' %}" method="POST" style="display:inline;">
+                        {% csrf_token %}
+                        <input id="remark-reopen" type="submit" style="font-size: 80%;" value="{% trans 'Reopen' %}" title="{% trans 'Reopen' %}" />
+                        </form>
+                    {% endif %}
+                {% else %}
+                    {% if remark.status == 'open' %}
+                        <br />{% trans 'Status' %}: {% trans "Mark as reviewed" %}
+                        <br />
+                        <form action="{% url reviewapp.changeremarkstatus remark.pk 'acknowledged' %}" method="POST" style="display:inline;">
+                        {% csrf_token %}
+                        <input id="remark-acknowledged" type="submit" style="font-size: 80%;" value="{% trans 'Mark as reviewed' %}" title="{% trans 'Mark as reviewed' %}" />
+                        </form>
+                    {% endif %}
+                    {% if remark.status == 'acknowledged' %}
+                        <br />{% trans 'Status' %}: {% trans "Revised (awaiting approval)" %}
+                    {% endif %}
+                {% endif %}
+                {% if remark.status == 'closed' %}
+                    <br />{% trans 'Status' %}: {% trans "Closed" %}
+                {% endif %}
+                </li>
+                {% endfor %}
+            {% endfor %}
+        </ul>
+    </div>
+    {% endif %}
+
+    <h2>{{ object.scientific_title }}</h2>
+
+
+    <h3>{% trans 'Study Type' %}:</h3>
+        {% if object.is_observational %}
+            <p>{% trans 'Observational Study' %}</p>
+        {% else %}
+            <p>{% trans 'Intervention Study' %}</p>
+        {% endif %}
+        <div class="spacer"> </div>
+
+    {% if object.is_observational %}
+    <h3>{% trans 'Observational Study Fields' %}:</h3>
+    <ul>
+        <li>
+            <span class="label">{% trans 'Time Perspective' %}: </span>
+            <span class="value">{{ object.time_perspective }}</span>
+        </li>
+        <li>
+            <span class="label">{% trans 'Observational Study Design' %}: </span>
+            <span class="value">{{ object.observational_study_design }}</span>
+        </li>
+    </ul>
+    {% endif %}
+    <div class="spacer"> </div>
+
+    <h3>{% trans 'Scientific Title' %}:</h3>
+        {% for t in translations|dictsortreversed:"language" %}
+            {% if t.scientific_title %}
+            <div class="title">
+                <h2>{{ t.language }}</h2>
+                <p>{{ t.scientific_title }}</p>
+            </div>
+            {% endif %}
+        {% endfor %}
+        {% if object.scientific_title %}
+            <div class="title">
+
+                <h2>en</h2>
+                <p>{{ object.scientific_title }}</p>
+            </div>
+        {% endif %}
+        <div class="spacer"> </div>
+
+    <h3>{% trans 'Trial Identification' %}</h3>
+    <ul>
+        <li>
+            <span class="label">{% trans 'UTN Number' %}: </span>
+            <span class="value">{{ object.utrn_number }}</span>
+        </li>
+        <li>
+            <p><span class="label">{% trans 'Public Title' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.public_title %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.public_title }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.public_title %}
+                <div class="title">
+
+                    <h2>en</h2>
+                    <p>{{ object.public_title }}</p>
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Scientific Acronym' %}:</span></p>
+
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.scientific_acronym %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.scientific_acronym }}: {{ t.scientific_acronym_expansion }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.scientific_acronym %}
+                <div class="title">
+                    <h2>en</h2>
+
+                    <p>{{ object.scientific_acronym_display }}</p>
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Public Acronym' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.acronym %}
+                <div class="title">
+
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.acronym }}: {{ t.acronym_expansion }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.acronym %}
+                <div class="title">
+                    <h2>en</h2>
+                    <p>{{ object.acronym_display }}</p>
+
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+        <li class="subset">
+            <span class="legend">{% trans 'Secondary Identifying Numbers' %}:</span>
+            {% for secid in object.trial_number %}
+            <ul class="{% cycle 'even' 'odd' %}">
+                <li>
+
+                    <span class="label">{{ secid.id_number }}</span><br />
+                    <span class="value">{% trans 'Issuing Authority' %}:</span>
+                    <span class="value">{{ secid.issuing_authority }}</span>
+                </li>
+            </ul>
+            {% endfor %}
+        </li>
+
+        {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Trial Identification'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+
+    </ul>
+
+    <h3>{% trans 'Sponsors' %}</h3>
+    <ul>
+        <li>
+            <span class="label">{% trans 'Primary Sponsor' %}:</span>
+            <span class="value">{{ object.primary_sponsor.name }}</span>
+        </li>
+        {% if object.secondary_sponsors %}
+        <li class="subset">
+
+            <span class="legend">{% trans 'Secondary Sponsors' %}:</span>
+            <ul>
+            {%  for sponsors in object.secondary_sponsors %}
+                <li class="{% cycle 'even' 'odd' %}">
+                    <span class="label">{% trans 'Institution' %}:</span>
+                    <span class="value">{{ sponsors.institution.name }}</span>
+                </li>
+            {% endfor %}
+            </ul>
+
+        </li>
+        {% endif %}
+        <li class="subset">
+            <span class="legend">{% trans 'Source(s) of Monetary or Material Support' %}:</span>
+            <ul>
+            {%  for source_support in object.support_sources %}
+                <li class="{% cycle 'even' 'odd' %}">
+                    <span class="label">{% trans 'Institution' %}:</span>
+                    <span class="value">{{ source_support.institution }}</span>
+
+                </li>
+            {% endfor %}
+            </ul>
+        </li>
+
+        {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Sponsors'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+
+    </ul>
+
+    <h3>{% trans 'Health Conditions' %}</h3>
+    <ul>
+        <li>
+
+        <p><span class="label">{% trans 'Health Condition(s) or Problem(s)' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.hc_freetext %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.hc_freetext }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.hc_freetext %}
+                <div class="title">
+
+                    <h2>en</h2>
+                    <p>{{ object.hc_freetext }}</p>
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'General Descriptors for Health Condition(s)' %}:</span></p>
+
+            {% for hc in object.hc_code %}
+                {% for hc_trans in hc.translations_all|dictsortreversed:"language" %}
+                    {% if hc_trans.text %}
+                    <div class="title">
+                        <h2>{{ hc_trans.language }}</h2>
+                        <p>
+                            <span class="label">{{ hc.code }}:</span>
+                            <span class="value">{{ hc_trans.text }}</span>
+                        </p>
+                    </div>
+
+                    {% endif %}
+                {% endfor %}
+                {% if hc.text %}
+                    <div class="title">
+                        <h2>en</h2>
+                        <p>
+                            <span class="label">{{ hc.code }}:</span>
+                            <span class="value">{{ hc.text }}</span>
+                        </p>
+                    </div>
+
+                {% endif %}
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+        <li>
+            <p><span class="label">{% trans 'Specific Descriptors for Health Condition(s)' %}:</span></p>
+            {% for hc in object.hc_keyword %}
+                {% for hc_trans in hc.translations_all|dictsortreversed:"language" %}
+                    {% if hc_trans.text %}
+                    <div class="title">
+                        <h2>{{ hc_trans.language }}</h2>
+
+                        <p>
+                            <span class="label">{{ hc.code }}:</span>
+                            <span class="value">{{ hc_trans.text }}</span>
+                        </p>
+                    </div>
+                    {% endif %}
+                {% endfor %}
+                {% if hc.text %}
+                    <div class="title">
+                        <h2>en</h2>
+
+                        <p>
+                            <span class="label">{{ hc.code }}:</span>
+                            <span class="value">{{ hc.text }}</span>
+                        </p>
+                    </div>
+                {% endif %}
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+
+        {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Health Conditions'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+
+    </ul>
+
+    <h3>{% trans 'Interventions' %}</h3>
+    <ul>
+        <li class="subset">
+            <span class="legend">{% trans 'Intervention Code(s)' %}</span>
+            <ul>
+            {% for iv in object.intervention_code %}
+                <li>
+
+                    <span class="label">{{ iv.label }}</span>
+                </li>
+            {% endfor %}
+            </ul>
+        </li>
+        <li>
+        <p><span class="label">{% trans 'Interventions' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.i_freetext %}
+                <div class="title">
+
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.i_freetext|linebreaksbr }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.i_freetext %}
+                <div class="title">
+                    <h2>en</h2>
+                    <p>{{ object.i_freetext|linebreaksbr }}</p>
+
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Descriptor for Intervention(s)' %}:</span></p>
+            {% for intervention in object.intervention_keyword %}
+                {% for i_trans in intervention.translations_all|dictsortreversed:"language" %}
+                    {% if i_trans.text %}
+                    <div class="title">
+                        <h2>{{ i_trans.language }}</h2>
+
+                        <p>
+                            <span class="label">{{ intervention.code }}:</span>
+                            <span class="value">{{ i_trans.text }}</span>
+                        </p>
+                    </div>
+                    {% endif %}
+                {% endfor %}
+                {% if intervention.text %}
+                    <div class="title">
+                        <h2>en</h2>
+                        <p>
+                            <span class="label">{{ intervention.code }}:</span>
+                            <span class="value">{{ intervention.text }}</span>
+                        </p>
+                    </div>
+                {% endif %}
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+
+        {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Interventions'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+
+    </ul>
+
+    <h3>{% trans 'Recruitment' %}</h3>
+    <ul>
+        <li>
+            <span class="label">{% trans 'Recruitment Status' %}:</span>
+            <span class="value">{{ object.recruitment_status.label }}</span>
+        </li>
+
+        <li class="subset">
+            <span class="legend">{% trans 'Recruitment Country' %}</span>
+            <ul>
+            {% for recruitment in object.trial_recruitment_country %}
+                <li>{{ recruitment.description }}{% if not forloop.last %}, {% endif %}</li>
+            {% endfor %}
+            </ul>
+        </li>
+        <li>
+            {% if enrollment_start_date %}
+                <span class="label">{% trans 'Planned Date of First Enrollment' %}:</span>
+                <span class="value">{{ enrollment_start_date }}</span>
+            {% endif %}
+        </li>
+        <li>
+            {% if enrollment_end_date %}
+                <span class="label">{% trans 'Planned Date of Last Enrollment' %}:</span>
+                <span class="value">{{ enrollment_end_date }}</span>
+            {% endif %}
+        </li>
+        <li>
+            <table class="dataTable">
+                <tr>
+                    <th>{% trans 'Target Sample Size' %}:</th>
+
+                    <th>{% trans 'Gender (inclusion sex)' %}:</th>
+                    <th>{% trans 'Inclusion Minimum Age' %}:</th>
+                    <th>{% trans 'Inclusion Maximum Age' %}:</th>
+                </tr>
+                <tr>
+                    <td>{{ object.target_sample_size }}</td>
+                    <td>{{ object.gender }}</td>
+
+                    <td>{{ object.agemin_value }} {{ object.agemin_unit }}</td>
+                    <td>{{ object.agemax_value }} {{ object.agemax_unit }}</td>
+                </tr>
+            </table>
+        </li>
+        <li>
+            <p><span class="label">{% trans 'Inclusion Criteria' %}:</span></p>
+
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.inclusion_criteria %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.inclusion_criteria|linebreaksbr }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.inclusion_criteria %}
+                <div class="title">
+                    <h2>en</h2>
+
+                    <p>{{ object.inclusion_criteria|linebreaksbr }}</p>
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Exclusion Criteria' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.exclusion_criteria %}
+                <div class="title">
+
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.exclusion_criteria|linebreaksbr }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.exclusion_criteria %}
+                <div class="title">
+                    <h2>en</h2>
+                    <p>{{ object.exclusion_criteria|linebreaksbr }}</p>
+
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+
+        {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Recruitment'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+
+    </ul>
+
+    <h3>{% trans 'Study Type' %}</h3>
+    <ul>
+
+        <li>
+            <p><span class="label">{% trans 'Study Design' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.study_design %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.study_design }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+            {% if object.study_design|linebreaksbr %}
+                <div class="title">
+
+                    <h2>en</h2>
+                    <p>{{ object.study_design|linebreaksbr }}</p>
+                </div>
+            {% endif %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <table class="dataTable">
+
+                <tr>
+                    <th><span class="label">{% trans 'Expanded access program' %}</span></th>
+                    <th><span class="label">{% trans 'Study Purpose' %}</span></th>
+                    <th><span class="label">{% trans 'Intervention Assignment' %}</span></th>
+                    <th><span class="label">{% trans 'Number of arms' %}</span></th>
+                    <th><span class="label">{% trans 'Masking type' %}</span></th>
+
+                    <th><span class="label">{% trans 'Allocation type' %}</span></th>
+                    <th><span class="label">{% trans 'Study Phase' %}</span></th>
+                </tr>
+                <tr>
+                    <td><span class="value">{{ object.expanded_access_program }}</span></td>
+                    <td><span class="value">{{ object.purpose.label }}</span></td>
+                    <td><span class="value">{{ object.intervention_assignment.label }}</span></td>
+
+                    <td><span class="value">{{ object.number_of_arms }}</span></td>
+                    <td><span class="value">{{ object.masking.label }}</span></td>
+                    <td><span class="value">{{ object.allocation.label }}</span></td>
+                    <td><span class="value">{{ object.phase.label }}</span></td>
+                </tr>
+            </table>
+        </li>
+
+        {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Study Type'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+
+    </ul>
+
+    <h3>{% trans 'Outcomes' %}</h3>
+    <ul>
+        <li>
+            <p><span class="label">{% trans 'Primary Outcomes' %}:</span></p>
+            {% for outcome in object.primary_outcomes %}
+                {% for out_trans in outcome.translations_all|dictsortreversed:"language" %}
+                    {% if out_trans.description %}
+                    <div class="title">
+                        <h2>{{ out_trans.language }}</h2>
+
+                        <p>{{ out_trans.description|linebreaksbr }}</p>
+                    </div>
+                    {% endif %}
+                {% endfor %}
+                {% if outcome.description %}
+                    <div class="title">
+                        <h2>en</h2>
+                        <p>{{ outcome.description|linebreaksbr }}</p>
+                    </div>
+                {% endif %}
+                <div class="spacer"> </div>
+
+            {% endfor %}
+        </li>
+        <li>
+            <p><span class="label">{% trans 'Secondary Outcomes' %}:</span></p>
+            {% for outcome in object.secondary_outcomes %}
+                {% for out_trans in outcome.translations_all|dictsortreversed:"language" %}
+                    {% if out_trans.description %}
+                    <div class="title">
+                        <h2>{{ out_trans.language }}</h2>
+                        <p>{{ out_trans.description|linebreaksbr }}</p>
+
+                    </div>
+                    {% endif %}
+                {% endfor %}
+                {% if outcome.description %}
+                    <div class="title">
+                        <h2>en</h2>
+                        <p>{{ outcome.description|linebreaksbr }}</p>
+                    </div>
+                {% endif %}
+                <div class="spacer"> </div>
+
+            {% endfor %}
+        </li>
+
+        {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Outcomes'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+    </ul>
+
+    <h3>{% trans 'Contacts' %}</h3>
+    <ul>
+        {% if object.public_contacts %}
+        <li class="subset">
+            <span class="legend">{% trans 'Contacts for Public Queries' %}</span>
+
+            {% for contact in object.public_contacts %}
+            <ul class="vcard">
+                <li>
+                    <b>{% trans 'Full Name' %}:</b>
+                    <span class="fn">{{ contact.firstname }} {{ contact.middlename }} {{ contact.lastname }}</span>
+                </li>
+                <li>
+                    <ul class="adr">
+
+                        <li>
+                            <b>{% trans 'Address' %}:</b>
+                            <span class="street-address">{{ contact.address }}</span>
+                        </li>
+                        <li>
+                            <b>{% trans 'City' %}: </b>
+                            <span><span class="locality">{{ contact.city }}</span> / <span class="country-name">{{ contact.country }}</span></span>
+
+                        </li>
+                        <li>
+                            <b>{% trans 'Zip Code' %}:</b>
+                            <span class="postal-code">{{ contact.zip }}</span>
+                        </li>
+                    </ul>
+                </li>
+                <li>
+
+                    <b>{% trans 'Telephone' %}:</b>
+                    <span class="tel">{{ contact.telephone }}</span>
+                </li>
+                <li>
+                    <b>E-mail:</b>
+                    <span class="email">{{ contact.email }}</span>
+                </li>
+
+                <li>
+                    <b>{% trans 'Affiliation' %}:</b>
+                    <span class="org">{{ contact.affiliation }}</span>
+                </li>
+            </ul>
+            {% if forloop.counter|divisibleby:3 and not forloop.last %}
+                <hr class="spacer" size="1"/>
+            {% endif %}
+            {% if forloop.last %}
+                <div class="spacer">&nbsp;</div>
+
+            {% endif %}
+            {% endfor %}
+        </li>
+        {% endif %}
+
+        {% if object.scientific_contacts %}
+        <li class="subset">
+            <span class="legend">{% trans 'Contacts for Scientific Queries' %}</span>
+            {% for contact in object.scientific_contacts %}
+            <ul class="vcard">
+                <li>
+                    <b>{% trans 'Full Name' %}:</b>
+
+                    <span class="fn">{{ contact.firstname }} {{ contact.middlename }} {{ contact.lastname }}</span>
+                </li>
+                <li>
+                    <ul class="adr">
+                        <li>
+                            <b>{% trans 'Address' %}:</b>
+                            <span class="street-address">{{ contact.address }}</span>
+
+                        </li>
+                        <li>
+                            <b>{% trans 'City' %}: </b>
+                            <span><span class="locality">{{ contact.city }}</span> / <span class="country-name">{{ contact.country }}</span></span>
+                        </li>
+                        <li>
+
+                            <b>{% trans 'Zip Code' %}:</b>
+                            <span class="postal-code">{{ contact.zip }}</span>
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    <b>{% trans 'Telephone' %}:</b>
+
+                    <span class="tel">{{ contact.telephone }}</span>
+                </li>
+                <li>
+                    <b>E-mail:</b>
+                    <span class="email">{{ contact.email }}</span>
+                </li>
+                <li>
+
+                    <b>{% trans 'Affiliation' %}:</b>
+                    <span class="org">{{ contact.affiliation }}</span>
+                </li>
+            </ul>
+            {% if forloop.counter|divisibleby:3 and not forloop.last %}
+                <hr class="spacer" size="1"/>
+            {% endif %}
+            {% if forloop.last %}
+                <div class="spacer">&nbsp;</div>
+            {% endif %}
+            {% endfor %}
+        </li>
+
+        {% endif %}
+
+
+        {% if object.site_contacts %}
+        <li class="subset">
+            <span class="legend">{% trans 'Contact(s) for Site Queries' %}</span>
+            {% for contact in object.site_contacts %}
+            <ul class="vcard">
+                <li>
+                    <b>{% trans 'Full Name' %}:</b>
+                    <span class="fn">{{ contact.firstname }} {{ contact.middlename }} {{ contact.lastname }}</span>
+
+                </li>
+                <li>
+                    <ul class="adr">
+                        <li>
+                            <b>{% trans 'Address' %}:</b>
+                            <span class="street-address">{{ contact.address }}</span>
+                        </li>
+                        <li>
+
+                            <b>{% trans 'City' %}: </b>
+                            <span><span class="locality">{{ contact.city }}</span> / <span class="country-name">{{ contact.country }}</span></span>
+                        </li>
+                        <li>
+                            <b>{% trans 'Zip Code' %}:</b>
+                            <span class="postal-code">{{ contact.zip }}</span>
+
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    <b>{% trans 'Telephone' %}:</b>
+                    <span class="tel">{{ contact.telephone }}</span>
+                </li>
+                <li>
+
+                    <b>E-mail:</b>
+                    <span class="email">{{ contact.email }}</span>
+                </li>
+                <li>
+                    <b>{% trans 'Affiliation' %}:</b>
+                    <span class="org">{{ contact.affiliation }}</span>
+                </li>
+
+            </ul>
+            {% if forloop.counter|divisibleby:3 and not forloop.last %}
+                <hr class="spacer" size="1"/>
+            {% endif %}
+            {% if forloop.last %}
+                <div class="spacer">&nbsp;</div>
+            {% endif %}
+            {% endfor %}
+        </li>
+        {% endif %}
+
+        {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Contacts'|slugify %}">{% trans 'Remark' %}</a></li>
+        {% endif %}
+
+    </ul>
+
+    {% if object.trial_attach %}
+        <h3>{% trans 'Attachments' %}</h3>
+        <ul>
+            {%  for attach in object.trial_attach %}
+                <li>
+                {% if not attach.public %}
+                    [{% trans 'Private'%}]
+                {% else %}
+                    [{% trans 'Public'%}]
+                {% endif %}
+                
+                {% if attach.file %}
+                <li>
+                    <a href="http://{{host}}{{attach.get_relative_url}}">
+                    http://{{host}}{{attach.get_relative_url}}</a>
+                    ({{ attach.description }})
+                </li>
+
+                {% else %}
+                <li>
+                    <a href="{{attach.attach_url}}">
+                        {{attach.attach_url}}
+                    </a>({{ attach.description }})
+                </li>
+                {% endif %}
+                
+                </li>
+            {% endfor %}
+            {% if perms.reviewapp.add_remark %}
+            <li><a class="button addNew" href="{% url reviewapp.openremark object.submission.id 'Attachments'|slugify %}">{% trans 'Remark' %}</a></li>
+            {% endif %}
+        </ul>
+    {% endif %}
+
+{% endblock %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/clinicaltrial_detail_published.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/clinicaltrial_detail_published.html (revision 994)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/clinicaltrial_detail_published.html (revision 994)
@@ -0,0 +1,656 @@
+{% extends "base.html" %}
+
+{% load i18n %}
+
+{% block body_title %}{% trans 'Clinical Trial' %}{% endblock %}
+
+{% block extrahead %}
+<style type="text/css">
+    span.label, span.legend {
+        font-weight: bold;
+    }
+    span.legend {
+        display: block;
+        margin: 0.5em 0;
+        text-decoration: underline;
+    }
+    .mainContent ul li {
+        margin-bottom: 1em;
+    }
+    .mainContent li.subset {
+        border: 1px solid silver;
+        padding: 0.5em;
+        clear: both;
+    }
+    .mainContent li.subset ul {
+        padding: 0em;
+    }
+    .mainContent li.subset .odd {
+        background-color: #F4F9FD;
+    }
+    .mainContent li.subset ul.vcard {
+        float: left;
+        width: 33%;
+        margin: 1.5em 0 1em;
+    }
+    div.title {
+      margin-left: 1%;
+      border: 4px solid #CCC;
+      border-radius: 16px;
+      -moz-border-radius: 16px;
+      -webkit-border-radius: 16px;
+      margin-bottom: 2em;
+      background: #EEE;
+      overflow: hidden;
+      padding: 0;
+      width: 31%;
+      float: left;
+    }
+
+    div.title h2 {
+      color: #CCC;
+      font-size: 18pt;
+      line-height: 54pt;
+      margin-top: -16px;
+      margin-right: 10px;
+      font-variant: small-caps;
+      letter-spacing: -1pt;
+      text-align: right;
+    }
+
+    html > body div.title h2 {
+      margin-bottom: -30pt;
+    }
+
+    div.title p {
+      margin-left: 14pt;
+      line-height: 200%;
+      margin-right: 14pt;
+    }
+</style>
+{% endblock %}
+
+{% block stepmenu_top %}
+    {{ block.super }}
+    <small>
+        / <a href="{% url repository.index %}">{% trans 'Registered Trials' %}</a>
+    </small>
+    <big>/ {{ object.identifier }}</big>
+{% endblock %}
+
+{% block body %}
+    <h2>{{ register_number }}</h2>
+    <h2>{{ scientific_title }}</h2>
+
+    <span class="label">{% trans 'Registration Date:' %}</span>
+    <span class="value">{{ fossil_created }}</span>
+
+    <h3>{% trans 'Study Type' %}:</h3>
+        {% if object.is_observational %}
+            <p>{% trans 'Observational Study' %}</p>
+        {% else %}
+            <p>{% trans 'Intervention Study' %}</p>
+        {% endif %}
+        <div class="spacer"> </div>
+
+    {% if object.is_observational %}
+    <h3>{% trans 'Observational Study Fields' %}:</h3>
+    <ul>
+        <li>
+            <span class="label">{% trans 'Time Perspective' %}: </span>
+            <span class="value">{{ time_perspective }}</span>
+        </li>
+        <li>
+            <span class="label">{% trans 'Observational Study Design' %}: </span>
+            <span class="value">{{ observational_study_design }}</span>
+        </li>
+    </ul>
+    {% endif %}
+    <div class="spacer"> </div>
+
+    <h3>{% trans 'Scientific Title' %}:</h3>
+        {% for t in translations|dictsortreversed:"language" %}
+            {% if t.scientific_title %}
+            <div class="title">
+                <h2>{{ t.language }}</h2>
+                <p>{{ t.scientific_title }}</p>
+            </div>
+            {% endif %}
+        {% endfor %}
+        <div class="spacer"> </div>
+
+    <h3>{% trans 'Trial Identification' %}</h3>
+    <ul>
+        <li>
+            <span class="label">{% trans 'UTN Number' %}: </span>
+            <span class="value">{{ object.fossil.utrn_number }}</span>
+        </li>
+        <li>
+            <p><span class="label">{% trans 'Public Title' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.public_title %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.public_title }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Scientific Acronym' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.scientific_acronym %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.scientific_acronym }}: {{ t.scientific_acronym_expansion }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Public Acronym' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.acronym %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.acronym }}: {{ t.acronym_expansion }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+        </li>
+        <div class="spacer"> </div>
+        <li class="subset">
+            <span class="legend">{% trans 'Secondary Identifying Numbers' %}:</span>
+            {% for secid in object.trial_number %}
+            <ul class="{% cycle 'even' 'odd' %}">
+                <li>
+                    <span class="label">{{ secid.id_number }}</span><br />
+                    <span class="value">{% trans 'Issuing Authority' %}:</span>
+                    <span class="value">{{ secid.issuing_authority }}</span>
+                </li>
+            </ul>
+            {% endfor %}
+        </li>
+    </ul>
+
+    <h3>{% trans 'Sponsors' %}</h3>
+    <ul>
+        <li>
+            <span class="label">{% trans 'Primary Sponsor' %}:</span>
+            <span class="value">{{ object.primary_sponsor.name }}</span>
+        </li>
+        {% if object.secondary_sponsors %}
+        <li class="subset">
+            <span class="legend">{% trans 'Secondary Sponsors' %}:</span>
+            <ul>
+            {%  for sponsors in object.secondary_sponsors %}
+                <li class="{% cycle 'even' 'odd' %}">
+                    <span class="label">{% trans 'Institution' %}:</span>
+                    <span class="value">{{ sponsors.institution.name }}</span>
+                </li>
+            {% endfor %}
+            </ul>
+        </li>
+        {% endif %}
+
+        {% if object.support_sources %}
+        <li class="subset">
+            <span class="legend">{% trans 'Source(s) of Monetary or Material Support' %}:</span>
+            <ul>
+            {%  for source_support in object.support_sources %}
+                <li class="{% cycle 'even' 'odd' %}">
+                    <span class="label">{% trans 'Institution' %}:</span>
+                    <span class="value">{{ source_support.institution.name }}</span>
+                </li>
+            {% endfor %}
+            </ul>
+        </li>
+        {% endif %}
+    </ul>
+
+    <h3>{% trans 'Health Conditions' %}</h3>
+    <ul>
+        <li>
+        <p><span class="label">{% trans 'Health Condition(s) or Problem(s)' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.hc_freetext %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.hc_freetext }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'General Descriptors for Health Condition(s)' %}:</span></p>
+            {% for hc in object.hc_code %}
+                {% for hc_trans in hc.translations|dictsortreversed:"language" %}
+                    {% if hc_trans.text %}
+                    <div class="title">
+                        <h2>{{ hc_trans.language }}</h2>
+                        <p>
+                            <span class="label">{{ hc.code }}:</span>
+                            <span class="value">{{ hc_trans.text }}</span>
+                        </p>
+                    </div>
+                    {% endif %}
+                {% endfor %}
+                <div class="title">
+                    <h2>en</h2>
+                    <p>
+                        <span class="label">{{ hc.code }}:</span>
+                        <span class="value">{{ hc.text }}</span>
+                    </p>
+                </div>
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+        <li>
+            <p><span class="label">{% trans 'Specific Descriptors for Health Condition(s)' %}:</span></p>
+            {% for hc in object.hc_keyword %}
+                {% for hc_trans in hc.translations|dictsortreversed:"language" %}
+                    {% if hc_trans.text %}
+                    <div class="title">
+                        <h2>{{ hc_trans.language }}</h2>
+                        <p>
+                            <span class="label">{{ hc.code }}:</span>
+                            <span class="value">{{ hc_trans.text }}</span>
+                        </p>
+                    </div>
+                    {% endif %}
+                {% endfor %}
+                <div class="title">
+                    <h2>en</h2>
+                    <p>
+                        <span class="label">{{ hc.code }}:</span>
+                        <span class="value">{{ hc.text }}</span>
+                    </p>
+                </div>
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+    </ul>
+
+    <h3>{% trans 'Interventions' %}</h3>
+    <ul>
+        <li class="subset">
+            <span class="legend">{% trans 'Intervention Code(s)' %}</span>
+            <ul>
+            {% for iv in object.i_code %}
+                <li>
+                    <span class="label">{{ iv.description|default:iv.label }}</span>
+                </li>
+            {% endfor %}
+            </ul>
+        </li>
+        <li>
+        <p><span class="label">{% trans 'Interventions' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.i_freetext %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.i_freetext|linebreaksbr }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Descriptor for Intervention(s)' %}:</span></p>
+            {% for intervention in object.intervention_keyword %}
+                {% for i_trans in intervention.translations|dictsortreversed:"language" %}
+                    {% if i_trans.text %}
+                    <div class="title">
+                        <h2>{{ i_trans.language }}</h2>
+                        <p>
+                            <span class="label">{{ intervention.code }}:</span>
+                            <span class="value">{{ i_trans.text }}</span>
+                        </p>
+                    </div>
+                    {% endif %}
+                {% endfor %}
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+    </ul>
+
+    <h3>{% trans 'Recruitment' %}</h3>
+    <ul>
+        <li>
+            <span class="label">{% trans 'Recruitment Status' %}:</span>
+            <span class="value">{{ object.rec_status }}</span>
+        </li>
+        <li class="subset">
+            <span class="legend">{% trans 'Recruitment Country' %}</span>
+            <ul>
+            {% for recruitment in object.recruitment_country %}
+                <li>{{ recruitment.description }}{% if not forloop.last %}, {% endif %}</li>
+            {% endfor %}
+            </ul>
+        </li>
+        <li>
+            <span class="label">{% trans 'Planned Date of First Enrollment' %}:</span>
+            {% if object.enrollment_start_actual %}
+                <span class="value">{{ object.enrollment_start_actual }}</span>
+            {% else %}
+                <span class="value">{{ object.enrollment_start_planned }}</span>
+            {% endif %}
+        </li>
+        <li>
+            <table class="dataTable">
+                <tr>
+                    <th>{% trans 'Target Sample Size' %}:</th>
+                    <th>{% trans 'Gender (inclusion sex)' %}:</th>
+                    <th>{% trans 'Inclusion Minimum Age' %}:</th>
+                    <th>{% trans 'Inclusion Maximum Age' %}:</th>
+                </tr>
+                <tr>
+                    <td>{{ object.target_sample_size }}</td>
+                    <td>{{ object.gender }}</td>
+                    <td>{{ object.agemin_value }} {{ object.agemin_unit }}</td>
+                    <td>{{ object.agemax_value }} {{ object.agemax_unit }}</td>
+                </tr>
+            </table>
+        </li>
+        <li>
+            <p><span class="label">{% trans 'Inclusion Criteria' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.inclusion_criteria %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.inclusion_criteria|linebreaksbr }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <p><span class="label">{% trans 'Exclusion Criteria' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.exclusion_criteria %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.exclusion_criteria|linebreaksbr }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+        </li>
+        <div class="spacer"> </div>
+    </ul>
+
+    <h3>{% trans 'Study Type' %}</h3>
+    <ul>
+        <li>
+            <p><span class="label">{% trans 'Study Design' %}:</span></p>
+            {% for t in translations|dictsortreversed:"language" %}
+                {% if t.study_design %}
+                <div class="title">
+                    <h2>{{ t.language }}</h2>
+                    <p>{{ t.study_design }}</p>
+                </div>
+                {% endif %}
+            {% endfor %}
+        </li>
+        <div class="spacer"> </div>
+        <li>
+            <table class="dataTable">
+                <tr>
+                    <th><span class="label">{% trans 'Expanded access program' %}</span></th>
+                    <th><span class="label">{% trans 'Study Purpose' %}</span></th>
+                    <th><span class="label">{% trans 'Intervention Assignment' %}</span></th>
+                    <th><span class="label">{% trans 'Number of arms' %}</span></th>
+                    <th><span class="label">{% trans 'Masking type' %}</span></th>
+                    <th><span class="label">{% trans 'Allocation type' %}</span></th>
+                    <th><span class="label">{% trans 'Study Phase' %}</span></th>
+                </tr>
+                <tr>
+                    <td><span class="value">{{ object.expanded_access_program }}</span></td>
+                    <td><span class="value">{{ object.purpose.label }}</span></td>
+                    <td><span class="value">{{ object.intervention_assignment.label }}</span></td>
+                    <td><span class="value">{{ object.number_of_arms }}</span></td>
+                    <td><span class="value">{{ object.masking.label }}</span></td>
+                    <td><span class="value">{{ object.allocation.label }}</span></td>
+                    <td><span class="value">{{ object.phase.label }}</span></td>
+                </tr>
+            </table>
+        </li>
+    </ul>
+
+    <h3>{% trans 'Outcomes' %}</h3>
+    <ul>
+        <li>
+            <p><span class="label">{% trans 'Primary Outcomes' %}:</span></p>
+            {% for outcome in object.primary_outcomes %}
+                {% for out_trans in outcome.translations|dictsortreversed:"language" %}
+                    {% if out_trans.description %}
+                    <div class="title">
+                        <h2>{{ out_trans.language }}</h2>
+                        <p>{{ out_trans.description|linebreaksbr }}</p>
+                    </div>
+                    {% endif %}
+                {% endfor %}
+                <div class="title">
+                    <h2>en</h2>
+                    <p>{{ outcome.description|linebreaksbr }}</p>
+                </div>
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+        <li>
+            <p><span class="label">{% trans 'Secondary Outcomes' %}:</span></p>
+            {% for outcome in object.secondary_outcomes %}
+                {% for out_trans in outcome.translations|dictsortreversed:"language" %}
+                    {% if out_trans.description %}
+                    <div class="title">
+                        <h2>{{ out_trans.language }}</h2>
+                        <p>{{ out_trans.description|linebreaksbr }}</p>
+                    </div>
+                    {% endif %}
+                {% endfor %}
+                <div class="title">
+                    <h2>en</h2>
+                    <p>{{ outcome.description|linebreaksbr }}</p>
+                </div>
+                <div class="spacer"> </div>
+            {% endfor %}
+        </li>
+    </ul>
+
+    <h3>{% trans 'Contacts' %}</h3>
+    <ul>
+        {% if object.public_contact %}
+        <li class="subset">
+            <span class="legend">{% trans 'Contacts for Public Queries' %}</span>
+            {% for contact in object.public_contact %}
+            <ul class="vcard">
+                <li>
+                    <b>{% trans 'Full Name' %}:</b>
+                    <span class="fn">{{ contact.firstname }} {{ contact.middlename }} {{ contact.lastname }}</span>
+                </li>
+                <li>
+                    <ul class="adr">
+                        <li>
+                            <b>{% trans 'Address' %}:</b>
+                            <span class="street-address">{{ contact.address }}</span>
+                        </li>
+                        <li>
+                            <b>{% trans 'City' %}: </b>
+                            <span><span class="locality">{{ contact.city }}</span> /
+                                <span class="country-name">{{ contact.country.description }}</span></span>
+                        </li>
+                        <li>
+                            <b>{% trans 'Zip Code' %}:</b>
+                            <span class="postal-code">{{ contact.zip }}</span>
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    <b>{% trans 'Telephone' %}:</b>
+                    <span class="tel">{{ contact.telephone }}</span>
+                </li>
+                <li>
+                    <b>E-mail:</b>
+                    <span class="email">{{ contact.email }}</span>
+                </li>
+                <li>
+                    <b>{% trans 'Affiliation' %}:</b>
+                    <span class="org">{{ contact.affiliation.name }}</span>
+                </li>
+            </ul>
+            {% if forloop.counter|divisibleby:3 and not forloop.last %}
+                <hr class="spacer" size="1"/>
+            {% endif %}
+            {% if forloop.last %}
+                <div class="spacer">&nbsp;</div>
+            {% endif %}
+            {% endfor %}
+        </li>
+        {% endif %}
+
+        {% if object.scientific_contact %}
+        <li class="subset">
+            <span class="legend">{% trans 'Contacts for Scientific Queries' %}</span>
+            {% for contact in object.scientific_contact %}
+            <ul class="vcard">
+                <li>
+                    <b>{% trans 'Full Name' %}:</b>
+                    <span class="fn">{{ contact.firstname }} {{ contact.middlename }} {{ contact.lastname }}</span>
+                </li>
+                <li>
+                    <ul class="adr">
+                        <li>
+                            <b>{% trans 'Address' %}:</b>
+                            <span class="street-address">{{ contact.address }}</span>
+                        </li>
+                        <li>
+                            <b>{% trans 'City' %}: </b>
+                            <span><span class="locality">{{ contact.city }}</span> / <span class="country-name">{{ contact.country.description }}</span></span>
+                        </li>
+                        <li>
+                            <b>{% trans 'Zip Code' %}:</b>
+                            <span class="postal-code">{{ contact.zip }}</span>
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    <b>{% trans 'Telephone' %}:</b>
+                    <span class="tel">{{ contact.telephone }}</span>
+                </li>
+                <li>
+                    <b>E-mail:</b>
+                    <span class="email">{{ contact.email }}</span>
+                </li>
+                <li>
+                    <b>{% trans 'Affiliation' %}:</b>
+                    <span class="org">{{ contact.affiliation.name }}</span>
+                </li>
+            </ul>
+            {% if forloop.counter|divisibleby:3 and not forloop.last %}
+                <hr class="spacer" size="1"/>
+            {% endif %}
+            {% if forloop.last %}
+                <div class="spacer">&nbsp;</div>
+            {% endif %}
+            {% endfor %}
+        </li>
+        {% endif %}
+
+
+        {% if object.site_contact %}
+        <li class="subset">
+            <span class="legend">{% trans 'Contact(s) for Site Queries' %}</span>
+            {% for contact in object.site_contact %}
+            <ul class="vcard">
+                <li>
+                    <b>{% trans 'Full Name' %}:</b>
+                    <span class="fn">{{ contact.firstname }} {{ contact.middlename }} {{ contact.lastname }}</span>
+                </li>
+                <li>
+                    <ul class="adr">
+                        <li>
+                            <b>{% trans 'Address' %}:</b>
+                            <span class="street-address">{{ contact.address }}</span>
+                        </li>
+                        <li>
+                            <b>{% trans 'City' %}: </b>
+                            <span><span class="locality">{{ contact.city }}</span> / <span class="country-name">{{ contact.country.description }}</span></span>
+                        </li>
+                        <li>
+                            <b>{% trans 'Zip Code' %}:</b>
+                            <span class="postal-code">{{ contact.zip }}</span>
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    <b>{% trans 'Telephone' %}:</b>
+                    <span class="tel">{{ contact.telephone }}</span>
+                </li>
+                <li>
+                    <b>E-mail:</b>
+                    <span class="email">{{ contact.email }}</span>
+                </li>
+                <li>
+                    <b>{% trans 'Affiliation' %}:</b>
+                    <span class="org">{{ contact.affiliation.name }}</span>
+                </li>
+            </ul>
+            {% if forloop.counter|divisibleby:3 and not forloop.last %}
+                <hr class="spacer" size="1"/>
+            {% endif %}
+            {% if forloop.last %}
+                <div class="spacer">&nbsp;</div>
+            {% endif %}
+            {% endfor %}
+        </li>
+        {% endif %}
+    </ul>
+
+    {% if object.previous_revision %}
+    <div>
+        <a href="{% url repository.trial_registered trial_fossil_id=object.previous_revision.pk %}">
+            {% trans 'Previous Revision' %}</a>
+    </div>
+    {% endif %}
+
+    {% block attachs %}{% endblock %}
+    {% if attachs %}
+        <h3>{% trans 'Attachments' %}</h3>
+        <ul>
+            {%  for attach in attachs %}
+
+                {% if attach.file %}
+                <li>
+                    <a href="http://{{host}}{{attach.get_relative_url}}">
+                    http://{{host}}{{attach.get_relative_url}}</a>
+                    ({{ attach.description }})
+                </li>
+
+                {% else %}
+                <li>
+                    <a href="{{attachment.attach_url}}">
+                        {{attach.attach_url}}                        
+                    </a>
+                    ({{ attach.description }})
+                </li>
+                {% endif %}
+
+            {% endfor %}
+        </ul>
+    {% endif %}
+
+    {% block additional_links %}
+    <h3>{% trans 'Additional Links' %}:</h3>
+    <ul>
+        <li><a href="{% url repository.trial_ictrp_version trial_fossil_id=object.trial_id,trial_version=object.version %}">
+            {% trans "Download as ICTRP format" %}</a></li>
+
+        <li><a href="{% url repository.trial_otxml_version trial_fossil_id=object.trial_id,trial_version=object.version %}">
+            {% trans "Download as OpenTrials XML format" %}</a></li>
+
+    </ul>
+    {% endblock %}
+
+{% endblock %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/step_2.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/step_2.html (revision 819)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/step_2.html (revision 819)
@@ -0,0 +1,14 @@
+{% extends "repository/trial_form.html" %}
+{% load i18n %}
+{% load polyglot_tags %}
+
+{% block extra_buttons %}<input onclick="new_institution('{{formset.management_form.prefix}}')" type="button" value="{% trans 'New Institution' %}"/>{% endblock %}
+
+{% block endjs %}{{ block.super }}
+    <script type="text/javascript">
+        function new_institution(target){
+            return window.open('{% url new_institution %}#'+target,'n_i','status=0,location=0,height=380');
+        }
+    </script>
+{% endblock %}
+
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/step_3.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/step_3.html (revision 847)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/step_3.html (revision 847)
@@ -0,0 +1,27 @@
+{% extends "repository/trial_form.html" %}
+{% load i18n %}
+{% load polyglot_tags %}
+
+{% block endjs %}
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $("div.g select")
+                .change(getterm_event(
+                        {'decs_url': '{% url decs.getdescendants code="C" %}',
+                        'icd10_url': '{% url icd10.get_chapters %}'}, 
+                        '{{ LANGUAGE_CODE }}'))
+                .each(function(){$(this).change();});
+
+            $("div.s select")
+                .change(search_event(
+                        {'decs_url': '{% url decs.search lang=LANGUAGE_CODE, term="" %}',
+                        'icd10_url': '{% url icd10.search lang=LANGUAGE_CODE, term="" %}'},
+                        '{% trans "Search terms" %}',
+                        '{{ LANGUAGE_CODE }}'))
+                .each(function(){$(this).change();});
+        });
+    </script>
+{# the super is called at the end because the js change the elements above and generates conflicts with confirm-before-leave function #}
+{{ block.super }}
+{% endblock %}
+
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/add_done.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/add_done.html (revision 457)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/add_done.html (revision 457)
@@ -0,0 +1,7 @@
+{% extends "base.html" %}
+
+{% block body_title %}{% trans "Submission done" %}{% endblock %}
+
+{% block body %}
+    <h3>{{public_title}}, {% trans "added." %}</h3>
+{% endblock %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/xml/xml_opentrials.xml
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/xml/xml_opentrials.xml (revision 839)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/xml/xml_opentrials.xml (revision 839)
@@ -0,0 +1,202 @@
+{% extends "base.xml" %}
+{% load repository_tags %}
+{% block root %}
+<!DOCTYPE trials SYSTEM "http://localhost:8000/xml/opentrials.dtd">
+<trials version="{{ opentrials_xml_version }}">
+    <trial status="{{ object.status|default_if_none:"published" }}"
+           date_registration="{{ object.date_registration|date:"Y-m-d" }}"
+           created="{{ object.created|date:"Y-m-d" }}"
+           updated="{{ object.updated|date:"Y-m-d" }}">
+        <trial_identification>
+            <trial_id>{{ object.trial_id }}</trial_id>
+            <utrn_number>{{ object.utrn_number }}</utrn_number>
+            <reg_name>{{ reg_name }}</reg_name>
+            <public_title>{{ object.public_title }}</public_title>
+            <acronym>{{ object.acronym }}</acronym>
+            <acronym_expansion>{{ object.acronym_expansion }}</acronym_expansion>
+            <scientific_title>{{ object.scientific_title }}</scientific_title>
+            <scientific_acronym>{{ object.scientific_acronym }}</scientific_acronym>
+            <scientific_acronym_expansion>{{ object.scientific_acronym_expansion }}</scientific_acronym_expansion>
+        </trial_identification>
+
+        <sponsors_and_support>
+            <primary_sponsor country_code="{{ object.primary_sponsor.country.label }}" type="{{ object.primary_sponsor.i_type.label|prep_label_for_xml }}">
+                <name>{{ object.primary_sponsor.name }}</name>
+                <address>{{ object.primary_sponsor.address }}</address>
+            </primary_sponsor>
+
+            {%  for sponsor in object.secondary_sponsors %}
+            <secondary_sponsor country_code="{{ sponsor.institution.country.label }}" type="{{ sponsor.institution.i_type.label|prep_label_for_xml }}">
+                <name>{{ sponsor.institution.name }}</name>
+                <address>{{ sponsor.institution.address }}</address>
+            </secondary_sponsor>
+            {% endfor %}
+
+            {%  for source in object.support_sources %}
+            <source_support country_code="{{ source.institution.country.label }}" type="{{ sponsor.institution.i_type.label|prep_label_for_xml }}">
+                <name>{{ source.institution.name }}</name>
+                <address>{{ source.institution.address }}</address>
+            </source_support>
+            {% endfor %}
+        </sponsors_and_support>
+
+        <health_conditions>
+            {% for hc in object.hc_code %}
+            <hc_code vocabulary="{{ hc.vocabulary|prep_label_for_xml }}" version="{{ hc.version }}" code="{{ hc.code }}">
+                <text>{{ hc.text }}</text>
+                {% if hc.translations %}
+                {% for hc_translation in hc.translations %}
+                <text_translation lang="{{ hc_translation.language }}">{{ hc_translation.text }}</text_translation>
+                {% endfor %}
+                {% endif %}
+            </hc_code>
+            {% endfor %}
+
+            {% for hc in object.hc_keyword %}
+            <keyword vocabulary="{{ hc.vocabulary|prep_label_for_xml }}" version="{{ hc.version }}" code="{{ hc.code }}">
+                <text>{{ hc.text }}</text>
+                {% if hc.translations %}
+                {% for hc_translation in hc.translations %}
+                <text_translation lang="{{ hc_translation.language }}">{{ hc_translation.text }}</text_translation>
+                {% endfor %}
+                {% endif %}
+            </keyword>
+            {% endfor %}
+
+            <freetext>{{ object.hc_freetext }}</freetext>
+        </health_conditions>
+
+        <interventions>
+            {% for iv in object.i_code %}
+            <i_code value="{{ iv.label|prep_label_for_xml }}"></i_code>
+            {% endfor %}
+
+            {% for iv in object.intervention_keyword %}
+            <keyword vocabulary="{{ iv.vocabulary|prep_label_for_xml }}" version="{{ iv.version }}" code="{{ iv.code }}">
+                <text>{{ iv.text }}</text>
+                {% if iv.translations %}
+                {% for i_translation in iv.translations %}
+                <text_translation lang="{{ i_translation.language }}">{{ i_translation.text }}</text_translation>
+                {% endfor %}
+                {% endif %}
+            </keyword>
+            {% endfor %}
+
+            <freetext>{{ object.i_freetext }}</freetext>
+        </interventions>
+
+        <recruitment status="{{ object.recruitment_status.label|prep_label_for_xml }}">
+            {% for country in object.recruitment_country %}
+            <recruitment_country value="{{ country.label }}"></recruitment_country>
+            {% endfor %}
+
+            <inclusion_criteria>{{ object.inclusion_criteria }}</inclusion_criteria>
+            <exclusion_criteria>{{ object.exclusion_criteria }}</exclusion_criteria>
+            <gender value="{{ object.gender|lower|switch:"-=both,f=female,m=male" }}"></gender>
+            <agemin value="{{ object.agemin_value }}" unit="{{ object.agemin_unit|switch:"-=null,Y=years,M=months,W=weeks,D=days,H=hours" }}"></agemin>
+            <agemax value="{{ object.agemax_value }}" unit="{{ object.agemax_unit|switch:"-=null,Y=years,M=months,W=weeks,D=days,H=hours" }}"></agemax>
+
+            {% if object.enrollment_start_actual %}
+            <date_enrolment_actual start="{{ object.date_enrollment_start }}" end="{{ object.date_enrollment_end }}"></date_enrolment_actual>
+            {% else %}
+            <date_enrolment_anticipated start="{{ object.date_enrollment_start }}" end="{{ object.date_enrollment_end }}"></date_enrolment_anticipated>
+            {% endif %}
+
+            <target_size value="{{ object.target_sample_size }}"></target_size>
+        </recruitment>
+
+        <study expanded_access_program="{{ object.expanded_access_program|default_if_none:0|yesno }}"
+               number_of_arms="{{ object.number_of_arms }}">
+            <study_design>{{ object.study_design }}</study_design>
+            {% if object.study_type %}<type value="{{ object.study_type.label|prep_label_for_xml }}"></type>{% endif %}
+            <phase value="{{ object.phase.label|prep_label_for_xml }}"></phase>
+            <purpose value="{{ object.purpose.label|prep_label_for_xml }}"></purpose>
+            <intervention_assignment value="{{ object.intervention_assignment.label|prep_label_for_xml }}"></intervention_assignment>
+            <masking value="{{ object.masking.label|prep_label_for_xml }}"></masking>
+            <allocation value="{{ object.allocation.label|prep_label_for_xml }}"></allocation>
+        </study>
+
+        <outcomes>
+            {% for outcome in object.primary_outcomes %}
+            <primary_outcome value="{{ outcome.description }}">
+                {% for outcome_trans in outcome.translations %}
+                <outcome_translation value="{{ outcome_trans.description }}" lang="{{ outcome_trans.language }}"></outcome_translation>
+                {% endfor %}
+            </primary_outcome>
+            {% endfor %}
+
+            {% for outcome in object.secondary_outcomes %}
+            <secondary_outcome value="{{ outcome.description }}">
+                {% for outcome_trans in outcome.translations %}
+                <outcome_translation value="{{ outcome_trans.description }}" lang="{{ outcome_trans.language }}"></outcome_translation>
+                {% endfor %}
+            </secondary_outcome>
+            {% endfor %}
+        </outcomes>
+
+        <contacts>
+            {% for person in persons %}
+            <person pid="{{ person.pk }}" country_code="{{ person.country.label }}">
+                <firstname>{{ person.firstname }}</firstname>
+                <middlename>{{ person.middlename }}</middlename>
+                <lastname>{{ person.lastname }}</lastname>
+                <address>{{ person.address }}</address>
+                <city>{{ person.city }}</city>
+                <zip>{{ person.zip }}</zip>
+                <telephone>{{ person.telephone }}</telephone>
+                <email>{{ person.email }}</email>
+                {% if person.affiliation %}
+                <affiliation country_code="{{ person.affiliation.country.label }}" type="{{ person.affiliation.i_type.label|prep_label_for_xml }}">
+                    <name>{{ person.affiliation.name }}</name>
+                    <address>{{ person.affiliation.address }}</address>
+                </affiliation>
+                {% endif %}
+            </person>
+            {% endfor %}
+
+            {% for contact in object.public_contact %}
+            <public_contact person="{{ contact.pk }}"></public_contact>
+            {% endfor %}
+            
+            {% for contact in object.scientific_contact %}
+            <scientific_contact person="{{ contact.pk }}"></scientific_contact>
+            {% endfor %}
+
+            {% for contact in object.site_contact %}
+            <site_contact person="{{ contact.pk }}"></site_contact>
+            {% endfor %}
+        </contacts>
+
+        <secondary_ids>
+            {% for secid in object.trial_number %}
+            <secondary_id>
+                <sec_id>{{ secid.id_number }}</sec_id>
+                <issuing_authority>{{ secid.issuing_authority }}</issuing_authority>    
+            </secondary_id>
+            {% endfor %}
+        </secondary_ids>
+
+        <references>
+            <link url="{% url repository.trial_registered_version trial_fossil_id=object.trial_id, trial_version=object.version %}"></link>
+        </references>
+
+        {% if include_translations %}
+        {% for translation in object.translations %}
+        <translation lang="{{ translation.language }}">
+            <public_title>{{ translation.public_title }}</public_title>
+            <acronym>{{ translation.acronym }}</acronym>
+            <acronym_expansion>{{ translation.acronym_expansion }}</acronym_expansion>
+            <scientific_title>{{ translation.scientific_title }}</scientific_title>
+            <scientific_acronym>{{ translation.scientific_acronym }}</scientific_acronym>
+            <scientific_acronym_expansion>{{ translation.scientific_acronym_expansion }}</scientific_acronym_expansion>
+            <hc_freetext>{{ translation.hc_freetext }}</hc_freetext>
+            <i_freetext>{{ translation.i_freetext }}</i_freetext>
+            <inclusion_criteria>{{ translation.inclusion_criteria }}</inclusion_criteria>
+            <exclusion_criteria>{{ translation.exclusion_criteria }}</exclusion_criteria>
+            <study_design>{{ translation.study_design }}</study_design>
+        </translation>
+        {% endfor %}
+        {% endif %}
+    </trial>
+</trials>
+{% endblock %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/xml/xml_ictrp.xml
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/xml/xml_ictrp.xml (revision 814)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/xml/xml_ictrp.xml (revision 814)
@@ -0,0 +1,132 @@
+{% extends "base.xml" %}
+
+{% block root %}
+<trials>
+    <trial>
+        <main>
+            <trial_id>{{ object.trial_id }}</trial_id>
+            <utrn>{{ object.utrn_number }}</utrn>
+            <reg_name>{{ reg_name }}</reg_name>
+            <date_registration>{{ object.date_registration|date:"d/m/Y" }}</date_registration>
+            <primary_sponsor>{{ object.primary_sponsor.name }}</primary_sponsor>
+            <public_title>{{ object.public_title }}</public_title>
+            <acronym>{{ object.acronym_display }}</acronym>
+            <scientific_title>{{ object.scientific_title }}</scientific_title>
+            <scientific_acronym>{{ object.scientific_acronym_display }}</scientific_acronym>
+            <date_enrolment>{{ object.date_enrollment_start }}</date_enrolment>
+            <type_enrolment>{% if object.enrollment_start_actual %}actual{% else %}anticipated{% endif %}</type_enrolment>
+            <target_size>{{ object.target_sample_size }}</target_size>
+            <recruitment_status>{{ object.recruitment_status.label }}</recruitment_status>
+            <url>{% url repository.trial_registered_version trial_fossil_id=object.trial_id, trial_version=object.version %}</url>
+            <study_type>{{ object.study_type.label }}</study_type>
+            <study_design>{{ object.study_design }}</study_design>
+            <phase>{{ object.phase.label }}</phase>
+            <hc_freetext>{{ object.hc_freetext }}</hc_freetext>
+            <i_freetext>{{ object.i_freetext }}</i_freetext>            
+        </main>
+        <contacts>
+        {% for contact in object.public_contact %}
+            <contact>
+                <type>public</type>
+                <firstname>{{ contact.firstname }}</firstname>
+                <middlename>{{ contact.middlename }}</middlename>
+                <lastname>{{ contact.lastname }}</lastname>
+                <address>{{ contact.address }}</address>
+                <city>{{ contact.city }}</city>
+                <country1>{{ contact.country.description }}</country1>
+                <zip>{{ contact.zip }}</zip>
+                <telephone>{{ contact.telephone }}</telephone>
+                <email>{{ contact.email }}</email>
+                <affiliation>{{ contact.affiliation.name }}</affiliation>
+            </contact>
+        {% endfor %}
+        {% for contact in object.scientific_contact %}
+            <contact>
+                <type>scientific</type>
+                <firstname>{{ contact.firstname }}</firstname>
+                <middlename>{{ contact.middlename }}</middlename>
+                <lastname>{{ contact.lastname }}</lastname>
+                <address>{{ contact.address }}</address>
+                <city>{{ contact.city }}</city>
+                <country1>{{ contact.country.description }}</country1>
+                <zip>{{ contact.zip }}</zip>
+                <telephone>{{ contact.telephone }}</telephone>
+                <email>{{ contact.email }}</email>
+                <affiliation>{{ contact.affiliation.name }}</affiliation>
+            </contact>
+        {% endfor %}
+        </contacts>
+        <countries>
+        {% for country in object.recruitment_country %}
+            <country2>{{ country.description }}</country2>
+        {% endfor %}
+        </countries>
+        <criteria>
+            <inclusion_criteria>{{ object.inclusion_criteria }}</inclusion_criteria>
+            <agemin>{{ object.agemin_value }}{% if object.agemin_unit != '-' %}{{ object.agemin_unit }}{% endif %}</agemin>
+            <agemax>{{ object.agemax_value }}{% if object.agemax_unit != '-' %}{{ object.agemax_unit }}{% endif %}</agemax>
+            <gender>{{ object.gender }}</gender>
+            <exclusion_criteria>{{ object.exclusion_criteria }}</exclusion_criteria>
+        </criteria>
+        <health_condition_code>
+            {% for hc in object.hc_code %}
+            <hc_code>{{ hc.code }}</hc_code>
+            {% endfor %}
+        </health_condition_code>
+        <health_condition_keyword>
+            {% for hc in object.hc_keyword %}
+            <hc_keyword>{{ hc.code }}</hc_keyword>
+            {% endfor %}
+        </health_condition_keyword>
+        <intervention_code>
+            {% for iv in object.i_code %}
+            <i_code>{{ iv.label }}</i_code>
+            {% endfor %}
+        </intervention_code>
+        <intervention_keyword>
+            {% for iv in object.intervention_keyword %}
+            <i_keyword>{{ iv.code }}</i_keyword>
+            {% endfor %}
+        </intervention_keyword>
+        <primary_outcome>
+            {% for outcomes in object.primary_outcomes %}
+            <prim_outcome>{{ outcomes.description }}</prim_outcome>
+            {% endfor %}
+        </primary_outcome>
+        <secondary_outcome>
+            {% for outcomes in object.secondary_outcomes %}
+            <sec_outcome>{{ outcomes.description }}</sec_outcome>
+            {% empty %}
+            <sec_outcome></sec_outcome>
+            {% endfor %}
+        </secondary_outcome>
+        <secondary_sponsor>
+            {%  for sponsors in object.secondary_sponsors %}
+            <sponsor_name>{{ sponsors.institution.name }}</sponsor_name>
+            {% empty %}
+            <sponsor_name></sponsor_name>
+            {% endfor %}
+        </secondary_sponsor>
+        <secondary_ids>
+            {% for secid in object.trial_number %}
+            <secondary_id>
+                <sec_id>{{ secid.id_number }}</sec_id>
+                <issuing_authority>{{ secid.issuing_authority }}</issuing_authority>    
+            </secondary_id>
+            {% empty %}
+            <secondary_id>
+                <sec_id></sec_id>
+                <issuing_authority></issuing_authority>    
+            </secondary_id>
+            {% endfor %}
+        </secondary_ids>
+        <source_support>
+            {%  for source_support in object.support_sources %}
+            <source_name>{{ source_support.institution.name }}</source_name>
+            {% empty %}
+            <source_name></source_name>
+            {% endfor %}
+        </source_support>        
+    </trial>
+</trials>
+{% endblock %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/xml/all_xml_ictrp.xml
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/xml/all_xml_ictrp.xml (revision 927)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/xml/all_xml_ictrp.xml (revision 927)
@@ -0,0 +1,134 @@
+{% extends "base.xml" %}
+
+{% block root %}
+<trials>
+{% for trial in trial_list %}
+    <trial>
+        <main>
+            <trial_id>{{ trial.ct_fossil.trial_id }}</trial_id>
+            <utrn>{{ trial.ct_fossil.utrn_number }}</utrn>
+            <reg_name>{{ reg_name }}</reg_name>
+            <date_registration>{{ trial.ct_fossil.date_registration|date:"d/m/Y" }}</date_registration>
+            <primary_sponsor>{{ trial.ct_fossil.primary_sponsor.name }}</primary_sponsor>
+            <public_title>{{ trial.ct_fossil.public_title }}</public_title>
+            <acronym>{{ trial.ct_fossil.acronym_display }}</acronym>
+            <scientific_title>{{ trial.ct_fossil.scientific_title }}</scientific_title>
+            <scientific_acronym>{{ trial.ct_fossil.scientific_acronym_display }}</scientific_acronym>
+            <date_enrolment>{{ trial.ct_fossil.date_enrollment_start }}</date_enrolment>
+            <type_enrolment>{% if trial.ct_fossil.enrollment_start_actual %}actual{% else %}anticipated{% endif %}</type_enrolment>
+            <target_size>{{ trial.ct_fossil.target_sample_size }}</target_size>
+            <recruitment_status>{{ trial.ct_fossil.recruitment_status.label }}</recruitment_status>
+            <url>{% url repository.trial_registered_version trial_fossil_id=trial.ct_fossil.trial_id, trial_version=trial.version %}</url>
+            <study_type>{{ trial.ct_fossil.study_type.label }}</study_type>
+            <study_design>{{ trial.ct_fossil.study_design }}</study_design>
+            <phase>{{ trial.ct_fossil.phase.label }}</phase>
+            <hc_freetext>{{ trial.ct_fossil.hc_freetext }}</hc_freetext>
+            <i_freetext>{{ trial.ct_fossil.i_freetext }}</i_freetext>            
+        </main>
+        <contacts>
+        {% for contact in trial.public_contact %}
+            <contact>
+                <type>public</type>
+                <firstname>{{ contact.firstname }}</firstname>
+                <middlename>{{ contact.middlename }}</middlename>
+                <lastname>{{ contact.lastname }}</lastname>
+                <address>{{ contact.address }}</address>
+                <city>{{ contact.city }}</city>
+                <country1>{{ contact.country.description }}</country1>
+                <zip>{{ contact.zip }}</zip>
+                <telephone>{{ contact.telephone }}</telephone>
+                <email>{{ contact.email }}</email>
+                <affiliation>{{ contact.affiliation.name }}</affiliation>
+            </contact>
+        {% endfor %}
+        {% for contact in trial.ct_fossil.scientific_contact %}
+            <contact>
+                <type>scientific</type>
+                <firstname>{{ contact.firstname }}</firstname>
+                <middlename>{{ contact.middlename }}</middlename>
+                <lastname>{{ contact.lastname }}</lastname>
+                <address>{{ contact.address }}</address>
+                <city>{{ contact.city }}</city>
+                <country1>{{ contact.country.description }}</country1>
+                <zip>{{ contact.zip }}</zip>
+                <telephone>{{ contact.telephone }}</telephone>
+                <email>{{ contact.email }}</email>
+                <affiliation>{{ contact.affiliation.name }}</affiliation>
+            </contact>
+        {% endfor %}
+        </contacts>
+        <countries>
+        {% for country in trial.ct_fossil.recruitment_country %}
+            <country2>{{ country.description }}</country2>
+        {% endfor %}
+        </countries>
+        <criteria>
+            <inclusion_criteria>{{ trial.ct_fossil.inclusion_criteria }}</inclusion_criteria>
+            <agemin>{{ trial.ct_fossil.agemin_value }}{% if trial.ct_fossil.agemin_unit != '-' %}{{ trial.ct_fossil.agemin_unit }}{% endif %}</agemin>
+            <agemax>{{ trial.ct_fossil.agemax_value }}{% if trial.ct_fossil.agemax_unit != '-' %}{{ trial.ct_fossil.agemax_unit }}{% endif %}</agemax>
+            <gender>{{ trial.ct_fossil.gender }}</gender>
+            <exclusion_criteria>{{ trial.ct_fossil.exclusion_criteria }}</exclusion_criteria>
+        </criteria>
+        <health_condition_code>
+            {% for hc in trial.ct_fossil.hc_code %}
+            <hc_code>{{ hc.code }}</hc_code>
+            {% endfor %}
+        </health_condition_code>
+        <health_condition_keyword>
+            {% for hc in trial.ct_fossil.hc_keyword %}
+            <hc_keyword>{{ hc.code }}</hc_keyword>
+            {% endfor %}
+        </health_condition_keyword>
+        <intervention_code>
+            {% for iv in trial.ct_fossil.i_code %}
+            <i_code>{{ iv.label }}</i_code>
+            {% endfor %}
+        </intervention_code>
+        <intervention_keyword>
+            {% for iv in trial.ct_fossil.intervention_keyword %}
+            <i_keyword>{{ iv.code }}</i_keyword>
+            {% endfor %}
+        </intervention_keyword>
+        <primary_outcome>
+            {% for outcomes in trial.ct_fossil.primary_outcomes %}
+            <prim_outcome>{{ outcomes.description }}</prim_outcome>
+            {% endfor %}
+        </primary_outcome>
+        <secondary_outcome>
+            {% for outcomes in trial.ct_fossil.secondary_outcomes %}
+            <sec_outcome>{{ outcomes.description }}</sec_outcome>
+            {% empty %}
+            <sec_outcome></sec_outcome>
+            {% endfor %}
+        </secondary_outcome>
+        <secondary_sponsor>
+            {%  for sponsors in trial.ct_fossil.secondary_sponsors %}
+            <sponsor_name>{{ sponsors.institution.name }}</sponsor_name>
+            {% empty %}
+            <sponsor_name></sponsor_name>
+            {% endfor %}
+        </secondary_sponsor>
+        <secondary_ids>
+            {% for secid in trial.ct_fossil.trial_number %}
+            <secondary_id>
+                <sec_id>{{ secid.id_number }}</sec_id>
+                <issuing_authority>{{ secid.issuing_authority }}</issuing_authority>    
+            </secondary_id>
+            {% empty %}
+            <secondary_id>
+                <sec_id></sec_id>
+                <issuing_authority></issuing_authority>    
+            </secondary_id>
+            {% endfor %}
+        </secondary_ids>
+        <source_support>
+            {%  for source_support in trial.ct_fossil.support_sources %}
+            <source_name>{{ source_support.institution.name }}</source_name>
+            {% empty %}
+            <source_name></source_name>
+            {% endfor %}
+        </source_support>        
+    </trial>
+{% endfor %}
+</trials>
+{% endblock %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/step_4.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/step_4.html (revision 847)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/step_4.html (revision 847)
@@ -0,0 +1,20 @@
+{% extends "repository/trial_form.html" %}
+{% load i18n %}
+{% load polyglot_tags %}
+
+{% block endjs %}
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $("div.form select")
+                .change(search_event(
+                        {'decs_url': '{% url decs.search lang=LANGUAGE_CODE, term="" %}',
+                        'icd10_url': '{% url icd10.search lang=LANGUAGE_CODE, term="" %}'},
+                        '{% trans "Search terms" %}',
+                        '{{ LANGUAGE_CODE }}'))
+                .each(function(){$(this).change();});
+        });
+    </script>
+{# the super is called at the end because the js change the elements above and generates conflicts with confirm-before-leave function #}
+{{ block.super }}
+{% endblock %}
+
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/trial_form.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/trial_form.html (revision 819)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/trial_form.html (revision 819)
@@ -0,0 +1,131 @@
+{% extends "repository/submission_step.html" %}
+{% load i18n %}
+{% load remark %}
+{% load polyglot_tags %}
+
+{% block extrahead %}
+        <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}css/multilingual.css"/>
+{% endblock %}
+
+{% block body %}
+    {% include "repository/messages.html" %}
+
+    {% if remarks %}
+    <div class="warning">
+        <a class="minimize button" onclick="$(this.parentNode).toggleClass('warning-minimized').find('ul').toggle('slow')"><img src="{{MEDIA_URL}}media/img/admin/arrow-down.gif"/></a>
+        <a class="maximize button" onclick="$(this.parentNode).toggleClass('warning-minimized').find('ul').toggle('slow')"><img src="{{MEDIA_URL}}media/img/admin/arrow-up.gif"/></a>
+        <h2>{% trans 'Remarks' %}</h2>
+        <ul>
+            {% for remark in remarks %}
+            <li id="remark_{{ remark.id }}">{{ remark.text }}
+                <input onclick="ack_remark({{ remark.id }})" type="button" style="font-size: 80%;" value="{% trans "Mark as reviewed" %}" title="{% trans "Mark as reviewed" %}" />
+            </li>
+            {% endfor %}
+        </ul>
+    </div>
+    {% endif %}
+    <div class="required_fields"><span>(*)</span> {% trans 'Required fields' %}</div>
+    <h2>{% trans title %}</h2>
+    <form action="./" method="POST" class="confirm-before-leave">{% csrf_token %}
+        {% for form in forms %}
+        <fieldset>
+            <legend>{% firstof form.title form.form.title %}</legend>
+            <table class="dataTable" cellspacing="0">
+                {{ form.as_table }}
+            </table>
+        </fieldset>
+        {% endfor %}
+
+        {% for formset in formsets %}
+            {{ formset.management_form }}
+            <fieldset id="{{formset.management_form.prefix}}">
+            <legend>{{ formset.form.title }}</legend>
+
+
+            <div class="{{formset.management_form.prefix}}">
+            {% for form in formset.forms %}
+                <table class="dataTable {% cycle 'even' 'odd' %}" cellspacing="0">
+                    {{ form.as_table }}
+                </table>
+            {% endfor %}
+            </div>
+            <div style="text-align: center">
+                {% block disappear_clone_button %}
+                <input onclick="cloneMore('div.{{formset.management_form.prefix}} table:last','{{formset.management_form.prefix}}')" type="button" value="{% trans 'Add more' %}" />
+                {% endblock %}
+                {% block extra_buttons %}{% endblock %}
+                {% if forloop.last %}
+                    {% block extra_buttons_step_8 %}{% endblock %}
+                {% endif %}
+            </div>
+            </fieldset>
+        {% endfor %}
+        <input type="submit" value="{% trans 'Save' %}" {% if not request.can_change_trial %}disabled="disabled"{% endif %}/>
+    </form>
+
+{% endblock %}
+
+{% block endjs %}{{ block.super }}
+
+<script type="text/javascript" src="{{MEDIA_URL}}js/multilingual.js"></script>
+
+<script type="text/javascript">
+    {% polyglot_js_constants available_languages %}
+
+    $(document).ready(function() {
+        $("select[multiple]").asmSelect({
+                addItemTarget: 'bottom',
+                animate: true,
+                highlight: true,
+                sortable: false
+        });
+        $('.dataTable th img').cluetip({sticky: true, closePosition: 'title',local:true, cursor: 'pointer'});
+    });
+</script>
+
+<script type="text/javascript">
+    $(document).ready(function() {
+        $('#id_target_sample_size').keyup(function() { 
+            this.value = this.value.replace(/[^0-9]/g,'');
+        });
+        
+        $('#id_number_of_arms').keyup(function() { 
+            this.value = this.value.replace(/[^0-9]/g,'');
+        });
+    });
+</script>
+
+<script type="text/javascript">
+    // customization for the Brazilian registry of clinical trials
+    // #190 Show Brazil at the beginning of the selects
+    $(document).ready(function(){
+        $("#asmSelect0 option").first().after($("#asmSelect0 option[value=1]"));
+    });
+</script>
+
+<script type="text/javascript">
+    $(document).ready(function() {
+        // Confirm before user leave page and lose modified data without save them
+        $('form.confirm-before-leave').submit(function(){
+            $(this).data('modified', false);
+            window.onbeforeunload = null;
+        }).each(function(){
+            // Sets this form to modified as false, but after some field be modified, so update this attribute to true
+            $(this).data('modified', false);
+        });
+        
+        // Sets inputs change event to set form modified as true
+        $('form.confirm-before-leave').find(':input').change(function(){
+            $(this).parents('form').data('modified', true);
+
+            // When a user leaves the current page without save, and has modified some field, asks for its confirmation
+            window.onbeforeunload = confirmExit;
+            function confirmExit(){
+                // TODO: translate
+                return '{% trans 'You have done modifications on some fields. Are you sure you want to leave without save before?' %}';
+            }
+        });
+    });
+</script>
+{% endblock %}
+
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/step_8.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/step_8.html (revision 819)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/step_8.html (revision 819)
@@ -0,0 +1,29 @@
+{% extends "repository/trial_form.html" %}
+{% load i18n %}
+{% load polyglot_tags %}
+
+{% block disappear_clone_button %}{% endblock %}
+{% block extra_buttons_step_8 %}
+    <input type="submit" value="{% trans 'Save new contact' %}"/>
+{% endblock %}
+
+{% block endjs %}{{ block.super }}
+    <script type="text/javascript" src="{{MEDIA_URL}}js/jquery.smoothscroll.js"></script>
+
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $("a[href=#new_contact]").smoothScroll();
+        });
+
+        function new_institution(target){
+            return window.open('{% url new_institution %}#'+target,'n_i','status=0,location=0,height=380');
+        }
+    </script>
+    <script type="text/javascript">
+        // customization for the Brazilian registry of clinical trials
+        // #190 Show Brazil at the beginning of the selects
+        $(document).ready(function(){
+            $("#id_new_contact-0-country option").first().after($("#id_new_contact-0-country option[value=1]"));
+        });
+    </script>
+{% endblock %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/new_institution.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/new_institution.html (revision 842)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/new_institution.html (revision 842)
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+    <head>
+        <title>{{ form.title }}</title>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+        
+        <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/style.css"/>
+        <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/jquery.cluetip.css"/>
+        
+        <style type="text/css">
+            fieldset  {
+                margin: 2em;
+            }
+            form table.dataTable th {
+                width: 25%;
+            }
+        </style>
+        
+        <script type="text/javascript" src="{{ MEDIA_URL }}js/local/jquery.js"></script>
+        <script type="text/javascript" src="{{ MEDIA_URL }}js/local/jquery-ui.js"></script>
+        <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.cluetip.min.js" type="text/javascript"></script>
+        
+        <script type="text/javascript">
+            // customization for the Brazilian registry of clinical trials
+            // #190 Show Brazil at the beginning of the selects
+            $(document).ready(function(){
+                $("#id_country option").first().after($("#id_country option[value=1]"));
+            });
+        </script>
+        
+        <script type="text/javascript">
+            function new_institution(){
+                var target = document.location.toString();
+                if(target.match('#')){
+                    target = target.split('#')[1];
+                }
+                
+                if(target==='new_contact'){
+                    new_institution_contact(target);
+                }else if(target==='primary_sponsor'){
+                    new_institution_field(target);
+                }else{
+                    new_institution_sponsors(target);
+                }
+            }
+
+            function new_institution_field(target){
+                var data = '', op = '';
+                $('form *[name]').each(function(){data+=op+this.name+'='+this.value;op='&';});
+                $.post(
+                    $('form').attr('action'),
+                    data,
+                    function(data, ts, xmlhttp){
+                        if(data.match(/<[a-z]+[^>]+>/)){
+                            $("table.dataTable").html(data);
+                        }else {
+                            data=$.parseJSON(data);
+                            var select = opener.$('tr.'+target+' select');
+                            var newoption = opener.$('<option>').attr('value',data[0].pk).html(data[0].fields.name);
+                            select.append(newoption).val(data[0].pk);
+                            window.close();
+                        }
+                    },
+                    'text'
+                );
+            }
+
+            function new_institution_sponsors(target){
+                var data = '', op = '';
+                $('form *[name]').each(function(){data+=op+this.name+'='+this.value;op='&';});
+                $.post(
+                    $('form').attr('action'),
+                    data,
+                    function(data, ts, xmlhttp){
+                        if(data.match(/<[a-z]+[^>]+>/)){
+                            $("table.dataTable").html(data);
+                        }else {
+                            data=$.parseJSON(data);
+                            opener.$('select').each(function(){
+                                var newoption = opener.$('<option>').attr('value',data[0].pk).html(data[0].fields.name);
+                                opener.$(this).append(newoption);
+                            });
+                            var total = opener.$("div."+target+" select").length;
+                            var targetSel = opener.$('#id_'+target+'-'+(total-1)+'-institution')[0];
+                            if(targetSel.selectedIndex === 0){
+                                targetSel.selectedIndex = $(targetSel).find("option").length-1;
+                            }else{
+                                opener.cloneMore('div.'+target+' table:last',target);
+                                targetSel = opener.$('#id_'+target+'-'+total+'-institution')[0];
+                                targetSel.selectedIndex = $(targetSel).find("option").length-1;
+                            }
+                            window.close();
+                        }
+                    },
+                    'text'
+                );
+            }
+            
+            function new_institution_contact(target){
+                var data = '', op = '';
+                $('form *[name]').each(function(){data+=op+this.name+'='+this.value;op='&';});
+                $.post(
+                    $('form').attr('action'),
+                    data,
+                    function(data, ts, xmlhttp){
+                        if(data.match(/<[a-z]+[^>]+>/)){
+                            $("table.dataTable").html(data);
+                        } else {
+                            data=$.parseJSON(data);
+                            opener.$('select[id$=affiliation]').each(function(){
+                                var newoption = opener.$('<option>').attr('value',data[0].pk).html(data[0].fields.name);
+                                opener.$(this).append(newoption);
+                            });
+                            var total = opener.$("div."+target+" select[id$=affiliation]").length;
+                            var targetSel = opener.$('#id_'+target+'-'+(total-1)+'-affiliation')[0];
+                            if(targetSel.selectedIndex === 0){
+                                targetSel.selectedIndex = $(targetSel).find("option").length-1;
+                            }else{
+                                opener.cloneMore('div.'+target+' table:last',target);
+                                targetSel = opener.$('#id_'+target+'-'+total+'-affiliation')[0];
+                                targetSel.selectedIndex = $(targetSel).find("option").length-1;
+                            }
+                            window.close();
+                        }
+                    },
+                    'text'
+                );
+            }
+
+            $(document).ready(function() {
+                $('.dataTable th img').cluetip({sticky: true, closePosition: 'title',local:true, cursor: 'pointer'});
+            });
+        </script>
+{% load i18n %}
+    </head>
+    <body>
+        <form action="{% url new_institution %}" method="post" onsubmit="return false;">{% csrf_token %}
+            <fieldset>
+                <legend>{{ form.title }}</legend>
+                <table class="dataTable" cellspacing="0">
+                    {{ form.as_table }}
+                </table>
+                <input type="button" value="{% trans 'Save' %}" onclick="new_institution();"/>
+            </fieldset>
+        </form>
+    </body>
+</html>
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/trial_index.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/trial_index.html (revision 774)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/trial_index.html (revision 774)
@@ -0,0 +1,56 @@
+{% extends "base.html" %}
+{% load i18n %}
+{% block body_title %}{% trans "Trial Summary" %}{% endblock %}
+
+{% block stepmenu_top %}
+    {{ block.super }}
+    <small>
+        / <a href="{% url reviewapp.submissionlist %}">{% trans 'Submissions' %}</a>
+    </small>
+    <big>/ {% trans 'Trial Summary' %}</big>
+    <div style="float:right; margin-right:20px;">
+        <small><a href="{% url repository.trialview trial_pk %}">{% trans 'Preview' %}</a></small>
+    </div>
+{% endblock %}
+
+{% block body %}
+
+{% include "repository/messages.html" %}
+
+<table class="dataTable trialsummary">
+    <thead>
+        <tr>
+            <th>{% trans "Part" %}</th>
+            <th>{% trans "Form name" %}</th>
+
+            {% for lang in submission.get_mandatory_languages %}
+                <th>{% trans "Status" %} ({% trans lang %})</th>
+            {% endfor %}    
+        </tr>
+    </thead>
+    {% for link in links %} 
+        <tr>
+            <td>{{forloop.counter}}</td>
+            <td><a href="{{link.url}}">{{ link.label }}</a></td>
+            {% for lang in link.trans %}
+                <td><img src="{{lang.icon}}" alt="{{lang.leg}}" title="{{lang.leg}}"/>&nbsp;&nbsp;{{lang.msg}}</td>
+            {% endfor %}    
+        </tr>
+    {% endfor %}    
+</table>
+<table border="0">
+    <tr>
+    <td>
+        <form name="submit_submission" action="#" method="POST">
+            {% csrf_token %}
+            <input type="submit" name="submit_submission" value="{% trans "Submit for Review" %}" {% if not submit %} disabled="disabled" {% endif %} />
+        </form>
+    </td>
+    <td>
+        <div style="margin-left:10px;">
+            <img src="{{ status_message.icon }}" alt="{{status_message.msg}}" title="{{status_message.msg}}" />&nbsp;&nbsp;{{ status_message.msg }}
+        </div>
+    </td>
+    </tr>
+</table>
+{% endblock %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/clinicaltrial_recruiting.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/clinicaltrial_recruiting.html (revision 677)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/clinicaltrial_recruiting.html (revision 677)
@@ -0,0 +1,61 @@
+{% extends "base.html" %}
+
+{% load i18n %}
+
+{% block body_title %}{% trans "Clinical Trials" %}{% endblock %}
+
+{% block stepmenu_top %}
+    {{ block.super }}
+    <big>/ {% trans 'Recruiting' %}</big>
+{% endblock %}
+
+{% block body %}
+
+    {% if objects.object_list %}
+        {% for ct in objects.object_list %}
+        <table class="trial_table">
+            <tr>
+                <td class="trial_label" width="50%">{% trans 'Title' %}</td>
+                <td class="trial_label" width="30%">{% trans 'Primary Id Number' %}</td>
+                <td class="trial_content" width="20%"><a href="{% url repository.trial_registered ct.trial_id %}">{{ ct.trial_id }}</a></td>
+            </tr>
+            <tr>
+                <td class="trial_title" rowspan="2"><a href="{% url repository.trial_registered ct.trial_id %}">{{ ct.main_title }}</a></td>
+                <td class="trial_label">{% trans 'Recruitment Status' %}</td>
+                <td class="trial_content">{{ ct.rec_status }}</td>
+            </tr>
+            <tr>
+                <td class="trial_label">{% trans 'Date of Registration' %}</td>
+                <td class="trial_content">{{ ct.date_registration }}</td>
+            </tr>
+        </table>
+        {% endfor %}
+        
+        {% if paginator.num_pages > 1 %}
+        <div class="pagination">
+            {% if objects.has_previous %}
+                <a href="?page=1"><<</a>
+                <a href="?page={{ objects.previous_page_number }}"><</a>
+            {% endif %}
+            
+            {% for p in paginator.page_range %}
+                {% if p == page %}
+                  <span class="current">
+                      {{ p }}
+                  </span>
+                {% else %}
+                    <a href="?page={{ p }}">{{ p }}</a>
+                {% endif %}
+            {% endfor %}
+            
+            {% if objects.has_next %}
+                  <a href="?page={{ objects.next_page_number }}">></a>
+                  <a href="?page={{ paginator.num_pages }}">>></a>
+            {% endif %}
+        </div>
+        {% endif %}
+
+    {% else %}
+        <p>{% trans 'No clinical trials recruiting.' %}</p>
+    {% endif %}
+{% endblock %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/clinicaltrial_list.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/clinicaltrial_list.html (revision 711)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/clinicaltrial_list.html (revision 711)
@@ -0,0 +1,65 @@
+{% extends "base.html" %}
+
+{% load i18n %}
+
+{% block body_title %}{% trans "Clinical Trials" %}{% endblock %}
+
+{% block stepmenu_top %}
+    {{ block.super }}
+    <big>/ {% trans 'Registered Trials' %}</big>
+{% endblock %}
+
+{% block body %}
+
+    {% if objects.object_list %}
+        {% for ct in objects.object_list %}
+        <table class="trial_table">
+            <tr>
+                <td class="trial_label" width="50%">{% trans 'Title' %}</td>
+                <td class="trial_label" width="30%">{% trans 'Primary Id Number' %}</td>
+                <td class="trial_content" width="20%"><a href="{% url repository.trial_registered ct.trial_id %}">{{ ct.trial_id }}</a></td>
+            </tr>
+            <tr>
+                <td class="trial_title" rowspan="2"><a href="{% url repository.trial_registered ct.trial_id %}">{{ ct.main_title }}</a></td>
+                <td class="trial_label">{% trans 'Recruitment Status' %}</td>
+                <td class="trial_content">{{ ct.rec_status }}</td>
+            </tr>
+            <tr>
+                <td class="trial_label">{% trans 'Date of Registration' %}</td>
+                <td class="trial_content">{{ ct.date_registration }}</td>
+            </tr>
+        </table>
+        {% endfor %}
+        
+        {% if paginator.num_pages > 1 %}
+        <div class="pagination">
+            {% if objects.has_previous %}
+                <a href="?page=1"><<</a>
+                <a href="?page={{ objects.previous_page_number }}"><</a>
+            {% endif %}
+            
+            {% for p in paginator.page_range %}
+                {% if p == page %}
+                  <span class="current">
+                      {{ p }}
+                  </span>
+                {% else %}
+                    <a href="?page={{ p }}">{{ p }}</a>
+                {% endif %}
+            {% endfor %}
+            
+            {% if objects.has_next %}
+                  <a href="?page={{ objects.next_page_number }}">></a>
+                  <a href="?page={{ paginator.num_pages }}">>></a>
+            {% endif %}
+        </div>
+        {% endif %}
+
+    {% else %}
+        {% if q %}
+             <p>{% trans 'No clinical trial has been found with the term:' %} {{ q }}</p>
+        {% else %}
+            <p>{% trans 'No clinical trial has been registered.' %}</p>
+        {% endif %}
+    {% endif %}
+{% endblock %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/add_clinicalTrials.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/add_clinicalTrials.html (revision 345)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/add_clinicalTrials.html (revision 345)
@@ -0,0 +1,12 @@
+{% extends "base.html" %}
+{% load i18n %}
+{% block body_title %}{% trans "Add a new Clinical Trial Record" %}{% endblock %}
+
+{% block body %}
+    <form action="./" method="POST">{% csrf_token %}
+        <table>
+        {{form.as_table}}
+        </table>
+        <input type="submit">
+    </form>
+{% endblock %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/messages.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/messages.html (revision 774)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/messages.html (revision 774)
@@ -0,0 +1,7 @@
+{% if messages %}
+<ul class="messages">
+    {% for msg in messages %}
+    <li>{{ msg }}</li>
+    {% endfor %}
+</ul>
+{% endif %}
Index: /tags/v1.0.23rc1/opentrials/repository/templates/repository/attachments.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/repository/attachments.html (revision 994)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/repository/attachments.html (revision 994)
@@ -0,0 +1,148 @@
+{% extends "repository/submission_step.html" %}
+{% load i18n %}
+{% load remark %}
+{% load polyglot_tags %}
+
+{% block body %}
+
+    {% include "repository/messages.html" %}
+    
+    {% if remarks %}
+    <div class="warning">
+        <a class="minimize button" onclick="$(this.parentNode).toggleClass('warning-minimized').find('ul').toggle('slow')"><img src="{{MEDIA_URL}}media/img/admin/arrow-down.gif"/></a>
+        <a class="maximize button" onclick="$(this.parentNode).toggleClass('warning-minimized').find('ul').toggle('slow')"><img src="{{MEDIA_URL}}media/img/admin/arrow-up.gif"/></a>
+        <h2>{% trans 'Remarks' %}</h2>
+        <ul>
+            {% for remark in remarks %}
+            <li id="remark_{{ remark.id }}">{{ remark.text }}
+                <input onclick="ack_remark({{ remark.id }})" type="button" style="font-size: 80%;" value="{% trans "Mark as reviewed" %}" title="{% trans "Mark as reviewed" %}" />
+            </li>
+            {% endfor %}
+        </ul>
+    </div>
+    {% endif %}
+    <div class="required_fields"><span>(*)</span> {% trans 'Required fields' %}</div>
+    
+    <h2>{% trans title %}</h2>
+    
+    {% if existing_attachments %}
+        <h3>{% trans 'Existing attachments' %}</h3>
+
+        {% for attachment in existing_attachments %}
+            <ul>
+                {% if attachment.file %}
+                <li>{% trans 'File' %}:
+                    <a href="http://{{host}}{{attachment.get_relative_url}}">
+                        http://{{host}}{{attachment.get_relative_url}}
+                    </a>
+                </li>
+                {% else %}
+                <li>{% trans 'File' %}:
+                    <a href="{{attachment.attach_url}}">
+                        {{attachment.attach_url}}
+                    </a>
+                </li>
+                {% endif %}
+                <li>{% trans 'Description' %}: {{attachment.description}}</li>
+                <li>
+                    <form action="./" method='POST'>{% csrf_token %}
+                        <input type="hidden" name='remove' value='{{attachment.id}}'/>
+                        <input type="button" value='{%trans "Remove" %}' onclick="if(confirm('{%trans "Remove this attachment?" %}')) submit()" />
+                    </form>
+                </li>
+            </ul> 
+
+        {% endfor %}
+    {% endif %}
+    
+    <h3>{% trans 'New attachment form' %}</h3>
+    <form action="./" method="POST" enctype="multipart/form-data" >{% csrf_token %}
+
+        {% for formset in formsets %}
+            {{ formset.management_form }}
+            <fieldset>
+            <legend>{{ formset.form.title }}</legend>
+
+
+            <div class="{{formset.management_form.prefix}}">
+            {% for form in formset.forms %}
+                <table class="dataTable {% cycle 'even' 'odd' %}" cellspacing="0">
+                    {{ form.as_table }}
+                </table>
+            {% endfor %}
+            </div>
+            <div style="text-align: center">
+              <input onclick="cloneMore('div.{{formset.management_form.prefix}} table:last','{{formset.management_form.prefix}}')" type="button" value="{% trans "Add more" %}" />
+            </div>
+            </fieldset>
+        {% endfor %}
+        <input type="submit" value="{% trans "Save" %}" {% if not request.can_change_trial %}disabled="disabled"{% endif %}/>
+    </form>
+
+{% endblock %}
+
+{% block endjs %}{{ block.super }}
+
+<script type="text/javascript" src="{{MEDIA_URL}}js/multilingual.js"></script>
+
+<script type="text/javascript">
+    {% polyglot_js_constants available_languages %}
+
+    $(document).ready(function() {
+        $("select[multiple]").asmSelect({
+                addItemTarget: 'bottom',
+                animate: true,
+                highlight: true,
+                sortable: false
+        });
+        $('.dataTable th img').cluetip({sticky: true, closePosition: 'title',local:true, cursor: 'pointer'});
+    });
+</script>
+
+<script type="text/javascript">
+    $(document).ready(function() {
+       $('select[name*="attach_type"]').change(function() {
+         name = $(this)[0].name;
+         value = $(this)[0].value;
+         order = parseInt(name.replace(/[^0-9]/g, ''))
+
+         if(value == 'file'){
+             //hide url, show file
+             $('input[name*="url"]')[order].disabled = true
+             $('input[name*="file"]')[order].disabled = false
+         }
+         else{
+             //hide file, show url
+             $('input[name*="url"]')[order].disabled = false
+             $('input[name*="file"]')[order].disabled = true
+         }         
+       });
+     });
+</script>
+
+<script type="text/javascript">
+    $(document).ready(function() {
+        // Confirm before user leave page and lose modified data without save them
+        $('form.confirm-before-leave').submit(function(){
+            $(this).data('modified', false);
+            window.onbeforeunload = null;
+        }).each(function(){
+            // Sets this form to modified as false, but after some field be modified, so update this attribute to true
+            $(this).data('modified', false);
+        });
+        
+        // Sets inputs change event to set form modified as true
+        $('form.confirm-before-leave').find(':input').change(function(){
+            $(this).parents('form').data('modified', true);
+
+            // When a user leaves the current page without save, and has modified some field, asks for its confirmation
+            window.onbeforeunload = confirmExit;
+            function confirmExit(){
+                // TODO: translate
+                return '{% trans 'You have done modifications on some fields. Are you sure you want to leave without save before?' %}';
+            }
+        });
+    });
+</script>
+{% endblock %}
+
Index: /tags/v1.0.23rc1/opentrials/repository/templates/admin/repository/publishedtrial/change_form.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/templates/admin/repository/publishedtrial/change_form.html (revision 867)
+++ /tags/v1.0.23rc1/opentrials/repository/templates/admin/repository/publishedtrial/change_form.html (revision 867)
@@ -0,0 +1,120 @@
+{% extends "admin/change_form.html" %}
+
+{% load i18n %}
+
+{% block extrastyle %}{{ block.super }}
+<style type="text/css">
+    .buttons {
+        padding: 5px;
+    }
+
+    .form-row div.value {
+        margin-left: 190px;
+    }
+</style>
+{% endblock extrastyle %}
+
+{% block content %}
+<div id="content-main">
+
+<div class="module buttons">
+    {% if original.display == 'True' %}
+    <a href="display-off/">{% trans "Set Display Off" %}</a>
+    {% else %}
+    <a href="display-on/">{% trans "Set Display On" %}</a>
+    {% endif %}
+</div>
+
+<fieldset class="module aligned wide">
+    {% for field in trial_fields %}
+    <div class="form-row {{ field.name }}">
+        <div>
+            <label>
+              {% if field.name == "translations" %}
+                {% trans "Translations" %}
+              {% else %}{% if field.name == "support_sources" %}
+                {% trans "Support Sources" %}
+              {% else %}{% if field.name == "primary_outcomes" %}
+                {% trans "Primary Outcomes" %}
+              {% else %}{% if field.name == "secondary_outcomes" %}
+                {% trans "Secondary Outcomes" %}
+              {% else %}{% if field.name == "trial_number" %}
+                {% trans "Trial Numbers" %}
+              {% else %}{% if field.name == "hc_code" %}
+                {% trans "Health Codes" %}
+              {% else %}{% if field.name == "intervention_keyword" %}
+                {% trans "Intervention Keywords" %}
+              {% else %}{% if field.name == "secondary_sponsors" %}
+                {% trans "Secondary Sponsors" %}
+              {% else %}{% if field.name == "hc_keyword" %}
+                {% trans "Health Keywords" %}
+              {% else %}
+                {{ field.label }}
+              {% endif %}{% endif %}{% endif %}{% endif %}{% endif %}{% endif %}{% endif %}
+                {% endif %}{% endif %}
+            </label>
+        
+            <div class="value">
+              {% if field.name == "primary_sponsor" %}
+                {% trans "ID" %}: {{ field.value.pk }}<br/>
+                {% trans "Name" %}: {{ field.value.name }}<br/>
+                {% trans "Address" %}: {{ field.value.address }}<br/>
+                {% trans "Country" %}: {{ field.value.country.description|default:field.value.country.label }}<br/>
+                {% trans "Creator" %}: {{ field.value.creator.username }}
+              {% else %}{% if field.name in vocabulary_fields %}
+                {% if field.value.description %}
+                  {{ field.value.description }}
+                {% else %}
+                  {{ field.value.label }}
+                {% endif %}
+              {% else %}{% if field.name == "public_contact" %}
+                {% for item in field.value %}
+                {{ item.firstname }} {{ item.middlename }} {{ item.lastname }}<br/>
+                {% endfor %}
+              {% else %}{% if field.name == "scientific_contact" %}
+                {% for item in field.value %}
+                {{ item.firstname }} {{ item.middlename }} {{ item.lastname }}<br/>
+                {% endfor %}
+              {% else %}{% if field.name == "site_contact" %}
+                {% for item in field.value %}
+                {{ item.firstname }} {{ item.middlename }} {{ item.lastname }}<br/>
+                {% endfor %}
+              {% else %}{% if field.name == "i_code" %}
+                {% for item in field.value %}{{ item.description|default:item.label }}<br/>{% endfor %}
+              {% else %}{% if field.name == "recruitment_country" %}
+                {% for item in field.value %}{{ item.description|default:item.label }}<br/>{% endfor %}
+              {% else %}{% if field.name == "translations" %}
+                {% for item in field.value %}{{ item.language }}<br/>{% endfor %}
+              {% else %}{% if field.name == "support_sources" %}
+                {% for item in field.value %}{{ item.name }}<br/>{% endfor %}
+              {% else %}{% if field.name == "secondary_sponsors" %}
+                {% for item in field.value %}{{ item.name }}<br/>{% endfor %}
+              {% else %}{% if field.name in outcome_fields %}
+                {% for item in field.value %}
+                {% trans "Description" %}: {{ item.description }},
+                {% trans "Interest" %}: {{ item.interest }}<br/>
+                {% endfor %}
+              {% else %}{% if field.name == "trial_number" %}
+                {% for item in field.value %}
+                {% trans "Issuing Authority" %}: {{ item.issuing_authority }},
+                {% trans "ID Number" %}: {{ item.id_number }}<br/>
+                {% endfor %}
+              {% else %}{% if field.name in description_fields %}
+                {% for item in field.value %}
+                {% trans "Vocabulary" %}: {{ item.vocabulary }},
+                {% trans "Code" %}: {{ item.code }},
+                {% trans "Text" %}: {{ item.text }},
+                {% trans "Translations" %}: {% for t in item.translations %}{{ t.text }} ({{ t.language }}), {% endfor %}<br/>
+                {% endfor %}
+              {% else %}
+                {{ field.value }}
+              {% endif %}{% endif %}{% endif %}{% endif %}{% endif %}{% endif %}{% endif %}
+                {% endif %}{% endif %}{% endif %}{% endif %}{% endif %}{% endif %}
+            </div>
+        </div>
+    </div>
+    {% endfor %}
+</fieldset>
+
+</div>
+{% endblock content %}
Index: /tags/v1.0.23rc1/opentrials/repository/xml/validate.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/validate.py (revision 839)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/validate.py (revision 839)
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+
+import sys, os
+from lxml import etree
+
+cur_dir = os.path.dirname(os.path.abspath(__file__))
+DEFAULT_DTD = os.path.join(cur_dir, 'opentrials.dtd')
+ICTRP_DTD = os.path.join(cur_dir, 'who_ictrp.dtd')
+
+class InvalidOpenTrialsXML(Exception): pass
+
+def validate_xml(filename_or_xmltree, dtd=DEFAULT_DTD):
+    """
+    Validates a XML file according to a given DTD file.
+    """
+    parser = etree.XMLParser(dtd_validation=False)
+    dtd = etree.DTD(dtd)
+
+    if isinstance(filename_or_xmltree, basestring):
+        tree = etree.parse(filename_or_xmltree, parser)
+    else:
+        tree = filename_or_xmltree
+    
+    valid = dtd.validate(tree)
+
+    if not valid:
+        raise InvalidOpenTrialsXML(dtd.error_log.filter_from_errors())
+
+    return True
+
+if __name__ == '__main__':
+    for arg in sys.argv[1:]:
+        print '%-16s' % arg,
+
+        try:
+            result = validate_xml(arg)
+        except etree.XMLSyntaxError, e:
+            print 'ERROR: malformed XML: %s' % e
+        except InvalidOpenTrialsXML, e:
+            print 'INVALID'
+            print e
+        else:    
+            print 'OK'
+
+""" # OLD CODE:
+
+parser = etree.XMLParser(dtd_validation=False)
+
+dtd = etree.DTD('opentrials.dtd')
+for arg in sys.argv[1:]:
+    print '%-16s' % arg,
+    try:
+        tree = etree.parse(arg, parser)
+    except etree.XMLSyntaxError:
+        print 'ERROR: malformed XML'
+    else:    
+        if dtd.validate(tree):
+            print 'OK'
+        else:
+            print 'INVALID'
+            print dtd.error_log.filter_from_errors()[0]
+"""
+
Index: /tags/v1.0.23rc1/opentrials/repository/xml/generate.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/generate.py (revision 930)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/generate.py (revision 930)
@@ -0,0 +1,200 @@
+import datetime
+
+from django.template.loader import render_to_string
+from django.conf import settings
+
+from repository import choices
+from repository.xml import OPENTRIALS_XML_VERSION
+from repository.templatetags.repository_tags import prep_label_for_xml
+
+from vocabulary.models import CountryCode, InterventionCode, StudyPurpose
+from vocabulary.models import InterventionAssigment, StudyMasking, StudyAllocation
+from vocabulary.models import StudyPhase, StudyType, RecruitmentStatus, InstitutionType
+
+VALID_FUNCTIONS = (
+    'xml_ictrp',
+    'xml_opentrials',
+    'xml_opentrials_mod',
+    )
+
+def xml_ictrp(fossils, **kwargs):
+    """Generates an ICTRP XML for a given Clinical Trial and returns as string."""
+    
+    trials = []
+    
+    for fossil in fossils:
+        trial = {}
+        ct_fossil = fossil.get_object_fossil()
+        trial['ct_fossil'] = ct_fossil
+        trial['public_contact'] = ct_fossil.public_contact if ct_fossil.public_contact \
+                                            else ct_fossil.scientific_contact
+        trial['hash_code'] = fossil.pk
+        trial['previous_revision'] = fossil.previous_revision       
+        trial['version'] = fossil.revision_sequential
+        trials.append(trial)
+        
+    return render_to_string(
+            'repository/xml/all_xml_ictrp.xml', # old clinicaltrial_detail.xml
+            {'trial_list': trials, 'reg_name': settings.REG_NAME},
+            )              
+
+def xml_opentrials(trial, persons, include_translations=True, **kwargs):
+    """Generates an Opentrials XML for a given Clinical Trial and returns as string."""
+
+    for translation in trial.translations:
+        translation['primary_outcomes'] = []
+        for outcome in trial.primary_outcomes:
+            for out_trans in outcome['translations']:
+                if out_trans['language'] == translation['language']:
+                    translation['primary_outcomes'].append(out_trans)
+
+        translation['secondary_outcomes'] = []
+        for outcome in trial.secondary_outcomes:
+            for out_trans in outcome['translations']:
+                if out_trans['language'] == translation['language']:
+                    translation['secondary_outcomes'].append(out_trans)
+
+    return render_to_string(
+            'repository/xml/xml_opentrials.xml',
+            {'object': trial,
+             'reg_name': settings.REG_NAME,
+             'persons': persons,
+             'include_translations': include_translations,
+             'opentrials_xml_version': OPENTRIALS_XML_VERSION},
+            )
+
+MOD_TEMPLATE = """<!-- ===========================================================================
+File: opentrials-vocabularies.mod
+
+OpenTrials: Latin-American and Caribbean Clinical Trial Record XML DTD
+DTD Version 1.0: %(generation)s
+
+Entity definitions used by the opentrials.dtd file.
+This file should be generated automatically from controlled vocabulary data
+such as those from Vocabulary application.
+=========================================================================== -->
+
+%(entities)s"""
+
+def xml_opentrials_mod(**kwargs):
+    """Generates the MOD file with valid vocabularies for Opentrials XML standard."""
+    entities = []
+
+    # Languages
+    #entities.append('\n'.join([
+    #        '<!ENTITY % language.options',
+    #        '    "en|es|fr|pt|other">'
+    #        ]))
+
+    # Health conditions
+    entities.append('\n'.join([
+            '<!-- TRDS 12: health condition attributes -->',
+            '<!ENTITY % vocabulary.options',
+            '    "decs|icd10|other">',
+            ]))
+
+    # Intervention codes
+    icodes = map(prep_label_for_xml, InterventionCode.objects.values_list('label', flat=True))
+    entities.append('\n'.join([
+            '<!-- TRDS 13: intervention descriptor attributes -->',
+            '<!-- attribute options cannot contain slashes "/" -->',
+            '<!ENTITY % interventioncode.options',
+            '    "%s">' % '|'.join(icodes), # FIXME: check why labels were defined with
+                                            # '-' replacing ' ' on old .mod
+            ]))
+
+    # Study statuses
+    statuses = map(prep_label_for_xml, RecruitmentStatus.objects.values_list('label', flat=True))
+    entities.append('\n'.join([
+            '<!ENTITY % requirementstatus.options',
+            '    "%s">' % '|'.join(statuses),
+            ]))
+
+    # Age units
+    entities.append('\n'.join([
+            '<!ENTITY % ageunit.options',
+            '    "null|years|months|weeks|days|hours">',
+            ]))
+
+    # Genders
+    entities.append('\n'.join([
+            '<!ENTITY % gender.options',
+            '    "female|male|both">',
+            ]))
+
+    # Purposes
+    purposes = map(prep_label_for_xml, StudyPurpose.objects.values_list('label', flat=True))
+    entities.append('\n'.join([
+            '<!-- TRDS 15b: study_design attributes -->',
+            '<!ENTITY % purpose.options',
+            '    "%s">' % '|'.join(purposes),
+            ]))
+
+    # Assignment
+    assignments = map(prep_label_for_xml, InterventionAssigment.objects.values_list('label', flat=True))
+    entities.append('\n'.join([
+            '<!ENTITY % assignment.options',
+            '    "%s">' % '|'.join(assignments),
+            ]))
+
+    # Masking
+    maskings = map(prep_label_for_xml, StudyMasking.objects.values_list('label', flat=True))
+    entities.append('\n'.join([
+            '<!ENTITY % masking.options',
+            '    "%s">' % '|'.join(maskings),
+            ]))
+
+    # Allocation
+    allocations = map(prep_label_for_xml, StudyAllocation.objects.values_list('label', flat=True))
+    entities.append('\n'.join([
+            '<!ENTITY % allocation.options',
+            '    "%s">' % '|'.join(allocations),
+            ]))
+
+    # Phases
+    phases = map(prep_label_for_xml, StudyPhase.objects.values_list('label', flat=True))
+    entities.append('\n'.join([
+            '<!-- TRDS 15c -->',
+            '<!ENTITY % phase.options',
+            '    "%s">' % '|'.join(phases), # FIXME: replace N/A for null?
+            ]))
+
+    # Contact types
+    entities.append('\n'.join([
+            '<!ENTITY % contacttype.options',
+            '    "public|scientific|site">',
+            ]))
+
+    # Countries
+    countries = CountryCode.objects.values_list('label', flat=True)
+    entities.append('\n'.join([
+            '<!ENTITY % country.options',
+            '    "%s">' % '|'.join(countries),
+            ]))
+
+    # Trial Statuses
+    statuses = [st[0] for st in choices.TRIAL_RECORD_STATUS]
+    entities.append('\n'.join([
+            '<!ENTITY % trialstatus.options',
+            '    "%s">' % '|'.join(statuses),
+            ]))
+
+    # Study Types
+    study_types = map(prep_label_for_xml, StudyType.objects.values_list('label', flat=True))
+    entities.append('\n'.join([
+            '<!ENTITY % study_type.options',
+            '    "%s">' % '|'.join(study_types),
+            ]))
+
+    # Institution Types
+    institution_types = map(prep_label_for_xml, InstitutionType.objects.values_list('label', flat=True))
+    entities.append('\n'.join([
+            '<!ENTITY % institution_type.options',
+            '    "%s">' % '|'.join(institution_types),
+            ]))
+
+    return MOD_TEMPLATE%{
+            'generation': datetime.date.today().strftime('%Y-%m-%d'),
+            'entities': '\n\n'.join(entities),
+            }
+
Index: /tags/v1.0.23rc1/opentrials/repository/xml/loading.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/loading.py (revision 980)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/loading.py (revision 980)
@@ -0,0 +1,759 @@
+try:
+  from lxml import etree
+except ImportError:
+  try:
+    # Python 2.5
+    import xml.etree.cElementTree as etree
+  except ImportError:
+    try:
+      # Python 2.5
+      import xml.etree.ElementTree as etree
+    except ImportError:
+      try:
+        # normal cElementTree install
+        import cElementTree as etree
+      except ImportError:
+        try:
+          # normal ElementTree install
+          import elementtree.ElementTree as etree
+        except ImportError:
+          raise Exception("Failed to import lxml/ElementTree from any known place")
+
+import re
+from datetime import datetime
+from django.db.models.fields import NOT_PROVIDED, CharField, TextField
+from repository.models import ClinicalTrial, Institution, PublicContact, ScientificContact
+from repository.models import SiteContact, TrialNumber, TrialSecondarySponsor, TrialSupportSource
+from repository.models import Outcome, Descriptor, Contact
+from vocabulary.models import StudyType, StudyPurpose, InterventionAssigment, StudyMasking
+from vocabulary.models import StudyAllocation, StudyPhase, RecruitmentStatus, CountryCode
+from vocabulary.models import InterventionCode
+from repository.xml import OPENTRIALS_XML_VERSION
+from validate import validate_xml, ICTRP_DTD
+
+UPDATE_IF_EXISTS = 'u'
+REPLACE_IF_EXISTS = 'r'
+SKIP_IF_EXISTS = 's'
+
+GENDERS = {'both':'-', 'male':'M', 'female':'F'}
+AGE_UNITS = {'null':'-', 'years':'Y', 'months':'M', 'weeks':'W', 'days':'D', 'hours':'H'}
+EXP_AGE_ICTRP = re.compile('^(\d+)(-|Y|M|W|D|H)?$')
+
+class OpenTrialsXMLImport(object):
+    def __init__(self, creator=None):
+        self.creator = creator
+
+    # OPENTRIALS XML
+
+    def parse_opentrials(self, filename_or_xmltree):
+        """
+        Validates a given file and parses it without to persist on database. Collected
+        trials are just saved in the attribute '_parsed_trials' to be imported after.
+
+        For WHO OpenTrials XML format.
+        """
+        # Validates using DTD
+        validation = validate_xml(filename_or_xmltree)
+
+        if validation is not True:
+            raise Exception(validation)
+
+        self._parsed_trials = []
+        
+        # Loads XML file
+        if isinstance(filename_or_xmltree, basestring):
+            fp = file(filename_or_xmltree)
+            tree = etree.parse(fp)
+        else:
+            tree = filename_or_xmltree
+            fp = None
+
+        trials = tree.getroot()
+        trials_attrs = dict(trials.items())
+
+        for trial in trials.iterchildren():
+            # Collects the list of trials, as dictionaries
+            fields = self.collect_trial_fields_opentrials(trial)
+
+            # Loads the trial from database and clear it or just create a new instance in memory
+            try:
+                ct = ClinicalTrial.objects.get(trial_id=fields['trial_id'])
+            except ClinicalTrial.DoesNotExist:
+                ct = None
+
+            self._parsed_trials.append((fields, ct))
+
+        if fp:
+            fp.close()
+
+        return self._parsed_trials
+
+    def import_opentrials(self, filename_or_xmltree, if_exists=UPDATE_IF_EXISTS):
+        """
+        Uses lxml to load a file in OpenTrials XML format and load it into database.
+        """
+
+        self.parse_opentrials(filename_or_xmltree)
+
+        return self.import_parsed(if_exists)
+
+    def collect_trial_fields_opentrials(self, node):
+        fields = {}
+        translations = []
+
+        # Fields: created, date_registration, status, updated
+        fields.update(dict(node.items()))
+
+        # Collect fields
+        for block in node.iterchildren():
+            if block.tag == 'trial_identification':
+                for field in block.iterchildren():
+                    if field.tag in ('trial_id', 'utrn', 'reg_name', 'public_title', 'acronym',
+                                     'acronym_expansion', 'scientific_title', 'scientific_acronym',
+                                     'scientific_acronym_expansion'):
+                        fields[field.tag] = field.text
+            elif block.tag == 'sponsors_and_support':
+                for field in block.iterchildren():
+                    if field.tag == 'primary_sponsor':
+                        fields[field.tag] = self.get_institution(field)
+                    elif field.tag == 'secondary_sponsor':
+                        fields.setdefault('secondary_sponsors', [])
+                        fields['secondary_sponsors'].append(self.get_institution(field))
+                    elif field.tag == 'source_support':
+                        fields.setdefault('source_support', [])
+                        fields['source_support'].append(self.get_institution(field))
+            elif block.tag == 'health_conditions':
+                for field in block.iterchildren():
+                    if field.tag == 'hc_code':
+                        fields.setdefault('hc_codes', [])
+                        fields['hc_codes'].append(self.get_hc_or_ic(field))
+                    elif field.tag == 'keyword':
+                        fields.setdefault('hc_keywords', [])
+                        fields['hc_keywords'].append(self.get_hc_or_ic(field))
+                    elif field.tag == 'freetext':
+                        fields['hc_freetext'] = field.text
+            elif block.tag == 'interventions':
+                for field in block.iterchildren():
+                    if field.tag == 'i_code':
+                        fields.setdefault('i_codes', [])
+                        fields['i_codes'].append(self.get_i_code(field))
+                    elif field.tag == 'keyword':
+                        fields.setdefault('i_keywords', [])
+                        fields['i_keywords'].append(self.get_hc_or_ic(field))
+                    elif field.tag == 'freetext':
+                        fields['i_freetext'] = field.text
+            elif block.tag == 'recruitment':
+                fields['recruitment_status'] = dict(block.items())['status']
+
+                for field in block.iterchildren():
+                    if field.tag == 'recruitment_country':
+                        fields.setdefault('recruitment_country', [])
+                        fields['recruitment_country'].append({'label': dict(field.items())['value']})
+                    elif field.tag in ('inclusion_criteria','exclusion_criteria'):
+                        fields[field.tag] = field.text
+                    elif field.tag in ('gender','target_size'):
+                        fields[field.tag] = dict(field.items())['value']
+                    elif field.tag in ('agemin','agemax'):
+                        attrs = dict(field.items())
+                        fields[field.tag+'_value'] = attrs['value']
+                        fields[field.tag+'_unit'] = attrs['unit']
+                    elif field.tag == 'date_enrolment_anticipated':
+                        attrs = dict(field.items())
+                        fields['enrollment_start_planned'] = attrs['start']
+                        fields['enrollment_end_planned'] = attrs['end']
+                    elif field.tag == 'date_enrolment_actual':
+                        attrs = dict(field.items())
+                        fields['enrollment_start_actual'] = attrs['start']
+                        fields['enrollment_end_actual'] = attrs['end']
+            elif block.tag == 'study':
+                # expanded_access_program, number_of_arms
+                fields.update(dict(block.items()))
+
+                for field in block.iterchildren():
+                    if field.tag == 'study_design':
+                        fields[field.tag] = field.text
+                    elif field.tag == 'type':
+                        fields['study_type'] = dict(field.items())['value']
+                    elif field.tag in ('phase', 'purpose', 'intervention_assignment', 'masking', 'allocation'):
+                        fields[field.tag] = dict(field.items())['value']
+            elif block.tag == 'outcomes':
+                for field in block.iterchildren():
+                    if field.tag == 'primary_outcome':
+                        fields.setdefault('primary_outcomes', [])
+                        fields['primary_outcomes'].append(self.get_outcome(field))
+                    elif field.tag == 'secondary_outcome':
+                        fields.setdefault('secondary_outcomes', [])
+                        fields['secondary_outcomes'].append(self.get_outcome(field))
+            elif block.tag == 'contacts':
+                for field in block.iterchildren():
+                    if field.tag == 'person':
+                        fields.setdefault('persons', [])
+                        fields['persons'].append(self.get_person(field))
+                    elif field.tag == 'public_contact':
+                        fields.setdefault('public_contact', [])
+                        fields['public_contact'].append({'pid': dict(field.items())['person']})
+                    elif field.tag == 'scientific_contact':
+                        fields.setdefault('scientific_contact', [])
+                        fields['scientific_contact'].append({'pid': dict(field.items())['person']})
+                    elif field.tag == 'site_contact':
+                        fields.setdefault('site_contact', [])
+                        fields['site_contact'].append({'pid': dict(field.items())['person']})
+            elif block.tag == 'secondary_ids':
+                for sid in block.iterchildren():
+                    fields.setdefault('secondary_ids', [])
+                    sec_id = {}
+                    for field in sid.iterchildren():
+                        sec_id[field.tag] = field.text
+                    fields['secondary_ids'].append(sec_id)
+            elif block.tag == 'references':
+                for field in block.iterchildren():
+                    if field.tag == 'link':
+                        fields.setdefault('urls', [])
+                        fields['urls'].append(dict(field.items())['url'])
+            elif block.tag == 'staff_note':
+                fields['staff_note'] = field.text
+            elif block.tag == 'translation':
+                fields.setdefault('translations', [])
+                trans = {}
+                for field in block.iterchildren():
+                    trans[field.tag] = field.text
+                fields['translations'].append(trans)
+
+        return fields
+
+    # WHO ICTRP
+
+    def parse_ictrp(self, filename_or_xmltree):
+        """
+        Validates a given file and parses it without to persist on database. Collected
+        trials are just saved in the attribute '_parsed_trials' to be imported after.
+
+        For WHO ICTRP format.
+        """
+        # Validates using DTD
+        validation = validate_xml(filename_or_xmltree, dtd=ICTRP_DTD)
+
+        if validation is not True:
+            raise Exception(validation)
+
+        self._parsed_trials = []
+        
+        # Loads XML file
+        if isinstance(filename_or_xmltree, basestring):
+            fp = file(filename_or_xmltree)
+            tree = etree.parse(fp)
+        else:
+            tree = filename_or_xmltree
+            fp = None
+
+        trials = tree.getroot()
+        trials_attrs = dict(trials.items())
+
+        for trial in trials.iterchildren():
+            # Collects the list of trials, as dictionaries
+            fields = self.collect_trial_fields_ictrp(trial)
+
+            # Loads the trial from database and clear it or just create a new instance in memory
+            try:
+                ct = ClinicalTrial.objects.get(trial_id=fields['trial_id'])
+            except ClinicalTrial.DoesNotExist:
+                ct = None
+
+            self._parsed_trials.append((fields, ct))
+
+        if fp:
+            fp.close()
+
+        return self._parsed_trials
+
+    def import_ictrp(self, filename_or_xmltree, if_exists=UPDATE_IF_EXISTS):
+        """
+        Uses lxml to load a file in OpenTrials XML format and load it into database.
+        """
+
+        self.parse_ictrp(filename_or_xmltree)
+
+        return self.import_parsed(if_exists)
+
+    def collect_trial_fields_ictrp(self, node):
+        fields = {}
+        translations = []
+
+        # Fields: created, date_registration, status, updated
+        fields.update(dict(node.items()))
+
+        # Collect fields
+        for block in node.iterchildren():
+            if block.tag == 'main':
+                for field in block.iterchildren():
+                    if field.tag in ('trial_id', 'utrn', 'reg_name', 'date_registration',
+                                     'public_title', 'acronym', 'scientific_title', 'scientific_acronym',
+                                     'date_enrolment', 'type_enrolment', 'target_size', 'recruitment_status',
+                                     'url', 'study_type', 'study_design', 'phase', 'hc_freetext', 'i_freetext'):
+                        fields[field.tag] = field.text
+                    elif field.tag == 'primary_sponsor':
+                        fields[field.tag] = {'name': field.text}
+
+                if fields['type_enrolment'] == 'actual':
+                    fields['enrollment_start_actual'] = fields['date_enrolment']
+                    #fields['enrollment_end_actual']
+                    fields.pop('type_enrolment'); fields.pop('date_enrolment')
+                else:
+                    fields['enrollment_start_planned'] = fields['date_enrolment']
+                    #fields['enrollment_end_planned']
+                    fields.pop('type_enrolment'); fields.pop('date_enrolment')
+            elif block.tag == 'contacts':
+                fields.setdefault('persons', [])
+
+                for field in block.iterchildren():
+                    contact = self.get_contact_ictrp(field)
+                    fields['persons'].append(contact)
+
+                    if contact['type'] == 'public':
+                        fields.setdefault('public_contact', [])
+                        fields['public_contact'].append({
+                            'firstname': contact['firstname'],
+                            'middlename': contact['middlename'],
+                            'lastname': contact['lastname'],
+                            })
+                    elif contact['type'] == 'scientific':
+                        fields.setdefault('scientific_contact', [])
+                        fields['scientific_contact'].append({
+                            'firstname': contact['firstname'],
+                            'middlename': contact['middlename'],
+                            'lastname': contact['lastname'],
+                            })
+            elif block.tag == 'countries':
+                fields.setdefault('recruitment_country', [])
+                for item in block.iterchildren():
+                    fields['recruitment_country'].append({'description': item.text})
+            elif block.tag == 'criteria':
+                for item in block.iterchildren():
+                    if item.tag in ('inclusion_criteria','exclusion_criteria'):
+                        fields[field.tag] = field.text
+                    elif item.tag == 'gender':
+                        fields[field.tag] = {'F':'female', 'M':'male'}.get(field.text.upper(), 'both')
+                    elif item.tag in ('agemin','agemax'):
+                        m = EXP_AGE_ICTRP.match(field.text)
+                        if m:
+                            fields[field.tag+'_value'] = m.groups(1)
+                            fields[field.tag+'_unit'] = m.groups(2) or '-'
+            elif block.tag == 'health_condition_code':
+                fields.setdefault('hc_codes', [])
+                for item in block.iterchildren():
+                    fields['hc_codes'].append({'code': item.text})
+            elif block.tag == 'health_condition_keyword':
+                fields.setdefault('hc_keywords', [])
+                for item in block.iterchildren():
+                    fields['hc_keywords'].append({'code': item.text})
+            elif block.tag == 'intervention_code':
+                fields.setdefault('i_codes', [])
+                for item in block.iterchildren():
+                    fields['i_codes'].append({'value': item.text})
+            elif block.tag == 'intervention_keyword':
+                fields.setdefault('i_keywords', [])
+                for item in block.iterchildren():
+                    fields['i_keywords'].append({'code': item.text})
+            elif block.tag == 'primary_outcome':
+                fields.setdefault('primary_outcomes', [])
+                for item in block.iterchildren():
+                    fields['primary_outcomes'].append({'value': field.text})
+            elif block.tag == 'secondary_outcome':
+                fields.setdefault('secondary_outcomes', [])
+                for item in block.iterchildren():
+                    fields['secondary_outcomes'].append({'value': field.text})
+            elif block.tag == 'secondary_sponsor':
+                fields.setdefault('secondary_sponsors', [])
+                for item in block.iterchildren():
+                    fields['secondary_sponsors'].append({'name': item.text})
+            elif block.tag == 'secondary_ids':
+                fields.setdefault('secondary_ids', [])
+                for item in block.iterchildren():
+                    fields['secondary_ids'].append({'sec_id': item.text})
+            elif block.tag == 'source_support':
+                fields.setdefault('source_support', [])
+                for item in block.iterchildren():
+                    fields['source_support'].append({'name': item})
+
+        return fields
+
+    def get_contact_ictrp(self, node):
+        ret = {}
+
+        for field in node.iterchildren():
+            if field.tag == 'affiliation':
+                ret[field.tag] = {'name': field.text}
+            elif field.tag == 'country1':
+                ret['country_code'] = {'description': field.text}
+            else:
+                ret[field.tag] = field.text
+
+        return ret
+
+    # ALL FORMATS
+
+    def import_parsed(self, if_exists=UPDATE_IF_EXISTS):
+        """
+        Imports from parsed trials, stored in the attribute '_parsed_trials'. They
+        should be collected using the method 'parse_opentrials'.
+
+        Case "if_exists" ==
+
+        - UPDATE_IF_EXISTS: will keep the trials exactly as they are, just updating their fields.
+                            This means that existing child objects will keep as they are, just updating.
+        - REPLACE_IF_EXISTS: will empty the current trial and fill its fields again with imported field values.
+                             This means that existing child objects will be deleted to have only the imported ones.
+        - SKIP_IF_EXISTS: will not import anything for existing trials
+        """
+
+        if not hasattr(self, '_parsed_trials'):
+            raise Exception(_("To import parsed trials it's necessary to call method 'parse_opentrials' before."))
+
+        imported_trials = []
+        
+        for fields, ct in self._parsed_trials:
+            # Loads the trial from database and clear it or just create a new instance in memory
+            if not ct:
+                try:
+                    ct = ClinicalTrial.objects.get(trial_id=fields['trial_id'])
+                except ClinicalTrial.DoesNotExist:
+                    ct = None
+
+            if ct:
+                if if_exists == SKIP_IF_EXISTS:
+                    continue
+
+                elif if_exists == REPLACE_IF_EXISTS:
+                    self.clear_fields(ct)
+            else:
+                ct = ClinicalTrial(trial_id=fields['trial_id'])
+
+            # Sets the field values and clean them
+            self.set_trial_fields(ct, fields)
+
+            # Children objects
+            self.set_trial_children(ct, fields)
+
+            # TODO: call validation
+
+            # Sets the status as the last thing to make a consistent fossil
+            ct.status = ct.new_status
+            ct.save()
+
+            imported_trials.append(ct)
+
+        return imported_trials
+
+    def get_default(self, field):
+        if isinstance(field.default, NOT_PROVIDED) or field.default == NOT_PROVIDED:
+            if isinstance(field, (CharField, TextField)):
+                return ''
+            else:
+                return None
+        elif callable(field.default):
+            return field.default()
+        else:
+            return field.default
+
+    def date_from(self, datestr):
+        try:
+            return datetime.strptime(datestr, '%Y-%m-%d').date()
+        except ValueError:
+            return datetime.strptime(datestr, '%d/%m/%Y').date()
+
+    def set_trial_fields(self, ct, fields):
+        # Char fields
+        ct.public_title = fields.get('public_title', None) or ct.public_title
+        ct.utrn_number = fields.get('utrn_number', None) or ct.utrn_number
+        #ct.reg_name = fields.get('reg_name', None) or ct.reg_name # Maybe should create a new field?
+        ct.acronym = fields.get('acronym', None) or ct.acronym
+        ct.acronym_expansion = fields.get('acronym_expansion', None) or ct.acronym_expansion
+        ct.scientific_title = fields.get('scientific_title', None) or ct.scientific_title
+        ct.scientific_acronym = fields.get('scientific_acronym', None) or ct.scientific_acronym
+        ct.scientific_acronym_expansion = fields.get('scientific_acronym_expansion', None) or ct.scientific_acronym_expansion
+        ct.staff_note = fields.get('staff_note', None) or ct.staff_note
+        ct.study_design = fields.get('study_design', None) or ct.study_design
+        ct.hc_freetext = fields.get('hc_freetext', None) or ct.hc_freetext
+        ct.i_freetext = fields.get('i_freetext', None) or ct.i_freetext
+        ct.inclusion_criteria = fields.get('inclusion_criteria', None) or ct.inclusion_criteria
+        ct.exclusion_criteria = fields.get('exclusion_criteria', None) or ct.exclusion_criteria
+        ct.enrollment_start_planned = fields.get('enrollment_start_planned', None) or ct.enrollment_start_planned
+        ct.enrollment_start_actual = fields.get('enrollment_start_actual', None) or ct.enrollment_start_actual
+        ct.enrollment_end_planned = fields.get('enrollment_end_planned', None) or ct.enrollment_end_planned
+        ct.enrollment_end_actual = fields.get('enrollment_end_actual', None) or ct.enrollment_end_actual
+        ct.language = fields.get('language', None) or ct.language
+        ct.new_status = fields.get('status', None) or ct.status # Temporary to be saved only in the end of all
+
+        # Integer fields
+        ct.agemin_value = fields.get('agemin_value', None) or ct.agemin_value
+        ct.agemax_value = fields.get('agemax_value', None) or ct.agemax_value
+        ct.number_of_arms = fields.get('number_of_arms', None) or ct.number_of_arms
+        ct.target_sample_size = fields.get('target_size', None) or ct.target_sample_size
+
+        # Boolean fields
+        if fields.get('expanded_access_program', None):
+            ct.expanded_access_program = fields['expanded_access_program'] == 'yes'
+
+        # Date fiels
+        if fields.get('updated', None):
+            ct.updated = self.date_from(fields['updated'])
+        if fields.get('created', None):
+            ct.created = self.date_from(fields['created'])
+        if fields.get('exported', None):
+            ct.exported = self.date_from(fields['exported'])
+        if fields.get('date_registration', None):
+            ct.date_registration = self.date_from(fields['date_registration'])
+
+        # Flag fields
+        ct.gender = GENDERS[fields.get('gender', 'both')]
+        ct.agemin_unit = AGE_UNITS[fields.get('agemin_unit', 'null')]
+        ct.agemax_unit = AGE_UNITS[fields.get('agemax_unit', 'null')]
+        
+        # Foreign keys
+        if fields.get('primary_sponsor', None):
+            ct.primary_sponsor = self.get_instituion_from_db(fields['primary_sponsor'])
+        if fields.get('study_type', None):
+            ct.study_type, new = StudyType.objects.get_or_create(label=self.prep_label(fields['study_type']))
+        if fields.get('purpose', None):
+            ct.purpose, new = StudyPurpose.objects.get_or_create(label=self.prep_label(fields['purpose']))
+        if fields.get('intervention_assignment', None):
+            ct.intervention_assignment, new = InterventionAssigment.objects.get_or_create(label=self.prep_label(fields['intervention_assignment']))
+        if fields.get('masking', None):
+            ct.masking, new = StudyMasking.objects.get_or_create(label=self.prep_label(fields['masking']))
+        if fields.get('allocation', None):
+            ct.allocation, new = StudyAllocation.objects.get_or_create(label=self.prep_label(fields['allocation']))
+        if fields.get('phase', None):
+            ct.phase, new = StudyPhase.objects.get_or_create(label=self.prep_label(fields['phase']))
+        if fields.get('recruitment_status', None):
+            ct.recruitment_status, new = RecruitmentStatus.objects.get_or_create(label=self.prep_label(fields['recruitment_status']))
+
+        ct.save()
+
+    def set_trial_children(self, ct, fields):
+        for country in fields.get('recruitment_country', []):
+            if country.get('label', None):
+                country_obj, new = CountryCode.objects.get_or_create(
+                        label=country['label'],
+                        defaults={'description': country.get('description', '')},
+                        )
+            else:
+                country_obj = CountryCode.objects.get(description=country['description'])
+            ct.recruitment_country.add(country_obj)
+
+        for person in fields.get('persons', []):
+            
+            contact = Contact.objects.filter(email=person['email'], creator=self.creator)
+                
+            if contact:
+                contact = contact[0]    
+            else:
+                contact = Contact()
+                contact.creator = self.creator
+                contact.firstname = person.get('firstname')
+                contact.middlename = person.get('middlename')
+                contact.lastname = person.get('lastname')
+                contact.address = person.get('address')
+                contact.city = person.get('city')
+                if person.get('country_code', None):
+                    if person['country_code'].get('label', None):
+                        contact.country = CountryCode.objects.get(label=person['country_code']['label'])
+                    else:
+                        contact.country = CountryCode.objects.get(description=person['country_code']['description'])
+                contact.zip = person.get('zip')
+                contact.telephone = person.get('telephone')
+                contact.email = person.get('email')
+                if person.get('affiliation', None):
+                    contact.affiliation = self.get_instituion_from_db(person['affiliation'])
+
+                contact.save()
+
+        for item in fields.get('public_contact', []):
+            if item.get('pid', None):
+                contact = Contact.objects.get(pk=item['pid'])
+            else:
+                contact = Contact.objects.filter(email=person['email'], creator=self.creator)[0]
+            PublicContact.objects.get_or_create(trial=ct, contact=contact)
+
+        for item in fields.get('scientific_contact', []):
+            if item.get('pid', None):
+                contact = Contact.objects.get(pk=item['pid'])
+            else:
+                contact = Contact.objects.filter(email=person['email'], creator=self.creator)[0]
+            ScientificContact.objects.get_or_create(trial=ct, contact=contact)
+
+        for item in fields.get('site_contact', []):
+            contact = Contact.objects.get(pk=item)
+            SiteContact.objects.get_or_create(trial=ct, contact=contact)
+
+        for item in fields.get('secondary_ids', []):
+            TrialNumber.objects.get_or_create(
+                    trial=ct,
+                    issuing_authority=item.get('issuing_authority', ''),
+                    id_number=item['sec_id'],
+                    )
+
+        for item in fields.get('secondary_sponsor', []):
+            inst = self.get_instituion_from_db(item)
+            TrialSecondarySponsor.objects.get_or_create(trial=ct, institution=inst)
+
+        for item in fields.get('secondary_sponsor', []):
+            inst = self.get_instituion_from_db(item)
+            TrialSupportSource.objects.get_or_create(trial=ct, institution=inst)
+
+        for item in fields.get('primary_outcomes', []):
+            outcome, new = Outcome.objects.get_or_create(trial=ct, interest='primary', description=item['value'])
+            for trans in item.get('translations', []):
+                outcome.translations.get_or_create(description=trans['description'], language=trans['language'])
+
+        for item in fields.get('secondary_outcomes', []):
+            outcome, new = Outcome.objects.get_or_create(trial=ct, interest='secondary', description=item['value'])
+            for trans in item.get('translations', []):
+                outcome.translations.get_or_create(description=trans['description'], language=trans['language'])
+
+        for item in fields.get('hc_codes', []):
+            descriptor, new = Descriptor.objects.get_or_create(
+                    trial=ct,
+                    aspect='HealthCondition',
+                    level='general',
+                    vocabulary=item.get('vocabulary', 'DeCS'), # FIXME
+                    code=item['code'],
+                    defaults={
+                        'version': item.get('version', ''),
+                        'text': item.get('value', ''),
+                        }
+                    )
+            for trans in item.get('translations', []):
+                trans_obj = descriptor.translations.get_translation_for_object(trans['lang'], descriptor, create_if_not_exist=True)
+                trans_obj.text=trans['value']
+                trans_obj.save()
+
+        for item in fields.get('hc_keywords', []):
+            descriptor, new = Descriptor.objects.get_or_create(
+                    trial=ct,
+                    aspect='HealthCondition',
+                    level='specific',
+                    vocabulary=item.get('vocabulary', 'DeCS'), # FIXME
+                    code=item['code'],
+                    defaults={
+                        'version': item.get('version', ''),
+                        'text': item.get('value', ''),
+                        }
+                    )
+            for trans in item.get('translations', []):
+                trans_obj = descriptor.translations.get_translation_for_object(trans['lang'], descriptor, create_if_not_exist=True)
+                trans_obj.text=trans['value']
+                trans_obj.save()
+
+        for item in fields.get('i_codes', []):
+            i_code, new = InterventionCode.objects.get_or_create(label=item['value'])
+            ct.i_code.add(i_code)
+
+        for item in fields.get('i_keywords', []):
+            descriptor, new = Descriptor.objects.get_or_create(
+                    trial=ct,
+                    aspect='Intervention',
+                    level='specific',
+                    vocabulary=item.get('vocabulary', 'DeCS'), # FIXME
+                    code=item['code'],
+                    defaults={
+                        'version': item.get('version', ''),
+                        'text': item.get('value', ''),
+                        }
+                    )
+            for trans in item.get('translations', []):
+                trans_obj = descriptor.translations.get_translation_for_object(trans['lang'], descriptor, create_if_not_exist=True)
+                trans_obj.text=trans['value']
+                trans_obj.save()
+
+    def get_institution(self, node):
+        ret = dict(node.items())
+
+        for field in node.iterchildren():
+            if field.tag in ('name','address'):
+                ret[field.tag] = field.text
+
+        return ret
+
+    def get_hc_or_ic(self, node):
+        ret = {}
+        ret.update(dict(node.items()))
+
+        for field in node.iterchildren():
+            if field.tag == 'text':
+                ret['value'] = field.text
+            elif field.tag == 'text_translation':
+                trans = dict(field.items())
+                trans['value'] = field.text
+
+                ret.setdefault('translations', [])
+                ret['translations'].append(trans)
+
+        return ret
+
+    def get_i_code(self, node):
+        return dict(node.items())
+
+    def get_person(self, node):
+        ret = {}
+        ret.update(dict(node.items()))
+
+        if isinstance(ret.get('country_code', None), basestring):
+            ret['country_code'] = {'label': ret['country_code']}
+
+        for field in node.iterchildren():
+            if field.tag == 'affiliation':
+                ret[field.tag] = self.get_institution(field)
+            else:
+                ret[field.tag] = field.text
+
+        return ret
+
+    def get_outcome(self, node):
+        ret = {}
+        ret.update(dict(node.items()))
+        ret['translations'] = []
+
+        for field in node.iterchildren():
+            if field.tag == 'outcome_translation':
+                ret['translations'].append(dict(field.items()))
+
+        return ret
+
+    def clear_fields(self, ct):
+        # Update fields to default values
+        for field in ClinicalTrial._meta.fields:
+            if field.name in ('trial_id','id'):
+                continue
+
+            setattr(ct, field.name, self.get_default(field))
+
+        # Remove children
+        ct.trialnumber_set.all().delete()
+        ct.outcome_set.all().delete()
+        ct.trialsecondarysponsor_set.all().delete()
+        ct.trialsupportsource_set.all().delete()
+        ct.public_contact.all().delete() # pay attention to this - to see what is it deleting
+        ct.scientific_contact.all().delete() # pay attention to this - to see what is it deleting
+        ct.site_contact.all().delete() # pay attention to this - to see what is it deleting
+        ct.descriptor_set.all().delete()
+        ct.translations.all().delete()
+
+    def get_instituion_from_db(self, fields):
+        if fields.get('country_code', None):
+            country = CountryCode.objects.get(label=fields['country_code'])
+        else:
+            country = CountryCode.objects.all()[0] # FIXME TODO
+
+        inst, new = Institution.objects.get_or_create(
+                name=fields['name'],
+                country=country,
+                address=fields.get('address', ''),
+                defaults={'creator': self.creator},
+                )
+        return inst
+
+    def prep_label(self, label):
+        """Because labels replace white spaces for underlines, we must make the contrary
+        here to make possible to find them."""
+        return label.replace('_', ' ')
+
Index: /tags/v1.0.23rc1/opentrials/repository/xml/samples/sample_0a.xml
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/samples/sample_0a.xml (revision 839)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/samples/sample_0a.xml (revision 839)
@@ -0,0 +1,6 @@
+<!DOCTYPE trial SYSTEM "opentrials.dtd">
+<!--malformed XML (the study_type close tag is missing)-->
+<trial>
+    <study_type>interventional
+</trial>
+
Index: /tags/v1.0.23rc1/opentrials/repository/xml/samples/sample_0b.xml
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/samples/sample_0b.xml (revision 839)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/samples/sample_0b.xml (revision 839)
@@ -0,0 +1,5 @@
+<!DOCTYPE trial SYSTEM "opentrials.dtd">
+<!--an invalid OpenTrials trial XML (there is no particle_spin element in the DTD)-->
+<trial>
+    <particle_spin>half-pint</particle_spin>
+</trial>
Index: /tags/v1.0.23rc1/opentrials/repository/xml/samples/sample_1a.xml
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/samples/sample_1a.xml (revision 839)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/samples/sample_1a.xml (revision 839)
@@ -0,0 +1,67 @@
+<!DOCTYPE trial SYSTEM "opentrials.dtd">
+<!--the simplest possible valid OpenTrials trial XML-->
+<!--based on data from the ANZCTR; trial: ACTRN12610000133033-->
+<trial type="interventional">
+    <trial_identification>
+      	<!--TRDS 10a (1)-->
+        <scientific_title>Tactile and kinesthetic stimulation program during hospitalization and behavioral analysis in preterm neonates</scientific_title>
+    </trial_identification>
+    <sponsors_and_support>
+	<!--TRDS 5 (1)-->
+	<primary_sponsor country_code="BR">
+	    <name>Conselho Nacional de Desenvolvimento Cientifico e Tecnologico</name>
+	</primary_sponsor>
+    </sponsors_and_support>
+    <health_conditions>
+	<freetext>preterm neonates</freetext>
+    </health_conditions>
+    <interventions>
+    	<i_code value="behavioural" />
+    </interventions>
+    <recruitment study_status="completed">
+        <recruitment_country value="BR" />
+	<inclusion_criteria>
+	Stable preterm infants weighing &lt; 2500 grams, with no significant perinatal asphyxia.
+	</inclusion_criteria>
+    </recruitment>
+    <study_type>
+        <study_design>
+	    Thirty-two clinically stable preterm infants weighing &lt; 2500
+	    grams, with no significant perinatal asphyxia, were allocated to
+	    two groups: a control group (CG) in which no intervention was made
+	    (n=16) and a study group (SG) in which the newborn infants received
+	    tactile and kinesthetic stimulation (n=16). Data on the infants’
+	    clinical progress were collected from medical charts and behavioral
+	    evaluations were carried out using a series of weekly, 8-minute
+	    films recorded from study admission until hospital discharge.
+	</study_design>
+    </study_type>
+    <outcomes>
+	<primary_outcome>
+	    Predominance of self-regulated behavior in Behavioral Scale
+	    (adapted from Neonatal Behavioral Assessment Scale NBAS).
+	    Timepoint: every week, at least one week after beggining of
+	    stimulation until hospital discharge.
+	</primary_outcome>
+    </outcomes>
+    <contacts>
+	<public_contact persons="p1"/>
+	<scientific_contact persons="p1"/>
+	<person pid="p1" country_code="BR">
+	    <firstname>Andreia</firstname>
+	    <middlename>Menandro</middlename>
+	    <lastname>Ferreira</lastname>
+	    <address>
+		Rua Cônego Valadão, 1539, apt 53
+		Gopouva
+	    </address>
+	    <city>Guarulhos, SP</city>
+	    <zip>07040-000</zip>
+	    <telephone>+55 (11) 2422-7034</telephone>
+	    <email>andreiamdeia@yahoo.com</email>
+	    <affiliation>Universidade de São Paulo</affiliation>
+	</person>
+    </contacts>
+
+</trial>
+
Index: /tags/v1.0.23rc1/opentrials/repository/xml/samples/sample_1b.xml
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/samples/sample_1b.xml (revision 839)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/samples/sample_1b.xml (revision 839)
@@ -0,0 +1,167 @@
+<!DOCTYPE trial SYSTEM "opentrials.dtd">
+<!--a realistic and valid OpenTrials trial XML-->
+<!--based on data from the ANZCTR trial ACTRN12610000133033-->
+<!--source: http://www.anzctr.org.au/trial_view.aspx?ID=335059-->
+<trial type="interventional">
+    <trial_identification>
+  	<!--TRDS 10a (1)-->
+        <scientific_title>Behavioral analysis of preterm neonates included in a tactile and kinesthetic stimulation program during hospitalization in preterm neonates</scientific_title>
+	<!--TRDS 10b (0-1)-->
+        <scientific_acronym>BATIK</scientific_acronym>
+	<!--TRDS 9a (0-1)-->
+	<public_title>Tactile and kinesthetic stimulation program during hospitalization and behavioral analysis in preterm neonates</public_title>
+	<!--TRDS 9b (0-1)-->
+        <acronym>TAKS</acronym>
+	<!--TRDS 3a/3b (0-1)-->
+	<utn>U9999-9999-0102</utn>
+	<!--TRDS 1 (0-1)-->
+	<opentrials_id>RBR-9zz-2bc</opentrials_id>
+	<secondary_ids>
+	    <secondary_id>
+		<!--TRDS 3a (0-N)-->
+		<sec_id>ACTRN12610000133033</sec_id>
+		<!--TRDS 3b (0-N)-->
+		<issuing_authority>ANZCTR</issuing_authority>
+	    </secondary_id>
+	</secondary_ids>
+    </trial_identification>
+    <sponsors_and_support>
+	<!--TRDS 5 (1)-->
+	<primary_sponsor country_code="BR">
+	    <name>Universidade de São Paulo</name>
+	    <address>
+		Rua Prof. Mello Moraes, 1721
+		Cidade Universitaria
+		Sao Paulo, SP, CEP 055508-900
+	    </address>
+	</primary_sponsor>
+	<!--TRDS 6 (0..*)-->
+	<secondary_sponsor country_code="BR">
+	    <name>Andreia Menandro Ferreira</name>
+	    <address>
+		Rua Cônego Valadão, 1539, apt 53
+		Gopouva,
+		Guarulhos, SP, CEP 07040-000
+	    </address>
+	</secondary_sponsor>
+	<!--TRDS 4 (0..*)-->
+	<source_support country_code="BR">
+	    <name>Conselho Nacional de Desenvolvimento Cientifico e Tecnologico</name>
+	    <address>
+		SEPN 507 Ed. CNPq - Terreo - Sala 7
+		Brasília, DF, CEP 70740-901
+	    </address>
+	</source_support>
+    </sponsors_and_support>
+    <health_conditions>
+        <!--TRDS 12a (0..1)-->
+	<freetext>preterm neonates</freetext>
+        <!--TRDS 12b (0..*)-->
+	<hc_code vocabulary="decs" version="2009">M01.060.703.520</hc_code>
+        <!--TRDS 12c (0..*)-->
+	<keyword vocabulary="decs">C13.703.420.491.500</keyword>
+    </health_conditions>
+    <interventions>
+        <!--TRDS 13a (0..1)-->
+	<freetext>
+	Stable preterm neonates received tactile and kinesthetic stimulation
+	during hospitalization; by trained author and mothers. With ligth
+	touch and arms and legs mobilization; during 5 to 15 minutes daily,
+	since preterm was clinically stable until hospital discharge.
+	</freetext>
+        <!--TRDS 13b (0..*)-->
+	<i_code value="behavioural" />
+        <!--TRDS 13c (0..*)-->
+	<keyword vocabulary="decs" version="2009">F02.830.816.850</keyword>
+    </interventions>
+    <recruitment study_status="completed">
+        <!--TRDS 11 (1+)-->
+        <recruitment_country value="BR" />
+        <!--TRDS 14a (1)-->
+	<inclusion_criteria>
+    	    Stable preterm infants weighing &lt; 2500 grams, with no significant perinatal asphyxia.
+	</inclusion_criteria>
+        <!--TRDS 14b (0..1)-->
+	<gender value="both" />
+        <!--TRDS 14c (0..1)-->
+	<agemin unit="weeks">31</agemin>
+        <!--TRDS 14d (0..1)-->
+	<agemax unit="weeks">36</agemax>
+        <!--TRDS 14e (0..1)-->
+	<exclusion_criteria>
+	    Vision and/or hear disfuction; neurological problems; instable preterms; without family autorization.
+	</exclusion_criteria>
+        <!--TRDS 16 (1)-->
+	<date_enrolment_anticipated>2004-10-01</date_enrolment_anticipated>
+        <!--TRDS 16 (1)-->
+	<date_enrolment_actual>2004-10-01</date_enrolment_actual>
+        <!--TRDS 17 (1)-->
+	<target_size>32</target_size>
+    </recruitment>
+    <study_type>
+        <!--TRDS 15b (1)-->
+        <study_design expanded_access_program="no"
+		      purpose="prevention"
+		      intervention_assignment="parallel"
+		      number_of_arms="2"
+		      masking="open"
+		      allocation="non-randomized-controlled">
+	    Thirty-two clinically stable preterm infants weighing &lt; 2500
+	    grams, with no significant perinatal asphyxia, were allocated to
+	    two groups: a control group (CG) in which no intervention was made
+	    (n=16) and a study group (SG) in which the newborn infants received
+	    tactile and kinesthetic stimulation (n=16). Data on the infants’
+	    clinical progress were collected from medical charts and behavioral
+	    evaluations were carried out using a series of weekly, 8-minute
+	    films recorded from study admission until hospital discharge.
+	</study_design>
+	<study_endpoint value="safety" />
+	<study_endpoint value="efficacy" />
+	<study_endpoint value="bioequivalence" />
+	<study_endpoint value="biodisponibility" />
+	<study_endpoint value="pharmacokinetics" />
+	<study_endpoint value="pharmacodynamics" />
+	<study_endpoint value="pharmacogenetics" />
+        <!--TRDS 15c (1)-->
+	<phase value="1-2" />
+    </study_type>
+    <outcomes>
+        <!--TRDS 19 (1..*)-->
+	<primary_outcome>
+	    Predominance of self-regulated behavior in Behavioral Scale
+	    (adapted from Neonatal Behavioral Assessment Scale NBAS).
+	    Timepoint: every week, at least one week after beggining of
+	    stimulation until hospital discharge.
+	</primary_outcome>
+        <!--TRDS 20 (1..*)-->
+	<secondary_outcome>
+	    Shorter duration of hospital stay.
+	    Timepoint: after hospitalization.
+	</secondary_outcome>
+    </outcomes>
+    <contacts>
+        <!--TRDS 7 (1..*)-->
+	<public_contact persons="p1"/>
+        <!--TRDS 8 (1..*)-->
+	<scientific_contact persons="p1"/>
+	<person pid="p1" country_code="BR">
+	    <firstname>Andreia</firstname>
+	    <middlename>Menandro</middlename>
+	    <lastname>Ferreira</lastname>
+	    <address>
+		Rua Cônego Valadão, 1539, apt 53
+		Gopouva
+	    </address>
+	    <city>Guarulhos, SP</city>
+	    <zip>07040-000</zip>
+	    <telephone>+55 (11) 2422-7034</telephone>
+	    <email>andreiamdeia@yahoo.com</email>
+	    <affiliation>Universidade de São Paulo</affiliation>
+	</person>
+    </contacts>
+    <references>
+	<link url="http://www.anzctr.org.au/trial_view.aspx?ID=335059">
+	    Original trial record at ANZCTR
+	</link>
+    </references>
+</trial>
Index: /tags/v1.0.23rc1/opentrials/repository/xml/samples/vitamin-c-opentrials.xml
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/samples/vitamin-c-opentrials.xml (revision 814)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/samples/vitamin-c-opentrials.xml (revision 814)
@@ -0,0 +1,142 @@
+<?xml version="1.0"?> <!-- standalone="no" -->
+<!-- <!DOCTYPE document PUBLIC "http://localhost:8000/xml/who_ictrp.dtd"> -->
+<!--N/U marks fields that are not used by when importing to the OpenTrials platform-->
+<trials xmlns="http://localhost:8000/xml/who_ictrp.dtd"
+        xmlns:opentrials="http://localhost:8000/xml/opentrials.dtd">
+    <trial>
+        <main>
+            <trial_id>IRCT138708271460N1</trial_id> <!--becomes secondary id-->
+            <reg_name>IRCT</reg_name>               <!--becomes secondary id-->
+            <date_registration>2009-02-16</date_registration> <!--N/U-->
+            <primary_sponsor>Tabriz Univ Med Sci</primary_sponsor>
+            <public_title xml:lang="en">
+                Comparison of Ascorbic Acid and Grape Seed Extract in
+                Oxidative Stress Induced by on Pump Heart Surgery
+            </public_title>
+            <acronym></acronym>
+            <scientific_title xml:lang="en">
+                Effect of Ascorbic Acid and Grape Seed Extract
+                "Vitis Vinifera L." on Oxidative Stress Induced by on Pump
+                Coronary Artery by Pass Grafting Surgery
+            </scientific_title>
+            <date_enrolment>2008-11-01</date_enrolment>
+            <type_enrolment>anticipated</type_enrolment>
+            <target_size>75</target_size>
+            <recruitment_status>Complete</recruitment_status> <!--inconsistent with date and type of enrolment-->
+            <url>http://www.irct.ir/searchresult.php?id=1460&amp;number=1</url> <!--N/U-->
+            <study_type>interventional</study_type>
+            <study_design xml:lang="en">
+                Randomization: randomized.
+                Blinding:  Double blind.
+                Placebo: not used.
+                Assignment: Parallel.
+                Purpose: Supportive care.
+                Other design features:
+                <!-- <opentrials:study_design></opentrials:study_design> -->
+            </study_design>
+            <phase>2-3</phase>
+            <hc_freetext xml:lang="en">
+                Condition 1: Coronary Atrery Bypass Graft (CABG).
+                Condition 2: Atherosclerotic heart disease.
+                Condition 3: Ischaemic cardiomyopathy.
+            </hc_freetext>
+            <i_freetext xml:lang="en">
+                Intervention 1: Control Group: without intervention.
+                Intervention 2: Grape Seed Extract 100 mg/6h.
+                Intervention 3: Vit C 25 mg/kg.
+            </i_freetext>
+        </main>
+        <contacts>
+            <contact>
+                <type>public</type>
+                <firstname>Naser safaei, MD, Surgeon</firstname>
+                <middlename/>
+                <lastname/>
+                <address>Tabriz Univ Med Sci</address>
+                <city>Tabriz</city>
+                <country1>Iran, Islamic Republic Of</country1>
+                <zip>51656-65811</zip>
+                <telephone>+98-411-3357767</telephone>
+                <email>drsafaei@yahoo.com</email>
+                <affiliation>Tabriz Univ Med Sci</affiliation>
+            </contact>
+            <contact>
+                <type>scientific</type>
+                <firstname>Dr Naser Safaei</firstname>
+                <middlename/>
+                <lastname/>
+                <address>Daneshgah St,Tabriz Univ Med Sci</address>
+                <city>Tabriz</city>
+                <country1>Iran, Islamic Republic Of</country1>
+                <zip>51656-65811</zip>
+                <telephone>+98-411-3357767</telephone>
+                <email>drsafaei@yahoo.com</email>
+                <affiliation>Tabriz Univ Med Sci</affiliation>
+            </contact>
+            <!-- also: type=site for site contacts, one per site in the country
+                 hosting the repository-->
+        </contacts>
+        <countries>
+            <country2>Iran, Islamic Republic Of</country2>
+        </countries>
+        <criteria>
+            <inclusion_criteria xml:lang="en">
+                Candidates for elective CABG surgery
+                with pump for first time, 3 Vessel Disease (3VD).
+            </inclusion_criteria>
+            <exclusion_criteria xml:lang="en">
+                High risk patients, Those who need another
+                heart surgery beside CABG, Urgent patients Diabetics, Ischemic
+                time more than 120 min.
+            </exclusion_criteria>
+            <agemin unit="null" opentrials:unit="no-limit">0</agemin>
+            <agemax opentrials:unit="years">150</agemax>
+            <gender>both</gender>
+        </criteria>
+        <health_condition_code>
+            <hc_code/>
+        </health_condition_code>
+        <health_condition_keyword>
+            <hc_keyword opentrials:vocabulary="DeCS" opentrials:code="C14.280.647">
+                    Myocardial Ischemia
+            </hc_keyword>
+            <hc_keyword>Atherosclerotic heart disease</hc_keyword>
+            <hc_keyword>Ischaemic cardiomyopathy</hc_keyword>
+        </health_condition_keyword>
+        <intervention_code>
+            <i_code>Not applicable</i_code>
+            <i_code>Treatment: drugs</i_code>
+            <i_code>Treatment: drugs</i_code>
+            <i_code></i_code>
+        </intervention_code>
+        <intervention_keyword>
+            <i_keyword></i_keyword>
+        </intervention_keyword>
+        <primary_outcome>
+            <prim_outcome>
+                Left Ventricular Ejection Fraction (LVEF).
+                Timepoint: Before and after CABG.
+                Method of measurement: Trans Thoracic Echocardiography (TTE)
+            </prim_outcome>
+        </primary_outcome>
+        <secondary_outcome>
+            <sec_outcome>
+                Total Antioxidant Capacity (TAC).
+                Timepoint: Before, middle and after CABG.
+                Method of measurement: Biochemistry (blood sample)
+            </sec_outcome>
+        </secondary_outcome>
+        <secondary_sponsor>
+            <sponsor_name></sponsor_name>
+        </secondary_sponsor>
+        <secondary_ids>
+            <secondary_id>
+                <sec_id>NCT00839085</sec_id>
+                <issuing_authority>ClinicalTrials.gov</issuing_authority>
+            </secondary_id>
+        </secondary_ids>
+        <source_support>
+            <source_name>Tabriz University of Medical Sciences</source_name>
+        </source_support>
+    </trial>
+</trials>
Index: /tags/v1.0.23rc1/opentrials/repository/xml/samples/ecgovbr-ictrp-2011-03-11.xml
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/samples/ecgovbr-ictrp-2011-03-11.xml (revision 906)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/samples/ecgovbr-ictrp-2011-03-11.xml (revision 906)
@@ -0,0 +1,712 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<trials>
+
+    <trial>
+        <main>
+            <trial_id>RBR-5kz-yp8</trial_id>
+            <utrn>None</utrn>
+            <reg_name>REBEC</reg_name>
+            <date_registration></date_registration>
+            <primary_sponsor>Oswaldo Cruz Foundation</primary_sponsor>
+            <public_title>Pharmacokinetics of the Tablet Formulation of Lopinavir/r as Standard and Increased Dosage During Pregnancy</public_title>
+            <acronym></acronym>
+            <scientific_title>Pharmacokinetics of the Tablet Formulation of Lopinavir/r as Standard and Increased Dosage During Pregnancy in HIV-Infected Women</scientific_title>
+            <scientific_acronym></scientific_acronym>
+            <date_enrolment>01/02/2008</date_enrolment>
+            <type_enrolment>anticipated</type_enrolment>
+            <target_size>60</target_size>
+            <recruitment_status>recruiting</recruitment_status>
+            <url>http://127.0.0.1:8000/rg/RBR-5kz-yp8/v1/</url>
+            <study_type></study_type>
+            <study_design>Estudo farmacocinético, prospectivo, aberto, alocação paralela, fase 4, randomizado, preventivo.</study_design>
+            <phase>4</phase>
+            <hc_freetext>HIV Infections
+Pregnancy
+</hc_freetext>
+            <i_freetext>Drug: Lopinavir / ritonavir
+Lopinavir/r (200/50 mg, 2 tablets every 12 hours) plus two nucleoside analogs, starting at any time between 14 and 30 weeks of gestation and maintained for at least 6 weeks after delivery.
+Other Name: Kaletra
+Drug: Lopinavir/ritonavir
+Lopinavir/r (200/50 mg, 2 tablets every 12 hours) plus two nucleoside analogs, starting at any time between 14 and 30 weeks of gestation, increase the lopinavir/r dosage (200/50 mg, 3 tablets every 12 hours) in the third trimester (from 25 weeks on), and return to standard dose(200/50 mg, 2 tablets every 12 hours)for at least 6 weeks after delivery.
+Other Name: Kaletra
+</i_freetext>            
+        </main>
+        <contacts>
+        
+        
+            <contact>
+                <type>scientific</type>
+                <firstname>Marília</firstname>
+                <middlename>Santini</middlename>
+                <lastname>Oliveira</lastname>
+                <address></address>
+                <city>Rio de Janeiro</city>
+                <country1>Brazil</country1>
+                <zip>12345-123</zip>
+                <telephone>23423422234</telephone>
+                <email>su@abc.com</email>
+                <affiliation>Fundação Oswaldo Cruz</affiliation>
+            </contact>
+        
+        </contacts>
+        <countries>
+        
+            <country2>Brazil</country2>
+        
+        </countries>
+        <criteria>
+            <inclusion_criteria>Capacity to consent and wish to participate in the study, documented by signing the specific informed consent form (ICF) of the study.
+Pregnancy documented by urine or blood examination or ultrasound.
+Gestational age of 14 to 30 weeks calculated by ultrasound, obstetric examination or date of last menstruation, depending on what is considered to be more exact by the medical investigator.
+HIV infection documented by two serological tests using different methods or analysis of HIV viral load with a positive result.
+No use of antiretroviral drugs at the time of diagnosis of pregnancy (previous prophylaxis and treatment are allowed).
+Intention to continue the treatment of the study for at least 6 weeks after delivery.</inclusion_criteria>
+            <agemin>18Y</agemin>
+            <agemax>0</agemax>
+            <gender>F</gender>
+            <exclusion_criteria>History of hypersensitivity to lopinavir or ritonavir.
+Need for the concomitant use of contraindicated drugs in combination with lopinavir/ritonavir.
+Any condition that, in the opinion of the medical researchers, impairs the participation in and fulfillment of the procedures of the study.
+</exclusion_criteria>
+        </criteria>
+        <health_condition_code>
+            
+            <hc_code>C20</hc_code>
+            
+        </health_condition_code>
+        <health_condition_keyword>
+            
+            <hc_keyword>Z21</hc_keyword>
+            
+            <hc_keyword>G08.686.785.760.769</hc_keyword>
+            
+        </health_condition_keyword>
+        <intervention_code>
+            
+            <i_code>drug</i_code>
+            
+        </intervention_code>
+        <intervention_keyword>
+            
+            <i_keyword>G02.111.325.500</i_keyword>
+            
+        </intervention_keyword>
+        <primary_outcome>
+            
+            <prim_outcome>Pharmacokinetic parameters of the tablet formulation of lopinavir/r at second and third pregnancy trimester and 6 weeks after delivery</prim_outcome>
+            
+        </primary_outcome>
+        <secondary_outcome>
+            
+            <sec_outcome>Ratio between the serum concentration of lopinavir/r in maternal blood and in cord blood</sec_outcome>
+            
+        </secondary_outcome>
+        <secondary_sponsor>
+            
+            <sponsor_name></sponsor_name>
+            
+        </secondary_sponsor>
+        <secondary_ids>
+            
+            <secondary_id>
+                <sec_id>NCT00605098</sec_id>
+                <issuing_authority>Clinicaltrials.gov</issuing_authority>    
+            </secondary_id>
+            
+        </secondary_ids>
+        <source_support>
+            
+            <source_name></source_name>
+            
+        </source_support>        
+    </trial>
+
+    <trial>
+        <main>
+            <trial_id>RBR-4s7gh3</trial_id>
+            <utrn>U1111-1119-5101</utrn>
+            <reg_name>REBEC</reg_name>
+            <date_registration>02/03/2011</date_registration>
+            <primary_sponsor>Hospital de Clínicas de Porto Alegre</primary_sponsor>
+            <public_title>PREVER Study: Efficacy of Chlorthalidone associated with Amiloride versus  Losartan in reducing blood pressure of patients with hypertension Prever 2 Study
+</public_title>
+            <acronym>PREVER: Prevention of Cardiovascular outcomes in patients with hypertension</acronym>
+            <scientific_title>PREVER Study: Efficacy of Chlorthalidone associated with Amiloride versus  Losartan in reducing blood pressure of patients with hypertension Prever 2 Study
+</scientific_title>
+            <scientific_acronym>PREVER 2: Prevention of Cardiovascular outcomes in patients with hypertension</scientific_acronym>
+            <date_enrolment>01/02/2011</date_enrolment>
+            <type_enrolment>actual</type_enrolment>
+            <target_size>2400</target_size>
+            <recruitment_status>recruiting</recruitment_status>
+            <url>http://127.0.0.1:8000/rg/RBR-4s7gh3/v1/</url>
+            <study_type></study_type>
+            <study_design>Double-blind Randomized Clinical Trial</study_design>
+            <phase>3</phase>
+            <hc_freetext>Hypertension</hc_freetext>
+            <i_freetext>Drug: Chlorthalidone 12,5 mg associated with Amiloride 2,5 mg once daily
+Drug: Losartan 25 mg once daily 
+During 18 months.</i_freetext>            
+        </main>
+        <contacts>
+        
+            <contact>
+                <type>public</type>
+                <firstname>Flávio</firstname>
+                <middlename>Danni</middlename>
+                <lastname>Fuchs</lastname>
+                <address>Rua Ramiro Barcelos 2350 2º Andar Serviço de Cardiologia</address>
+                <city>Porto Alegre</city>
+                <country1>Brazil</country1>
+                <zip>90035-903</zip>
+                <telephone>51 33598449</telephone>
+                <email>ffuchs@hcpa.ufrgs.br</email>
+                <affiliation>Hospital de Clínicas de Porto Alegre</affiliation>
+            </contact>
+        
+        
+            <contact>
+                <type>scientific</type>
+                <firstname>Flávio</firstname>
+                <middlename>Danni</middlename>
+                <lastname>Fuchs</lastname>
+                <address>Rua Ramiro Barcelos 2350 2º Andar Serviço de Cardiologia</address>
+                <city>Porto Alegre</city>
+                <country1>Brazil</country1>
+                <zip>90035-903</zip>
+                <telephone>51 33598449</telephone>
+                <email>ffuchs@hcpa.ufrgs.br</email>
+                <affiliation>Hospital de Clínicas de Porto Alegre</affiliation>
+            </contact>
+        
+        </contacts>
+        <countries>
+        
+            <country2>Brazil</country2>
+        
+        </countries>
+        <criteria>
+            <inclusion_criteria>I. Individuals with 40 to 70 years, of both sexes;
+II. Diagnosis of Hypertension in stage I, ie, systolic (SBP)  between 140-159 mmHg or diastolic blood pressure (DBP) between 90-99 mmHg</inclusion_criteria>
+            <agemin>40Y</agemin>
+            <agemax>70Y</agemax>
+            <gender>-</gender>
+            <exclusion_criteria>I. Chronic diseases that reduce life expectancy or difficulty in understanding the guidelines, which limit the possibility of participation in the study;
+II. Refusal to participate or sign an informed consent;
+III. Pregnancy or women most likely to become pregnant during the study;
+IV. Known allergy to any of the study drugs;
+V. Prior diagnosis of secondary hypertension ;
+</exclusion_criteria>
+        </criteria>
+        <health_condition_code>
+            
+            <hc_code>C14</hc_code>
+            
+        </health_condition_code>
+        <health_condition_keyword>
+            
+            <hc_keyword>I10</hc_keyword>
+            
+        </health_condition_keyword>
+        <intervention_code>
+            
+            <i_code>drug</i_code>
+            
+        </intervention_code>
+        <intervention_keyword>
+            
+            <i_keyword>d27.505.696.560.500</i_keyword>
+            
+            <i_keyword>D03.383.129.308.507</i_keyword>
+            
+        </intervention_keyword>
+        <primary_outcome>
+            
+            <prim_outcome>I. Lowering blood pressure to less than 140/90 mmHg;
+II. Incidence of Adverse Events;
+III. Incidence of diabetes mellitus, microalbuminuria, hypokalemia, hiperuricemia and left ventricular hypertrophy on ECG.
+</prim_outcome>
+            
+        </primary_outcome>
+        <secondary_outcome>
+            
+            <sec_outcome>I. All-cause mortality
+II. Incidence of Coronary Artery Disease (Acute Coronary Syndrome, need for revascularization, sudden death)
+III. Fatal and nonfatal stroke
+IV. Heart failure (requiring hospitalization)
+V. Duplication of plasma levels of creatinine or need for dialysis
+VI. Incidence of diabetes mellitus.
+</sec_outcome>
+            
+        </secondary_outcome>
+        <secondary_sponsor>
+            
+            <sponsor_name></sponsor_name>
+            
+        </secondary_sponsor>
+        <secondary_ids>
+            
+            <secondary_id>
+                <sec_id>08621</sec_id>
+                <issuing_authority>CEP- GPPG- Hospital de Clínicas de Porto Alegre</issuing_authority>    
+            </secondary_id>
+            
+            <secondary_id>
+                <sec_id>NCT00971165</sec_id>
+                <issuing_authority>Clinical Trials </issuing_authority>    
+            </secondary_id>
+            
+        </secondary_ids>
+        <source_support>
+            
+            <source_name>FINEP</source_name>
+            
+        </source_support>        
+    </trial>
+
+    <trial>
+        <main>
+            <trial_id>RBR-7sw5hf</trial_id>
+            <utrn>U1111-1119-1317</utrn>
+            <reg_name>REBEC</reg_name>
+            <date_registration>02/02/2011</date_registration>
+            <primary_sponsor>Luciano Ambrosio Ferreira</primary_sponsor>
+            <public_title>LASER ACUPUNCTURE TO TEMPOROMANDIBULAR DISORDER TREATMENT</public_title>
+            <acronym></acronym>
+            <scientific_title>ADJUVANT LASER ACUPUNCTURE TO OCCLUSAL SPLINT THERAPY: A CONTROLLED TRIAL IN TEMPOROMANDIBULAR DISORDERS PATIENTS</scientific_title>
+            <scientific_acronym></scientific_acronym>
+            <date_enrolment>01/02/2011</date_enrolment>
+            <type_enrolment>anticipated</type_enrolment>
+            <target_size>40</target_size>
+            <recruitment_status>not yet recruiting</recruitment_status>
+            <url>http://127.0.0.1:8000/rg/RBR-7sw5hf/v1/</url>
+            <study_type></study_type>
+            <study_design>Randomized double-blind controlled study. </study_design>
+            <phase>3</phase>
+            <hc_freetext>Temporomandibular disorder, stress</hc_freetext>
+            <i_freetext>In order to reduce the likelihood of systematic errors and allow the use of statistical tests, there will be a simple procedure of random allocation of subjects of this research, which will be  distributed in two groups of 20 subjects by drawing lots. Each group will receive a specific treatment modality for TMD defined as follows: 1) Group Therapy - neuromuscular relaxing splint and laser
+acupuncture; 2) Control Group - neuromuscular
+relaxing relaxing splint and placebo laser. Within each group, the therapeutic will be maintained until the end of the study, the patients being aware voluntary and consistent with the possibility
+of receiving one of two proposed therapies
+(therapeutic or placebo), were not informed during the processing of their nature therapies. At the end of the study, patients receiving a placebo therapy may undergo therapy for active laser acupuncture if they have persistent symptoms or if they wish. Simple randomisation by using sealed opaque envelope is assumed. In each subject is
+assigned a sealed opaque envelope, where
+information about the group to which belong will be contained. The number of envelopes for the therapeutic group is equal to the control group,the envelopes being identical with each other. The
+draw will be conducted by a person without any link to the survey, which will be in the custody of groups and their participants, the researcher revealed only when the first therapeutic application.
+Describe the methods used to generate the sequence in which subjects will be
+randomised (sequence generation):
+Simple randomisation by using a randomisation table created by computer software (SPSS for Windows 13.0) through computerised sequence generation.
+
+Study Group Intervention:
+Low intensity laser acupuncture to  temporomandibular disorder treatment, directed to study group. The acupuncture points: S6, SI19, GB20, LI4, L3, SJ3, GB34, Ex-3, low power (50mW) infrared laser, for 90s each, with the objective of sedation.
+Laser acupuncture therapy will happen weekly in one-hour sessions. It will begin at february,4, 2011. Laser treatment is continuous and punctual, directed at each point for a period of 90 seconds. Twelve weekly sessions will complete three months of treatment.
+The laser acupuncture therapy will follow the standards of protection for the use of lasers, including the protection of patients&#39; eyes. Such protection inhibits the visual stimulus during application of therapy.
+
+Study and Control Groups intervention:
+Neuromuscular relaxing occlusal splint is a dentistry conventional treatment directed to all participants of the research (study and control groups). The splints will be made of acrylic and individually adjusted by surface&#39;s sanding . The adjustment is to obtain simultaneous tooth contacts in a physiological mandibular position, where the chewing muscles and temporomandibular joints are protected from excessive occlusal loads. They will wear it for three months, at the night, when usually the involuntary muscle hyperactivity occurs. The adjustments will take place weekly, aiming occlusal changes that result in facial muscleand joint relaxation.
+
+Control Group Intervention:
+The control group will receive, in addition to conventional therapy for neuromuscular relaxing plate, the laser-acupuncture simulation characterized as placebo.
+Acupuncture points given for temporomandibular disorders: S6, SI19, GB20, LI4, L3, SJ3, GB34, Ex-3 will receive the treatment simulation by same study group&#39;s apparatus, by 90 seconds without applying pressure or radiation. There will be no emission of laser for this group, so the power button the device will be turned to the off position. Patients wear dark protection glasses that inhibit any view. No sound is emitted by the device, even when off or on. The issue of low power laser is painless, no sensation is felt when the true application of laser happens. The use of glasses that inhibit the view of the patient allows individuals do not know the nature of light, active or placebo. Placebo laser acupuncture will happen weekly in one-hour sessions. Twelve weekly sessions will complete three months of placebo therapy. This group will receive the same protection and biosecurity condute than study group.</i_freetext>            
+        </main>
+        <contacts>
+        
+            <contact>
+                <type>public</type>
+                <firstname>Luciano </firstname>
+                <middlename>Ambrosio</middlename>
+                <lastname>Ferreira</lastname>
+                <address>Luis Andrade silveira, 207, Centenário</address>
+                <city>Juiz de Fora</city>
+                <country1>Brazil</country1>
+                <zip>36045-280</zip>
+                <telephone>32 32245637</telephone>
+                <email>l3a6f9@yahoo.com.br</email>
+                <affiliation>Universidade Federal de Juiz de Fora</affiliation>
+            </contact>
+        
+        
+            <contact>
+                <type>scientific</type>
+                <firstname>Luciano </firstname>
+                <middlename>Ambrosio</middlename>
+                <lastname>Ferreira</lastname>
+                <address>Luis Andrade silveira, 207, Centenário</address>
+                <city>Juiz de Fora</city>
+                <country1>Brazil</country1>
+                <zip>36045-280</zip>
+                <telephone>32 32245637</telephone>
+                <email>l3a6f9@yahoo.com.br</email>
+                <affiliation>Universidade Federal de Juiz de Fora</affiliation>
+            </contact>
+        
+        </contacts>
+        <countries>
+        
+            <country2>Brazil</country2>
+        
+        </countries>
+        <criteria>
+            <inclusion_criteria>All subjects participated in this study volunteers by signing the consent
+• female subjects;
+• aged between 20 and 40;
+• irrespective of race, creed or social level;
+• presence of a diagnosis of myofascial pain and arthralgia orofacial chronic, persisting for a minimum period of six months;
+• minimum intensity of muscle and joint pain of 4.0 points, measured in the Visual Analog Scale (VAS) during the first evaluation.</inclusion_criteria>
+            <agemin>20Y</agemin>
+            <agemax>40Y</agemax>
+            <gender>F</gender>
+            <exclusion_criteria>Subjects with evidence of muscle diseases, rheumatic and joint systemic origin, such as fibromyalgia and rheumatoid arthritis;
+• presence of fungal skin changes, hyperplastic, erythematous keloid or continuity in areas related to acupuncture points;
+• medical, pharmacological, psychological or physical therapy for temporomandibular disorder (TMD), concomitant therapies introduced in this study;
+• pregnants, the possible influence of intrauterine contraction and movement promoted by some acupuncture points such as LI4;
+• report or finding of facial trauma as a possible etiology of temporomandibular disorder;
+• individuals who have undergone prior treatment with neuromuscular relaxing plate, acupuncture or laser therapy for temporomandibular disorder;
+• subject denture wearers an upper or lower;
+• individuals with intellectual disability or impairment that would hinder the collection of data.</exclusion_criteria>
+        </criteria>
+        <health_condition_code>
+            
+            <hc_code>C05</hc_code>
+            
+        </health_condition_code>
+        <health_condition_keyword>
+            
+            <hc_keyword>C05.500.607.221.897</hc_keyword>
+            
+            <hc_keyword>F01.145.126.990</hc_keyword>
+            
+        </health_condition_keyword>
+        <intervention_code>
+            
+            <i_code>radiation</i_code>
+            
+            <i_code>other</i_code>
+            
+        </intervention_code>
+        <intervention_keyword>
+            
+            <i_keyword>H02.004</i_keyword>
+            
+            <i_keyword>E02.594.540</i_keyword>
+            
+            <i_keyword>E06.276</i_keyword>
+            
+        </intervention_keyword>
+        <primary_outcome>
+            
+            <prim_outcome>Physical symptoms evaluation before the intervention and after 1, 2 and 3 months after the intervention. Measurement of muscle and joint pain orofacial by applying the visual analogue scale to palpation stomatognathic sites . At each time, the average intensity of pain experienced by each group will be mensured. The provision of these temporal averages (moments of 0, 1, 2 and 3) will prepare the development of physical symptoms in each group. This evolution will be compared between the groups in order to verify the effectiveness of proposed therapies.
+
+Diagnostic Criteria for Temporomandibular Disorders Research (RDC / TMD, Axis II) to assess the psychosocial impact of emotional distress associated to temporomandibular disorder. Levels of depression and no specific sumptoms (somatization) will be  measured through SCL 90R questionary, contained in RDC/DTM. This instrument will be applied before and after institution of therapy in each group. A comparison of symptoms of somatization and depression in the two instances indicate a possible change of these symptoms.</prim_outcome>
+            
+        </primary_outcome>
+        <secondary_outcome>
+            
+            <sec_outcome></sec_outcome>
+            
+        </secondary_outcome>
+        <secondary_sponsor>
+            
+            <sponsor_name>Marcos Vinicius Queiroz de Paula</sponsor_name>
+            
+            <sponsor_name>Universidade Federal de Juiz de Fora</sponsor_name>
+            
+            <sponsor_name>Amanda Buchara Pereira</sponsor_name>
+            
+        </secondary_sponsor>
+        <secondary_ids>
+            
+            <secondary_id>
+                <sec_id>398/2008 </sec_id>
+                <issuing_authority>Comitê de Ética em Pesquisa da Universidade Federal de Juiz de Fora</issuing_authority>    
+            </secondary_id>
+            
+            <secondary_id>
+                <sec_id>0253.0.180.000-08</sec_id>
+                <issuing_authority>CAAE - CONEP</issuing_authority>    
+            </secondary_id>
+            
+            <secondary_id>
+                <sec_id>ACTRN12611000088943</sec_id>
+                <issuing_authority>Australian New Zealand Clinical Trials Registry</issuing_authority>    
+            </secondary_id>
+            
+        </secondary_ids>
+        <source_support>
+            
+            <source_name>Luciano Ambrosio Ferreira</source_name>
+            
+            <source_name>Universidade Federal de Juiz de Fora</source_name>
+            
+        </source_support>        
+    </trial>
+
+    <trial>
+        <main>
+            <trial_id>RBR-5kzyp8</trial_id>
+            <utrn>U1234-1234-1234</utrn>
+            <reg_name>REBEC</reg_name>
+            <date_registration></date_registration>
+            <primary_sponsor>Oswaldo Cruz Foundation</primary_sponsor>
+            <public_title>Pharmacokinetics of the Tablet Formulation of Lopinavir/r as Standard and Increased Dosage During Pregnancy</public_title>
+            <acronym></acronym>
+            <scientific_title>Pharmacokinetics of the Tablet Formulation of Lopinavir/r as Standard and Increased Dosage During Pregnancy in HIV-Infected Women</scientific_title>
+            <scientific_acronym></scientific_acronym>
+            <date_enrolment>01/02/2008</date_enrolment>
+            <type_enrolment>anticipated</type_enrolment>
+            <target_size>60</target_size>
+            <recruitment_status>recruiting</recruitment_status>
+            <url>http://127.0.0.1:8000/rg/RBR-5kzyp8/v2/</url>
+            <study_type></study_type>
+            <study_design>Estudo farmacocinético, prospectivo, aberto, alocação paralela, fase 4, randomizado, preventivo.</study_design>
+            <phase>4</phase>
+            <hc_freetext>HIV Infections
+Pregnancy
+</hc_freetext>
+            <i_freetext>Drug: Lopinavir / ritonavir
+Lopinavir/r (200/50 mg, 2 tablets every 12 hours) plus two nucleoside analogs, starting at any time between 14 and 30 weeks of gestation and maintained for at least 6 weeks after delivery.
+Other Name: Kaletra
+Drug: Lopinavir/ritonavir
+Lopinavir/r (200/50 mg, 2 tablets every 12 hours) plus two nucleoside analogs, starting at any time between 14 and 30 weeks of gestation, increase the lopinavir/r dosage (200/50 mg, 3 tablets every 12 hours) in the third trimester (from 25 weeks on), and return to standard dose(200/50 mg, 2 tablets every 12 hours)for at least 6 weeks after delivery.
+Other Name: Kaletra
+</i_freetext>            
+        </main>
+        <contacts>
+        
+        
+            <contact>
+                <type>scientific</type>
+                <firstname>Marília</firstname>
+                <middlename>Santini</middlename>
+                <lastname>Oliveira</lastname>
+                <address></address>
+                <city>Rio de Janeiro</city>
+                <country1>Brazil</country1>
+                <zip>12345-123</zip>
+                <telephone>23423422234</telephone>
+                <email>su@abc.com</email>
+                <affiliation>Fundação Oswaldo Cruz</affiliation>
+            </contact>
+        
+        </contacts>
+        <countries>
+        
+            <country2>Brazil</country2>
+        
+        </countries>
+        <criteria>
+            <inclusion_criteria>Capacity to consent and wish to participate in the study, documented by signing the specific informed consent form (ICF) of the study.
+Pregnancy documented by urine or blood examination or ultrasound.
+Gestational age of 14 to 30 weeks calculated by ultrasound, obstetric examination or date of last menstruation, depending on what is considered to be more exact by the medical investigator.
+HIV infection documented by two serological tests using different methods or analysis of HIV viral load with a positive result.
+No use of antiretroviral drugs at the time of diagnosis of pregnancy (previous prophylaxis and treatment are allowed).
+Intention to continue the treatment of the study for at least 6 weeks after delivery.</inclusion_criteria>
+            <agemin>18Y</agemin>
+            <agemax>0</agemax>
+            <gender>F</gender>
+            <exclusion_criteria>History of hypersensitivity to lopinavir or ritonavir.
+Need for the concomitant use of contraindicated drugs in combination with lopinavir/ritonavir.
+Any condition that, in the opinion of the medical researchers, impairs the participation in and fulfillment of the procedures of the study.
+</exclusion_criteria>
+        </criteria>
+        <health_condition_code>
+            
+            <hc_code>C20</hc_code>
+            
+        </health_condition_code>
+        <health_condition_keyword>
+            
+            <hc_keyword>Z21</hc_keyword>
+            
+            <hc_keyword>G08.686.785.760.769</hc_keyword>
+            
+        </health_condition_keyword>
+        <intervention_code>
+            
+            <i_code>drug</i_code>
+            
+        </intervention_code>
+        <intervention_keyword>
+            
+            <i_keyword>G02.111.325.500</i_keyword>
+            
+        </intervention_keyword>
+        <primary_outcome>
+            
+            <prim_outcome>Pharmacokinetic parameters of the tablet formulation of lopinavir/r at second and third pregnancy trimester and 6 weeks after delivery</prim_outcome>
+            
+        </primary_outcome>
+        <secondary_outcome>
+            
+            <sec_outcome>Ratio between the serum concentration of lopinavir/r in maternal blood and in cord blood</sec_outcome>
+            
+        </secondary_outcome>
+        <secondary_sponsor>
+            
+            <sponsor_name></sponsor_name>
+            
+        </secondary_sponsor>
+        <secondary_ids>
+            
+            <secondary_id>
+                <sec_id>NCT00605098</sec_id>
+                <issuing_authority>Clinicaltrials.gov</issuing_authority>    
+            </secondary_id>
+            
+        </secondary_ids>
+        <source_support>
+            
+            <source_name></source_name>
+            
+        </source_support>        
+    </trial>
+
+    <trial>
+        <main>
+            <trial_id>RBR-74rr6s</trial_id>
+            <utrn>U1111-1119-5061</utrn>
+            <reg_name>REBEC</reg_name>
+            <date_registration>02/03/2011</date_registration>
+            <primary_sponsor>Hospital de Clínicas de Porto Alegre</primary_sponsor>
+            <public_title>PREVER Study: Efficacy of the combination of Chlorthalidone and Amiloride versus placebo in the prevention of hypertension in patients with prehypertension PREVER 1 Study</public_title>
+            <acronym>PREVER 1 Study: Prevention of Cardiovascular outcomes in patients with prehypertension </acronym>
+            <scientific_title>PREVER Study: Efficacy of the combination of Chlorthalidone and Amiloride versus placebo in the prevention of hypertension in patients with prehypertension PREVER 1 Study</scientific_title>
+            <scientific_acronym>PREVER 1 Study: Prevention of Cardiovascular outcomes in patients with prehypertension </scientific_acronym>
+            <date_enrolment>01/02/2011</date_enrolment>
+            <type_enrolment>actual</type_enrolment>
+            <target_size>1350</target_size>
+            <recruitment_status>recruiting</recruitment_status>
+            <url>http://127.0.0.1:8000/rg/RBR-74rr6s/v1/</url>
+            <study_type></study_type>
+            <study_design>Randomized Clinical Trial, double-blind, placebo controled trial</study_design>
+            <phase>3</phase>
+            <hc_freetext>Prehypertension</hc_freetext>
+            <i_freetext>Drug: Chlorthalidone 12,5 mg plus amiloride 2,5 mg once daily for 18 months
+Drug: placebo once daily for 18 months
+
+</i_freetext>            
+        </main>
+        <contacts>
+        
+            <contact>
+                <type>public</type>
+                <firstname>Flávio</firstname>
+                <middlename>Danni</middlename>
+                <lastname>Fuchs</lastname>
+                <address>Rua Ramiro Barcelos 2350 2º Andar Serviço de Cardiologia</address>
+                <city>Porto Alegre</city>
+                <country1>Brazil</country1>
+                <zip>90035-903</zip>
+                <telephone>51 33598449</telephone>
+                <email>ffuchs@hcpa.ufrgs.br</email>
+                <affiliation>Hospital de Clínicas de Porto Alegre</affiliation>
+            </contact>
+        
+        
+            <contact>
+                <type>scientific</type>
+                <firstname>Flávio</firstname>
+                <middlename>Danni</middlename>
+                <lastname>Fuchs</lastname>
+                <address>Rua Ramiro Barcelos 2350 2º Andar Serviço de Cardiologia</address>
+                <city>Porto Alegre</city>
+                <country1>Brazil</country1>
+                <zip>90035-903</zip>
+                <telephone>51 33598449</telephone>
+                <email>ffuchs@hcpa.ufrgs.br</email>
+                <affiliation>Hospital de Clínicas de Porto Alegre</affiliation>
+            </contact>
+        
+        </contacts>
+        <countries>
+        
+            <country2>Brazil</country2>
+        
+        </countries>
+        <criteria>
+            <inclusion_criteria>I. individuals with 30 to 70 years of age 
+II. Systolic Arterial Pressure 120-139 mmHg or Diastolic Arterial Pressure 80-89 mmHg;</inclusion_criteria>
+            <agemin>30Y</agemin>
+            <agemax>70Y</agemax>
+            <gender>-</gender>
+            <exclusion_criteria>I. Previous diagnosis of hypertension or use of antihypertensive drugs;
+II. Allergies to Chlorthalidone Amiloride;
+III. Known cardiovascular disease (previous Miocardial Infarction, previous stroke, heart failure or clinical manifestations, for example, current or previous angina, intermittent claudication ...);
+IV. Chronic diseases that limit the participation or the prospect of life (such as cancer, rheumatic disease, disability, etc.);
+V. Analgesics or anti-inflammatory use for 30 days or more;
+VI. Inability to measure blood pressure;
+VII. Difficulty in understanding that limits participation in the study;
+VIII. IF WOMEN: Pregnant or planning to become pregnant in the next two years;
+IX. Patients who have participated in other randomized trials (the last six months);
+</exclusion_criteria>
+        </criteria>
+        <health_condition_code>
+            
+            <hc_code>C14</hc_code>
+            
+        </health_condition_code>
+        <health_condition_keyword>
+            
+            <hc_keyword>I10</hc_keyword>
+            
+        </health_condition_keyword>
+        <intervention_code>
+            
+            <i_code>drug</i_code>
+            
+        </intervention_code>
+        <intervention_keyword>
+            
+            <i_keyword>D27.505.696.560.500</i_keyword>
+            
+        </intervention_keyword>
+        <primary_outcome>
+            
+            <prim_outcome>Incidence of hypertension, by blood pressure greater or equal to 140/90 mmHg.
+</prim_outcome>
+            
+            <prim_outcome>Adverse events. 
+</prim_outcome>
+            
+        </primary_outcome>
+        <secondary_outcome>
+            
+            <sec_outcome>I. All-cause mortality
+II. Incidence of Coronary Artery Disease (Acute Coronary Syndrome, need for revascularization, sudden death)
+III. Fatal and nonfatal stroke
+IV. Heart failure (requiring hospitalization)
+V. Duplication of plasma levels of creatinine or need for dialysis
+VI. Incidence of diabetes mellitus.
+VII. Microalbuminuria
+VIII. Hypokalemia
+IX. Hyperuricemia
+X. Left ventricular hypertrophy on Eletrocardiogram</sec_outcome>
+            
+        </secondary_outcome>
+        <secondary_sponsor>
+            
+            <sponsor_name></sponsor_name>
+            
+        </secondary_sponsor>
+        <secondary_ids>
+            
+            <secondary_id>
+                <sec_id>08621</sec_id>
+                <issuing_authority>CEP- GPPG- Hospital de Clínicas de Porto Alegre</issuing_authority>    
+            </secondary_id>
+            
+            <secondary_id>
+                <sec_id>NCT00970931</sec_id>
+                <issuing_authority>Clinical Trials </issuing_authority>    
+            </secondary_id>
+            
+        </secondary_ids>
+        <source_support>
+            
+            <source_name>FINEP</source_name>
+            
+        </source_support>        
+    </trial>
+
+</trials>
+
+
Index: /tags/v1.0.23rc1/opentrials/repository/xml/samples/vitamin-c-ictrp.xml
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/samples/vitamin-c-ictrp.xml (revision 207)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/samples/vitamin-c-ictrp.xml (revision 207)
@@ -0,0 +1,134 @@
+<?xml version="1.0"?>
+<trials>
+    <trial>
+        <main>
+            <trial_id>IRCT138708271460N1</trial_id>
+            <utrn/>
+            <reg_name>IRCT</reg_name>
+            <date_registration>2009-02-16</date_registration>
+            <primary_sponsor>Tabriz Univ Med Sci</primary_sponsor>
+            <public_title>
+                Comparison of Ascorbic Acid and Grape Seed Extract in 
+                Oxidative Stress Induced by on Pump Heart Surgery
+            </public_title>
+            <acronym></acronym>
+            <scientific_title>
+                Effect of Ascorbic Acid and Grape Seed Extract 
+                "Vitis Vinifera L." on Oxidative Stress Induced by on Pump 
+                Coronary Artery by Pass Grafting Surgery
+            </scientific_title>
+            <date_enrolment>2008-11-01</date_enrolment>
+            <type_enrolment>anticipated</type_enrolment>
+            <target_size>75</target_size>
+            <recruitment_status>Complete</recruitment_status>
+            <url>http://www.irct.ir/searchresult.php?id=1460&amp;number=1</url>
+            <study_type>interventional</study_type>
+            <study_design>
+                Randomization: randomized.
+                Blinding:  Double blind.
+                Placebo: not used.
+                Assignment: Parallel.
+                Purpose: Supportive care.
+                Other design features:
+            </study_design>
+            <phase>2-3</phase>
+            <hc_freetext>
+                Condition 1: Coronary Atrery Bypass Graft (CABG).
+                Condition 2: Atherosclerotic heart disease.
+                Condition 3: Ischaemic cardiomyopathy.
+            </hc_freetext>
+            <i_freetext>
+                Intervention 1: Control Group: without intervention.
+                Intervention 2: Grape Seed Extract 100 mg/6h.
+                Intervention 3: Vit C 25 mg/kg.
+            </i_freetext>
+        </main>
+        <contacts>
+            <contact>
+                <type>public</type>
+                <firstname>Naser safaei, MD, Surgeon</firstname>
+                <middlename/>
+                <lastname/>
+                <address>Tabriz Univ Med Sci</address>
+                <city>Tabriz</city>
+                <country1>Iran, Islamic Republic Of</country1>
+                <zip>51656-65811</zip>
+                <telephone>+98-411-3357767</telephone>
+                <email>drsafaei@yahoo.com</email>
+                <affiliation>Tabriz Univ Med Sci</affiliation>
+            </contact>
+            <contact>
+                <type>scientific</type>
+                <firstname>Dr Naser Safaei</firstname>
+                <middlename/>
+                <lastname/>
+                <address>Daneshgah St,Tabriz Univ Med Sci</address>
+                <city>Tabriz</city>
+                <country1>Iran, Islamic Republic Of</country1>
+                <zip>51656-65811</zip>
+                <telephone>+98-411-3357767</telephone>
+                <email>drsafaei@yahoo.com</email>
+                <affiliation>Tabriz Univ Med Sci</affiliation>
+            </contact>
+        </contacts>
+        <countries>
+            <country2>Iran, Islamic Republic Of</country2>
+        </countries>
+        <criteria>
+            <inclusion_criteria>
+                Inclusion Criteria: Candidates for elective CABG surgery 
+                with pump for first time, 3 Vessel Disease (3VD). &#xD;
+                Exclusion Criteria: High risk patients, Those who need another 
+                heart surgery beside CABG, Urgent patients Diabetics, Ischemic 
+                time more than 120 min.&#xD;
+            </inclusion_criteria>
+            <agemin>0</agemin>
+            <agemax>150</agemax>
+            <gender>Both male and female</gender>
+            <exclusion_criteria/>
+        </criteria>
+        <health_condition_code>
+            <hc_code/>
+        </health_condition_code>
+        <health_condition_keyword>
+            <hc_keyword>Ischaemic heart diseases</hc_keyword>
+            <hc_keyword>Atherosclerotic heart disease</hc_keyword>
+            <hc_keyword>Ischaemic cardiomyopathy</hc_keyword>
+        </health_condition_keyword>
+        <intervention_code>
+            <i_code>Not applicable</i_code>
+            <i_code>Treatment: drugs</i_code>
+            <i_code>Treatment: drugs</i_code>
+            <i_code></i_code>
+        </intervention_code>
+        <intervention_keyword>
+            <i_keyword></i_keyword>
+        </intervention_keyword>
+        <primary_outcome>
+            <prim_outcome>
+                Left Ventricular Ejection Fraction (LVEF).
+                Timepoint: Before and after CABG. 
+                Method of measurement: Trans Thoracic Echocardiography (TTE)
+            </prim_outcome>
+        </primary_outcome>
+        <secondary_outcome>
+            <sec_outcome>
+                Total Antioxidant Capacity (TAC).
+                Timepoint: Before, middle and after CABG.
+                Method of measurement: Biochemistry (blood sample)
+            </sec_outcome>
+        </secondary_outcome>
+        <secondary_sponsor>
+            <sponsor_name></sponsor_name>
+        </secondary_sponsor>
+        <secondary_ids>
+            <secondary_id>
+                <sec_id>NCT00839085</sec_id>
+                <issuing_authority>ClinicalTrials.gov</issuing_authority>
+            </secondary_id>
+        </secondary_ids>
+        <source_support>
+            <source_name>Tabriz University of Medical Sciences</source_name>
+        </source_support>
+    </trial>
+</trials>
Index: /tags/v1.0.23rc1/opentrials/repository/xml/samples/ecgovbr-ictrp-2011-03-24.xml
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/samples/ecgovbr-ictrp-2011-03-24.xml (revision 929)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/samples/ecgovbr-ictrp-2011-03-24.xml (revision 929)
@@ -0,0 +1,472 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<trials>
+
+    <trial>
+        <main>
+            <trial_id>RBR-4s7gh3</trial_id>
+            <utrn>U1111-1119-5101</utrn>
+            <reg_name>REBEC</reg_name>
+            <date_registration>02/03/2011</date_registration>
+            <primary_sponsor>Hospital de Clínicas de Porto Alegre</primary_sponsor>
+            <public_title>PREVER Study: Efficacy of Chlorthalidone associated with Amiloride versus  Losartan in reducing blood pressure of patients with hypertension Prever 2 Study
+</public_title>
+            <acronym>PREVER: Prevention of Cardiovascular outcomes in patients with hypertension</acronym>
+            <scientific_title>PREVER Study: Efficacy of Chlorthalidone associated with Amiloride versus  Losartan in reducing blood pressure of patients with hypertension Prever 2 Study
+</scientific_title>
+            <scientific_acronym>PREVER 2: Prevention of Cardiovascular outcomes in patients with hypertension</scientific_acronym>
+            <date_enrolment>01/02/2011</date_enrolment>
+            <type_enrolment>actual</type_enrolment>
+            <target_size>2400</target_size>
+            <recruitment_status>recruiting</recruitment_status>
+            <url>http://127.0.0.1:8000/rg/RBR-4s7gh3/v1/</url>
+            <study_type></study_type>
+            <study_design>Double-blind Randomized Clinical Trial</study_design>
+            <phase>3</phase>
+            <hc_freetext>Hypertension</hc_freetext>
+            <i_freetext>Drug: Chlorthalidone 12,5 mg associated with Amiloride 2,5 mg once daily
+Drug: Losartan 25 mg once daily 
+During 18 months.</i_freetext>            
+        </main>
+        <contacts>
+        
+            <contact>
+                <type>public</type>
+                <firstname>Flávio</firstname>
+                <middlename>Danni</middlename>
+                <lastname>Fuchs</lastname>
+                <address>Rua Ramiro Barcelos 2350 2º Andar Serviço de Cardiologia</address>
+                <city>Porto Alegre</city>
+                <country1>Brazil</country1>
+                <zip>90035-903</zip>
+                <telephone>51 33598449</telephone>
+                <email>ffuchs@hcpa.ufrgs.br</email>
+                <affiliation>Hospital de Clínicas de Porto Alegre</affiliation>
+            </contact>
+        
+        
+            <contact>
+                <type>scientific</type>
+                <firstname>Flávio</firstname>
+                <middlename>Danni</middlename>
+                <lastname>Fuchs</lastname>
+                <address>Rua Ramiro Barcelos 2350 2º Andar Serviço de Cardiologia</address>
+                <city>Porto Alegre</city>
+                <country1>Brazil</country1>
+                <zip>90035-903</zip>
+                <telephone>51 33598449</telephone>
+                <email>ffuchs@hcpa.ufrgs.br</email>
+                <affiliation>Hospital de Clínicas de Porto Alegre</affiliation>
+            </contact>
+        
+        </contacts>
+        <countries>
+        
+            <country2>Brazil</country2>
+        
+        </countries>
+        <criteria>
+            <inclusion_criteria>I. Individuals with 40 to 70 years, of both sexes;
+II. Diagnosis of Hypertension in stage I, ie, systolic (SBP)  between 140-159 mmHg or diastolic blood pressure (DBP) between 90-99 mmHg</inclusion_criteria>
+            <agemin>40Y</agemin>
+            <agemax>70Y</agemax>
+            <gender>-</gender>
+            <exclusion_criteria>I. Chronic diseases that reduce life expectancy or difficulty in understanding the guidelines, which limit the possibility of participation in the study;
+II. Refusal to participate or sign an informed consent;
+III. Pregnancy or women most likely to become pregnant during the study;
+IV. Known allergy to any of the study drugs;
+V. Prior diagnosis of secondary hypertension ;
+</exclusion_criteria>
+        </criteria>
+        <health_condition_code>
+            
+            <hc_code>C14</hc_code>
+            
+        </health_condition_code>
+        <health_condition_keyword>
+            
+            <hc_keyword>I10</hc_keyword>
+            
+        </health_condition_keyword>
+        <intervention_code>
+            
+            <i_code>drug</i_code>
+            
+        </intervention_code>
+        <intervention_keyword>
+            
+            <i_keyword>d27.505.696.560.500</i_keyword>
+            
+            <i_keyword>D03.383.129.308.507</i_keyword>
+            
+        </intervention_keyword>
+        <primary_outcome>
+            
+            <prim_outcome>I. Lowering blood pressure to less than 140/90 mmHg;
+II. Incidence of Adverse Events;
+III. Incidence of diabetes mellitus, microalbuminuria, hypokalemia, hiperuricemia and left ventricular hypertrophy on ECG.
+</prim_outcome>
+            
+        </primary_outcome>
+        <secondary_outcome>
+            
+            <sec_outcome>I. All-cause mortality
+II. Incidence of Coronary Artery Disease (Acute Coronary Syndrome, need for revascularization, sudden death)
+III. Fatal and nonfatal stroke
+IV. Heart failure (requiring hospitalization)
+V. Duplication of plasma levels of creatinine or need for dialysis
+VI. Incidence of diabetes mellitus.
+</sec_outcome>
+            
+        </secondary_outcome>
+        <secondary_sponsor>
+            
+            <sponsor_name></sponsor_name>
+            
+        </secondary_sponsor>
+        <secondary_ids>
+            
+            <secondary_id>
+                <sec_id>08621</sec_id>
+                <issuing_authority>CEP- GPPG- Hospital de Clínicas de Porto Alegre</issuing_authority>    
+            </secondary_id>
+            
+            <secondary_id>
+                <sec_id>NCT00971165</sec_id>
+                <issuing_authority>Clinical Trials </issuing_authority>    
+            </secondary_id>
+            
+        </secondary_ids>
+        <source_support>
+            
+            <source_name>FINEP</source_name>
+            
+        </source_support>        
+    </trial>
+
+    <trial>
+        <main>
+            <trial_id>RBR-7sw5hf</trial_id>
+            <utrn>U1111-1119-1317</utrn>
+            <reg_name>REBEC</reg_name>
+            <date_registration>02/02/2011</date_registration>
+            <primary_sponsor>Luciano Ambrosio Ferreira</primary_sponsor>
+            <public_title>LASER ACUPUNCTURE TO TEMPOROMANDIBULAR DISORDER TREATMENT</public_title>
+            <acronym></acronym>
+            <scientific_title>ADJUVANT LASER ACUPUNCTURE TO OCCLUSAL SPLINT THERAPY: A CONTROLLED TRIAL IN TEMPOROMANDIBULAR DISORDERS PATIENTS</scientific_title>
+            <scientific_acronym></scientific_acronym>
+            <date_enrolment>01/02/2011</date_enrolment>
+            <type_enrolment>anticipated</type_enrolment>
+            <target_size>40</target_size>
+            <recruitment_status>not yet recruiting</recruitment_status>
+            <url>http://127.0.0.1:8000/rg/RBR-7sw5hf/v1/</url>
+            <study_type></study_type>
+            <study_design>Randomized double-blind controlled study. </study_design>
+            <phase>3</phase>
+            <hc_freetext>Temporomandibular disorder, stress</hc_freetext>
+            <i_freetext>In order to reduce the likelihood of systematic errors and allow the use of statistical tests, there will be a simple procedure of random allocation of subjects of this research, which will be  distributed in two groups of 20 subjects by drawing lots. Each group will receive a specific treatment modality for TMD defined as follows: 1) Group Therapy - neuromuscular relaxing splint and laser
+acupuncture; 2) Control Group - neuromuscular
+relaxing relaxing splint and placebo laser. Within each group, the therapeutic will be maintained until the end of the study, the patients being aware voluntary and consistent with the possibility
+of receiving one of two proposed therapies
+(therapeutic or placebo), were not informed during the processing of their nature therapies. At the end of the study, patients receiving a placebo therapy may undergo therapy for active laser acupuncture if they have persistent symptoms or if they wish. Simple randomisation by using sealed opaque envelope is assumed. In each subject is
+assigned a sealed opaque envelope, where
+information about the group to which belong will be contained. The number of envelopes for the therapeutic group is equal to the control group,the envelopes being identical with each other. The
+draw will be conducted by a person without any link to the survey, which will be in the custody of groups and their participants, the researcher revealed only when the first therapeutic application.
+Describe the methods used to generate the sequence in which subjects will be
+randomised (sequence generation):
+Simple randomisation by using a randomisation table created by computer software (SPSS for Windows 13.0) through computerised sequence generation.
+
+Study Group Intervention:
+Low intensity laser acupuncture to  temporomandibular disorder treatment, directed to study group. The acupuncture points: S6, SI19, GB20, LI4, L3, SJ3, GB34, Ex-3, low power (50mW) infrared laser, for 90s each, with the objective of sedation.
+Laser acupuncture therapy will happen weekly in one-hour sessions. It will begin at february,4, 2011. Laser treatment is continuous and punctual, directed at each point for a period of 90 seconds. Twelve weekly sessions will complete three months of treatment.
+The laser acupuncture therapy will follow the standards of protection for the use of lasers, including the protection of patients&#39; eyes. Such protection inhibits the visual stimulus during application of therapy.
+
+Study and Control Groups intervention:
+Neuromuscular relaxing occlusal splint is a dentistry conventional treatment directed to all participants of the research (study and control groups). The splints will be made of acrylic and individually adjusted by surface&#39;s sanding . The adjustment is to obtain simultaneous tooth contacts in a physiological mandibular position, where the chewing muscles and temporomandibular joints are protected from excessive occlusal loads. They will wear it for three months, at the night, when usually the involuntary muscle hyperactivity occurs. The adjustments will take place weekly, aiming occlusal changes that result in facial muscleand joint relaxation.
+
+Control Group Intervention:
+The control group will receive, in addition to conventional therapy for neuromuscular relaxing plate, the laser-acupuncture simulation characterized as placebo.
+Acupuncture points given for temporomandibular disorders: S6, SI19, GB20, LI4, L3, SJ3, GB34, Ex-3 will receive the treatment simulation by same study group&#39;s apparatus, by 90 seconds without applying pressure or radiation. There will be no emission of laser for this group, so the power button the device will be turned to the off position. Patients wear dark protection glasses that inhibit any view. No sound is emitted by the device, even when off or on. The issue of low power laser is painless, no sensation is felt when the true application of laser happens. The use of glasses that inhibit the view of the patient allows individuals do not know the nature of light, active or placebo. Placebo laser acupuncture will happen weekly in one-hour sessions. Twelve weekly sessions will complete three months of placebo therapy. This group will receive the same protection and biosecurity condute than study group.</i_freetext>            
+        </main>
+        <contacts>
+        
+            <contact>
+                <type>public</type>
+                <firstname>Luciano </firstname>
+                <middlename>Ambrosio</middlename>
+                <lastname>Ferreira</lastname>
+                <address>Luis Andrade silveira, 207, Centenário</address>
+                <city>Juiz de Fora</city>
+                <country1>Brazil</country1>
+                <zip>36045-280</zip>
+                <telephone>32 32245637</telephone>
+                <email>l3a6f9@yahoo.com.br</email>
+                <affiliation>Universidade Federal de Juiz de Fora</affiliation>
+            </contact>
+        
+        
+            <contact>
+                <type>scientific</type>
+                <firstname>Luciano </firstname>
+                <middlename>Ambrosio</middlename>
+                <lastname>Ferreira</lastname>
+                <address>Luis Andrade silveira, 207, Centenário</address>
+                <city>Juiz de Fora</city>
+                <country1>Brazil</country1>
+                <zip>36045-280</zip>
+                <telephone>32 32245637</telephone>
+                <email>l3a6f9@yahoo.com.br</email>
+                <affiliation>Universidade Federal de Juiz de Fora</affiliation>
+            </contact>
+        
+        </contacts>
+        <countries>
+        
+            <country2>Brazil</country2>
+        
+        </countries>
+        <criteria>
+            <inclusion_criteria>All subjects participated in this study volunteers by signing the consent
+• female subjects;
+• aged between 20 and 40;
+• irrespective of race, creed or social level;
+• presence of a diagnosis of myofascial pain and arthralgia orofacial chronic, persisting for a minimum period of six months;
+• minimum intensity of muscle and joint pain of 4.0 points, measured in the Visual Analog Scale (VAS) during the first evaluation.</inclusion_criteria>
+            <agemin>20Y</agemin>
+            <agemax>40Y</agemax>
+            <gender>F</gender>
+            <exclusion_criteria>Subjects with evidence of muscle diseases, rheumatic and joint systemic origin, such as fibromyalgia and rheumatoid arthritis;
+• presence of fungal skin changes, hyperplastic, erythematous keloid or continuity in areas related to acupuncture points;
+• medical, pharmacological, psychological or physical therapy for temporomandibular disorder (TMD), concomitant therapies introduced in this study;
+• pregnants, the possible influence of intrauterine contraction and movement promoted by some acupuncture points such as LI4;
+• report or finding of facial trauma as a possible etiology of temporomandibular disorder;
+• individuals who have undergone prior treatment with neuromuscular relaxing plate, acupuncture or laser therapy for temporomandibular disorder;
+• subject denture wearers an upper or lower;
+• individuals with intellectual disability or impairment that would hinder the collection of data.</exclusion_criteria>
+        </criteria>
+        <health_condition_code>
+            
+            <hc_code>C05</hc_code>
+            
+        </health_condition_code>
+        <health_condition_keyword>
+            
+            <hc_keyword>C05.500.607.221.897</hc_keyword>
+            
+            <hc_keyword>F01.145.126.990</hc_keyword>
+            
+        </health_condition_keyword>
+        <intervention_code>
+            
+            <i_code>radiation</i_code>
+            
+            <i_code>other</i_code>
+            
+        </intervention_code>
+        <intervention_keyword>
+            
+            <i_keyword>H02.004</i_keyword>
+            
+            <i_keyword>E02.594.540</i_keyword>
+            
+            <i_keyword>E06.276</i_keyword>
+            
+        </intervention_keyword>
+        <primary_outcome>
+            
+            <prim_outcome>Physical symptoms evaluation before the intervention and after 1, 2 and 3 months after the intervention. Measurement of muscle and joint pain orofacial by applying the visual analogue scale to palpation stomatognathic sites . At each time, the average intensity of pain experienced by each group will be mensured. The provision of these temporal averages (moments of 0, 1, 2 and 3) will prepare the development of physical symptoms in each group. This evolution will be compared between the groups in order to verify the effectiveness of proposed therapies.
+
+Diagnostic Criteria for Temporomandibular Disorders Research (RDC / TMD, Axis II) to assess the psychosocial impact of emotional distress associated to temporomandibular disorder. Levels of depression and no specific sumptoms (somatization) will be  measured through SCL 90R questionary, contained in RDC/DTM. This instrument will be applied before and after institution of therapy in each group. A comparison of symptoms of somatization and depression in the two instances indicate a possible change of these symptoms.</prim_outcome>
+            
+        </primary_outcome>
+        <secondary_outcome>
+            
+            <sec_outcome></sec_outcome>
+            
+        </secondary_outcome>
+        <secondary_sponsor>
+            
+            <sponsor_name>Marcos Vinicius Queiroz de Paula</sponsor_name>
+            
+            <sponsor_name>Universidade Federal de Juiz de Fora</sponsor_name>
+            
+            <sponsor_name>Amanda Buchara Pereira</sponsor_name>
+            
+        </secondary_sponsor>
+        <secondary_ids>
+            
+            <secondary_id>
+                <sec_id>398/2008 </sec_id>
+                <issuing_authority>Comitê de Ética em Pesquisa da Universidade Federal de Juiz de Fora</issuing_authority>    
+            </secondary_id>
+            
+            <secondary_id>
+                <sec_id>0253.0.180.000-08</sec_id>
+                <issuing_authority>CAAE - CONEP</issuing_authority>    
+            </secondary_id>
+            
+            <secondary_id>
+                <sec_id>ACTRN12611000088943</sec_id>
+                <issuing_authority>Australian New Zealand Clinical Trials Registry</issuing_authority>    
+            </secondary_id>
+            
+        </secondary_ids>
+        <source_support>
+            
+            <source_name>Luciano Ambrosio Ferreira</source_name>
+            
+            <source_name>Universidade Federal de Juiz de Fora</source_name>
+            
+        </source_support>        
+    </trial>
+
+    <trial>
+        <main>
+            <trial_id>RBR-74rr6s</trial_id>
+            <utrn>U1111-1119-5061</utrn>
+            <reg_name>REBEC</reg_name>
+            <date_registration>02/03/2011</date_registration>
+            <primary_sponsor>Hospital de Clínicas de Porto Alegre</primary_sponsor>
+            <public_title>PREVER Study: Efficacy of the combination of Chlorthalidone and Amiloride versus placebo in the prevention of hypertension in patients with prehypertension PREVER 1 Study</public_title>
+            <acronym>PREVER 1 Study: Prevention of Cardiovascular outcomes in patients with prehypertension </acronym>
+            <scientific_title>PREVER Study: Efficacy of the combination of Chlorthalidone and Amiloride versus placebo in the prevention of hypertension in patients with prehypertension PREVER 1 Study</scientific_title>
+            <scientific_acronym>PREVER 1 Study: Prevention of Cardiovascular outcomes in patients with prehypertension </scientific_acronym>
+            <date_enrolment>01/02/2011</date_enrolment>
+            <type_enrolment>actual</type_enrolment>
+            <target_size>1350</target_size>
+            <recruitment_status>recruiting</recruitment_status>
+            <url>http://127.0.0.1:8000/rg/RBR-74rr6s/v1/</url>
+            <study_type></study_type>
+            <study_design>Randomized Clinical Trial, double-blind, placebo controled trial</study_design>
+            <phase>3</phase>
+            <hc_freetext>Prehypertension</hc_freetext>
+            <i_freetext>Drug: Chlorthalidone 12,5 mg plus amiloride 2,5 mg once daily for 18 months
+Drug: placebo once daily for 18 months
+
+</i_freetext>            
+        </main>
+        <contacts>
+        
+            <contact>
+                <type>public</type>
+                <firstname>Flávio</firstname>
+                <middlename>Danni</middlename>
+                <lastname>Fuchs</lastname>
+                <address>Rua Ramiro Barcelos 2350 2º Andar Serviço de Cardiologia</address>
+                <city>Porto Alegre</city>
+                <country1>Brazil</country1>
+                <zip>90035-903</zip>
+                <telephone>51 33598449</telephone>
+                <email>ffuchs@hcpa.ufrgs.br</email>
+                <affiliation>Hospital de Clínicas de Porto Alegre</affiliation>
+            </contact>
+        
+        
+            <contact>
+                <type>scientific</type>
+                <firstname>Flávio</firstname>
+                <middlename>Danni</middlename>
+                <lastname>Fuchs</lastname>
+                <address>Rua Ramiro Barcelos 2350 2º Andar Serviço de Cardiologia</address>
+                <city>Porto Alegre</city>
+                <country1>Brazil</country1>
+                <zip>90035-903</zip>
+                <telephone>51 33598449</telephone>
+                <email>ffuchs@hcpa.ufrgs.br</email>
+                <affiliation>Hospital de Clínicas de Porto Alegre</affiliation>
+            </contact>
+        
+        </contacts>
+        <countries>
+        
+            <country2>Brazil</country2>
+        
+        </countries>
+        <criteria>
+            <inclusion_criteria>I. individuals with 30 to 70 years of age 
+II. Systolic Arterial Pressure 120-139 mmHg or Diastolic Arterial Pressure 80-89 mmHg;</inclusion_criteria>
+            <agemin>30Y</agemin>
+            <agemax>70Y</agemax>
+            <gender>-</gender>
+            <exclusion_criteria>I. Previous diagnosis of hypertension or use of antihypertensive drugs;
+II. Allergies to Chlorthalidone Amiloride;
+III. Known cardiovascular disease (previous Miocardial Infarction, previous stroke, heart failure or clinical manifestations, for example, current or previous angina, intermittent claudication ...);
+IV. Chronic diseases that limit the participation or the prospect of life (such as cancer, rheumatic disease, disability, etc.);
+V. Analgesics or anti-inflammatory use for 30 days or more;
+VI. Inability to measure blood pressure;
+VII. Difficulty in understanding that limits participation in the study;
+VIII. IF WOMEN: Pregnant or planning to become pregnant in the next two years;
+IX. Patients who have participated in other randomized trials (the last six months);
+</exclusion_criteria>
+        </criteria>
+        <health_condition_code>
+            
+            <hc_code>C14</hc_code>
+            
+        </health_condition_code>
+        <health_condition_keyword>
+            
+            <hc_keyword>I10</hc_keyword>
+            
+        </health_condition_keyword>
+        <intervention_code>
+            
+            <i_code>drug</i_code>
+            
+        </intervention_code>
+        <intervention_keyword>
+            
+            <i_keyword>D27.505.696.560.500</i_keyword>
+            
+        </intervention_keyword>
+        <primary_outcome>
+            
+            <prim_outcome>Incidence of hypertension, by blood pressure greater or equal to 140/90 mmHg.
+</prim_outcome>
+            
+            <prim_outcome>Adverse events. 
+</prim_outcome>
+            
+        </primary_outcome>
+        <secondary_outcome>
+            
+            <sec_outcome>I. All-cause mortality
+II. Incidence of Coronary Artery Disease (Acute Coronary Syndrome, need for revascularization, sudden death)
+III. Fatal and nonfatal stroke
+IV. Heart failure (requiring hospitalization)
+V. Duplication of plasma levels of creatinine or need for dialysis
+VI. Incidence of diabetes mellitus.
+VII. Microalbuminuria
+VIII. Hypokalemia
+IX. Hyperuricemia
+X. Left ventricular hypertrophy on Eletrocardiogram</sec_outcome>
+            
+        </secondary_outcome>
+        <secondary_sponsor>
+            
+            <sponsor_name></sponsor_name>
+            
+        </secondary_sponsor>
+        <secondary_ids>
+            
+            <secondary_id>
+                <sec_id>08621</sec_id>
+                <issuing_authority>CEP- GPPG- Hospital de Clínicas de Porto Alegre</issuing_authority>    
+            </secondary_id>
+            
+            <secondary_id>
+                <sec_id>NCT00970931</sec_id>
+                <issuing_authority>Clinical Trials </issuing_authority>    
+            </secondary_id>
+            
+        </secondary_ids>
+        <source_support>
+            
+            <source_name>FINEP</source_name>
+            
+        </source_support>        
+    </trial>
+
+</trials>
+
+
Index: /tags/v1.0.23rc1/opentrials/repository/xml/samples/generated-from-test-otxml.xml
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/samples/generated-from-test-otxml.xml (revision 839)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/samples/generated-from-test-otxml.xml (revision 839)
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE trials SYSTEM "http://ensaiosclinicos.gov.br/xml/opentrials.dtd">
+<trials version="1">
+    <trial status="published"
+           date_registration="2011-01-19"
+           created="2011-01-19"
+           updated="2011-01-19">
+        <trial_identification>
+            <trial_id>RBR-9fm6bk</trial_id>
+            <utrn_number>None</utrn_number>
+            <reg_name>REBEC</reg_name>
+            <public_title>A long study about HIV</public_title>
+            <acronym>HIV Study</acronym>
+            <acronym_expansion>Long HIV Study</acronym_expansion>
+            <scientific_title>Full trial: a long study about HIV</scientific_title>
+            <scientific_acronym>HIV Study</scientific_acronym>
+            <scientific_acronym_expansion>Long HIV Study</scientific_acronym_expansion>
+        </trial_identification>
+
+        <sponsors_and_support>
+            <primary_sponsor country_code="BR" type="clinical_research_network">
+                <name>New name of ACNE</name>
+                <address>Av. Goias, 1249, Centro</address>
+            </primary_sponsor>
+
+            
+
+            
+        </sponsors_and_support>
+
+        <health_conditions>
+            
+            <hc_code vocabulary="decs" version="" code="C02">
+                <text>Virus diseases</text>
+                
+                
+                <text_translation lang="pt-br">Viroses</text_translation>
+                
+                
+            </hc_code>
+            
+
+            
+            <keyword vocabulary="decs" version="" code="D12.776.124.486.485.114.254.150.440">
+                <text>HIV Antibodies</text>
+                
+                
+                <text_translation lang="pt-br">Anticorpos Anti-HIV</text_translation>
+                
+                
+            </keyword>
+            
+
+            <freetext>HC free text</freetext>
+        </health_conditions>
+
+        <interventions>
+            
+            <i_code value="drug"></i_code>
+            
+            <i_code value="device"></i_code>
+            
+
+            
+            <keyword vocabulary="decs" version="" code="G02.111.570.080.689.330.400">
+                <text>HIV Enhancer</text>
+                
+                
+                <text_translation lang="pt-br">Ampliador HIV</text_translation>
+                
+                
+            </keyword>
+            
+
+            <freetext>I free text</freetext>
+        </interventions>
+
+        <recruitment status="not_yet_recruiting">
+            
+            <recruitment_country value="BR"></recruitment_country>
+            
+
+            <inclusion_criteria>Many criterias we could include here</inclusion_criteria>
+            <exclusion_criteria>Male at all</exclusion_criteria>
+            <gender value="female"></gender>
+            <agemin value="60" unit="years"></agemin>
+            <agemax value="5" unit="months"></agemax>
+
+            
+            <date_enrolment_actual start="11/2010" end=""></date_enrolment_actual>
+            
+
+            <target_size value="3"></target_size>
+        </recruitment>
+
+        <study expanded_access_program="no"
+               number_of_arms="2">
+            <study_design>The study design of this</study_design>
+            <type value="interventional"></type>
+            <phase value="null"></phase>
+            <purpose value="diagnostic"></purpose>
+            <intervention_assignment value="single-group"></intervention_assignment>
+            <masking value="open"></masking>
+            <allocation value="non-randomized-controlled"></allocation>
+        </study>
+
+        <outcomes>
+            
+            <primary_outcome value="Description of outcome 1">
+                
+            </primary_outcome>
+            
+
+            
+            <secondary_outcome value="Description of outcome 2">
+                
+            </secondary_outcome>
+            
+        </outcomes>
+
+        <contacts>
+            
+            <person pid="1" country_code="BR">
+                <firstname>Tarsila</firstname>
+                <middlename>Ribeiro</middlename>
+                <lastname>Neiva</lastname>
+                <address>Rua Boituva, 449</address>
+                <city>Goiania</city>
+                <zip>74000-970</zip>
+                <telephone>+55(62)4525-1343</telephone>
+                <email>tarsila@raminel.com.br</email>
+                
+                <affiliation country_code="BR" type="clinical_research_network">
+                    <name>New name of ACNE</name>
+                    <address>Av. Goias, 1249, Centro</address>
+                </affiliation>
+                
+            </person>
+            
+            <person pid="2" country_code="BR">
+                <firstname>Linus</firstname>
+                <middlename>Ribeiro</middlename>
+                <lastname>Neiva</lastname>
+                <address>Rua Boituva, 449</address>
+                <city>Goiania</city>
+                <zip>74000-970</zip>
+                <telephone>+55(62)4525-1343</telephone>
+                <email>linus@raminel.com.br</email>
+                
+                <affiliation country_code="BR" type="clinical_research_network">
+                    <name>New name of ACNE</name>
+                    <address>Av. Goias, 1249, Centro</address>
+                </affiliation>
+                
+            </person>
+            
+            <person pid="1" country_code="BR">
+                <firstname>Tarsila</firstname>
+                <middlename>Ribeiro</middlename>
+                <lastname>Neiva</lastname>
+                <address>Rua Boituva, 449</address>
+                <city>Goiania</city>
+                <zip>74000-970</zip>
+                <telephone>+55(62)4525-1343</telephone>
+                <email>tarsila@raminel.com.br</email>
+                
+                <affiliation country_code="BR" type="clinical_research_network">
+                    <name>New name of ACNE</name>
+                    <address>Av. Goias, 1249, Centro</address>
+                </affiliation>
+                
+            </person>
+            
+
+            
+            <public_contact person="1"></public_contact>
+            
+            <public_contact person="2"></public_contact>
+            
+            
+            
+            <scientific_contact person="1"></scientific_contact>
+            
+
+            
+        </contacts>
+
+        <secondary_ids>
+            
+        </secondary_ids>
+
+        <references>
+            <link url="/rg/RBR-9fm6bk/v3/"></link>
+        </references>
+
+        
+        
+        
+    </trial>
+</trials>
+
+
Index: /tags/v1.0.23rc1/opentrials/repository/xml/__init__.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/__init__.py (revision 839)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/__init__.py (revision 839)
@@ -0,0 +1,2 @@
+OPENTRIALS_XML_VERSION = 1
+
Index: /tags/v1.0.23rc1/opentrials/repository/xml/READ-ME.txt
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/READ-ME.txt (revision 814)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/READ-ME.txt (revision 814)
@@ -0,0 +1,17 @@
+=======================
+Aditional validation
+=======================
+
+OpenTrials trial XML documents validated through the opentrials.dtd should be subject
+to additional checks which cannot be expressed via DTD alone:
+
+- the health_conditions element must contain at least one of its sub-elements: (freetext?, code*, keyword*)
+
+- target_size must be a positive integer
+
+
+======================================
+Updating opentrials-vocabularies.mod
+======================================
+
+- options must adhere to XML syntax for tokens (XXX: ellaborate)
Index: /tags/v1.0.23rc1/opentrials/repository/xml/who_ictrp.dtd
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/who_ictrp.dtd (revision 839)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/who_ictrp.dtd (revision 839)
@@ -0,0 +1,108 @@
+<!-- 
+		WHO ICTRP XML DTD, http://www.who.int/ictrp
+		DTD Version 1.0: 23-4-2008
+    
+    15-9-2008 - freetext elements moved from Elements health_condition and intervention to Element main and renamed                           hc_freetext and i_freetext
+              - Element health_condition renamed to health_condition_code
+              - Element intervention renamed to intervention_code		
+              - added Elements health_condition_keyword, hc_keyword, hc_code
+              - added Elements intervention_keyword, i_keyword, i_code
+              - renamed Element country to country1
+              - added Element country2
+              - added xml declarations (? for zero or one, * for zero or more, + for 1 or more)
+              - added a few examples to some elements
+
+   16-10-2008 - replaced all * with + because we would like to receive all elements if if they are blank and empty 
+                elements are considered as 1 in the 1:n relationship
+
+   17-10-2008 - renamed main element contact to contacts to avoid redundance 
+              - added a child element called secondary_id under secondary_ids and renamed old secondary_id to sec_id
+
+   14-11-2008 - removed ? from the contacts and criteria and secondary_id elements
+   
+   17-11-2008- added + to source_name 
+ 
+   1-5-2009 - added element trials
+
+-->
+
+<!ELEMENT trials (trial+)>
+
+    <!ELEMENT trial (main,contacts,countries,criteria,health_condition_code,health_condition_keyword,intervention_code,
+              intervention_keyword,primary_outcome,secondary_outcome,secondary_sponsor,secondary_ids,source_support)>
+
+        <!ELEMENT main (trial_id,utrn?,reg_name,date_registration,primary_sponsor,public_title,acronym?,scientific_title,scientific_acronym?,
+                  date_enrolment,type_enrolment,target_size,recruitment_status,url?,study_type,study_design,phase,hc_freetext?,i_freetext?)>
+            <!ELEMENT trial_id (#PCDATA)>
+            <!ELEMENT utrn (#PCDATA)>
+            <!ELEMENT reg_name (#PCDATA)>
+            <!ELEMENT date_registration (#PCDATA)><!-- dd/mm/yyyy -->
+            <!ELEMENT primary_sponsor (#PCDATA)>
+            <!ELEMENT public_title (#PCDATA)>
+            <!ELEMENT acronym (#PCDATA)>
+            <!ELEMENT scientific_title (#PCDATA)>
+            <!ELEMENT scientific_acronym (#PCDATA)>
+            <!ELEMENT date_enrolment (#PCDATA)><!-- dd/mm/yyyy -->
+            <!ELEMENT type_enrolment (#PCDATA)>
+            <!ELEMENT target_size (#PCDATA)>
+            <!ELEMENT recruitment_status (#PCDATA)><!-- Pending,Recruiting,Suspended,Complete,Other -->
+            <!ELEMENT url (#PCDATA)>
+            <!ELEMENT study_type (#PCDATA)><!-- interventional,observational -->
+            <!ELEMENT study_design (#PCDATA)>
+            <!ELEMENT phase (#PCDATA)>
+            <!ELEMENT hc_freetext (#PCDATA)>
+            <!ELEMENT i_freetext (#PCDATA)>
+
+        <!ELEMENT contacts (contact+)>
+            <!ELEMENT contact (type,firstname,middlename,lastname,address,city,country1,zip,telephone,email,affiliation)>
+                <!ELEMENT type (#PCDATA)><!-- Public,Scientific -->
+                <!ELEMENT firstname (#PCDATA)>
+                <!ELEMENT middlename (#PCDATA)>
+                <!ELEMENT lastname (#PCDATA)>
+                <!ELEMENT address (#PCDATA)>
+                <!ELEMENT city (#PCDATA)>
+                <!ELEMENT country1 (#PCDATA)>
+                <!ELEMENT zip (#PCDATA)>
+                <!ELEMENT telephone (#PCDATA)>
+                <!ELEMENT email (#PCDATA)>
+                <!ELEMENT affiliation (#PCDATA)>
+
+        <!ELEMENT countries (country2+)>
+            <!ELEMENT country2 (#PCDATA)>
+
+        <!ELEMENT criteria (inclusion_criteria,agemin,agemax,gender,exclusion_criteria)>
+            <!ELEMENT inclusion_criteria (#PCDATA)>
+            <!ELEMENT agemin (#PCDATA)>
+            <!ELEMENT agemax (#PCDATA)>
+            <!ELEMENT gender (#PCDATA)>
+            <!ELEMENT exclusion_criteria (#PCDATA)>
+
+        <!ELEMENT health_condition_code (hc_code+)>
+            <!ELEMENT hc_code (#PCDATA)>
+
+        <!ELEMENT health_condition_keyword (hc_keyword+)>
+            <!ELEMENT hc_keyword (#PCDATA)>
+
+        <!ELEMENT intervention_code (i_code+)>
+            <!ELEMENT i_code (#PCDATA)>
+
+        <!ELEMENT intervention_keyword (i_keyword+)>
+            <!ELEMENT i_keyword (#PCDATA)>
+
+        <!ELEMENT primary_outcome (prim_outcome+)>
+            <!ELEMENT prim_outcome (#PCDATA)>
+
+        <!ELEMENT secondary_outcome (sec_outcome+)>
+            <!ELEMENT sec_outcome (#PCDATA)>
+
+        <!ELEMENT secondary_sponsor (sponsor_name+)>
+            <!ELEMENT sponsor_name (#PCDATA)>
+
+        <!ELEMENT secondary_ids (secondary_id+)>
+            <!ELEMENT secondary_id (sec_id,issuing_authority)>
+                <!ELEMENT sec_id (#PCDATA)>
+                <!ELEMENT issuing_authority (#PCDATA)>
+
+        <!ELEMENT source_support (source_name+)>
+            <!ELEMENT source_name (#PCDATA)>
+
Index: /tags/v1.0.23rc1/opentrials/repository/xml/opentrials.dtd
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/opentrials.dtd (revision 839)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/opentrials.dtd (revision 839)
@@ -0,0 +1,207 @@
+<!-- ===========================================================================
+File: opentrials.dtd
+
+OpenTrials: Latin-American and Caribbean Clinical Trial Record XML DTD
+DTD Version 1.0: 2010-03-01
+
+This DTD depends on the opentrials-vocabularies.mod definitions file.
+
+See:
+http://reddes.bvsalud.org/projects/clinical-trials/wiki/RegistrationDataModel
+
+Partially based on the WHO ICTRP XML DTD, http://www.who.int/ictrp
+DTD Version 1.0: 2008-04-23 (with changes up to and including 2008-09-15)
+Most element names are the same. Structure is different, with more validation
+in the form of attribute enumerations. Also, this is intended to represent a
+single trial record.
+
+Comments:
+  - "formset n/9" refer to each of the 9 trial submission forms
+  - "TRDS n (x..y)": field number in the ICTRP Trial Registration Data Set
+                     (x..y) indicate element multiplicity in UML notation
+=========================================================================== -->
+
+<!ENTITY % vocabularies SYSTEM "opentrials-vocabularies.mod">
+%vocabularies;
+
+<!ELEMENT trials (trial+)>
+    <!ATTLIST trials version (1) #REQUIRED>
+
+<!ELEMENT trial (trial_identification, sponsors_and_support, health_conditions,
+          interventions, recruitment, study, outcomes, contacts, secondary_ids?,
+          references?, staff_note?, translation*)>
+    <!-- trial record must have explicit attribute type="interventional"
+         in preparation for eventual support for observational studies -->
+    <!ATTLIST trial
+        status (%trialstatus.options;) #REQUIRED
+        date_registration CDATA #REQUIRED
+        created CDATA #IMPLIED
+        updated CDATA #IMPLIED
+    >
+
+    <!-- formset 1/9 -->
+    <!ELEMENT trial_identification (trial_id?, utrn_number?, reg_name?, public_title?,
+                    acronym?, acronym_expansion?, scientific_title, scientific_acronym?,
+                    scientific_acronym_expansion?)>
+
+    <!ELEMENT trial_id (#PCDATA)>                              <!--TRDS 1 (0..1)-->
+    <!ELEMENT utrn_number (#PCDATA)>                                    <!--TRDS 3 (0..1)-->
+    <!ELEMENT reg_name (#PCDATA)>
+    <!ELEMENT public_title (#PCDATA)>                           <!--TRDS 9a (0..1)-->
+    <!ELEMENT acronym (#PCDATA)>                                <!--TRDS 9b (0..1)-->
+    <!ELEMENT acronym_expansion (#PCDATA)>                     <!--TRDS 10b (0..1)-->
+    <!ELEMENT scientific_title (#PCDATA)>                       <!--TRDS 10a (1)-->
+    <!ELEMENT scientific_acronym (#PCDATA)>                     <!--TRDS 10b (0..1)-->
+    <!ELEMENT scientific_acronym_expansion (#PCDATA)>                     <!--TRDS 10b (0..1)-->
+
+    <!ELEMENT secondary_ids (secondary_id*)>
+        <!ELEMENT secondary_id (sec_id, issuing_authority)>
+            <!ELEMENT sec_id (#PCDATA)>                         <!--TRDS 3a (0..*)-->
+            <!ELEMENT issuing_authority (#PCDATA)>              <!--TRDS 3b (0..*)-->
+
+    <!-- formset 2/9 -->
+    <!ELEMENT sponsors_and_support (primary_sponsor, secondary_sponsor*, source_support*)>
+    <!ELEMENT primary_sponsor (name, address?)>                 <!--TRDS 5 (1)-->
+        <!ATTLIST primary_sponsor country_code (%country.options;) #REQUIRED>
+        <!ATTLIST primary_sponsor type (%institution_type.options;) #IMPLIED>
+    <!ELEMENT secondary_sponsor (name, address?)>               <!--TRDS 6 (0..*)-->
+        <!ATTLIST secondary_sponsor country_code (%country.options;) #REQUIRED>
+        <!ATTLIST secondary_sponsor type (%institution_type.options;) #IMPLIED>
+    <!ELEMENT source_support (name, address?)>                  <!--TRDS 4 (0..*)-->
+        <!ATTLIST source_support country_code (%country.options;) #REQUIRED>
+        <!ATTLIST source_support type (%institution_type.options;) #IMPLIED>
+    <!ELEMENT name (#PCDATA)>
+    <!ELEMENT address (#PCDATA)>
+
+    <!-- formset 3/9 -->
+    <!ELEMENT health_conditions (hc_code*, keyword*, freetext?)>
+        <!ELEMENT freetext (#PCDATA)>                               <!--TRDS 12a, 13a (0..1)-->
+        <!ELEMENT hc_code (text, text_translation*)>                <!--TRDS 12b (0..*)-->
+            <!ATTLIST hc_code
+                code CDATA #IMPLIED
+                vocabulary (%vocabulary.options;) #IMPLIED
+                version CDATA #IMPLIED>
+        <!ELEMENT keyword (text, text_translation*)>                <!--TRDS 12c, 13c (0..*)-->
+            <!ATTLIST keyword
+                code CDATA #IMPLIED
+                vocabulary (%vocabulary.options;) #IMPLIED
+                version CDATA #IMPLIED>
+        <!ELEMENT text (#PCDATA)>
+        <!ELEMENT text_translation (#PCDATA)>
+            <!ATTLIST text_translation lang CDATA #REQUIRED>
+
+    <!-- formset 4/9 -->
+    <!ELEMENT interventions (i_code*, keyword*, freetext?)>           <!--TRDS 12a (0..1)-->
+        <!ELEMENT i_code (#PCDATA)>                               <!--TRDS 12b (0..*)-->
+            <!ATTLIST i_code value (%interventioncode.options;) #REQUIRED>
+
+    <!-- formset 5/9 -->
+    <!ELEMENT recruitment (recruitment_country+,
+                           inclusion_criteria,
+                           exclusion_criteria?,
+                           gender?,
+                           agemin?,
+                           agemax?,
+                           date_enrolment_anticipated?,
+                           date_enrolment_actual?,
+                           target_size?)>
+        <!ATTLIST recruitment status (%requirementstatus.options;) #REQUIRED>
+
+        <!ELEMENT recruitment_country EMPTY>                          <!--TRDS 11 (1..*)-->
+            <!ATTLIST recruitment_country
+                value (%country.options;) #REQUIRED>
+        <!ELEMENT inclusion_criteria (#PCDATA)>                       <!--TRDS 14a (1)-->
+        <!ELEMENT exclusion_criteria (#PCDATA)>                       <!--TRDS 14e (0..1)-->
+        <!ELEMENT gender EMPTY>                                       <!--TRDS 14b (0..1)-->
+            <!ATTLIST gender value (%gender.options;) #REQUIRED>
+        <!ELEMENT agemin EMPTY>                                   <!--TRDS 14c (0..1)-->
+            <!ATTLIST agemin value CDATA #REQUIRED>
+            <!ATTLIST agemin unit (%ageunit.options;) #IMPLIED>
+        <!ELEMENT agemax EMPTY>                                   <!--TRDS 14d (0..1)-->
+            <!ATTLIST agemax value CDATA #REQUIRED>
+            <!ATTLIST agemax unit (%ageunit.options;) #IMPLIED>
+        <!ELEMENT date_enrolment_anticipated EMPTY> <!--ISO-8601 date format: YYYY-MM-DD-->
+            <!ATTLIST date_enrolment_anticipated
+                start CDATA #IMPLIED
+                end CDATA #IMPLIED
+            >
+        <!ELEMENT date_enrolment_actual EMPTY>      <!--ISO-8601 date format: YYYY-MM-DD-->
+            <!ATTLIST date_enrolment_actual
+                start CDATA #IMPLIED
+                end CDATA #IMPLIED
+            >
+        <!ELEMENT target_size EMPTY>
+            <!ATTLIST target_size value CDATA #REQUIRED>
+
+    <!-- formset 6/9 -->
+    <!ELEMENT study (study_design, type?, phase, purpose, intervention_assignment,
+                masking, allocation)>
+        <!ATTLIST study
+            expanded_access_program (yes|no) #IMPLIED
+            number_of_arms NMTOKEN #IMPLIED
+        >
+        <!ELEMENT study_design (#PCDATA)>
+        <!ELEMENT type EMPTY>                                    <!--TRDS 15c (0..1)-->
+            <!ATTLIST type value (%study_type.options;) #REQUIRED>
+        <!ELEMENT phase EMPTY>
+            <!ATTLIST phase value (%phase.options;) #REQUIRED>
+        <!ELEMENT purpose EMPTY>
+            <!ATTLIST purpose value (%purpose.options;) #REQUIRED>
+        <!ELEMENT intervention_assignment EMPTY>
+            <!ATTLIST intervention_assignment value (%assignment.options;) #REQUIRED>
+        <!ELEMENT masking EMPTY>
+            <!ATTLIST masking value (%masking.options;) #REQUIRED>
+        <!ELEMENT allocation EMPTY>
+            <!ATTLIST allocation value (%allocation.options;) #REQUIRED>
+
+    <!-- formset 7/9 -->
+    <!ELEMENT outcomes (primary_outcome+, secondary_outcome*)>
+        <!ELEMENT primary_outcome (outcome_translation*)>
+            <!ATTLIST primary_outcome value CDATA #REQUIRED>
+        <!ELEMENT secondary_outcome (outcome_translation*)>
+            <!ATTLIST secondary_outcome value CDATA #REQUIRED>
+        <!ELEMENT outcome_translation EMPTY>
+            <!ATTLIST outcome_translation value CDATA #REQUIRED>
+
+    <!-- formset 8/9 -->
+    <!ELEMENT contacts (person+, public_contact+, scientific_contact+, site_contact*)>
+        <!ELEMENT public_contact EMPTY>
+            <!ATTLIST public_contact
+                person CDATA #REQUIRED>
+        <!ELEMENT scientific_contact EMPTY>
+            <!ATTLIST scientific_contact
+                person CDATA #REQUIRED>
+        <!ELEMENT site_contact EMPTY>
+            <!ATTLIST site_contact
+                person CDATA #REQUIRED>
+
+    <!ELEMENT person (firstname,middlename?,lastname,address,city,zip,telephone+,email,affiliation)>
+        <!ATTLIST person
+            pid CDATA #REQUIRED
+            country_code (%country.options;) #REQUIRED>
+        <!ELEMENT firstname (#PCDATA)>
+        <!ELEMENT middlename (#PCDATA)>
+        <!ELEMENT lastname (#PCDATA)>
+        <!ELEMENT address (#PCDATA)>
+        <!ELEMENT city (#PCDATA)>
+        <!ELEMENT zip (#PCDATA)>
+        <!ELEMENT telephone (#PCDATA)>
+        <!ELEMENT email (#PCDATA)>
+        <!ELEMENT affiliation (name, address?)>
+            <!ATTLIST affiliation country_code (%country.options;) #REQUIRED>
+            <!ATTLIST affiliation type (%institution_type.options;) #IMPLIED>
+
+    <!-- formset 9/9 -->
+    <!ELEMENT references (link*)>
+        <!ELEMENT link (#PCDATA)>
+            <!ATTLIST link url CDATA #REQUIRED>
+
+    <!ELEMENT staff_note (#PCDATA)>
+
+    <!ELEMENT translation (public_title?, acronym?, acronym_expansion?, scientific_title,
+                           scientific_acronym?, scientific_acronym_expansion?, hc_freetext?,
+                           i_freetext?, inclusion_criteria?, exclusion_criteria?, study_design?)>
+        <!ATTLIST translation lang CDATA #REQUIRED>
+        <!ELEMENT hc_freetext (#PCDATA)>
+        <!ELEMENT i_freetext (#PCDATA)>
+
Index: /tags/v1.0.23rc1/opentrials/repository/xml/opentrials-vocabularies.mod
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/xml/opentrials-vocabularies.mod (revision 994)
+++ /tags/v1.0.23rc1/opentrials/repository/xml/opentrials-vocabularies.mod (revision 994)
@@ -0,0 +1,60 @@
+<!-- ===========================================================================
+File: opentrials-vocabularies.mod
+
+OpenTrials: Latin-American and Caribbean Clinical Trial Record XML DTD
+DTD Version 1.0: 2011-01-18
+
+Entity definitions used by the opentrials.dtd file.
+This file should be generated automatically from controlled vocabulary data
+such as those from Vocabulary application.
+=========================================================================== -->
+
+<!-- TRDS 12: health condition attributes -->
+<!ENTITY % vocabulary.options
+    "decs|icd10|other">
+
+<!-- TRDS 13: intervention descriptor attributes -->
+<!-- attribute options cannot contain slashes "/" -->
+<!ENTITY % interventioncode.options
+    "drug|device|biologicalvaccine|proceduresurgery|radiation|behavioural|genetics|dietary_supplement|other">
+
+<!ENTITY % requirementstatus.options
+    "not_yet_recruiting|recruiting|suspended|recruitment_completed|other|terminated|withdrawn|data_analysis_completed">
+
+<!ENTITY % ageunit.options
+    "null|years|months|weeks|days|hours">
+
+<!ENTITY % gender.options
+    "female|male|both">
+
+<!-- TRDS 15b: study_design attributes -->
+<!ENTITY % purpose.options
+    "diagnostic|etiological|prognostic|prevention|treatment|other">
+
+<!ENTITY % assignment.options
+    "single-group|parallel|cross-over|factorial|other">
+
+<!ENTITY % masking.options
+    "open|single-blind|double-blind|triple-blind">
+
+<!ENTITY % allocation.options
+    "non-randomized-controlled|randomized-controlled|single-arm-study">
+
+<!-- TRDS 15c -->
+<!ENTITY % phase.options
+    "null|1|1-2|2|2-3|3|4|0">
+
+<!ENTITY % contacttype.options
+    "public|scientific|site">
+
+<!ENTITY % country.options
+    "AF|AX|AL|DZ|AS|AD|AO|AI|AQ|AG|AR|AM|AW|AU|AT|AZ|BS|BH|BD|BB|BY|BE|BZ|BJ|BM|BT|BO|BA|BW|BV|BR|IO|BN|BG|BF|BI|KH|CM|CA|CV|KY|CF|TD|CL|CN|CX|CC|CO|KM|CG|CD|CK|CR|CI|HR|CU|CY|CZ|DK|DJ|DM|DO|EC|EG|SV|GQ|ER|EE|ET|FK|FO|FJ|FI|FR|GF|PF|TF|GA|GM|GE|DE|GH|GI|GR|GL|GD|GP|GU|GT|GG|GN|GW|GY|HT|HM|VA|HN|HK|HU|IS|IN|ID|IR|IQ|IE|IM|IL|IT|JM|JP|JE|JO|KZ|KE|KI|KP|KR|KW|KG|LA|LV|LB|LS|LR|LY|LI|LT|LU|MO|MK|MG|MW|MY|MV|ML|MT|MH|MQ|MR|MU|YT|MX|FM|MD|MC|MN|ME|MS|MA|MZ|MM|NA|NR|NP|NL|AN|NC|NZ|NI|NE|NG|NU|NF|MP|NO|OM|PK|PW|PS|PA|PG|PY|PE|PH|PN|PL|pt-br|PR|QA|RE|RO|RU|RW|BL|SH|KN|LC|MF|PM|VC|WS|SM|ST|SA|SN|RS|SC|SL|SG|SK|SI|SB|SO|ZA|GS|es|LK|SD|SR|SJ|SZ|SE|CH|SY|TW|TJ|TZ|TH|TL|TG|TK|TO|TT|TN|TR|TM|TC|TV|UG|UA|AE|GB|US|UM|UY|UZ|VU|VE|VN|VG|VI|WF|EH|YE|ZM|ZW">
+
+<!ENTITY % trialstatus.options
+    "processing|published|archived">
+
+<!ENTITY % study_type.options
+    "interventional|observational">
+
+<!ENTITY % institution_type.options
+    "clinical_research_network|federal_agency|industry|ministery_of_health|non-governamental_agency|state_research_support_foundation|other">
Index: /tags/v1.0.23rc1/opentrials/repository/tests/01-models.txt
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/tests/01-models.txt (revision 689)
+++ /tags/v1.0.23rc1/opentrials/repository/tests/01-models.txt (revision 689)
@@ -0,0 +1,179 @@
+REPOSITORY - MODELS
+===================
+
+    >>> from djangoplus.test_utils import model_has_fields, is_model_class_fk,\
+    ...     is_field_type, is_model_pk
+
+                    ---------------------------------
+                    | TrialRegistrationDataSetModel | abstract
+                    ---------------------------------
+                            A           A
+                            |           |
+    -------------------------           |
+    |                                   |
+    |   -----------------               |       -------------------------
+    |---| ClinicalTrial |               |-------| TrialSecondarySponsor |
+    |   -----------------               |       -------------------------
+    |                                   |
+    |   ---------------                 |       ----------------------
+    |---| TrialNumber |                 |-------| TrialSupportSource |
+    |   ---------------                 |       ----------------------
+    |                                   |
+    |   ---------------                 |       -----------
+    |---| Institution |                 |-------| Contact |
+    |   ---------------                 |       -----------
+    |                                   |
+    |   -----------------               |       ---------------------
+    |---| PublicContact |               |-------| ScientificContact |
+    |   -----------------               |       ---------------------
+    |                                   |
+    |   ---------------                 |       -----------
+    |---| SiteContact |                 --------| Outcome |
+    |   ---------------                         -----------
+    |
+    |   --------------
+    ----| Descriptor |
+        --------------
+
+What is the abstract model class "TrialRegistrationDataSetModel" for?
+---------------------------------------------------------------------
+
+This abstract model class is detailed on the OpenTrials's official wiki:
+
+    http://reddes.bvsalud.org/projects/clinical-trials/wiki/TrialRegistrationDataSet
+
+In regards to the code, this mode class just generalizes a method to dump HTML with a
+table with its field values.
+
+    >>> from repository.models import TrialRegistrationDataSetModel
+
+ClinicalTrial
+-------------
+
+    >>> from repository.models import ClinicalTrial
+
+    >>> issubclass(ClinicalTrial, TrialRegistrationDataSetModel)
+    True
+
+    >>> model_has_fields(ClinicalTrial, ('id', 'trial_id', 'date_registration', 'scientific_title',
+    ...     'scientific_acronym', 'scientific_acronym_expansion', 'primary_sponsor', 'public_title',
+    ...     'acronym', 'acronym_expansion', 'hc_freetext', 'i_freetext', 'inclusion_criteria', 'gender',
+    ...     'agemin_value', 'agemin_unit', 'agemax_value', 'agemax_unit', 'exclusion_criteria', 'study_type', 
+    ...     'study_design', 'expanded_access_program', 'purpose', 'intervention_assignment', 'number_of_arms', 
+    ...     'masking', 'allocation', 'phase', 'enrollment_start_planned', 'enrollment_start_actual', 
+    ...     'enrollment_end_planned', 'enrollment_end_actual', 'target_sample_size', 'recruitment_status', 
+    ...     'created', 'updated', 'exported', 'status', 'staff_note'))
+    []
+
+TrialSecondarySponsor
+---------------------
+
+    >>> from repository.models import TrialSecondarySponsor
+
+    >>> issubclass(TrialSecondarySponsor, TrialRegistrationDataSetModel)
+    True
+
+    >>> model_has_fields(TrialSecondarySponsor, ('id', 'trial', 'institution'))
+    []
+
+TrialNumber
+-----------
+
+    >>> from repository.models import TrialNumber
+
+    >>> issubclass(TrialNumber, TrialRegistrationDataSetModel)
+    True
+
+    >>> model_has_fields(TrialNumber, ('id', 'trial', 'issuing_authority', 'id_number'))
+    []
+
+TrialSupportSource
+------------------
+
+    >>> from repository.models import TrialSupportSource
+
+    >>> issubclass(TrialSupportSource, TrialRegistrationDataSetModel)
+    True
+
+    >>> model_has_fields(TrialSupportSource, ('id', 'trial', 'institution'))
+    []
+
+Institution
+-----------
+
+    >>> from repository.models import Institution
+
+    >>> issubclass(Institution, TrialRegistrationDataSetModel)
+    True
+
+    >>> model_has_fields(Institution, ('id', 'name', 'address', 'country', 'creator'))
+    []
+
+Contact
+-------
+
+    >>> from repository.models import Contact
+
+    >>> issubclass(Contact, TrialRegistrationDataSetModel)
+    True
+
+    >>> model_has_fields(Contact, ('id', 'firstname', 'middlename', 'lastname', 'email',
+    ...     'affiliation', 'address', 'city', 'country', 'zip', 'telephone', 'creator'))
+    []
+
+PublicContact
+-------------
+
+    >>> from repository.models import PublicContact
+
+    >>> issubclass(PublicContact, TrialRegistrationDataSetModel)
+    True
+
+    >>> model_has_fields(PublicContact, ('id', 'trial', 'contact', 'status'))
+    []
+
+ScientificContact
+-----------------
+
+    >>> from repository.models import ScientificContact
+
+    >>> issubclass(ScientificContact, TrialRegistrationDataSetModel)
+    True
+
+    >>> model_has_fields(ScientificContact, ('id', 'trial', 'contact', 'status'))
+    []
+
+SiteContact
+-----------
+
+    >>> from repository.models import SiteContact
+
+    >>> issubclass(SiteContact, TrialRegistrationDataSetModel)
+    True
+
+    >>> model_has_fields(SiteContact, ('id', 'trial', 'contact', 'status'))
+    []
+
+Outcome
+-------
+
+    >>> from repository.models import Outcome
+
+    >>> issubclass(Outcome, TrialRegistrationDataSetModel)
+    True
+
+    >>> model_has_fields(Outcome, ('id', 'trial', 'interest', 'description', '_order'))
+    []
+
+Descriptor
+----------
+
+    >>> from repository.models import Descriptor
+
+    >>> issubclass(Descriptor, TrialRegistrationDataSetModel)
+    True
+
+    >>> model_has_fields(Descriptor, ('id', 'trial', 'aspect', 'vocabulary', 'version',
+    ...     'level', 'code', 'text', '_order'))
+    []
+
Index: /tags/v1.0.23rc1/opentrials/repository/tests/__init__.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/tests/__init__.py (revision 689)
+++ /tags/v1.0.23rc1/opentrials/repository/tests/__init__.py (revision 689)
@@ -0,0 +1,66 @@
+#coding: utf-8
+
+# FIXME: It seems it is with something missing from fixtures
+
+"""
+from django.test.client import Client
+from django.test import TestCase
+
+from repository.models import *
+
+class SecondaryNumbers(TestCase):
+    fixtures = ['first_3_trials.json']
+
+    def setUp(self):
+        title = u'Comparison of Ascorbic Acid and Grape Seed'
+        self.asc_trial = ClinicalTrial.objects.get(
+            public_title__istartswith=title)
+
+    def test_short_title(self):
+        start = u'Effect of Ascorbic Acid'
+        self.assertTrue(self.asc_trial.short_title().startswith(start))
+
+    def test_secondary_numbers(self):
+        self.assertEquals(len(self.asc_trial.trialnumber_set.all()), 2)
+
+    def test_public_contacts(self):
+        contacts = list(self.asc_trial.public_contacts())
+        self.assertEquals(len(contacts), 1)
+        self.assertEquals(contacts[0].firstname, u'Naser')
+
+    def test_scientific_contacts(self):
+        contacts = list(self.asc_trial.scientific_contacts())
+        self.assertEquals(len(contacts), 1)
+        self.assertEquals(contacts[0].firstname, u'Naser')
+
+class Step3Test(TestCase):
+    fixtures = ['first_3_trials.json']
+
+    def setUp(self):
+        self.client = Client()
+        self.trial = ClinicalTrial.objects.get(pk=1)
+
+    def test_submit(self):
+        self.client.login(username='admin',password='123456')
+        response = self.client.post('/rg/step_3/1/',{
+                'hc_freetext': 'test text to step 3',
+                'hc_freetext|pt-br': '',
+                'hc_freetext|es': '',
+                'g-TOTAL_FORMS': 1, 
+                'g-INITIAL_FORMS': 0,
+                'g-0-vocabulary': 'DeCS',
+                'g-0-code': 'C02',
+                'g-0-text': 'Virus diseases',
+                'g-0-text|pt-br': 'Viroses',
+                'g-0-text|es': 'Virosis',
+                's-TOTAL_FORMS': 1, 
+                's-INITIAL_FORMS': 0,
+                's-0-vocabulary': 'DeCS',
+                's-0-code': 'C03.752.530',
+                's-0-text': 'Malaria',
+                's-0-text|pt-br': 'Malária',
+                's-0-text|es': 'Malaria',
+            })
+        self.failUnlessEqual(response.status_code, 200)
+"""
+
Index: /tags/v1.0.23rc1/opentrials/repository/tests/02-serializing.txt
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/tests/02-serializing.txt (revision 839)
+++ /tags/v1.0.23rc1/opentrials/repository/tests/02-serializing.txt (revision 839)
@@ -0,0 +1,443 @@
+TRIAL SERIALIZATION
+===================
+
+Here we test all about ClinicalTrial serialization and deserialization to be fossilized
+and used to keep old versions of a trial archived.
+
+    >>> import datetime
+    >>> from django.utils import simplejson
+    >>> from repository.models import ClinicalTrial, Descriptor
+    >>> from repository.serializers import FossilClinicalTrial
+
+We must keep here everything a ClinicalTrial could have in two versions:
+
+1. a very minimalistic version (the minimum a trial could be)
+-------------------------------------------------------------
+
+    >>> trial_small = ClinicalTrial()
+    >>> trial_small.scientific_title = 'Small trial: Research about Colera on Haiti'
+    >>> trial_small.save()
+
+Serializing
+
+    >>> json = trial_small.serialize_for_fossil()
+
+    >>> isinstance(json, basestring)
+    True
+
+    >>> json_should_be = {
+    ...     'pk': trial_small.pk,
+    ...     '__unicode__': unicode(trial_small),
+    ...     '__model__': unicode('ClinicalTrial'),
+    ...     'id': trial_small.pk,
+    ...     'trial_id': None,
+    ...     'date_registration': None,
+    ...     'scientific_title': trial_small.scientific_title,
+    ...     'scientific_acronym': '',
+    ...     'scientific_acronym_expansion': '',
+    ...     'primary_sponsor': None,
+    ...     'public_title': '',
+    ...     'acronym': '',
+    ...     'acronym_expansion': '',
+    ...     'hc_freetext': '',
+    ...     'i_freetext': '',
+    ...     'inclusion_criteria': '',
+    ...     'gender': '-',
+    ...     'agemin_value': 0,
+    ...     'agemin_unit': '-',
+    ...     'agemax_value': 0,
+    ...     'agemax_unit': '-',
+    ...     'exclusion_criteria': '',
+    ...     'study_type': None,
+    ...     'study_design': '',
+    ...     'expanded_access_program': None,
+    ...     'purpose': None,
+    ...     'intervention_assignment': None,
+    ...     'number_of_arms': None,
+    ...     'masking': None,
+    ...     'allocation': None,
+    ...     'phase': None,
+    ...     'enrollment_start_planned': None,
+    ...     'enrollment_start_actual': None,
+    ...     'enrollment_end_planned': None,
+    ...     'enrollment_end_actual': None,
+    ...     'target_sample_size': 0,
+    ...     'recruitment_status': None,
+    ...     'created': trial_small.created.strftime('%Y-%m-%d %H:%M:%S'),
+    ...     'updated': None,
+    ...     'exported': None,
+    ...     'staff_note': '',
+    ...     'language': trial_small.language,
+    ...     'public_contact': [],
+    ...     'scientific_contact': [],
+    ...     'site_contact': [],
+    ...     'i_code': [],
+    ...     'recruitment_country': [],
+    ...     'support_sources': [],
+    ...     'acronym_display': '',
+    ...     'primary_outcomes': [],
+    ...     'secondary_outcomes': [],
+    ...     'trial_number': [],
+    ...     'hc_code': [],
+    ...     'hc_keyword': [],
+    ...     'utrn_number': None,
+    ...     'scientific_acronym_display': '',
+    ...     'intervention_keyword': [],
+    ...     'secondary_sponsors': [],
+    ...     'translations': [],
+    ... }
+
+Different key values
+
+    >>> for k,v in simplejson.loads(json).items():
+    ...     if v != json_should_be[k]:
+    ...         print '%s = %s  ->  %s = %s'%(k, v, k, json_should_be[k])
+
+Fields not serialized
+
+    >>> [k for k in json_should_be if k not in simplejson.loads(json)]
+    []
+
+Deserializing (not persistent)
+
+    >>> proxy = ClinicalTrial.objects.deserialize_for_fossil(json, persistent=False)
+
+    >>> isinstance(proxy, FossilClinicalTrial)
+    True
+
+    >>> proxy.scientific_title
+    'Small trial: Research about Colera on Haiti'
+
+    >>> proxy.created.strftime('%Y-%m-%d %H:%M:%S') == trial_small.created.strftime('%Y-%m-%d %H:%M:%S')
+    True
+
+TODO: Deserializing (persistent). To make only when necessary.
+
+2. a very big version (the maximum a trial could be)
+----------------------------------------------------
+
+    >>> from django.contrib.auth.models import User
+    >>> from repository.models import Institution, Contact, PublicContact, ScientificContact
+    >>> from vocabulary.models import CountryCode, StudyType, StudyPurpose,\
+    ...         InterventionAssigment, StudyMasking, StudyAllocation, StudyPhase,\
+    ...         RecruitmentStatus, InterventionCode, InstitutionType
+
+    >>> study_type = StudyType.objects.order_by('pk')[0]
+    >>> purpose = StudyPurpose.objects.order_by('pk')[0]
+    >>> intervention_assignment = InterventionAssigment.objects.order_by('pk')[0]
+    >>> masking = StudyMasking.objects.order_by('pk')[0]
+    >>> allocation = StudyAllocation.objects.order_by('pk')[0]
+    >>> phase = StudyPhase.objects.order_by('pk')[0]
+    >>> recruitment_status = RecruitmentStatus.objects.order_by('pk')[0]
+    >>> inst_type1 = InstitutionType.objects.order_by('pk')[0]
+
+    >>> brazil, new = CountryCode.objects.get_or_create(label='BR', defaults={'description': 'Brazil'})
+
+    >>> user1 = User.objects.create(username='serializer')
+
+    >>> inst1 = Institution.objects.create(
+    ...     name = 'ACME',
+    ...     address = 'Av. Goias, 1249, Centro',
+    ...     country = brazil,
+    ...     creator = user1,
+    ...     i_type = inst_type1,
+    ... )
+
+    >>> trial_big = ClinicalTrial()
+
+    >>> trial_big.date_registration = datetime.datetime.now()
+    >>> trial_big.scientific_title = 'Full trial: a long study about HIV'
+    >>> trial_big.scientific_acronym = 'HIV Study'
+    >>> trial_big.scientific_acronym_expansion = 'Long HIV Study'
+    >>> trial_big.primary_sponsor = inst1
+    >>> trial_big.public_title = 'A long study about HIV'
+    >>> trial_big.acronym = 'HIV Study'
+    >>> trial_big.acronym_expansion = 'Long HIV Study'
+    >>> trial_big.hc_freetext = 'HC free text'
+    >>> trial_big.i_freetext = 'I free text'
+    >>> trial_big.inclusion_criteria = 'Many criterias we could include here'
+    >>> trial_big.gender = 'F'
+    >>> trial_big.agemin_value = 60
+    >>> trial_big.agemin_unit = 'Y'
+    >>> trial_big.agemax_value = 5
+    >>> trial_big.agemax_unit = 'M'
+    >>> trial_big.exclusion_criteria = 'Male at all'
+    >>> trial_big.study_type = study_type
+    >>> trial_big.study_design = 'The study design of this'
+    >>> trial_big.expanded_access_program = False
+    >>> trial_big.purpose = purpose
+    >>> trial_big.intervention_assignment = intervention_assignment
+    >>> trial_big.number_of_arms = 2
+    >>> trial_big.masking = masking
+    >>> trial_big.allocation = allocation
+    >>> trial_big.phase = phase
+    >>> trial_big.enrollment_start_planned = '2010-12'
+    >>> trial_big.enrollment_start_actual = '2010-11'
+    >>> trial_big.enrollment_end_planned = '2012-03'
+    >>> trial_big.enrollment_end_actual = '2012-02'
+    >>> trial_big.target_sample_size = 3
+    >>> trial_big.recruitment_status = recruitment_status
+    >>> trial_big.updated = datetime.datetime.now()
+    >>> trial_big.exported = datetime.datetime.now()
+    >>> trial_big.status = 'published'
+    >>> trial_big.staff_note = 'Just a simple note to serialize'
+
+    >>> trial_big.save()
+
+Contacts
+
+    >>> contact1 = Contact.objects.create(
+    ...         firstname = 'Tarsila',
+    ...         middlename = 'Ribeiro',
+    ...         lastname = 'Neiva',
+    ...         email = 'tarsila@raminel.com.br',
+    ...         affiliation = inst1,
+    ...         address = 'Rua Boituva, 449',
+    ...         city = 'Goiania',
+    ...         country = brazil,
+    ...         zip = '74000-970',
+    ...         telephone = '+55(62)4525-1343',
+    ...         creator = user1,
+    ...     )
+
+    >>> contact2 = Contact.objects.create(
+    ...         firstname = 'Linus',
+    ...         middlename = 'Ribeiro',
+    ...         lastname = 'Neiva',
+    ...         email = 'linus@raminel.com.br',
+    ...         affiliation = inst1,
+    ...         address = 'Rua Boituva, 449',
+    ...         city = 'Goiania',
+    ...         country = brazil,
+    ...         zip = '74000-970',
+    ...         telephone = '+55(62)4525-1343',
+    ...         creator = user1,
+    ...     )
+
+    >>> pc1 = PublicContact.objects.create(trial=trial_big, contact=contact1)
+    >>> pc2 = PublicContact.objects.create(trial=trial_big, contact=contact2)
+
+    >>> sc1 = ScientificContact.objects.create(trial=trial_big, contact=contact1)
+
+    >>> trial_big.i_code.add(InterventionCode.objects.order_by('pk')[0])
+    >>> trial_big.i_code.add(InterventionCode.objects.order_by('pk')[1])
+
+    >>> trial_big.recruitment_country.add(brazil)
+
+Outcomes
+
+    >>> from repository.models import Outcome
+
+    >>> out1 = Outcome()
+    >>> out1.trial = trial_big
+    >>> out1.interest = 'primary'
+    >>> out1.description = 'Description of outcome 1'
+    >>> out1.save()
+
+    >>> out2 = Outcome()
+    >>> out2.trial = trial_big
+    >>> out2.interest = 'secondary'
+    >>> out2.description = 'Description of outcome 2'
+    >>> out2.save()
+
+Descriptors
+
+    >>> desc1 = Descriptor()
+    >>> desc1.trial = trial_big
+    >>> desc1.aspect = 'HealthCondition'
+    >>> desc1.vocabulary = 'DeCS'
+    >>> desc1.level = 'general'
+    >>> desc1.code = 'C02'
+    >>> desc1.text = 'Virus diseases'
+    >>> desc1.save()
+
+    >>> desc1.translations.create(text='Viroses', language='pt-br')
+    <DescriptorTranslation: pt-br>
+
+    >>> desc2 = Descriptor()
+    >>> desc2.trial = trial_big
+    >>> desc2.aspect = 'HealthCondition'
+    >>> desc2.vocabulary = 'DeCS'
+    >>> desc2.level = 'specific'
+    >>> desc2.code = 'D12.776.124.486.485.114.254.150.440'
+    >>> desc2.text = 'HIV Antibodies'
+    >>> desc2.save()
+
+    >>> desc2.translations.create(text=u'Anticorpos Anti-HIV', language='pt-br')
+    <DescriptorTranslation: pt-br>
+
+    >>> desc3 = Descriptor()
+    >>> desc3.trial = trial_big
+    >>> desc3.aspect = 'Intervention'
+    >>> desc3.vocabulary = 'DeCS'
+    >>> desc3.level = 'specific'
+    >>> desc3.code = 'G02.111.570.080.689.330.400'
+    >>> desc3.text = 'HIV Enhancer'
+    >>> desc3.save()
+
+    >>> desc3.translations.create(text=u'Ampliador HIV', language='pt-br')
+    <DescriptorTranslation: pt-br>
+
+Automatically created Trial ID
+
+    >>> trial_big.trial_id.startswith('RBR-')
+    True
+
+    >>> len(trial_big.trial_id) == 10
+    True
+
+Serializing
+
+    >>> json = trial_big.serialize_for_fossil()
+
+    >>> isinstance(json, basestring)
+    True
+
+    >>> json_should_be = {
+    ...     'pk': trial_big.pk,
+    ...     '__unicode__': unicode(trial_big),
+    ...     '__model__': unicode('ClinicalTrial'),
+    ...     'id': trial_big.pk,
+    ...     'trial_id': trial_big.trial_id,
+    ...     'date_registration': trial_big.date_registration.strftime('%Y-%m-%d %H:%M:%S'),
+    ...     'scientific_title': trial_big.scientific_title,
+    ...     'scientific_acronym': trial_big.scientific_acronym,
+    ...     'scientific_acronym_expansion': trial_big.scientific_acronym_expansion,
+    ...     'primary_sponsor': {'name': 'ACME', 'creator': {'username': 'serializer', 'email': ''}, 'country': {'translations': [{'description': 'Brasil (el)', 'language': 'es', 'label': 'BR'}, {'description': 'Brasil', 'language': 'pt-br', 'label': 'BR'}], 'description': 'Brazil', 'label': 'BR'}, 'i_type': {'translations': [{'description': u'Rede de Pesquisa Cl\xednica', 'language': 'pt-br', 'label': u'rede de pesquisa cl\xednica'}], 'description': 'Clinical Research Network', 'label': 'clinical research network'}, 'address': 'Av. Goias, 1249, Centro', 'pk': 1},
+    ...     'public_title': trial_big.public_title,
+    ...     'acronym': trial_big.acronym,
+    ...     'acronym_expansion': trial_big.acronym_expansion,
+    ...     'hc_freetext': trial_big.hc_freetext,
+    ...     'i_freetext': trial_big.i_freetext,
+    ...     'inclusion_criteria': trial_big.inclusion_criteria,
+    ...     'gender': trial_big.gender,
+    ...     'agemin_value': trial_big.agemin_value,
+    ...     'agemin_unit': trial_big.agemin_unit,
+    ...     'agemax_value': trial_big.agemax_value,
+    ...     'agemax_unit': trial_big.agemax_unit,
+    ...     'exclusion_criteria': trial_big.exclusion_criteria,
+    ...     'study_type': {'translations': [{'description': '', 'language': 'es', 'label': u'de intervenci\xf3n'}, {'description': '', 'language': 'pt-br', 'label': u'de interven\xe7\xe3o'}], 'description': '', 'label': 'interventional'},
+    ...     'study_design': trial_big.study_design,
+    ...     'expanded_access_program': trial_big.expanded_access_program,
+    ...     'purpose': {'translations': [{'description': '', 'language': 'es', 'label': u'diagn\xf3stico'}, {'description': '', 'language': 'pt-br', 'label': u'diagn\xf3stico'}], 'description': '', 'label': 'diagnostic'},
+    ...     'intervention_assignment': {'translations': [{'description': '', 'language': 'es', 'label': u'grupo \xfanico'}, {'description': '', 'language': 'pt-br', 'label': u'grupo \xfanico'}], 'description': '', 'label': 'single-group'},
+    ...     'number_of_arms': trial_big.number_of_arms,
+    ...     'masking': {'translations': [{'description': '', 'language': 'es', 'label': 'abierto'}, {'description': '', 'language': 'pt-br', 'label': 'aberto'}], 'description': '', 'label': 'open'},
+    ...     'allocation': {'translations': [{'description': '', 'language': 'es', 'label': 'controlado no aleatorio'}, {'description': '', 'language': 'pt-br', 'label': u'controlado n\xe3o-randomizado'}], 'description': '', 'label': 'non-randomized-controlled'},
+    ...     'phase': {'translations': [], 'description': 'not applicable', 'label': 'N/A'},
+    ...     'enrollment_start_planned': trial_big.enrollment_start_planned,
+    ...     'enrollment_start_actual': trial_big.enrollment_start_actual,
+    ...     'enrollment_end_planned': trial_big.enrollment_end_planned,
+    ...     'enrollment_end_actual': trial_big.enrollment_end_actual,
+    ...     'target_sample_size': trial_big.target_sample_size,
+    ...     'recruitment_status': {'translations': [{'description': '', 'language': 'es', 'label': u'a\xfan no reclutando'}, {'description': u'Iniciado ainda n\xe3o recrutando', 'language': 'pt-br', 'label': u'iniciado ainda n\xe3o recrutando'}], 'description': 'Not yet recruiting', 'label': 'not yet recruiting'},
+    ...     'created': trial_big.created.strftime('%Y-%m-%d %H:%M:%S'),
+    ...     'updated': trial_big.updated.strftime('%Y-%m-%d %H:%M:%S'),
+    ...     'exported': trial_big.exported.strftime('%Y-%m-%d %H:%M:%S'),
+    ...     'staff_note': trial_big.staff_note,
+    ...     'language': trial_big.language,
+    ...     'public_contact': [{'city': 'Goiania', 'zip': '74000-970', 'firstname': 'Tarsila', 'creator': {'username': 'serializer', 'email': ''}, 'middlename': 'Ribeiro', 'lastname': 'Neiva', 'telephone': '+55(62)4525-1343', 'affiliation': {'name': 'ACME', 'creator': {'username': 'serializer', 'email': ''}, 'country': {'translations': [{'description': 'Brasil (el)', 'language': 'es', 'label': 'BR'}, {'description': 'Brasil', 'language': 'pt-br', 'label': 'BR'}], 'description': 'Brazil', 'label': 'BR'}, 'i_type': {'translations': [{'description': u'Rede de Pesquisa Cl\xednica', 'language': 'pt-br', 'label': u'rede de pesquisa cl\xednica'}], 'description': 'Clinical Research Network', 'label': 'clinical research network'}, 'address': 'Av. Goias, 1249, Centro', 'pk': 1}, 'address': 'Rua Boituva, 449', 'pk': 1, 'country': {'translations': [{'description': 'Brasil (el)', 'language': 'es', 'label': 'BR'}, {'description': 'Brasil', 'language': 'pt-br', 'label': 'BR'}], 'description': 'Brazil', 'label': 'BR'}, 'email': 'tarsila@raminel.com.br'}, {'city': 'Goiania', 'zip': '74000-970', 'firstname': 'Linus', 'creator': {'username': 'serializer', 'email': ''}, 'middlename': 'Ribeiro', 'lastname': 'Neiva', 'telephone': '+55(62)4525-1343', 'affiliation': {'name': 'ACME', 'creator': {'username': 'serializer', 'email': ''}, 'country': {'translations': [{'description': 'Brasil (el)', 'language': 'es', 'label': 'BR'}, {'description': 'Brasil', 'language': 'pt-br', 'label': 'BR'}], 'description': 'Brazil', 'label': 'BR'}, 'i_type': {'translations': [{'description': u'Rede de Pesquisa Cl\xednica', 'language': 'pt-br', 'label': u'rede de pesquisa cl\xednica'}], 'description': 'Clinical Research Network', 'label': 'clinical research network'}, 'address': 'Av. Goias, 1249, Centro', 'pk': 1}, 'address': 'Rua Boituva, 449', 'pk': 2, 'country': {'translations': [{'description': 'Brasil (el)', 'language': 'es', 'label': 'BR'}, {'description': 'Brasil', 'language': 'pt-br', 'label': 'BR'}], 'description': 'Brazil', 'label': 'BR'}, 'email': 'linus@raminel.com.br'}],
+    ...     'scientific_contact': [{'city': 'Goiania', 'zip': '74000-970', 'firstname': 'Tarsila', 'creator': {'username': 'serializer', 'email': ''}, 'middlename': 'Ribeiro', 'lastname': 'Neiva', 'telephone': '+55(62)4525-1343', 'affiliation': {'name': 'ACME', 'creator': {'username': 'serializer', 'email': ''}, 'country': {'translations': [{'description': 'Brasil (el)', 'language': 'es', 'label': 'BR'}, {'description': 'Brasil', 'language': 'pt-br', 'label': 'BR'}], 'description': 'Brazil', 'label': 'BR'}, 'i_type': {'translations': [{'description': u'Rede de Pesquisa Cl\xednica', 'language': 'pt-br', 'label': u'rede de pesquisa cl\xednica'}], 'description': 'Clinical Research Network', 'label': 'clinical research network'}, 'address': 'Av. Goias, 1249, Centro', 'pk': 1}, 'address': 'Rua Boituva, 449', 'pk': 1, 'country': {'translations': [{'description': 'Brasil (el)', 'language': 'es', 'label': 'BR'}, {'description': 'Brasil', 'language': 'pt-br', 'label': 'BR'}], 'description': 'Brazil', 'label': 'BR'}, 'email': 'tarsila@raminel.com.br'}],
+    ...     'site_contact': [],
+    ...     'i_code': [{'translations': [{'description': '', 'language': 'es', 'label': 'medicamento'}, {'description': '', 'language': 'pt-br', 'label': 'medicamento'}], 'description': '', 'label': 'drug'}, {'translations': [{'description': '', 'language': 'es', 'label': 'dispositivo'}, {'description': '', 'language': 'pt-br', 'label': 'dispositivo'}], 'description': '', 'label': 'device'}],
+    ...     'recruitment_country': [{'translations': [{'description': 'Brasil (el)', 'language': 'es', 'label': 'BR'}, {'description': 'Brasil', 'language': 'pt-br', 'label': 'BR'}], 'description': 'Brazil', 'label': 'BR'}],
+    ...     'support_sources': [],
+    ...     'acronym_display': 'HIV Study: Long HIV Study',
+    ...     'primary_outcomes': [{'translations': [], 'description': 'Description of outcome 1', 'interest': 'primary'}],
+    ...     'secondary_outcomes': [{'translations': [], 'description': 'Description of outcome 2', 'interest': 'secondary'}],
+    ...     'date_enrollment_start': '11/2010',
+    ...     'trial_number': [],
+    ...     'hc_code': [{'code': 'C02', 'vocabulary': 'DeCS', 'level': 'general', 'text': 'Virus diseases', 'translations': [{'text': 'Viroses', 'language': 'pt-br'}], 'version': '', 'aspect': 'HealthCondition'}],
+    ...     'hc_keyword': [{'code': 'D12.776.124.486.485.114.254.150.440', 'vocabulary': 'DeCS', 'level': 'specific', 'text': 'HIV Antibodies', 'translations': [{'text': u'Anticorpos Anti-HIV', 'language': 'pt-br'}], 'version': '', 'aspect': 'HealthCondition'}],
+    ...     'utrn_number': None,
+    ...     'scientific_acronym_display': 'HIV Study: Long HIV Study',
+    ...     'intervention_keyword': [{'code': 'G02.111.570.080.689.330.400', 'vocabulary': 'DeCS', 'level': 'specific', 'text': 'HIV Enhancer', 'translations': [{'text': 'Ampliador HIV', 'language': 'pt-br'}], 'version': '', 'aspect': 'Intervention'}],
+    ...     'secondary_sponsors': [],
+    ...     'translations': [],
+    ... }
+
+Different key values
+
+    >>> for k,v in simplejson.loads(json).items():
+    ...     if v != json_should_be[k]:
+    ...         print '%s = %s  ->  %s = %s'%(k, v, k, json_should_be[k])
+
+Fields not serialized
+
+    >>> [k for k in json_should_be if k not in simplejson.loads(json)]
+    []
+
+Deserializing (not persistent)
+
+    >>> proxy = ClinicalTrial.objects.deserialize_for_fossil(json, persistent=False)
+
+    >>> isinstance(proxy, FossilClinicalTrial)
+    True
+
+    >>> proxy.scientific_title
+    'Full trial: a long study about HIV'
+
+Because sometimes there's a gap between a generation and other, we must handle their
+dates are exactly the same or difference for 1 second
+
+    >>> diff = (trial_small.created - proxy.created).seconds
+    >>> (diff in (-1,0,1)) or (diff, proxy.created, trial_small.created)
+    True
+
+    >>> proxy.primary_sponsor.name
+    'ACME'
+
+    >>> proxy.primary_sponsor.country.label
+    'BR'
+
+Deserializing (persistent). To make only when necessary.
+
+3. using django-fossil
+----------------------
+
+    >>> from fossil.models import Fossil
+
+Small changes (changing a field of the clinical trial)
+
+    >>> fossil_small1 = trial_small.create_fossil()
+
+    >>> trial_small.public_title = 'New public title for trial_small'
+    >>> trial_small.save()
+
+    >>> fossil_small2 = trial_small.create_fossil()
+
+    >>> fossil_small1 != fossil_small2
+    True
+
+    >>> fossil_small2.display_text == unicode(trial_small)
+    True
+
+Changes on referenced (changing a foreign object that the current trial is dependent)
+
+    >>> fossil_big1 = trial_big.create_fossil()
+
+    >>> inst1.name = 'New name of ACNE'
+    >>> inst1.save()
+
+    >>> fossil_big2 = trial_big.create_fossil()
+
+    >>> fossil_big1 != fossil_big2
+    True
+
+    >>> fossil_big2.display_text == unicode(trial_big)
+    True
+
+Testing fossil proxy object
+
+    >>> fossil_small2_obj = fossil_small2.get_object_fossil()
+
+    >>> repr(fossil_small2_obj) == '<FossilClinicalTrial: ClinicalTrial #%s>' % trial_small.pk
+    True
+
+    >>> fossil_small2_obj.public_title == trial_small.public_title
+    True
+
+    >>> unicode(fossil_small2_obj) == unicode(trial_small)
+    True
+
+
Index: /tags/v1.0.23rc1/opentrials/repository/tests/03-xml.txt
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/tests/03-xml.txt (revision 854)
+++ /tags/v1.0.23rc1/opentrials/repository/tests/03-xml.txt (revision 854)
@@ -0,0 +1,197 @@
+SERIALIZING TO XML FORMATS
+==========================
+
+    >>> from fossil.models import Fossil
+    >>> from repository.models import ClinicalTrial
+
+    >>> fossil_null, fossil_valid = Fossil.objects.filter(is_most_recent=True)
+
+    >>> from repository.xml.generate import xml_ictrp, xml_opentrials
+    >>> from repository.xml.validate import validate_xml, ICTRP_DTD
+
+    >>> from tempfile import NamedTemporaryFile
+
+    >>> from django.contrib.auth.models import User
+    >>> user_trialist, new = User.objects.get_or_create(username='trialist')
+
+Serializing to format ICTRP
+---------------------------
+
+    >>> ct = fossil_valid.get_object_fossil()
+    >>> ct.hash_code = fossil_valid.pk
+    >>> ct.previous_revision = fossil_valid.previous_revision
+    >>> ct.version = fossil_valid.revision_sequential
+
+    >>> xml_from_ictrp = xml_ictrp(ct)
+
+Validation of ICTRP using DTD file
+
+    >>> fp = NamedTemporaryFile(mode='w', delete=False)
+    >>> fp.write(xml_from_ictrp)
+    >>> fp.close()
+
+    >>> validate_xml(fp.name, dtd=ICTRP_DTD)
+    True
+
+Deserializing and Importing from ICTRP
+--------------------------------------
+
+Delete Trial to import again (to make the 'round trip')
+
+    >>> count_before = ClinicalTrial.objects.count()
+    >>> ClinicalTrial.objects.filter(trial_id=ct.trial_id).delete()
+    >>> ClinicalTrial.deleted_objects.filter(trial_id=ct.trial_id).delete()
+
+    >>> count_before == ClinicalTrial.all_objects.count() + 1
+    True
+
+Import xml from temporary file
+
+    >>> from repository.xml.loading import OpenTrialsXMLImport
+    >>> importer = OpenTrialsXMLImport(creator=user_trialist)
+
+    >>> count_before = ClinicalTrial.objects.count()
+
+    >>> imported_trials = importer.import_ictrp(fp.name)
+
+    >>> len(imported_trials)
+    1
+
+    >>> count_before == ClinicalTrial.objects.count() - 1
+    True
+
+Checks imported trial and its fields
+
+    >>> new_ct = ClinicalTrial.objects.get(trial_id=ct.trial_id)
+    >>> new_fossil = Fossil.objects.fossils_of_object(new_ct)[0]
+    >>> ct = new_fossil.get_object_fossil()
+    >>> ct.hash_code = fossil_valid.pk
+    >>> ct.previous_revision = fossil_valid.previous_revision
+    >>> ct.version = fossil_valid.revision_sequential
+    >>> ct.status = fossil_valid.indexers.key('status', fail_silent=True).value
+
+    >>> new_xml = xml_opentrials(ct, persons)
+
+    >>> fp_new = NamedTemporaryFile(mode='w', delete=False)
+    >>> fp_new.write(new_xml)
+    >>> fp_new.close()
+
+    >>> new_xml == xml_from_otxml
+    True
+
+    >>> #print fp.name, fp_new.name
+
+Serializing to format OpenTrials XML
+------------------------------------
+
+    >>> ct = fossil_valid.get_object_fossil()
+    >>> ct.hash_code = fossil_valid.pk
+    >>> ct.previous_revision = fossil_valid.previous_revision
+    >>> ct.version = fossil_valid.revision_sequential
+    >>> ct.status = fossil_valid.indexers.key('status', fail_silent=True).value
+
+    >>> persons = set(ct.scientific_contact + ct.public_contact + ct.site_contact)
+
+    >>> xml_from_otxml = xml_opentrials(ct, persons)
+
+Validation of OpenTrials XML using DTD file
+
+    >>> fp = NamedTemporaryFile(mode='w', delete=False)
+    >>> fp.write(xml_from_otxml)
+    >>> fp.close()
+
+    >>> validate_xml(fp.name)
+    True
+
+Deserializing and Importing from OpenTrials XML
+-----------------------------------------------
+
+Delete Trial to import again (to make the 'round trip')
+
+    >>> count_before = ClinicalTrial.objects.count()
+    >>> ClinicalTrial.objects.filter(trial_id=ct.trial_id).delete()
+    >>> ClinicalTrial.deleted_objects.filter(trial_id=ct.trial_id).delete()
+
+    >>> count_before == ClinicalTrial.all_objects.count() + 1
+    True
+
+Import xml from temporary file
+
+    >>> from repository.xml.loading import OpenTrialsXMLImport
+    >>> importer = OpenTrialsXMLImport(creator=user_trialist)
+
+    >>> count_before = ClinicalTrial.objects.count()
+
+This import is for a not existing trial. Default for "if_exists" is "UPDATE_IF_EXISTS"
+
+    >>> imported_trials = importer.import_opentrials(fp.name)
+
+    >>> len(imported_trials)
+    1
+
+    >>> count_before == ClinicalTrial.objects.count() - 1
+    True
+
+Checks imported trial and its fields
+
+    >>> new_ct = ClinicalTrial.objects.get(trial_id=ct.trial_id)
+    >>> new_fossil = Fossil.objects.fossils_of_object(new_ct)[0]
+    >>> ct = new_fossil.get_object_fossil()
+    >>> ct.hash_code = fossil_valid.pk
+    >>> ct.previous_revision = fossil_valid.previous_revision
+    >>> ct.version = fossil_valid.revision_sequential
+    >>> ct.status = fossil_valid.indexers.key('status', fail_silent=True).value
+
+    >>> new_xml = xml_opentrials(ct, persons)
+
+    >>> fp_new = NamedTemporaryFile(mode='w', delete=False)
+    >>> fp_new.write(new_xml)
+    >>> fp_new.close()
+
+    >>> new_xml == xml_from_otxml
+    True
+
+Cases for (already) existing trials
+
+    >>> from repository.xml.loading import REPLACE_IF_EXISTS, SKIP_IF_EXISTS
+
+    >>> imported_trials = importer.import_opentrials(fp.name, if_exists=SKIP_IF_EXISTS)
+
+    >>> len(imported_trials)
+    0
+
+    >>> count_before = ClinicalTrial.objects.count()
+
+    >>> imported_trials = importer.import_opentrials(fp.name, if_exists=REPLACE_IF_EXISTS)
+
+    >>> len(imported_trials)
+    1
+
+    >>> count_before == ClinicalTrial.objects.count()
+    True
+
+    >>> #print fp.name, fp_new.name
+
+Function that parses a XML file and loads it to memory without import it
+
+    >>> trials_to_import = importer.parse_opentrials(fp.name)
+
+    >>> len(trials_to_import)
+    1
+
+It returns a list of tuples. Each tuple has 2 nodes: the first is a dict with the new trial
+fields, and the second is the existing ClinicalTrial object (if exists).
+
+    >>> trials_to_import[0][0]['trial_id'] == ct.trial_id
+    True
+
+    >>> trials_to_import[0][1].trial_id == ct.trial_id
+    True
+
+And another function to import parsed files from memory
+
+    >>> imported_trials = importer.import_parsed(if_exists=REPLACE_IF_EXISTS)
+
+    >>> len(imported_trials)
+    1
+
Index: /tags/v1.0.23rc1/opentrials/repository/trds.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/trds.py (revision 260)
+++ /tags/v1.0.23rc1/opentrials/repository/trds.py (revision 260)
@@ -0,0 +1,52 @@
+from django.utils.translation import ugettext as _
+
+from repository.models import *
+
+TRDS_LABELS = (
+    (1,_('Primary Registry and Trial Identifying Number'), 'trial_id'),
+    (2,_('Date of Registration in Primary Registry'), 'date_registration'),
+    (3,_('Secondary Identifying Numbers'), 'trialnumber_set'),
+    (4,_('Source(s) of Monetary or Material Support'), 'support_sources'),
+    (5,_('Primary Sponsor'), 'primary_sponsor'),
+    (6,_('Secondary Sponsors'), 'secondary_sponsors'),
+    (7,_('Contacts for Public Queries'), 'public_contacts'),
+    (8,_('Contacts for Scientific Queries'), 'scientific_contacts'),
+    (9,_('Public Title'), 'public_title acronym'),
+    (10,_('Scientific Title'), 'scientific_title scientific_acronym'),
+    (11,_('Countries of Recruitment'), 'recruitmentcountry_set'),
+)
+
+class TRDSField(object):
+
+    def __init__(self, trial, number, title, subfields):
+        self.trial = trial
+        self.number = number
+        self.title = title
+        self.subfields = subfields.split()
+
+    def dump(self):
+        res = []
+        for attr_name in self.subfields:
+            d = {'attr_name':attr_name}
+            attr = getattr(self.trial, attr_name)
+            if callable(attr):
+                d['value'] = repr(attr())
+            else:
+                d['value'] = attr
+            res.append(d)
+        return res
+
+
+
+'''
+    # Scientific fields
+    (12,_('Health Condition(s) or Problem(s) Studied')),
+    (13,_('Intervention(s)')),
+    (14,_('Key Inclusion and Exclusion Criteria')),
+    (15,_('Study Type')),
+    (16,_('Date of First Enrollment')),
+    (17,_('Target Sample Size')),
+    (18,_('Recruitment Status')),
+    (19,_('Primary Outcome(s)')),
+    (20,_('Key Secondary Outcomes')),
+'''
Index: /tags/v1.0.23rc1/opentrials/repository/choices.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/choices.py (revision 847)
+++ /tags/v1.0.23rc1/opentrials/repository/choices.py (revision 847)
@@ -0,0 +1,68 @@
+# coding: utf-8
+
+from django.utils.translation import ugettext_lazy as _
+
+## Qualifiers for the relationship of secondary entities with a ClinicalTrial #
+
+INSTITUTIONAL_RELATION = [
+    ('SupportSource', _('Source of monetary or material support')), #TRDS 4
+    ('SecondarySponsor', _('Secondary sponsor')), #TRDS 6
+]
+
+CONTACT_RELATION = [
+    ('PublicContact', _('Contact for Public Queries')), #TRDS 7
+    ('ScientificContact', _('Contact for Scientific Queries')), #TRDS 8
+    ('SiteContact', _('Contact for Site Queries')), #TRDS 8
+]
+
+CONTACT_STATUS = [
+    ('Active', _('Active and current contact')),
+    ('Inactive', _('Inactive or previous contact')),
+]
+
+OUTCOME_INTEREST = [
+    ('primary', _('Primary')), # TRDS 19
+    ('secondary', _('Secondary')), # TRDS 20
+]
+
+#################################################### Limited choices fields ###
+
+
+TRIAL_RECORD_STATUS = [
+    ('processing', _('processing')),
+    ('published', _('published')),
+    ('archived', _('archived')),
+]
+PROCESSING_STATUS = TRIAL_RECORD_STATUS[0][0]
+PUBLISHED_STATUS  = TRIAL_RECORD_STATUS[1][0]
+ARCHIVED_STATUS   = TRIAL_RECORD_STATUS[2][0]
+
+
+INCLUSION_GENDER = [('-', _('both')), ('M', _('male')), ('F', _('female')),]
+
+INCLUSION_AGE_UNIT = [
+    ('-', _('no limit')),
+    ('Y', _('years')),
+    ('M', _('months')),
+    ('W', _('weeks')),
+    ('D', _('days')),
+    ('H', _('hours')),
+]
+
+######################################################## Descriptor choices ###
+
+TRIAL_ASPECT = [
+    ('HealthCondition', _('Health Condition or Problem Studied')), #TRDS 12
+    ('Intervention', _('Intervention')), #TRDS 13
+]
+
+DESCRIPTOR_LEVEL = [
+    ('general', _('General')),
+    ('specific', _('Specific')),
+]
+
+DESCRIPTOR_VOCABULARY = [
+    ('DeCS', _('DeCS: Health Sciences Descriptors')),
+    ('ICD-10', _('ICD-10: International Classification of Diseases (10th. rev.)')),
+    #('CAS', _('Chemical Abstracts Service')),
+]
Index: /tags/v1.0.23rc1/opentrials/repository/trds_forms.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/trds_forms.py (revision 964)
+++ /tags/v1.0.23rc1/opentrials/repository/trds_forms.py (revision 964)
@@ -0,0 +1,718 @@
+#coding: utf-8
+
+from assistance.models import FieldHelp, FieldHelpTranslation
+from repository.models import ClinicalTrial, Contact, Descriptor, Institution
+from repository.models import Outcome, TrialNumber
+from repository.models import TrialSecondarySponsor, TrialSupportSource
+from repository.models import SiteContact, PublicContact, ScientificContact
+from vocabulary.models import CountryCode, StudyPhase, StudyType, RecruitmentStatus
+from vocabulary.models import InterventionCode, StudyMasking, StudyAllocation
+from vocabulary.models import TimePerspective, ObservationalStudyDesign
+from vocabulary.models import StudyPurpose, InterventionAssigment, InstitutionType
+from repository.widgets import SelectWithLink, SelectInstitution, YearMonthWidget
+
+import choices
+
+from django.utils.encoding import force_unicode
+from django.utils.safestring import mark_safe
+from django.utils.translation import ugettext_lazy as _, get_language
+from django.forms.formsets import DELETION_FIELD_NAME
+from django.template.defaultfilters import linebreaksbr
+
+from django import forms
+from django.forms.forms import BoundField, conditional_escape
+
+from polyglot.multilingual_forms import MultilingualCharField, MultilingualTextField
+from polyglot.multilingual_forms import MultilingualModelChoiceField, MultilingualModelMultipleChoiceField
+from polyglot.multilingual_forms import MultilingualBaseForm, MultilingualBaseFormSet
+from polyglot.multilingual_forms import MultilingualModelCheckboxField
+
+from trial_validation import trial_validator, TRIAL_FORMS
+
+from datetime import date
+import re
+
+import settings
+
+class ReviewModelForm(MultilingualBaseForm):
+
+    def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_on_separate_row):
+        "Helper function for outputting HTML. Used by as_table(), as_ul(), as_p()."
+
+        top_errors = self.non_field_errors() # Errors that should be displayed above all fields.
+        output, hidden_fields = [], []
+        for name, field in self.fields.items():
+            bf = BoundField(self, field, name)
+            bf_errors = self.error_class([conditional_escape(error) for error in bf.errors]) # Escape and cache in local variable.
+            if bf.is_hidden:
+                if bf_errors:
+                    top_errors.extend([u'(Hidden field %s) %s' % (name, force_unicode(e)) for e in bf_errors])
+                hidden_fields.append(unicode(bf))
+            else:
+                if errors_on_separate_row and bf_errors:
+                    output.append(error_row % force_unicode(bf_errors))
+                if bf.label:
+                    label = conditional_escape(force_unicode(bf.label))
+                    # Only add the suffix if the label does not end in
+                    # punctuation.
+                    if self.label_suffix:
+                        if label[-1] not in ':?.!':
+                            label += self.label_suffix
+                    # Sets label with an asterisk if this is a obligatory field according to to validation rules
+                    if hasattr(self.Meta,'min_required'):
+                        if not hasattr(self.Meta,'count'):
+                            self.Meta.count = 0
+                        if self.Meta.min_required > 0 and self.Meta.count < self.Meta.min_required:
+                            if name != 'DELETE':
+                                label = label + ' <span class="required_field">(*)</span>'
+                    elif trial_validator.field_is_required(self, name):
+                        label = label + ' <span class="required_field">(*)</span>'
+                    label = bf.label_tag(label) or ''
+                else:
+                    label = ''
+
+
+                # Gets the field status for this field to use it as CSS class
+                if self.instance:
+                    field_status = trial_validator.get_field_status(self, name, self.instance)
+                else:
+                    field_status = ''
+
+                if field.help_text:
+                    help_text = help_text_html % force_unicode(field.help_text)
+                else:
+                    help_text = u''
+                form_name = self.__class__.__name__
+                help_record, new = FieldHelp.objects.get_or_create(form=form_name, field=name)
+
+                # Trying to get the translation for help_record
+                try:
+                    help_object = FieldHelpTranslation.objects.get_translation_for_object(
+                        lang=get_language(), model=FieldHelp, object_id=help_record.pk,
+                        )
+                    help_text = "<div class='help_text'>%s</div>" % (help_object.text,)
+                    if help_object.example:
+                        help_text = "%s<div class='help_text_example'>%s:<br />%s</div>" % (help_text, _("Example"), help_object.example)
+
+                    if not help_text.strip():
+                        help_text = unicode(help_record)
+                except (FieldHelpTranslation.DoesNotExist, AttributeError):
+                    help_text = "<div class='help_text'>%s</div>" % (help_record.text,)
+                    if help_record.example:
+                        help_text = "%s<div class='help_text_example'>%s:<br />%s</div>" % (help_text, _("Example"), help_record.example)
+
+                help_text = u'' + force_unicode(help_text)
+                help_text = linebreaksbr(help_text_html % help_text)
+                output.append(normal_row % {'errors': force_unicode(bf_errors),
+                                            'label': force_unicode(label),
+                                            'field': unicode(bf),
+                                            'help_text': help_text,
+                                            'help_id': 'id_%s-help%s' % ((self.prefix or name),help_record.pk),
+                                            'field_class': field_status,
+                                            'field_name': name,
+                                            })
+
+        # if necessary, updates the count of rendered repetitive forms
+        if hasattr(self.Meta,'min_required'):
+            if hasattr(self.Meta,'count'):
+                self.Meta.count = self.Meta.count + 1
+
+        if top_errors:
+            output.insert(0, error_row % force_unicode(top_errors))
+        if hidden_fields: # Insert any hidden fields in the last row.
+            str_hidden = u''.join(hidden_fields)
+
+            if output:
+                last_row = output[-1]
+                # Chop off the trailing row_ender (e.g. '</td></tr>') and
+                # insert the hidden fields.
+                if not last_row.endswith(row_ender):
+                    # This can happen in the as_p() case (and possibly others
+                    # that users write): if there are only top errors, we may
+                    # not be able to conscript the last row for our purposes,
+                    # so insert a new, empty row.
+                    last_row = normal_row % {'errors': '',
+                                             'label': '',
+                                             'field': '',
+                                             'help_text': '',
+                                             'help_id': 'id_%s-help%s' % (self.prefix,help_record.pk),
+                                             'issue': '',}
+                    output.append(last_row)
+                output[-1] = last_row[:-len(row_ender)] + str_hidden + row_ender
+            else:
+                # If there aren't any rows in the output, just append the
+                # hidden fields.
+                output.append(str_hidden)
+
+        return mark_safe(u'\n'.join(output))
+
+    def as_table(self):
+        "Returns this form rendered as HTML <tr>s -- excluding the <table></table>."
+        normal_row = u'''
+            <tr class="%(field_class)s %(field_name)s"><th><img src="/static/help.png" rel="#%(help_id)s"/>
+                    <div id="%(help_id)s" class="help">%(help_text)s</div>
+                    %(label)s</th>
+                <td>%(errors)s%(field)s
+                </td></tr>'''
+        return self._html_output(normal_row=normal_row,
+                                 error_row=u'<tr><td colspan="3">%s</td></tr>',
+                                 row_ender='</td></tr>',
+                                 help_text_html=u'%s',
+                                 errors_on_separate_row=False)
+
+#
+# Forms
+#
+
+def utrn_number_validate(data):
+    if data:
+        if not re.match('^U\d{4}-\d{4}-\d{4}$', data):
+            raise forms.ValidationError(_("Invalid format. Example: U1111-1111-1111"))
+    return data
+
+### step_1 #####################################################################
+class TrialIdentificationForm(ReviewModelForm):
+    class Meta:
+        model = ClinicalTrial
+        fields = ['scientific_title','scientific_acronym',
+                  'scientific_acronym_expansion','public_title',
+                  'acronym','acronym_expansion','utrn_number']
+
+    title = _('Trial Identification')
+    # TRDS 10a
+    scientific_title = forms.CharField(label=_('Scientific Title'),
+                                       max_length=2000,
+                                       widget=forms.Textarea)
+    # TRDS 10b
+    scientific_acronym = forms.CharField(required=False,
+                                         label=_('Scientific Acronym'),
+                                         max_length=255)
+    # TRDS 9a
+    public_title = forms.CharField(required=False,
+                                   label=_('Public Title'),
+                                   max_length=2000,
+                                   widget=forms.Textarea)
+    # TRDS 9b
+    acronym = forms.CharField(required=False, label=_('Acronym'),
+                              max_length=255)
+
+    def clean_utrn_number(self):
+        data = utrn_number_validate(self.cleaned_data['utrn_number'].strip())
+        if ClinicalTrial.objects.filter(utrn_number=data).exclude(pk=self.instance.pk).count() > 0:
+            raise forms.ValidationError(_('UTN number already exists.'))
+        return data
+
+
+class SecondaryIdForm(ReviewModelForm):
+    class Meta:
+        queryset = TrialNumber.objects.all()
+        min_required = 0
+        polyglot = False
+    title = _('Secondary Identifying Numbers')
+    # this is just to inherit the custom _html_output and as_table methods
+
+trial_validator.register(TRIAL_FORMS[0], [TrialIdentificationForm, SecondaryIdForm])
+
+### step_2 #####################################################################
+class PrimarySponsorForm(ReviewModelForm):
+    class Meta:
+        model = ClinicalTrial
+        fields = ['primary_sponsor']
+
+    def __init__(self, *args, **kwargs):
+        queryset = kwargs.pop('queryset', None)
+        super(PrimarySponsorForm, self).__init__(*args, **kwargs)
+        if queryset:
+            self.fields['primary_sponsor'].queryset = queryset
+
+    title = _('Primary Sponsor')
+
+def make_secondary_sponsor_form(user=None):
+    class SecondarySponsorForm(ReviewModelForm):
+        class Meta:
+            model = TrialSecondarySponsor
+            queryset = TrialSecondarySponsor.objects.all()
+            min_required = 0
+            polyglot = False
+            fields = ['institution','relation']
+
+        title = _('Secondary Sponsor(s)')
+        if user:
+            institution = forms.ModelChoiceField(queryset=Institution.objects.filter(creator=user).order_by('name'),
+                                                 label=_('Institution'))
+        relation = forms.CharField(widget=forms.HiddenInput, initial=choices.INSTITUTIONAL_RELATION[1][0])
+
+    return SecondarySponsorForm
+
+def make_support_source_form(user=None):
+    class SupportSourceForm(ReviewModelForm):
+        class Meta:
+            model = TrialSupportSource
+            queryset = TrialSupportSource.objects.all()
+            min_required = 0
+            polyglot = False
+            fields = ['institution','relation']
+
+        title = _('Source(s) of Monetary or Material Support')
+        if user:
+            institution = forms.ModelChoiceField(queryset=Institution.objects.filter(creator=user).order_by('name'),
+                                                 label=_('Institution'))
+        relation = forms.CharField(widget=forms.HiddenInput, initial=choices.INSTITUTIONAL_RELATION[0][0])
+
+    return SupportSourceForm
+
+trial_validator.register(TRIAL_FORMS[1], [PrimarySponsorForm, make_secondary_sponsor_form(), make_support_source_form()])
+
+
+
+### step_3 #####################################################################
+class HealthConditionsForm(ReviewModelForm):
+    class Meta:
+        model = ClinicalTrial
+        fields = ['hc_freetext',]
+
+    title = _('Health Condition(s) or Problem(s) Studied')
+
+    # TRDS 12a
+    hc_freetext = forms.CharField(label=_('Health Condition(s) or Problem(s)'),
+                                         required=False, max_length=8000,
+                                         widget=forms.Textarea)
+
+class GeneralHealthDescriptorForm(ReviewModelForm):
+    class Meta:
+        model = Descriptor
+        queryset = Descriptor.objects.filter(aspect=choices.TRIAL_ASPECT[0][0],level=choices.DESCRIPTOR_LEVEL[0][0])
+        min_required = 1
+        polyglot = False
+        exclude = ['trial','version']
+    title = _('General Descriptors for Health Condition(s)')
+    aspect = forms.CharField(widget=forms.HiddenInput,
+                              initial=choices.TRIAL_ASPECT[0][0])
+    level = forms.CharField(widget=forms.HiddenInput,
+                              initial=choices.DESCRIPTOR_LEVEL[0][0])
+
+class SpecificHealthDescriptorForm(ReviewModelForm):
+    class Meta:
+        model = Descriptor
+        queryset = Descriptor.objects.filter(aspect=choices.TRIAL_ASPECT[0][0],level=choices.DESCRIPTOR_LEVEL[1][0])
+        min_required = 1
+        polyglot = False
+        exclude = ['trial','version']
+    title = _('Specific Descriptors for Health Condition(s)')
+    aspect = forms.CharField(widget=forms.HiddenInput,
+                              initial=choices.TRIAL_ASPECT[0][0])
+    level = forms.CharField(widget=forms.HiddenInput,
+                             initial=choices.DESCRIPTOR_LEVEL[1][0])
+
+trial_validator.register(TRIAL_FORMS[2], [HealthConditionsForm, GeneralHealthDescriptorForm, SpecificHealthDescriptorForm])
+
+### step_4 #####################################################################
+class InterventionDescriptorForm(ReviewModelForm):
+    class Meta:
+        model = Descriptor
+        queryset = Descriptor.objects.filter(aspect=choices.TRIAL_ASPECT[1][0],
+                                            level=choices.DESCRIPTOR_LEVEL[0][0])
+        min_required = 1
+        polyglot = False
+        exclude = ['trial','version']
+    title = _('Descriptor for Intervention(s)')
+    aspect = forms.CharField(widget=forms.HiddenInput,
+                              initial=choices.TRIAL_ASPECT[1][0])
+    level = forms.CharField(widget=forms.HiddenInput,
+                             initial=choices.DESCRIPTOR_LEVEL[0][0]) # TODO: Change to DESCRIPTOR_LEVEL[1][0]
+
+class InterventionForm(ReviewModelForm):
+    title = _('Intervention(s)')
+    class Meta:
+        model = ClinicalTrial
+        fields = ['i_freetext','i_code']
+    title = _('Intervention(s)')
+
+    i_freetext = forms.CharField(label=_('Intervention(s)'),
+                                         required=False, max_length=8000,
+                                         widget=forms.Textarea)
+
+    i_code = MultilingualModelCheckboxField(
+                label=_("Intervention Code(s)"),
+                model=InterventionCode,
+                label_field='label',
+            )
+
+trial_validator.register(TRIAL_FORMS[3], [InterventionForm, InterventionDescriptorForm])
+
+### step_5 #####################################################################
+class RecruitmentForm(ReviewModelForm):
+    class Meta:
+        model = ClinicalTrial
+        fields = ['recruitment_status', 'recruitment_country',
+                  'target_sample_size', 'inclusion_criteria',
+                  'gender', 'agemin_value', 'agemin_unit',
+                  'agemax_value', 'agemax_unit', 'exclusion_criteria',
+                  ]
+
+    title = _('Recruitment')
+
+    # TRDS 18
+    recruitment_status = MultilingualModelChoiceField(
+            label=_('Study Status'),
+            queryset=RecruitmentStatus.objects.all(),
+            required=False,
+            label_field='label',
+            )
+
+    recruitment_country = MultilingualModelMultipleChoiceField(
+            label=_('Recruitment Country'),
+            model=CountryCode,
+            label_field='description',
+            )
+
+    # TRDS 16a,b (type_enrollment: anticipated or actual)
+    enrollment_start_date = forms.Field( # yyyy-mm or yyyy-mm-dd
+        required=False,
+        label=_('Planned Date of First Enrollment'),
+        widget=YearMonthWidget,
+        )
+    enrollment_end_date = forms.Field( # yyyy-mm or yyyy-mm-dd
+        required=False,
+        label=_('Planned Date of Last Enrollment'),
+        widget=YearMonthWidget,
+        )
+
+    # TRDS 17
+    target_sample_size = forms.IntegerField(label=_('Target Sample Size'),
+                                             initial=0 , required=False)
+    # TRDS 14a
+    inclusion_criteria = forms.CharField(label=_('Inclusion Criteria'),
+                                         required=False, max_length=8000,
+                                         widget=forms.Textarea)
+    # TRDS 14b
+    gender = forms.ChoiceField(label=_('Gender (inclusion sex)'),
+                               choices=choices.INCLUSION_GENDER)
+    # TRDS 14c
+    agemin_value = forms.IntegerField(required=False, label=_('Inclusion Minimum Age'))
+
+    agemin_unit = forms.ChoiceField(label=_('Minimum Age Unit'),
+                                   choices=choices.INCLUSION_AGE_UNIT)
+    # TRDS 14d
+    agemax_value = forms.IntegerField(required=False, label=_('Inclusion Maximum Age'))
+
+    agemax_unit = forms.ChoiceField(label=_('Maximum Age Unit'),
+                                   choices=choices.INCLUSION_AGE_UNIT)
+    # TRDS 14e
+    exclusion_criteria = forms.CharField(label=_('Exclusion Criteria'),required=False,
+                                        max_length=8000, widget=forms.Textarea,)
+
+    def clean_enrollment_end_date(self):
+        end_date = self.cleaned_data.get('enrollment_end_date')
+        if end_date is False:
+            raise forms.ValidationError(_("You must assign both Year and Month"))
+        return end_date
+
+    def clean_enrollment_start_date(self):
+        start_date = self.cleaned_data.get('enrollment_start_date')
+        if start_date is False:
+            raise forms.ValidationError(_("You must assign both Year and Month"))
+        return start_date
+
+    def __init__(self, *args, **kwargs):
+        self.base_fields.keyOrder = ['recruitment_status', 'recruitment_country',
+                'enrollment_start_date', 'enrollment_end_date', 'target_sample_size',
+                'inclusion_criteria', 'gender', 'agemin_value', 'agemin_unit',
+                'agemax_value', 'agemax_unit', 'exclusion_criteria']
+
+        super(RecruitmentForm, self).__init__(*args, **kwargs)
+
+        if self.instance:
+            self.fields['enrollment_start_date'].initial = self.instance.enrollment_start_planned or\
+                                                           self.instance.enrollment_start_actual
+            self.fields['enrollment_end_date'].initial = self.instance.enrollment_end_planned or\
+                                                         self.instance.enrollment_end_actual
+
+    def save(self, commit=True, *args, **kwargs):
+        obj = super(RecruitmentForm, self).save(commit=True, *args, **kwargs)
+
+        obj.enrollment_start_planned = None
+        obj.enrollment_start_actual = None
+        if self.cleaned_data.get('enrollment_start_date', None):
+            if self.cleaned_data['enrollment_start_date'] > date.today():
+                obj.enrollment_start_planned = self.cleaned_data['enrollment_start_date']
+            else:
+                obj.enrollment_start_actual = self.cleaned_data['enrollment_start_date']
+
+        obj.enrollment_end_planned = None
+        obj.enrollment_end_actual = None
+        if self.cleaned_data.get('enrollment_end_date', None):
+            if self.cleaned_data['enrollment_end_date'] > date.today():
+                obj.enrollment_end_planned = self.cleaned_data['enrollment_end_date']
+            else:
+                obj.enrollment_end_actual = self.cleaned_data['enrollment_end_date']
+
+        if commit:
+            obj.save()
+
+        return obj
+
+    def clean(self):
+        cleaned_data = super(RecruitmentForm, self).clean()
+
+        start_date = cleaned_data.get('enrollment_start_date')
+        end_date = cleaned_data.get('enrollment_end_date')
+        if end_date and start_date and start_date > end_date:
+            raise forms.ValidationError(_("Invalid date"))
+
+        return cleaned_data
+
+trial_validator.register(TRIAL_FORMS[4], [RecruitmentForm])
+
+### step_6 #####################################################################
+class StudyTypeForm(ReviewModelForm):
+    class Meta:
+        model = ClinicalTrial
+        fields = ['is_observational',
+                  'study_design',
+                  'expanded_access_program',
+                  'purpose',
+                  'intervention_assignment',
+                  'number_of_arms',
+                  'masking',
+                  'allocation',
+                  'phase',
+                  'observational_study_design',
+                  'time_perspective',]
+
+    title = _('Study Type')
+
+    # TRDS 15b
+    study_design = forms.CharField(label=_('Study Design'),
+                                         required=False, max_length=1000,
+                                         widget=forms.Textarea)
+
+    purpose = MultilingualModelChoiceField(
+        label=_('Study Purpose'),
+        queryset=StudyPurpose.objects.all(),
+        required=False,
+        label_field='label',
+        )
+
+    intervention_assignment = MultilingualModelChoiceField(
+        label=_('Intervention Assignment'),
+        queryset=InterventionAssigment.objects.all(),
+        required=False,
+        label_field='label',
+        )
+
+    masking = MultilingualModelChoiceField(
+        label=_('Masking type'),
+        queryset=StudyMasking.objects.all(),
+        required=False,
+        label_field='label',
+        )
+
+    is_observational = forms.ChoiceField(
+        label=_('Study Type'),
+        required=True,
+        choices=[
+            (False,_('Intervention')),
+            (True,_('Observational')),
+        ])
+
+    allocation = MultilingualModelChoiceField(
+        label=_('Allocation type'),
+        queryset=StudyAllocation.objects.all(),
+        required=False,
+        label_field='label',
+        )
+
+    # TRDS 15c
+    phase = MultilingualModelChoiceField(
+        label=_('Study Phase'),
+        queryset=StudyPhase.objects.all(),
+        required=False,
+        label_field='label',
+        )
+
+    time_perspective = MultilingualModelChoiceField(
+        label=_('Time Perspective'),
+        queryset=TimePerspective.objects.all(),
+        required=True,
+        label_field='label',
+        )
+
+    observational_study_design = MultilingualModelChoiceField(
+        label=_('Observational Study Design'),
+        queryset=ObservationalStudyDesign.objects.all(),
+        required=True,
+        label_field='label',
+        )
+
+    expanded_access_program = forms.ChoiceField(
+        label=_('Expanded access program'),
+        required=False,
+        choices=[
+            (None,_('Unknown')),
+            (True,_('Yes')),
+            (False,_('No')),
+        ])
+
+trial_validator.register(TRIAL_FORMS[5], [StudyTypeForm])
+
+### step_7 #####################################################################
+class PrimaryOutcomesForm(ReviewModelForm):
+    class Meta:
+        model = Outcome
+        queryset = Outcome.objects.filter(interest=choices.OUTCOME_INTEREST[0][0])
+        min_required = 1
+        polyglot = True
+        polyglot_fields = ['description']
+        fields = ['description','interest']
+
+    title = _('Primary Outcomes')
+    interest = forms.CharField(initial=choices.OUTCOME_INTEREST[0][0],
+                               widget=forms.HiddenInput)
+
+class SecondaryOutcomesForm(ReviewModelForm):
+    class Meta:
+        model = Outcome
+        queryset = Outcome.objects.filter(interest=choices.OUTCOME_INTEREST[1][0])
+        min_required = 0
+        polyglot = True
+        polyglot_fields = ['description']
+        fields = ['description','interest']
+
+    title = _('Secondary Outcomes')
+    interest = forms.CharField(initial=choices.OUTCOME_INTEREST[1][0],
+                               widget=forms.HiddenInput)
+
+trial_validator.register(TRIAL_FORMS[6], [PrimaryOutcomesForm,SecondaryOutcomesForm])
+
+### step_8 #####################################################################
+def make_public_contact_form(user=None):
+    class PublicContactForm(ReviewModelForm):
+        class Meta:
+            model = ClinicalTrial
+            queryset = PublicContact.objects.all()
+            min_required = 0
+            polyglot = False
+            fields = ['contact']
+
+        title = _('Contact(s) for Public Queries')
+        relation = forms.CharField(label=_('Relation'),
+                                   initial=choices.CONTACT_RELATION[0][0],
+                                   widget=forms.HiddenInput)
+        if user:
+            contact = forms.ModelChoiceField(queryset=Contact.objects.filter(creator=user).order_by('firstname', 'middlename', 'lastname'),
+                                             label=_('Contact'),
+                                             widget=SelectWithLink(link='#new_contact', text=_('New Contact')))
+        else:
+            contact = forms.ModelChoiceField(queryset=Contact.objects.all(),
+                                             label=_('Contact'),
+                                             widget=SelectWithLink(link='#new_contact', text=_('New Contact')))
+    return PublicContactForm
+
+def make_scientifc_contact_form(user=None):
+    class ScientificContactForm(ReviewModelForm):
+        class Meta:
+            model = ClinicalTrial
+            queryset = ScientificContact.objects.all()
+            min_required = 1
+            polyglot = False
+            fields = ['contact']
+
+        title = _('Contact(s) for Scientific Queries')
+        relation = forms.CharField(label=_('Relation'),
+                                   initial=choices.CONTACT_RELATION[1][0],
+                                   widget=forms.HiddenInput)
+        if user:
+            contact = forms.ModelChoiceField(queryset=Contact.objects.filter(creator=user).order_by('firstname', 'middlename', 'lastname'),
+                                             label=_('Contact'),
+                                             widget=SelectWithLink(link='#new_contact', text=_('New Contact')))
+        else:
+            contact = forms.ModelChoiceField(queryset=Contact.objects.all(),
+                                             label=_('Contact'),
+                                             widget=SelectWithLink(link='#new_contact', text=_('New Contact')))
+
+
+    return ScientificContactForm
+
+def make_site_contact_form(user=None):
+    class SiteContactForm(ReviewModelForm):
+        class Meta:
+            model = ClinicalTrial
+            queryset = SiteContact.objects.all()
+            min_required = 1
+            polyglot = False
+            fields = ['contact']
+
+        title = _('Contact(s) for Site Queries')
+        relation = forms.CharField(label=_('Relation'),
+                                   initial=choices.CONTACT_RELATION[2][0],
+                                   widget=forms.HiddenInput)
+
+        if user:
+            contact = forms.ModelChoiceField(queryset=Contact.objects.filter(creator=user).order_by('firstname', 'middlename', 'lastname'),
+                                             label=_('Contact'),
+                                             widget=SelectWithLink(link='#new_contact', text=_('New Contact')))
+        else:
+            contact = forms.ModelChoiceField(queryset=Contact.objects.all(),
+                                             label=_('Contact'),
+                                             widget=SelectWithLink(link='#new_contact', text=_('New Contact')))
+
+    return SiteContactForm
+
+trial_validator.register(TRIAL_FORMS[7], [make_public_contact_form(),make_scientifc_contact_form(),make_scientifc_contact_form()])
+
+#step8-partof
+# http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/
+# http://stackoverflow.com/questions/622982/django-passing-custom-form-parameters-to-formset
+def make_contact_form(user,formset_prefix=''):
+    class ContactForm(ReviewModelForm):
+        class Meta:
+            model = Contact
+
+        def __init__(self, *args, **kwargs):
+            super(ContactForm, self).__init__(*args, **kwargs)
+            self.fields.insert(0, 'relation', forms.ChoiceField(label=_('Contact Type'),
+                                   widget=forms.RadioSelect,
+                                   choices=choices.CONTACT_RELATION))
+
+        title = _('New Contact(s)')
+
+        firstname = forms.CharField(label=_('First Name'), max_length=50)
+        middlename = forms.CharField(label=_('Middle Name'), max_length=50,required=False)
+        lastname = forms.CharField(label=_('Last Name'), max_length=50)
+
+        email = forms.EmailField(label=_('E-mail'), max_length=255)
+
+        affiliation = forms.ModelChoiceField(queryset=Institution.objects.filter(creator=user).order_by('name'),
+                                             label=_('Institution'),
+                                             widget=SelectInstitution(formset_prefix=formset_prefix))
+
+        address = forms.CharField(label=_('Address'), max_length=255,required=False,
+                                  widget=forms.TextInput(attrs={'style': 'width:400px;'}))
+        city = forms.CharField(label=_('City'), max_length=255)
+
+        country = forms.ModelChoiceField(CountryCode.objects.all(),
+                                         label=_('Country'))
+
+        zip = forms.CharField(label=_('Postal Code'), max_length=50)
+        telephone = forms.CharField(label=_('Telephone'), max_length=255)
+
+    return ContactForm
+
+class NewInstitution(ReviewModelForm):
+    class Meta:
+        model = Institution
+
+    title = _('New Institution')
+
+    country = MultilingualModelChoiceField(
+                label=_('Country'),
+                queryset=CountryCode.objects.all(),
+                required=True,
+                label_field='description',)
+
+    i_type = MultilingualModelChoiceField(
+                label=_('Institution type'),
+                queryset=InstitutionType.objects.all(),
+                required=False,
+                label_field='label',)
Index: /tags/v1.0.23rc1/opentrials/repository/fixtures/first_3_trials.json
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/fixtures/first_3_trials.json (revision 628)
+++ /tags/v1.0.23rc1/opentrials/repository/fixtures/first_3_trials.json (revision 628)
@@ -0,0 +1,340 @@
+[
+  {
+    "pk": 2,
+    "model": "repository.clinicaltrial",
+    "fields": {
+      "scientific_title": "Minimal trial record (only required fields)",
+      "public_title": "",
+      "trial_id": null,
+      "inclusion_criteria": "",
+      "agemax_value": 0,
+      "agemax_unit": "-",
+      "agemin_unit": "-",
+      "scientific_acronym": "",
+      "acronym": "",
+      "target_sample_size": 0,
+      "staff_note": "",
+      "updated": "2009-10-19 21:11:43",
+      "hc_freetext": "",
+      "study_type": null,
+      "i_freetext": "",
+      "recruitment_status": null,
+      "phase": null,
+      "date_registration": null,
+      "agemin_value": 0,
+      "study_design": "",
+      "gender": "-",
+      "exclusion_criteria": "",
+      "primary_sponsor": null
+    }
+  },
+  {
+    "pk": 3,
+    "model": "repository.clinicaltrial",
+    "fields": {
+      "scientific_title": "Effect of Ascorbic Acid and Grape Seed Extract \"Vitis Vinifera L.\" on Oxidative Stress Induced by on Pump Coronary Artery by Pass Grafting Surgery",
+      "public_title": "Comparison of Ascorbic Acid and Grape Seed Extract in Oxidative Stress Induced by on Pump Heart Surgery",
+      "trial_id": null,
+      "inclusion_criteria": "Candidates for elective CABG surgery with pump for first time, 3 Vessel Disease (3VD).",
+      "agemax_value": 0,
+      "agemax_unit": "-",
+      "agemin_unit": "-",
+      "scientific_acronym": "",
+      "acronym": "",
+      "target_sample_size": 75,
+      "staff_note": "",
+      "updated": null,
+      "hc_freetext": "Condition 1: Coronary Atrery Bypass Graft (CABG).\r\nCondition 2: Atherosclerotic heart disease.\r\nCondition 3: Ischaemic cardiomyopathy.",
+      "study_type": 1,
+      "i_freetext": "Intervention 1: Control Group: without intervention.\r\nIntervention 2: Grape Seed Extract 100 mg/6h .\r\nIntervention 3: Vit C 25 mg/kg.",
+      "recruitment_status": 4,
+      "phase": 6,
+      "date_registration": null,
+      "agemin_value": 0,
+      "study_design": "Randomization: randomized. Blinding: Double blind. Placebo: not used. Assignment: Parallel. Purpose: Supportive care. Other design features: .",
+      "gender": "-",
+      "exclusion_criteria": "High risk patients, Those who need another heart surgery beside CABG, Urgent patients Diabetics, Ischemic time more than 120 min.",
+      "primary_sponsor": 2
+    }
+  },
+  {
+    "pk": 1,
+    "model": "repository.clinicaltrial",
+    "fields": {
+      "scientific_title": "A randomised, double-blind, placebo-controlled, factorial-design trial to assess the effect of aspirin and fish oil in the prevention of early thrombosis in arterio-venous fistulae in patients with Stage IV or V chronic kidney disease requiring haemodialysis",
+      "public_title": "",
+      "trial_id": null,
+      "inclusion_criteria": "1. Stage 4 or 5 chronic kidney disease\r\n2. Currently on haemodialysis or haemodialysis is planned to start within 6\r\nmonths (including patients currently on peritoneal dialysis).\r\n3. Planned AVF will be the primary haemodialysis access mechanism.\r\n4. Surgery to create an arterio-venous fistula in the upper or lower arm is planned.\r\n5. Aged over 18 years\r\n6. Life expectancy predicted to be 12 months minimum\r\n7. Treating team agreeable to patient\\'s involvement in the trial\r\n8. Informed consent ",
+      "agemax_value": 0,
+      "agemax_unit": "-",
+      "agemin_unit": "Y",
+      "scientific_acronym": "FAVOURED (Fish oil and Aspirin in Vascular acccess OUtcomes in REnal Disease)",
+      "acronym": "",
+      "target_sample_size": 1200,
+      "staff_note": "",
+      "updated": null,
+      "hc_freetext": "Early thrombosis in arterio-venous fistulae in patients with Stage IV or V chronic kidney disease requiring haemodialysis.",
+      "study_type": 1,
+      "i_freetext": "Aspirin 100 mg per day or matching placebo, commencing on the day prior to scheduled surgery and continuing for 3 months.",
+      "recruitment_status": 1,
+      "phase": 3,
+      "date_registration": null,
+      "agemin_value": 18,
+      "study_design": "",
+      "gender": "-",
+      "exclusion_criteria": "1. Revision of existing AVF rather than de novo AVF\r\n2. Medical indication for anti-platelet agent(s)\r\n3. Known intolerance of agents including hypersensitivity to aspirin\r\n4. Current use of aspirin within two weeks of commencing trial, and of fish oil within 4 weeks of commencing trial.\r\n5. Pregnancy, lactation or intention to fall pregnant during the time course of the study\r\n6. Known bleeding disorder or established diagnosis of active or suspected bleeding\r\n7. Known active peptic ulcer disease\r\n8. Already receiving anti-coagulation therapy such as warfarin\r\n9. Receiving regular anti-inflammatory agents for another indication such as\r\narthritis\r\n10.Potential non-compliance with treatment regimen in the view of the\r\ntreating clinicians\r\n11.Involved in another clinical trial where the intervention being trialled is likely to confound the outcome of this trial\r\n12.Previously randomised to this trial. ",
+      "primary_sponsor": 1
+    }
+  },
+  {
+    "pk": 1,
+    "model": "repository.trialnumber",
+    "fields": {
+      "id_number": "CRG120600100",
+      "trial": 1,
+      "issuing_authority": "Cochrane Renal Group"
+    }
+  },
+  {
+    "pk": 2,
+    "model": "repository.trialnumber",
+    "fields": {
+      "id_number": "ACTRN12607000569404",
+      "trial": 1,
+      "issuing_authority": "Australian New Zealand Clinical Trials Registry"
+    }
+  },
+  {
+    "pk": 3,
+    "model": "repository.trialnumber",
+    "fields": {
+      "id_number": "NCT00839085",
+      "trial": 3,
+      "issuing_authority": "ClinicalTrials.gov"
+    }
+  },
+  {
+    "pk": 4,
+    "model": "repository.trialnumber",
+    "fields": {
+      "id_number": "IRCT138708271460N1",
+      "trial": 3,
+      "issuing_authority": "Iranian Registry of Clinical Trials"
+    }
+  },
+  {
+    "pk": 1,
+    "model": "repository.trialsecondarysponsor",
+    "fields": {
+      "trial": 3,
+      "institution": 2
+    }
+  },
+  {
+    "pk": 1,
+    "model": "repository.institution",
+    "fields": {
+      "country": 158,
+      "name": "National Institute for Health Innovation",
+      "address": "School of Population Health\r\nTamaki Campus\r\nThe University of Auckland\r\nPrivate Bag 92019 \r\nAuckland Mail Centre\r\nAuckland 1142",
+      "creator": 1
+    }
+  },
+  {
+    "pk": 2,
+    "model": "repository.institution",
+    "fields": {
+      "country": 103,
+      "name": "Tabriz University of Medical Sciences",
+      "address": "Daneshgah St,Tabriz Univ Med Sci\r\nTabriz\r\nZip: 51656-65811",
+      "creator": 1
+    }
+  },
+  {
+    "pk": 1,
+    "model": "repository.contact",
+    "fields": {
+      "city": "Tabriz",
+      "zip": "51656-65811",
+      "firstname": "Naser",
+      "middlename": "",
+      "lastname": "Safaei",
+      "telephone": "+98-411-3357767",
+      "affiliation": 2,
+      "address": "Daneshgah St, Tabriz Univ Med Sci",
+      "country": 103,
+      "email": "drsafaei@yahoo.com",
+      "creator": 1
+    }
+  },
+  {
+    "pk": 1,
+    "model": "repository.publiccontact",
+    "fields": {
+      "status": "Active",
+      "trial": 3,
+      "contact": 1
+    }
+  },
+  {
+    "pk": 1,
+    "model": "repository.outcome",
+    "fields": {
+      "trial": 1,
+      "_order": 0,
+      "interest": "primary",
+      "description": "The primary outcome measure is (unassisted) patency of the AVF at ninety (90)days after surgery. This is defined as the presence of an audible bruit over the site of the arterio-venous anastomosis, without the need for surgical or radiological intervention from the time of creation until the time of assessment.\r\nThe assessment of patency will be made at this time even if the AVF is not yet used for haemodialysis (11). Measurement of bruit will also be taken at 1 month to better define the natural history of thrombotic events."
+    }
+  },
+  {
+    "pk": 6,
+    "model": "repository.outcome",
+    "fields": {
+      "trial": 3,
+      "_order": 0,
+      "interest": "primary",
+      "description": "Left Ventricular Ejection Fraction (LVEF). Timepoint: Before and after CABG. Method of measurement: Trans Thoracic Echocardiography (TTE)"
+    }
+  },
+  {
+    "pk": 7,
+    "model": "repository.outcome",
+    "fields": {
+      "trial": 3,
+      "_order": 0,
+      "interest": "secondary",
+      "description": "Total Antioxidant Capacity (TAC) . Timepoint: Before, middle and after CABG. Method of measurement: Biochemistry (blood sample)"
+    }
+  },
+  {
+    "pk": 2,
+    "model": "repository.outcome",
+    "fields": {
+      "trial": 1,
+      "_order": 1,
+      "interest": "secondary",
+      "description": "Functional patency at 6 months. This is defined as the ability to use the AVF for a minimum of 3 consecutive dialysis treatments to the satisfaction of the clinician(s), without the need to use alternative dialysis access, or to delay commencement of dialysis. In patients who have not needed to start dialysis,\r\nassessment of functional patency will be delayed until commencement of dialysis. "
+    }
+  },
+  {
+    "pk": 3,
+    "model": "repository.outcome",
+    "fields": {
+      "trial": 1,
+      "_order": 2,
+      "interest": "secondary",
+      "description": "Time to failure of primary patency. Time from AVF creation to need for first intervention. An event is defined as revision surgery, need for alternative access, or abandonment of AVF which ever comes first. Censored observations are defined as regaining renal function such that dialysis is not needed or still having a patent AVF at time of study analysis. There will be a minimum of 12 months follow up time for each patient. "
+    }
+  },
+  {
+    "pk": 4,
+    "model": "repository.outcome",
+    "fields": {
+      "trial": 1,
+      "_order": 3,
+      "interest": "secondary",
+      "description": "Time to failure of assisted patency. This is defined as time from AVF creation to abandonment of access. That is, radiological and surgical interventions to preserve or restore patency do not constitute failure. An event is defined as abandonment of the AVF as dialysis access. Censored observations will be as for time to failure of primary patency above. "
+    }
+  },
+  {
+    "pk": 5,
+    "model": "repository.outcome",
+    "fields": {
+      "trial": 1,
+      "_order": 4,
+      "interest": "secondary",
+      "description": "Adverse events. All serious adverse events (see section 5.4) will be collected. The analysis of this secondary outcome will focus specifically on bleeding events."
+    }
+  },
+  {
+    "pk": 1,
+    "model": "repository.descriptor",
+    "fields": {
+      "code": "C14",
+      "vocabulary": "DeCS",
+      "level": "general",
+      "text": "Cardiovascular Diseases",
+      "trial": 3,
+      "aspect": "HealthCondition",
+      "_order": 0
+    }
+  },
+  {
+    "pk": 8,
+    "model": "repository.descriptor",
+    "fields": {
+      "code": "50-81-7",
+      "vocabulary": "CAS",
+      "level": "specific",
+      "text": "L-Ascorbic acid",
+      "trial": 3,
+      "aspect": "Intervention",
+      "_order": 0
+    }
+  },
+  {
+    "pk": 9,
+    "model": "repository.descriptor",
+    "fields": {
+      "code": "C23.300.575.950.250",
+      "vocabulary": "DeCS",
+      "level": "specific",
+      "text": "Arteriovenous Fistula",
+      "trial": 1,
+      "aspect": "HealthCondition",
+      "_order": 0
+    }
+  },
+  {
+    "pk": 10,
+    "model": "repository.descriptor",
+    "fields": {
+      "code": "50-78-2",
+      "vocabulary": "CAS",
+      "level": "specific",
+      "text": "Benzoic acid, 2-(acetyloxy)-",
+      "trial": 1,
+      "aspect": "Intervention",
+      "_order": 0
+    }
+  },
+  {
+    "pk": 2,
+    "model": "repository.descriptor",
+    "fields": {
+      "code": "C14.280.647",
+      "vocabulary": "DeCS",
+      "level": "specific",
+      "text": "Myocardial Ischemia",
+      "trial": 3,
+      "aspect": "HealthCondition",
+      "_order": 1
+    }
+  },
+  {
+    "pk": 3,
+    "model": "repository.descriptor",
+    "fields": {
+      "code": "C14.280.647.250.260",
+      "vocabulary": "DeCS",
+      "level": "specific",
+      "text": "Coronary Artery Disease ",
+      "trial": 3,
+      "aspect": "HealthCondition",
+      "_order": 2
+    }
+  },
+  {
+    "pk": 7,
+    "model": "repository.descriptor",
+    "fields": {
+      "code": "C14.280.238",
+      "vocabulary": "DeCS",
+      "level": "specific",
+      "text": "Cardiomyopathies",
+      "trial": 3,
+      "aspect": "HealthCondition",
+      "_order": 3
+    }
+  }
+]
Index: /tags/v1.0.23rc1/opentrials/repository/fixtures/initial_data.json.old
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/fixtures/initial_data.json.old (revision 46)
+++ /tags/v1.0.23rc1/opentrials/repository/fixtures/initial_data.json.old (revision 46)
@@ -0,0 +1,83 @@
+[{"pk": 1,
+    "model": "registry.studytype",
+    "fields": {
+        "description": "interventional",
+        "label": "interventional"}},
+{"pk": 1,
+    "model": "registry.studytype",
+    "fields": {
+        "description": "observational",
+        "label": "observational"}},
+{"pk": 1,
+    "model": "registry.recruitmentstatus",
+    "fields": {
+        "description": "pending",
+        "label": "pending"}},
+{"pk": 2,
+    "model": "registry.recruitmentstatus",
+    "fields": {
+        "description": "recruiting",
+        "label": "recruiting"}},
+{"pk": 3,
+    "model": "registry.recruitmentstatus",
+    "fields": {
+        "description": "suspended",
+        "label": "suspended"}},
+{"pk": 1,
+    "model": "registry.clinicaltrial",
+    "fields": {
+        "public_title": "Sensitive and rapid titrimetric and spectrophotometric methods for the determination of stavudine in pharmaceuticals using bromate-bromide and three dyes",
+        "scientific_title": "Sensitive and rapid titrimetric and spectrophotometric methods for the determination of stavudine in pharmaceuticals using bromate-bromide and three dyes",
+        "recruitment_status": 1,
+        "target_sample_size": 4,
+        "study_type": 1,
+        "date_enrollment_anticipated": "2009-08-25"}},
+{"pk": 2,
+    "model": "registry.clinicaltrial",
+    "fields": {
+        "public_title": "The Brazilian time and frequency atomic standards program",
+        "scientific_title": "The Brazilian time and frequency atomic standards program",
+        "recruitment_status": 2,
+        "target_sample_size": 2,
+        "study_type": 1,
+        "date_enrollment_anticipated": "2009-08-31"}},
+{"pk": 3,
+    "model": "registry.clinicaltrial",
+    "fields": {
+        "public_title": "Thermal properties of metal-metal bonded Pd(I) complexes supported onto porous Vycor glass",
+        "scientific_title": "Thermal properties of metal-metal bonded Pd(I) complexes supported onto porous Vycor glass",
+        "recruitment_status": 1,
+        "target_sample_size": 10,
+        "study_type": 1,
+        "date_enrollment_anticipated": "2009-08-30"}},
+{"pk": 1,
+    "model": "registry.recruitmentcountry",
+    "fields": {
+        "trial": 1,
+        "country": "AX"}},
+{"pk": 2,
+    "model": "registry.recruitmentcountry",
+    "fields": {
+        "trial": 1,
+        "country": "AO"}},
+{"pk": 3,
+    "model": "registry.recruitmentcountry",
+    "fields": {
+        "trial": 2,
+        "country": "BR"}},
+{"pk": 4,
+    "model": "registry.recruitmentcountry",
+    "fields": {
+        "trial": 2,
+        "country": "BR"}},
+{"pk": 5,
+    "model": "registry.recruitmentcountry",
+    "fields": {
+        "trial": 3,
+        "country": "AF"}},
+{"pk": 6,
+    "model": "registry.recruitmentcountry",
+    "fields": {
+        "trial": 3,
+        "country": "DZ"}}
+]
Index: /tags/v1.0.23rc1/opentrials/repository/fixtures/clinicaltrial_detail.sample.xml
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/fixtures/clinicaltrial_detail.sample.xml (revision 95)
+++ /tags/v1.0.23rc1/opentrials/repository/fixtures/clinicaltrial_detail.sample.xml (revision 95)
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<trials>
+    <trial>
+        <main>
+            <trial_id>IRCT138708271460N1</trial_id>
+            <utrn/>
+            <reg_name>IRCT</reg_name>
+            <date_registration>2009-02-16</date_registration>
+            <primary_sponsor>Tabriz Univ Med Sci</primary_sponsor>
+            <public_title>Comparison of Ascorbic Acid and Grape Seed Extract in Oxidative Stress Induced by on Pump Heart Surgery</public_title>
+            <acronym />
+            <scientific_title>Effect of Ascorbic Acid and Grape Seed Extract "Vitis Vinifera L." on Oxidative Stress Induced by on Pump Coronary Artery by Pass Grafting Surgery</scientific_title>
+            <date_enrolment>2008-11-01</date_enrolment>
+            <type_enrolment>anticipated</type_enrolment>
+            <target_size>75</target_size>
+            <recruitment_status>Complete</recruitment_status>
+            <url>http://www.irct.ir/searchresult.php?id=1460&amp;number=1</url>
+            <study_type>interventional</study_type>
+            <study_design>Randomization: randomized.    Blinding:  Double blind.    Placebo: not used.    Assignment: Parallel.    Purpose: Supportive care.    Other design features:.</study_design>
+            <phase>2-3</phase>
+            <hc_freetext>Condition 1: Coronary Atrery Bypass Graft (CABG).   Condition 2: Atherosclerotic heart disease  .   Condition 3: Ischaemic cardiomyopathy.</hc_freetext>
+            <i_freetext>Intervention 1: Control Group: without intervention.   Intervention 2: Grape Seed Extract 100 mg/6h .   Intervention 3: Vit C 25 mg/kg.</i_freetext>
+        </main>
+        <contacts>
+            <contact>
+                <type>public</type>
+                <firstname>Naser safaei, MD, Surgeon</firstname>
+                <middlename/>
+                <lastname/>
+                <address>Tabriz Univ Med Sci</address>
+                <city>Tabriz</city>
+                <country1>Iran, Islamic Republic Of</country1>
+                <zip>51656-65811</zip>
+                <telephone>+98-411-3357767</telephone>
+                <email>drsafaei@yahoo.com</email>
+                <affiliation>Tabriz Univ Med Sci</affiliation>
+            </contact>
+            <contact>
+                <type>scientific</type>
+                <firstname>Dr Naser Safaei</firstname>
+                <middlename/>
+                <lastname/>
+                <address>Daneshgah St,Tabriz Univ Med Sci</address>
+                <city>Tabriz</city>
+                <country1>Iran, Islamic Republic Of</country1>
+                <zip>51656-65811</zip>
+                <telephone>+98-411-3357767</telephone>
+                <email>drsafaei@yahoo.com</email>
+                <affiliation>Tabriz Univ Med Sci</affiliation>
+            </contact>
+        </contacts>
+        <countries>
+            <country2>Iran, Islamic Republic Of</country2>
+        </countries>
+        <criteria>
+            <inclusion_criteria>Inclusion Criteria: Candidates for elective CABG surgery with pump for first time, 3 Vessel Disease (3VD). &#xD;3	Exclusion Criteria: High risk patients, Those who need another heart surgery beside CABG, Urgent patients Diabetics, Ischemic time more than 120 min.&#xD;4</inclusion_criteria>
+            <agemin>0</agemin>
+            <agemax>150</agemax>
+            <gender>Both male and female</gender>
+            <exclusion_criteria/>
+        </criteria>
+        <health_condition_code>
+            <hc_code/>
+        </health_condition_code>
+        <health_condition_keyword>
+            <hc_keyword>Ischaemic heart diseases</hc_keyword>
+            <hc_keyword>Atherosclerotic heart disease  </hc_keyword>
+            <hc_keyword>Ischaemic cardiomyopathy</hc_keyword>
+        </health_condition_keyword>
+        <intervention_code>
+            <i_code>Not applicable</i_code>
+            <i_code>Treatment: drugs</i_code>
+            <i_code>Treatment: drugs</i_code>
+            <i_code/>
+        </intervention_code>
+        <intervention_keyword>
+            <i_keyword/>
+        </intervention_keyword>
+        <primary_outcome>
+            <prim_outcome>Left Ventricular Ejection Fraction (LVEF). Timepoint: Before and after CABG. Method of measurement: Trans Thoracic Echocardiography  (TTE)</prim_outcome>
+        </primary_outcome>
+        <secondary_outcome>
+            <sec_outcome>Total Antioxidant Capacity (TAC) . Timepoint: Before, middle and after CABG. Method of measurement: Biochemistry (blood sample)</sec_outcome>
+        </secondary_outcome>
+        <secondary_sponsor>
+            <sponsor_name/>
+        </secondary_sponsor>
+        <secondary_ids>
+            <secondary_id>
+                <sec_id>NCT00839085</sec_id>
+                <issuing_authority> ClinicalTrials.gov</issuing_authority>
+            </secondary_id></secondary_ids>
+        <source_support>
+            <source_name>Tabriz University of Medical Sciences</source_name>
+        </source_support>
+    </trial>
+</trials>
Index: /tags/v1.0.23rc1/opentrials/repository/models.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/models.py (revision 964)
+++ /tags/v1.0.23rc1/opentrials/repository/models.py (revision 964)
@@ -0,0 +1,839 @@
+from django.db import models, IntegrityError
+
+from django.utils.translation import ugettext_lazy as _
+from django.utils.html import linebreaks
+from django.contrib.contenttypes import generic
+from django.contrib.contenttypes.models import ContentType
+from django.contrib.auth.models import User
+from django.contrib.sites.models import Site
+from django.core.urlresolvers import reverse
+from django.conf import settings
+from django.core.exceptions import ObjectDoesNotExist
+
+from fossil.models import Fossil, FossilManager
+from datetime import datetime
+import string
+from random import randrange, choice
+from time import sleep
+
+from utilities import safe_truncate
+
+from vocabulary.models import CountryCode, StudyPhase, StudyType, RecruitmentStatus
+from vocabulary.models import InterventionCode, InstitutionType, TimePerspective
+from vocabulary.models import StudyPurpose, InterventionAssigment, StudyMasking
+from vocabulary.models import ObservationalStudyDesign, StudyAllocation
+
+from polyglot.models import Translation
+from deleting.models import ControlledDeletion, NotDeletedManager
+
+from repository import choices
+
+from trial_validation import trial_validator
+from django.db.models.signals import post_save
+from serializers import serialize_trial, deserialize_trial
+from serializers import serialize_institution
+from serializers import serialize_contact
+from serializers import serialize_descriptor
+from serializers import serialize_outcome
+from serializers import serialize_trialnumber
+from serializers import serialize_trialsupportsource
+from serializers import serialize_trialsecondarysponsor
+
+def get_time_perspective_default():
+    return TimePerspective.objects.get(id=1)
+
+def length_truncate(text, max_size=240):
+    text = text.split('|')
+    size=max_size/len(text)
+    text = '|'.join([safe_truncate(t,size,'') for t in text])
+    return text
+
+# remove digits that look like letters and vice-versa
+# remove vowels to avoid forming words
+BASE28 = ''.join(d for d in string.digits+string.ascii_lowercase
+                   if d not in '1l0aeiou')
+
+TRIAL_ID_TRIES = 3
+
+def generate_trial_id(prefix, num_digits):
+    s = str(randrange(2,10)) # start with a numeric digit 2...9
+    s += ''.join(choice(BASE28) for i in range(1, num_digits))
+    return '-'.join([prefix, s])
+
+class TrialRegistrationDataSetModel(ControlledDeletion):
+    """More details on:
+        http://reddes.bvsalud.org/projects/clinical-trials/wiki/TrialRegistrationDataSet"""
+
+    def html_dump(self, seen=None, follow_sets=True):
+        html = [] # the enclosing <table> and </table> must be provided by the template
+        if seen is None:
+            seen = set([self.__class__.__name__])
+        for field in self._meta.fields:
+            value = getattr(self, field.name)
+            if field.rel and hasattr(value, 'html_dump'):
+                seen.add(value.__class__.__name__)
+                content = '<table bgcolor="yellow">%s</table>' % value.html_dump(seen, follow_sets=False)
+            else:
+                content = unicode(value)
+                if u'\n' in content:
+                    content = linebreaks(content)
+            html.append('<tr><th>%s</th><td>%s</td></tr>' % (field.name, content))
+        if follow_sets:
+            for field_name in dir(self):
+                try:
+                    value = getattr(self, field_name)
+                except AttributeError:
+                    continue # ignore Manager (objects attribute)
+                else:
+                    if hasattr(value, '__class__') and value.__class__.__name__=='RelatedManager':
+                        inner_html = []
+                        for rel_value in value.all():
+                            id = '#%s' % rel_value.pk
+                            if (hasattr(rel_value, 'html_dump') and
+                                    (rel_value.__class__.__name__ not in seen)):
+                                seen.add(rel_value.__class__.__name__)
+                                content = '<table>%s</table>' % rel_value.html_dump(seen, follow_sets=False)
+                            else:
+                                content = unicode(rel_value)
+                            if u'\n' in content:
+                                content = linebreaks(content)
+                            inner_html.append('<tr><th>%s</th><td>%s</td></tr>' % (id, content))
+                        content = '<table>%s</table>' % '\n\t'.join(inner_html)
+                        html.append('<tr><th>%s</th><td>%s</td></tr>' % (field_name, content))
+
+        return '\n'.join(html)
+
+
+    class Meta:
+        abstract = True
+
+class TrialsPublished(NotDeletedManager):
+    def get_query_set(self):
+        return super(TrialsPublished, self).get_query_set().filter(status__exact='published')
+
+class ClinicalTrialManager(NotDeletedManager):
+    def deserialize_for_fossil(self, data, persistent=False):
+        return deserialize_trial(data, persistent)
+
+class TrialFossilsQuerySet(models.query.QuerySet):
+    def proxies(self, language=None):
+        def get_proxy(obj):
+            ret = obj.get_object_fossil()
+            ret._language = language
+            ret.hash_code = obj.pk
+            ret.previous_revision = obj.previous_revision
+            return ret
+
+        return [get_proxy(obj) for obj in self.all()]
+
+class TrialsFossilManager(FossilManager):
+    _ctype = None
+
+    def get_query_set(self):
+        if not self._ctype:
+            self._ctype = ContentType.objects.get_for_model(ClinicalTrial)
+
+        return TrialFossilsQuerySet(PublishedTrial).filter(
+                content_type=self._ctype,
+                )
+
+    def recruiting(self):
+        return self.indexed(recruitment_status='recruiting', display='True').filter(is_most_recent=True)
+
+    def published(self, q=None):
+        if not q:
+            return self.indexed(display='True').filter(is_most_recent=True)
+        else:
+            return self.indexed(display='True', scientific_title__icontains=q).filter(is_most_recent=True) |\
+                    self.indexed(display='True', public_title__icontains=q).filter(is_most_recent=True) |\
+                    self.indexed(display='True', acronym__icontains=q).filter(is_most_recent=True) |\
+                    self.indexed(display='True', scientific_acronym__icontains=q).filter(is_most_recent=True) |\
+                    self.indexed(display='True', scientific_acronym_expansion__icontains=q).filter(is_most_recent=True) |\
+                    self.indexed(display='True', hc_freetext__icontains=q).filter(is_most_recent=True) |\
+                    self.indexed(display='True', i_freetext__icontains=q).filter(is_most_recent=True) |\
+                    self.indexed(display='True', primary_sponsor__icontains=q).filter(is_most_recent=True) |\
+                    self.indexed(display='True', scientific_contacts__icontains=q).filter(is_most_recent=True) |\
+                    self.indexed(display='True', utrn_number__icontains=q).filter(is_most_recent=True) |\
+                    self.indexed(display='True', secondary_ids__icontains=q).filter(is_most_recent=True)
+
+    def archived(self):
+        return self.indexed(display='True').filter(is_most_recent=False)
+
+    def proxies(self, language=None):
+        return self.get_query_set().proxies(language=language)
+
+class PublishedTrial(Fossil):
+    class Meta:
+        proxy = True
+        verbose_name = _('Published Trial')
+        verbose_name_plural = _('Published Trials')
+
+    objects = _default_manager = TrialsFossilManager()
+
+    @property
+    def trial_id(self):
+        try:
+            return self.indexers.key('trial_id').value
+        except ObjectDoesNotExist:
+            return ''
+
+    @property
+    def display(self):
+        try:
+            return self.indexers.key('display').value
+        except ObjectDoesNotExist:
+            return 'True'
+
+    @property
+    def status(self):
+        try:
+            return self.indexers.key('status').value
+        except ObjectDoesNotExist:
+            return 'published' if self.is_most_recent else 'archived'
+
+    @property
+    def scientific_title(self):
+        try:
+            return self.indexeds.key('scientific_title').value
+        except ObjectDoesNotExist:
+            return ''
+
+    @property
+    def public_title(self):
+        try:
+            return self.indexeds.key('public_title').value
+        except ObjectDoesNotExist:
+            return ''
+
+    @property
+    def acronym(self):
+        try:
+            return self.indexeds.key('acronym').value
+        except ObjectDoesNotExist:
+            return ''
+
+    @property
+    def scientific_acronym(self):
+        try:
+            return self.indexeds.key('scientific_acronym').value
+        except ObjectDoesNotExist:
+            return ''
+
+    @property
+    def scientific_acronym_expansion(self):
+        try:
+            return self.indexeds.key('scientific_acronym_expansion').value
+        except ObjectDoesNotExist:
+            return ''
+
+    @property
+    def hc_freetext(self):
+        try:
+            return self.indexeds.key('hc_freetext').value
+        except ObjectDoesNotExist:
+            return ''
+
+    @property
+    def i_freetext(self):
+        try:
+            return self.indexeds.key('i_freetext').value
+        except ObjectDoesNotExist:
+            return ''
+
+    @property
+    def primary_sponsor(self):
+        try:
+            return self.indexeds.key('primary_sponsor').value
+        except ObjectDoesNotExist:
+            return ''
+
+    @property
+    def scientific_contacts(self):
+        try:
+            return self.indexeds.key('scientific_contacts').value
+        except ObjectDoesNotExist:
+            return ''
+
+    @property
+    def utrn_number(self):
+        try:
+            return self.indexeds.key('utrn_number').value
+        except ObjectDoesNotExist:
+            return ''
+    @property
+    def secondary_ids(self):
+        try:
+            return self.indexeds.key('secondary_ids').value
+        except ObjectDoesNotExist:
+            return ''
+
+    def get_object_fossil(self, force_load=False):
+        if force_load or not getattr(self, '_object_fossil', None):
+            self._object_fossil = super(PublishedTrial, self).get_object_fossil()
+
+        return self._object_fossil
+    trial = property(get_object_fossil)
+
+class ClinicalTrial(TrialRegistrationDataSetModel):
+    objects = ClinicalTrialManager()
+    published = TrialsPublished()
+    fossils = TrialsFossilManager()
+
+    # TRDS 1
+    trial_id = models.CharField(_('Primary Id Number'), null=True, unique=True,
+                                max_length=255, editable=False)
+    # TRDS 2
+    date_registration = models.DateTimeField(_('Date of Registration'), null=True,
+                                         editable=False, db_index=True)
+
+    # TRDS 3 - (UTRN required for ICTRP DTD) Secondary Identifying Numbers
+    utrn_number = models.CharField(_('UTN Number'), null=True, blank=True,
+                                max_length=255, db_index=True)
+
+    # TRDS 10a
+    scientific_title = models.TextField(_('Scientific Title'),
+                                        max_length=2000)
+    # TRDS 10b
+    scientific_acronym = models.CharField(_('Scientific Acronym'), blank=True,
+                                          max_length=255)
+    # TRDS 10b
+    scientific_acronym_expansion = models.CharField(_('Scientific Acronym Expansion'),
+                                                    blank=True, max_length=255)
+    # TRDS 5
+    primary_sponsor = models.ForeignKey('Institution', null=True, blank=True,
+                                        verbose_name=_('Primary Sponsor'))
+    # TRDS 7
+    public_contact = models.ManyToManyField('Contact', through='PublicContact',
+                                            related_name='public_contact_of_set')
+    # TRDS 8
+    scientific_contact = models.ManyToManyField('Contact', through='ScientificContact',
+                                            related_name='scientific_contact_of_set')
+
+    site_contact = models.ManyToManyField('Contact', through='SiteContact',
+                                            related_name='site_contact_of_set')
+
+    # TRDS 9a
+    public_title = models.TextField(_('Public Title'), blank=True,
+                                    max_length=2000)
+    # TRDS 9b
+    acronym = models.CharField(_('Acronym'), blank=True, max_length=255)
+
+    # TRDS 9b
+    acronym_expansion = models.CharField(_('Acronym Expansion'), blank=True, max_length=255)
+
+    # TRDS 12a
+    hc_freetext = models.TextField(_('Health Condition(s)'), blank=True,
+                                   max_length=8000)
+    # TRDS 13a
+    i_freetext = models.TextField(_('Intervention(s)'), blank=True,
+                                   max_length=8000)
+
+    # TRDS 13b
+    i_code = models.ManyToManyField(InterventionCode)
+
+    # TRDS 14a
+    inclusion_criteria = models.TextField(_('Inclusion Criteria'), blank=True,
+                                          max_length=8000)
+    # TRDS 14b
+    gender = models.CharField(_('Inclusion Gender'), max_length=1,
+                              choices=choices.INCLUSION_GENDER,
+                              default=choices.INCLUSION_GENDER[0][0])
+    # TRDS 14c
+    agemin_value = models.PositiveIntegerField(_('Inclusion Minimum Age'),
+                                               default=0,null=True)
+    agemin_unit = models.CharField(_('Minimum Age Unit'), max_length=1,
+                                   choices=choices.INCLUSION_AGE_UNIT,
+                                   default=choices.INCLUSION_AGE_UNIT[0][0])
+    # TRDS 14d
+    agemax_value = models.PositiveIntegerField(_('Inclusion Maximum Age'),
+                                               default=0,null=True)
+    agemax_unit = models.CharField(_('Maximum Age Unit'), max_length=1,
+                                   choices=choices.INCLUSION_AGE_UNIT,
+                                   default=choices.INCLUSION_AGE_UNIT[0][0])
+    # TRDS 14e
+    exclusion_criteria = models.TextField(_('Exclusion Criteria'), blank=True,
+                                          max_length=8000)
+    # TRDS 15a
+    study_type = models.ForeignKey(StudyType, null=True, blank=True,
+                                   verbose_name=_('Study Type'))
+
+    # TRDS 15b
+    study_design = models.TextField(_('Study Design'), blank=True,
+                                          max_length=1000)
+    ######## begin TRDS 15b - study design details
+
+    expanded_access_program = models.NullBooleanField(_('Expanded access program'),
+                                                      null=True, blank=True)
+    purpose = models.ForeignKey(StudyPurpose, null=True, blank=True,
+                                           verbose_name=_('Study Purpose'))
+    intervention_assignment = models.ForeignKey(InterventionAssigment, null=True, blank=True,
+                                           verbose_name=_('Intervention Assignment'))
+    number_of_arms = models.PositiveIntegerField(_('Number of arms'), null=True, blank=True)
+    masking = models.ForeignKey(StudyMasking, null=True, blank=True,
+                                           verbose_name=_('Masking type'))
+    allocation = models.ForeignKey(StudyAllocation, null=True, blank=True,
+                                           verbose_name=_('Allocation type'))
+    ######## end TRDS 15b - study design details
+
+    # TRDS 15c
+    phase = models.ForeignKey(StudyPhase, null=True, blank=True,
+                              verbose_name=_('Study Phase'))
+
+    # TRDS 16a,b (type_enrollment="anticipated")
+    enrollment_start_planned = models.CharField( # yyyy-mm or yyyy-mm-dd
+        _('Planned Date of First Enrollment'), max_length=10, null=True, blank=True)
+    enrollment_start_actual = models.CharField( # yyyy-mm or yyyy-mm-dd
+        _('Actual Date of First Enrollment'), max_length=10, null=True, blank=True)
+    enrollment_end_planned = models.CharField( # yyyy-mm or yyyy-mm-dd
+        _('Planned Date of Last Enrollment'), max_length=10, null=True, blank=True)
+    enrollment_end_actual = models.CharField( # yyyy-mm or yyyy-mm-dd
+        _('Actual Date of Last Enrollment'), max_length=10, null=True, blank=True)
+
+    # TRDS 17
+    target_sample_size = models.PositiveIntegerField(_('Target Sample Size'),
+                                                       default=0)
+    # TRDS 18
+    recruitment_status = models.ForeignKey(RecruitmentStatus, null=True, blank=True,
+                                           verbose_name=_('Recruitment Status'))
+
+    # TRDS 11 - Countries of Recruitment
+    recruitment_country = models.ManyToManyField(CountryCode,
+        help_text=u'Several countries may be selected, one at a time')
+
+    #Observational filelds
+    is_observational = models.BooleanField(default=False, null=False)
+
+
+    time_perspective = models.ForeignKey(TimePerspective, null=True, blank=True,
+                                   default=get_time_perspective_default,
+                                   verbose_name=_('Time Perspective'))
+
+    observational_study_design = models.ForeignKey(ObservationalStudyDesign,
+                                                   null=True, blank=True,
+                                                   verbose_name=_('Observational Study Design')
+                                                   )
+
+    ################################### internal use, administrative fields ###
+    created = models.DateTimeField(default=datetime.now, editable=False)
+    updated = models.DateTimeField(_('Last Update'), null=True, editable=False)
+    exported = models.DateTimeField(null=True, editable=False)
+    status = models.CharField(_('Status'), max_length=64,
+                              choices=choices.TRIAL_RECORD_STATUS,
+                              default=choices.TRIAL_RECORD_STATUS[0][0])
+    staff_note = models.CharField(_('Record Note (staff use only)'),
+                                  max_length='255',
+                                  blank=True)
+    language = models.CharField(_('Submission language'), max_length=10,
+                                choices=settings.MANAGED_LANGUAGES_CHOICES,
+                                default=settings.DEFAULT_SUBMISSION_LANGUAGE)
+
+    translations = generic.GenericRelation('ClinicalTrialTranslation')
+
+    class Meta:
+        ordering = ['-updated',]
+
+    def save(self, *args, **kwargs):
+        if self.id:
+            self.updated = datetime.now()
+        if self.status == choices.PUBLISHED_STATUS and not self.trial_id:
+            # assigns the date of publication/registration
+            self.date_registration = datetime.now()
+
+            for i in range(TRIAL_ID_TRIES):
+                self.trial_id = generate_trial_id(settings.TRIAL_ID_PREFIX, settings.TRIAL_ID_DIGITS)
+                try:
+                    super(ClinicalTrial, self).save(*args, **kwargs)
+                except IntegrityError:
+                    if i < TRIAL_ID_TRIES:
+                        sleep(2**i) # wait to try again
+                    else:
+                        raise # all tries exhausted: give up
+                else:
+                    break # no need to try again
+        else:
+            super(ClinicalTrial, self).save(*args, **kwargs)
+
+    def identifier(self):
+        return self.trial_id or '(req:%s)' % self.pk
+
+    def short_title(self):
+        return safe_truncate(self.main_title(), 120)
+
+    def very_short_title(self):
+        tit = u'%s - %s' % (self.identifier(),
+                            self.short_title())
+        return safe_truncate(tit, 60)
+
+    def main_title(self):
+        if self.public_title:
+            return self.public_title
+        else:
+            return self.scientific_title
+
+    def __unicode__(self):
+        return u'%s %s' % (self.identifier(), self.short_title())
+
+    def trial_id_display(self):
+        ''' return the trial id or an explicit message it is None '''
+        if self.trial_id:
+            return self.trial_id
+        else:
+            msg = 'not assigned (request #%)' % self.pk
+
+    def acronym_display(self):
+        if self.acronym_expansion:
+            return u'%s: %s' % (self.acronym, self.acronym_expansion)
+        else:
+            return self.acronym
+
+    def scientific_acronym_display(self):
+        if self.scientific_acronym_expansion:
+            return u'%s: %s' % (self.scientific_acronym, self.scientific_acronym_expansion)
+        else:
+            return self.scientific_acronym
+
+    def record_status(self):
+        return self.submission.status
+
+    #TRDS 3 - Secondarty ID Numbers
+    def trial_number(self):
+        return self.trialnumber_set.all().select_related();
+
+    # TRDS 4 - Source(s) of Monetary Support
+    def support_sources(self):
+        return self.trialsupportsource_set.all()
+
+    # TRDS 6 - Secondary Sponsor(s)
+    def secondary_sponsors(self):
+        return self.trialsecondarysponsor_set.all()
+
+    def updated_str(self):
+        return self.updated.strftime('%Y-%m-%d %H:%M')
+    updated_str.short_description = _('Updated')
+
+    def related_health_conditions(self, aspect, level):
+        ''' return set of hc-code or keywords related to this trial with a
+            given relationship
+        '''
+        return self.descriptor_set.filter(aspect=aspect, level=level).select_related()
+
+    # TRDS 11 - Countries of Recruitment
+    def trial_recruitment_country(self):
+        ''' return set of countries of recruitment related to this trial with
+        '''
+        return self.recruitment_country.all().select_related()
+
+    #TRDS 12b - Health Condition Codes are generic, high level descriptors
+    def hc_code(self):
+        ''' return set of HC-Code related to this trial with
+            aspect = 'HealthCondition'
+            level  = 'general'
+        '''
+        return self.related_health_conditions('HealthCondition','general')
+
+    #TRDS 12c - Health Condition Keywords are specific descriptors
+    def hc_keyword(self):
+        ''' return set of HC-Code related to this trial with
+            aspect = 'HealthCondition'
+            level  = 'specific'
+        '''
+        return self.related_health_conditions('HealthCondition','specific')
+
+    #TRDS 13b - Intervetion Code
+    def intervention_code(self):
+        ''' return set of Intervention Code related to this trial with
+        '''
+        return self.i_code.all().select_related()
+
+    #TRDS 13c - Intervention Keyword
+    def intervention_keyword(self):
+        ''' return set of Intervention Keyword related to this trial with
+        '''
+        return self.descriptor_set.filter(aspect='Intervention').select_related()
+
+    #TRDS 19 - Primary Outcomes
+    def primary_outcomes(self):
+        ''' return set of Primary Outcomes related to this trial with
+        '''
+        return self.outcome_set.filter(interest='primary').select_related()
+
+    #TRDS 20 - Secondary Outcomes
+    def secondary_outcomes(self):
+        ''' return set of Secondary Outcomes related to this trial with
+        '''
+        return self.outcome_set.filter(interest='secondary').select_related()
+
+    def public_contacts(self):
+        return self.public_contact.all().select_related()
+
+    def scientific_contacts(self):
+        return self.scientific_contact.all().select_related()
+
+    def site_contacts(self):
+        return [ st.contact for st in self.sitecontact_set.all().select_related() ]
+
+    def trial_attach(self):
+        return self.submission.attachment_set.all().select_related()
+
+    def serialize_for_fossil(self, as_string=True):
+        return serialize_trial(self, as_string, attrs_to_ignore=['status','_deleted'])
+
+    @property
+    def public_url(self):
+        return reverse('repository.trial_registered', kwargs={'trial_fossil_id': self.trial_id})
+
+    def create_fossil(self):
+        fossil = PublishedTrial.objects.create_for_object(self)
+        fossil.set_indexer(key='trial_id', value=self.trial_id)
+        fossil.set_indexer(key='status', value=self.status)
+        fossil.set_indexer(key='display', value='True')
+
+        fossil.set_indexer(key='scientific_title', value=length_truncate("%s%s" % (self.scientific_title, '|'.join([trans.scientific_title for trans in self.translations.all()]))))
+        fossil.set_indexer(key='public_title', value=length_truncate("%s%s" % (self.public_title, '|'.join([trans.public_title for trans in self.translations.all()]))))
+        fossil.set_indexer(key='acronym', value="%s%s" % (self.acronym, '|'.join([trans.acronym for trans in self.translations.all()])))
+        fossil.set_indexer(key='scientific_acronym', value="%s%s" % (self.scientific_acronym, '|'.join([trans.scientific_acronym for trans in self.translations.all()])))
+        fossil.set_indexer(key='scientific_acronym_expansion', value="%s%s" % (self.scientific_acronym_expansion, '|'.join([trans.scientific_acronym_expansion for trans in self.translations.all()])))
+        fossil.set_indexer(key='hc_freetext', value=length_truncate("%s%s" % (self.hc_freetext, '|'.join([trans.hc_freetext for trans in self.translations.all()]))))
+        fossil.set_indexer(key='i_freetext', value=length_truncate("%s%s" % (self.i_freetext, '|'.join([trans.i_freetext for trans in self.translations.all()]))))
+        fossil.set_indexer(key='primary_sponsor', value=self.primary_sponsor.name)
+        fossil.set_indexer(key='scientific_contacts', value="%s" % ('|'.join(["%s|%s" % (contact.name(),contact.email) for contact in self.scientific_contacts()])))
+        fossil.set_indexer(key='utrn_number', value=self.utrn_number)
+        fossil.set_indexer(key='secondary_ids', value="%s" % ('|'.join([t_number.id_number for t_number in self.trial_number()])))
+
+
+        if self.recruitment_status:
+            fossil.set_indexer(key='recruitment_status', value=self.recruitment_status.label)
+
+        return fossil
+
+# Sets validation model to ClinicalTrial
+trial_validator.model = ClinicalTrial
+
+
+class ClinicalTrialTranslation(Translation):
+    # TRDS 10a
+    scientific_title = models.TextField(_('Scientific Title'), max_length=2000)
+    # TRDS 10b
+    scientific_acronym = models.CharField(_('Scientific Acronym'), blank=True, max_length=255)
+    # TRDS 10b
+    scientific_acronym_expansion = models.CharField(_('Scientific Acronym Expansion'), blank=True, max_length=255)
+    # TRDS 9a
+    public_title = models.TextField(_('Public Title'), blank=True, max_length=2000)
+    # TRDS 9b
+    acronym = models.CharField(_('Acronym'), blank=True, max_length=255)
+    # TRDS 9b
+    acronym_expansion = models.CharField(_('Acronym Expansion'), blank=True, max_length=255)
+    # TRDS 12a
+    hc_freetext = models.TextField(_('Health Condition(s)'), blank=True, max_length=8000)
+    # TRDS 13a
+    i_freetext = models.TextField(_('Intervention(s)'), blank=True, max_length=8000)
+    # TRDS 14a
+    inclusion_criteria = models.TextField(_('Inclusion Criteria'), blank=True, max_length=8000)
+    # TRDS 14e
+    exclusion_criteria = models.TextField(_('Exclusion Criteria'), blank=True, max_length=8000)
+    # TRDS 15b
+    study_design = models.TextField(_('Study Design'), blank=True, max_length=1000)
+
+    # This method is here just to be an example
+    #@classmethod
+    #def get_multilingual_fields(cls):
+    #    return ['public_title']
+
+    def serialize_for_fossil(self, as_string=True):
+        return serialize_trial(self, as_string, attrs_to_ignore=['content_type','object_id'])
+
+################################### Entities linked to a Clinical Trial ###
+
+# TRDS 3 - Secondary Identifying Numbers
+
+class TrialNumber(TrialRegistrationDataSetModel):
+    trial = models.ForeignKey(ClinicalTrial)
+    issuing_authority = models.CharField(_('Issuing Authority'),
+                                         max_length=255, db_index=True,)
+    id_number = models.CharField(_('Secondary Id Number'),
+                                max_length=255, db_index=True)
+
+    def __unicode__(self):
+        return u'%s: %s' % (self.issuing_authority, self.id_number)
+
+    def serialize_for_fossil(self, as_string=True):
+        return serialize_trialnumber(self, as_string)
+
+# TRDS 6 - Secondary Sponsor(s)
+class TrialSecondarySponsor(TrialRegistrationDataSetModel):
+    trial = models.ForeignKey(ClinicalTrial)
+    institution = models.ForeignKey('Institution', verbose_name=_('Institution'))
+
+    def __unicode__(self):
+        return u'%s' % self.institution
+
+    def serialize_for_fossil(self, as_string=True):
+        return serialize_trialsecondarysponsor(self, as_string)
+
+# TRDS 4 - Source(s) of Monetary Support
+class TrialSupportSource(TrialRegistrationDataSetModel):
+    trial = models.ForeignKey(ClinicalTrial)
+    institution = models.ForeignKey('Institution', verbose_name=_('Institution'))
+
+    def __unicode__(self):
+        return u'%s' % self.institution
+
+    def serialize_for_fossil(self, as_string=True):
+        return serialize_trialsupportsource(self, as_string)
+
+# TRDS 5 - Primary Sponsor
+
+class Institution(TrialRegistrationDataSetModel):
+    name = models.CharField(_('Name'), max_length=255)
+    address = models.TextField(_('Postal Address'), max_length=1500, blank=True)
+    country = models.ForeignKey(CountryCode, verbose_name=_('Country'))
+    creator = models.ForeignKey(User, related_name='institution_creator', editable=False)
+    i_type = models.ForeignKey(InstitutionType, null=True, blank=True,
+                                           verbose_name=_('Institution type'))
+
+    def __unicode__(self):
+        return safe_truncate(self.name, 120)
+
+    def serialize_for_fossil(self, as_string=True):
+        return serialize_institution(self, as_string)
+
+# TRDS 7 - Contact for Public Queries
+# TRDS 8 - Contact for Scientific Queries
+
+class Contact(TrialRegistrationDataSetModel):
+    firstname = models.CharField(_('First Name'), max_length=50)
+    middlename = models.CharField(_('Middle Name'), max_length=50, blank=True)
+    lastname = models.CharField(_('Last Name'), max_length=50)
+    email = models.EmailField(_('E-mail'), max_length=255)
+    affiliation = models.ForeignKey(Institution, null=True, blank=True,
+                                    verbose_name=_('Institution'))
+    address = models.CharField(_('Address'), max_length=255, blank=True)
+    city = models.CharField(_('City'), max_length=255, blank=True)
+    country = models.ForeignKey(CountryCode, null=True, blank=True,
+                                verbose_name=_('Country'),)
+    zip = models.CharField(_('Postal Code'), max_length=50, blank=True)
+    telephone = models.CharField(_('Telephone'), max_length=255, blank=True)
+
+    creator = models.ForeignKey(User, related_name='contact_creator', editable=False)
+
+    def name(self):
+        names = self.firstname + u' ' + self.middlename + u' ' + self.lastname
+        return u' '.join(names.split())
+
+    def __unicode__(self):
+        return self.name()
+
+    def serialize_for_fossil(self, as_string=True):
+        return serialize_contact(self, as_string)
+
+class PublicContact(TrialRegistrationDataSetModel):
+    trial = models.ForeignKey(ClinicalTrial)
+    contact = models.ForeignKey(Contact, verbose_name=_('Contact'))
+    status = models.CharField(_('Status'), max_length=255,
+                            choices = choices.CONTACT_STATUS,
+                            default = choices.CONTACT_STATUS[0][0])
+    class Meta:
+        unique_together = ('trial', 'contact')
+
+    def __unicode__(self):
+        return u'Public Contact for %s: %s (%s)' % (self.trial.short_title(),
+                                     self.contact.name(), self.status)
+
+class ScientificContact(TrialRegistrationDataSetModel):
+    trial = models.ForeignKey(ClinicalTrial)
+    contact = models.ForeignKey(Contact, verbose_name=_('Contact'))
+    status = models.CharField(_('Status'), max_length=255,
+                            choices = choices.CONTACT_STATUS,
+                            default = choices.CONTACT_STATUS[0][0])
+    class Meta:
+        unique_together = ('trial', 'contact')
+
+    def __unicode__(self):
+        return u'Scientific Contact for %s: %s (%s)' % (self.trial.short_title(),
+                                     self.contact.name(), self.status)
+
+class SiteContact(TrialRegistrationDataSetModel):
+    trial = models.ForeignKey(ClinicalTrial)
+    contact = models.ForeignKey(Contact, verbose_name=_('Contact'))
+    status = models.CharField(_('Status'), max_length=255,
+                            choices = choices.CONTACT_STATUS,
+                            default = choices.CONTACT_STATUS[0][0])
+    class Meta:
+        unique_together = ('trial', 'contact')
+
+    def __unicode__(self):
+        return u'Site Contact for %s: %s (%s)' % (self.trial.short_title(),
+                                     self.contact.name(), self.status)
+
+# TRDS 19 - Primary Outcome(s)
+# TRDS 20 - Key Secondary Outcome(s)
+
+class Outcome(TrialRegistrationDataSetModel):
+    trial = models.ForeignKey(ClinicalTrial)
+    interest = models.CharField(_('Interest'), max_length=32,
+                               choices=choices.OUTCOME_INTEREST,
+                               default = choices.OUTCOME_INTEREST[0][0])
+    description = models.TextField(_('Outcome Description'), max_length=8000)
+
+    translations = generic.GenericRelation('OutcomeTranslation')
+
+    class Meta:
+        order_with_respect_to = 'trial'
+
+    def __unicode__(self):
+        return safe_truncate(self.description, 80)
+
+    def translations_all(self):
+        return self.translations.all()
+
+    def serialize_for_fossil(self, as_string=True):
+        return serialize_outcome(self, as_string)
+
+class OutcomeTranslation(Translation):
+    description = models.TextField(_('Outcome Description'), max_length=8000)
+
+
+class Descriptor(TrialRegistrationDataSetModel):
+    class Meta:
+        order_with_respect_to = 'trial'
+
+    trial = models.ForeignKey(ClinicalTrial)
+    aspect = models.CharField(_('Trial Aspect'), max_length=255,
+                        choices=choices.TRIAL_ASPECT)
+    vocabulary = models.CharField(_('Vocabulary'), max_length=255,
+                        choices=choices.DESCRIPTOR_VOCABULARY)
+    version = models.CharField(_('Version'), max_length=64, blank=True)
+    level = models.CharField(_('Level'), max_length=64,
+                        choices=choices.DESCRIPTOR_LEVEL)
+    code = models.CharField(_('Code'), max_length=255)
+    text = models.CharField(_('Text'), max_length=255, blank=True)
+
+    translations = generic.GenericRelation('DescriptorTranslation')
+
+    def __unicode__(self):
+        return u'[%s] %s: %s' % (self.vocabulary, self.code, self.text)
+
+    def trial_identifier(self):
+        return self.trial.identifier()
+
+    def translations_all(self):
+        return self.translations.all()
+
+    def serialize_for_fossil(self, as_string=True):
+        return serialize_descriptor(self, as_string)
+
+class DescriptorTranslation(Translation):
+    text = models.CharField(_('Text'), max_length=255, blank=True)
+
+# SIGNALS
+
+def clinicaltrial_post_save(sender, instance, signal, **kwargs):
+    # This signal calls validation method to validate the instance according to
+    # rules made with mandatory fields but aren't obligatory on the model
+    trial_validator.validate(instance)
+
+    # Creates a fossil if the status is equal to 'published'
+    if instance.status == choices.PUBLISHED_STATUS:
+        instance.create_fossil()
+
+post_save.connect(clinicaltrial_post_save, sender=ClinicalTrial)
Index: /tags/v1.0.23rc1/opentrials/repository/urls.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/urls.py (revision 902)
+++ /tags/v1.0.23rc1/opentrials/repository/urls.py (revision 902)
@@ -0,0 +1,35 @@
+from django.conf.urls.defaults import *
+from django.views.generic.list_detail import object_detail, object_list
+
+from repository.models import ClinicalTrial
+
+from repository.views import edit_trial_index, full_view, index, step_1, step_2, step_3
+from repository.views import step_4, step_5, step_6, step_7, step_8, step_9, new_institution
+from repository.views import trial_registered, trial_view, recruiting, trial_ictrp, trial_otxml
+from repository.views import all_trials_ictrp
+
+
+urlpatterns = patterns('',
+    url(r'^edit/(\d+)/$', edit_trial_index, name='repository.edittrial'),
+    url(r'^view/(?P<trial_pk>\d+)/$', trial_view, name='repository.trialview'),
+    url(r'^new_institution/$', new_institution, name='new_institution'),
+    url(r'^step_1/(\d+)/$', step_1, name='step_1'),
+    url(r'^step_2/(\d+)/$', step_2, name='step_2'),
+    url(r'^step_3/(\d+)/$', step_3, name='step_3'),
+    url(r'^step_4/(\d+)/$', step_4, name='step_4'),
+    url(r'^step_5/(\d+)/$', step_5, name='step_5'),
+    url(r'^step_6/(\d+)/$', step_6, name='step_6'),
+    url(r'^step_7/(\d+)/$', step_7, name='step_7'),
+    url(r'^step_8/(\d+)/$', step_8, name='step_8'),
+    url(r'^step_9/(\d+)/$', step_9, name='step_9'),
+    #public
+    url(r'^recruiting/$', recruiting, name='repository.recruiting'),
+    url(r'^(?P<trial_fossil_id>[0-9A-Za-z-]+)/$', trial_registered, name='repository.trial_registered'),
+    url(r'^(?P<trial_fossil_id>[0-9A-Za-z-]+)/xml/ictrp/$', trial_ictrp, name='repository.trial_ictrp'),
+    url(r'^all/xml/ictrp$', all_trials_ictrp),
+    url(r'^(?P<trial_fossil_id>[0-9A-Za-z-]+)/xml/ot/$', trial_otxml, name='repository.trial_otxml'),
+    url(r'^(?P<trial_fossil_id>[0-9A-Za-z-]+)/v(?P<trial_version>\d+)/$', trial_registered, name='repository.trial_registered_version'),
+    url(r'^(?P<trial_fossil_id>[0-9A-Za-z-]+)/v(?P<trial_version>\d+)/xml/ictrp/$', trial_ictrp, name='repository.trial_ictrp_version'),
+    url(r'^(?P<trial_fossil_id>[0-9A-Za-z-]+)/v(?P<trial_version>\d+)/xml/opentrials/$', trial_otxml, name='repository.trial_otxml_version'),
+    url(r'^$', index, name='repository.index'),
+)
Index: /tags/v1.0.23rc1/opentrials/repository/trial_validation.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/trial_validation.py (revision 750)
+++ /tags/v1.0.23rc1/opentrials/repository/trial_validation.py (revision 750)
@@ -0,0 +1,294 @@
+"""
+This module aims to be the refactored code of old function "reviewapp/signals.py:check_trial_fields"
+
+The method trial_validator.register() was created in replacement to STEP_FORM_MATRIX
+"""
+
+import re
+
+from django.template.defaultfilters import slugify
+from django.utils import simplejson
+
+from reviewapp.consts import STEP_STATES, REMARK, MISSING, PARTIAL, COMPLETE, TRIAL_FORMS
+from polyglot.multilingual_forms import BaseMultilingualWidget
+
+FIELDS = {
+    TRIAL_FORMS[0]: {
+        'scientific_title': {'required': True, 'type': 'text', 'poly': True},
+        'scientific_acronym': {'required': False, 'type': 'text', 'poly': True},
+        'scientific_acronym_expansion': {'required': False, 'type': 'text', 'poly': True},
+        'public_title': {'required': False, 'type': 'text', 'poly': True},
+        'acronym': {'required': False, 'type': 'text', 'poly': True},
+        'acronym_expansion': {'required': False, 'type': 'text', 'poly': True},
+        'utrn_number': {'required': True, 'type': 'text', 'poly': False},
+    }, 
+    TRIAL_FORMS[1]: {
+        'primary_sponsor': {'required': True, 'type': 'text', 'poly': False}
+    },
+    TRIAL_FORMS[2]: {
+        'hc_freetext': {'required': True, 'type': 'text', 'poly': True}
+    },
+    TRIAL_FORMS[3]: {
+        'i_freetext': {'required': True, 'type': 'text', 'poly': True}, 
+        'i_code': {'required': True, 'type': 'mult', 'poly': False, 'queryset': None}
+    },
+    TRIAL_FORMS[4]: {
+        'recruitment_status': {'required': True, 'type': 'text', 'poly': False}, 
+        'recruitment_country': {'required': True, 'type': 'mult', 'poly': False, 'queryset': None},
+        #'enrollment_start_planned': {'required': True, 'type': 'text', 'poly': False},
+        #'enrollment_end_planned': {'required': True, 'type': 'text', 'poly': False},  
+        'target_sample_size': {'required': True, 'type': 'text', 'poly': False}, 
+        'inclusion_criteria': {'required': True, 'type': 'text', 'poly': True},
+        'exclusion_criteria': {'required': True, 'type': 'text', 'poly': True},  
+        'gender': {'required': True, 'type': 'text', 'poly': False}, 
+        'agemin_value': {'required': True, 'type': 'text', 'poly': False}, 
+        'agemin_unit': {'required': True, 'type': 'text', 'poly': False}, 
+        'agemax_value': {'required': True, 'type': 'text', 'poly': False}, 
+        'agemax_unit': {'required': True, 'type': 'text', 'poly': False}, 
+    },
+    TRIAL_FORMS[5]: {
+        #'study_type': {'required': True, 'type': 'text', 'poly': False}, 
+        'study_design': {'required': True, 'type': 'text', 'poly': True}, 
+        'phase': {'required': True, 'type': 'text', 'poly': False},
+        #'expanded_access_program': {'required': True, 'type': 'text', 'poly': False}, 
+        'intervention_assignment': {'required': True, 'type': 'text', 'poly': False}, 
+        'number_of_arms': {'required': True, 'type': 'text', 'poly': False},
+        'masking': {'required': True, 'type': 'text', 'poly': False},
+        'allocation': {'required': True, 'type': 'text', 'poly': False},
+        'purpose': {'required': True, 'type': 'text', 'poly': False}
+    },
+    TRIAL_FORMS[6]: {},
+    TRIAL_FORMS[7]: {}
+}
+
+class TrialValidator(object):
+    steps_forms = None # Replaced STEP_FORM_MATRIX
+    model = None
+    
+    def __init__(self):
+        self.steps_forms = {}
+
+    def register(self, step, forms):
+        self.steps_forms[step] = forms
+
+    def validate(self, instance):
+        """
+        FIXME: Some thoughts about this function:
+
+        - Should have comments/docs/tests
+        - Should be refactored (in progress)
+        - Seems to be too complex for what it does
+        """
+
+        if not hasattr(instance, 'submission'):
+            return
+        
+        fields_status = {}
+        mandatory_languages = [lang.lower() for lang in instance.submission.get_mandatory_languages()]
+
+        # Setting instance queryset on validation fields
+        FIELDS[TRIAL_FORMS[3]]['i_code']['queryset'] = instance.intervention_code()
+        FIELDS[TRIAL_FORMS[4]]['recruitment_country']['queryset'] = instance.recruitment_country.all()
+
+        # attachment
+        remarks = instance.submission.remark_set.filter(status='open').filter(context=slugify(TRIAL_FORMS[8])).count()
+        count = instance.submission.attachment_set.all().count()
+        for lang in mandatory_languages:
+            if remarks > 0:
+                fields_status.update({lang: {TRIAL_FORMS[8]: REMARK}})
+            elif count == 0:
+                fields_status.update({lang: {TRIAL_FORMS[8]: PARTIAL}})
+            else:
+                fields_status.update({lang: {TRIAL_FORMS[8]: COMPLETE}})
+
+        for step, forms in self.steps_forms.items():
+        
+            step_status = {}
+            
+            remarks = instance.submission.remark_set.filter(status='open').filter(context=slugify(step)).count()
+            if remarks > 0:
+                for lang in mandatory_languages:
+                    step_status.update({lang: REMARK})
+            else:
+                for form in forms:
+                    if hasattr(form.Meta,'queryset'):
+                        count = form.Meta.queryset.filter(trial=instance).count()
+                        
+                        for lang in mandatory_languages:
+                            if count < form.Meta.min_required:
+                                step_status.update({lang: MISSING})
+                            elif count == 0:
+                                if step_status.get(lang, '') != MISSING:
+                                    step_status.update({lang: PARTIAL})
+                            else:
+                                if not form.Meta.polyglot:
+                                    if step_status.get(lang, '') == '':
+                                        step_status.update({lang: COMPLETE})
+                                else:
+                                    for obj in form.Meta.queryset.filter(trial=instance):
+                                        for field in form.Meta.polyglot_fields:
+                                            if lang == 'en':
+                                                value = [getattr(obj, field)]
+                                            else:
+                                                list_value = obj.translations.filter(language=lang)
+                                                if len(list_value) > 0:
+                                                    value = getattr(list_value[0], field)
+                                                else:
+                                                    value = None
+
+                                            if value is None:
+                                                if form.Meta.min_required != 0:
+                                                    step_status.update({lang: MISSING})
+                                                else:
+                                                    if step_status.get(lang, '') != MISSING:
+                                                        step_status.update({lang: PARTIAL})
+                                            elif type(value) is str or type(value) is unicode:
+                                                if re.match('^\s*$', value):
+                                                    if step_status.get(lang, '') != MISSING:
+                                                        step_status.update({lang: MISSING})
+                                                    else:
+                                                        if step_status.get(lang, '') != MISSING:
+                                                            step_status.update({lang: PARTIAL})
+                                                else:
+                                                    if step_status.get(lang, '') == '':
+                                                        step_status.update({lang: COMPLETE})
+                                            else:
+                                                if len(str(value)) == 0:
+                                                    if form.Meta.min_required != 0:
+                                                        step_status.update({lang: MISSING})
+                                                    else:
+                                                        if step_status.get(lang, '') != MISSING:
+                                                            step_status.update({lang: PARTIAL})
+                                                else:
+                                                    if step_status.get(lang, '') == '':
+                                                        step_status.update({lang: COMPLETE})
+                    
+                    else:
+                        if hasattr(form.Meta,'model'):
+                            if form.Meta.model == self.model:
+                                check_fields = FIELDS[step]
+                                for field in form.base_fields.keys():
+                                    values = {}
+                                    if field in check_fields.keys():
+                                        if check_fields[field]['type'] == 'text':
+                                            values.update({'en': getattr(instance, field)})
+                                            
+                                            for trans in instance.translations.all():
+                                                if trans.language.lower() in mandatory_languages:
+                                                    if check_fields[field]['poly']:
+                                                        values.update({trans.language.lower(): getattr(trans, field)})
+                                                    else:
+                                                        values.update({trans.language.lower(): values['en']})
+                                                        
+                                            for lang, value in values.items():
+                                                if value is None:
+                                                    if check_fields[field]['required']:
+                                                        step_status.update({lang: MISSING})
+                                                    else:
+                                                        if step_status.get(lang, '') != MISSING:
+                                                            step_status.update({lang: PARTIAL})
+                                                elif type(value) is str or type(value) is unicode:
+                                                    if re.match('^\s*$', value):
+                                                        if check_fields[field]['required']:
+                                                            step_status.update({lang: MISSING})
+                                                        else:
+                                                            if step_status.get(lang, '') != MISSING:
+                                                                step_status.update({lang: PARTIAL})
+                                                    else:
+                                                        if step_status.get(lang, '') == '':
+                                                            step_status.update({lang: COMPLETE})
+                                                else:
+                                                    if len(str(value)) == 0:
+                                                        if check_fields[field]['required']:
+                                                            step_status.update({lang: MISSING})
+                                                        else:
+                                                            if step_status.get(lang, '') != MISSING:
+                                                                step_status.update({lang: PARTIAL})
+                                                    else:
+                                                        if step_status.get(lang, '') == '':
+                                                            step_status.update({lang: COMPLETE})
+                                        
+                                        else: 
+                                            if check_fields[field]['type'] == 'mult':
+                                                count = check_fields[field]['queryset'].count()
+
+                                                for lang in mandatory_languages:
+                                                    if count < 1:
+                                                        step_status.update({lang: MISSING})
+                                                    else:
+                                                        if step_status.get(lang, '') == '':
+                                                            step_status.update({lang: COMPLETE})
+
+            for language, status in step_status.items():
+                if fields_status.get(language) is None:
+                    fields_status[language] = {step: status}
+                else:
+                    fields_status[language].update({step: status})
+
+
+        # Stores the serialized dictionary with fields statuses in the submission, to be
+        # used in further later, when showing the form (also to block before the trial go
+        # to the next state)
+        instance.submission.fields_status = simplejson.dumps(fields_status)
+        instance.submission.save()
+
+    def field_is_required(self, form, field_name):
+        """Returns a boolean value about this is a required field according to validation rules"""
+
+        # Returns this is or is not a required field
+        try:
+            rules = self.get_rules_by_field(form, field_name)
+
+            if rules:
+                return rules['required']
+        except KeyError:
+            pass
+    
+    def get_rules_by_field(self, form, field_name):
+        """Returns a dictionary with rules from constant FIELDS for a given field."""
+
+        # Gets step where the given form is
+        step_in = None
+        for step, forms in self.steps_forms.items():
+            if form.__class__ in forms:
+                step_in = step
+                break
+
+        # Returns the rules from a dictionary
+        try:
+            return FIELDS[step_in][field_name]
+        except KeyError:
+            pass
+
+    def get_field_status(self, form, field_name, instance):
+        """Returns the status of a given field, for a given instance.submission"""
+
+        rules = self.get_rules_by_field(form, field_name)
+
+        if rules and rules['required']:
+            if field_name in form.fields:
+                field = form.fields[field_name]
+                field_value = form.initial.get(field_name, None)
+
+                # For multilingual fields
+                if isinstance(field.widget, BaseMultilingualWidget):
+                    # Default language value (english)
+                    values = [field_value]
+
+                    # Values for available languages (except to english)
+                    for lang in field.available_languages:
+                        if lang != 'en':
+                            values.append(field.widget.get_value_by_language(field_name, field_value, lang))
+
+                    # Returns "required" if any of translation values is not valid
+                    if not all(values):
+                        return 'required'
+
+                # For common fields
+                elif not field_value:
+                    return 'required'
+
+        return ''
+
+trial_validator = TrialValidator()
+
Index: /tags/v1.0.23rc1/opentrials/repository/migrations/0002_date_registration.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/migrations/0002_date_registration.py (revision 703)
+++ /tags/v1.0.23rc1/opentrials/repository/migrations/0002_date_registration.py (revision 703)
@@ -0,0 +1,296 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Changing field 'ClinicalTrial.date_registration'
+        db.alter_column('repository_clinicaltrial', 'date_registration', self.gf('django.db.models.fields.DateTimeField')(null=True))
+
+
+    def backwards(self, orm):
+        
+        # Changing field 'ClinicalTrial.date_registration'
+        db.alter_column('repository_clinicaltrial', 'date_registration', self.gf('django.db.models.fields.DateField')(null=True))
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'repository.clinicaltrial': {
+            'Meta': {'ordering': "['-updated']", 'object_name': 'ClinicalTrial'},
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'agemax_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemax_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'agemin_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemin_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'allocation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyAllocation']", 'null': 'True', 'blank': 'True'}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'date_registration': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}),
+            'enrollment_end_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_end_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'expanded_access_program': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+            'exported': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'gender': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_code': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.InterventionCode']", 'symmetrical': 'False'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'intervention_assignment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.InterventionAssigment']", 'null': 'True', 'blank': 'True'}),
+            'masking': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyMasking']", 'null': 'True', 'blank': 'True'}),
+            'number_of_arms': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'phase': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPhase']", 'null': 'True', 'blank': 'True'}),
+            'primary_sponsor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'public_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'public_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.PublicContact']", 'to': "orm['repository.Contact']"}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'purpose': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPurpose']", 'null': 'True', 'blank': 'True'}),
+            'recruitment_country': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.CountryCode']", 'symmetrical': 'False'}),
+            'recruitment_status': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.RecruitmentStatus']", 'null': 'True', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'scientific_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.ScientificContact']", 'to': "orm['repository.Contact']"}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'staff_note': ('django.db.models.fields.CharField', [], {'max_length': "'255'", 'blank': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'processing'", 'max_length': '64'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'study_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyType']", 'null': 'True', 'blank': 'True'}),
+            'target_sample_size': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'trial_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'unique': 'True', 'null': 'True'}),
+            'updated': ('django.db.models.fields.DateTimeField', [], {'null': 'True'})
+        },
+        'repository.clinicaltrialtranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'ClinicalTrialTranslation'},
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'})
+        },
+        'repository.contact': {
+            'Meta': {'object_name': 'Contact'},
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'affiliation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']", 'null': 'True', 'blank': 'True'}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'contact_creator'", 'to': "orm['auth.User']"}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '255'}),
+            'firstname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'lastname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'middlename': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
+            'telephone': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'zip': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'})
+        },
+        'repository.descriptor': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Descriptor'},
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'aspect': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'code': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'level': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"}),
+            'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
+            'vocabulary': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.descriptortranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'DescriptorTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
+        },
+        'repository.institution': {
+            'Meta': {'object_name': 'Institution'},
+            'address': ('django.db.models.fields.TextField', [], {'max_length': '1500', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']"}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'institution_creator'", 'to': "orm['auth.User']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.outcome': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Outcome'},
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'interest': ('django.db.models.fields.CharField', [], {'default': "'primary'", 'max_length': '32'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.outcometranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'OutcomeTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        },
+        'repository.publiccontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'PublicContact'},
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.scientificcontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'ScientificContact'},
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.sitecontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'SiteContact'},
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialnumber': {
+            'Meta': {'object_name': 'TrialNumber'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'id_number': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'issuing_authority': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsecondarysponsor': {
+            'Meta': {'object_name': 'TrialSecondarySponsor'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsupportsource': {
+            'Meta': {'object_name': 'TrialSupportSource'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'vocabulary.countrycode': {
+            'Meta': {'ordering': "['description']", 'object_name': 'CountryCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'}),
+            'submission_language': ('django.db.models.fields.CharField', [], {'max_length': '10', 'blank': 'True'})
+        },
+        'vocabulary.interventionassigment': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionAssigment'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.interventioncode': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.recruitmentstatus': {
+            'Meta': {'object_name': 'RecruitmentStatus'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyallocation': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyAllocation'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studymasking': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyMasking'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyphase': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPhase'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studypurpose': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPurpose'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studytype': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyType'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.vocabularytranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'VocabularyTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        }
+    }
+
+    complete_apps = ['repository']
Index: /tags/v1.0.23rc1/opentrials/repository/migrations/0001_initial.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/migrations/0001_initial.py (revision 505)
+++ /tags/v1.0.23rc1/opentrials/repository/migrations/0001_initial.py (revision 505)
@@ -0,0 +1,568 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Adding model 'ClinicalTrial'
+        db.create_table('repository_clinicaltrial', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('trial_id', self.gf('django.db.models.fields.CharField')(max_length=255, unique=True, null=True)),
+            ('date_registration', self.gf('django.db.models.fields.DateField')(null=True, db_index=True)),
+            ('scientific_title', self.gf('django.db.models.fields.TextField')(max_length=2000)),
+            ('scientific_acronym', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
+            ('scientific_acronym_expansion', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
+            ('primary_sponsor', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['repository.Institution'], null=True, blank=True)),
+            ('public_title', self.gf('django.db.models.fields.TextField')(max_length=2000, blank=True)),
+            ('acronym', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
+            ('acronym_expansion', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
+            ('hc_freetext', self.gf('django.db.models.fields.TextField')(max_length=8000, blank=True)),
+            ('i_freetext', self.gf('django.db.models.fields.TextField')(max_length=8000, blank=True)),
+            ('inclusion_criteria', self.gf('django.db.models.fields.TextField')(max_length=8000, blank=True)),
+            ('gender', self.gf('django.db.models.fields.CharField')(default='-', max_length=1)),
+            ('agemin_value', self.gf('django.db.models.fields.PositiveIntegerField')(default=0, null=True)),
+            ('agemin_unit', self.gf('django.db.models.fields.CharField')(default='-', max_length=1)),
+            ('agemax_value', self.gf('django.db.models.fields.PositiveIntegerField')(default=0, null=True)),
+            ('agemax_unit', self.gf('django.db.models.fields.CharField')(default='-', max_length=1)),
+            ('exclusion_criteria', self.gf('django.db.models.fields.TextField')(max_length=8000, blank=True)),
+            ('study_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vocabulary.StudyType'], null=True, blank=True)),
+            ('study_design', self.gf('django.db.models.fields.TextField')(max_length=1000, blank=True)),
+            ('expanded_access_program', self.gf('django.db.models.fields.NullBooleanField')(null=True, blank=True)),
+            ('purpose', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vocabulary.StudyPurpose'], null=True, blank=True)),
+            ('intervention_assignment', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vocabulary.InterventionAssigment'], null=True, blank=True)),
+            ('number_of_arms', self.gf('django.db.models.fields.PositiveIntegerField')(null=True, blank=True)),
+            ('masking', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vocabulary.StudyMasking'], null=True, blank=True)),
+            ('allocation', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vocabulary.StudyAllocation'], null=True, blank=True)),
+            ('phase', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vocabulary.StudyPhase'], null=True, blank=True)),
+            ('enrollment_start_planned', self.gf('django.db.models.fields.CharField')(max_length=10, null=True, blank=True)),
+            ('enrollment_start_actual', self.gf('django.db.models.fields.CharField')(max_length=10, null=True, blank=True)),
+            ('enrollment_end_planned', self.gf('django.db.models.fields.CharField')(max_length=10, null=True, blank=True)),
+            ('enrollment_end_actual', self.gf('django.db.models.fields.CharField')(max_length=10, null=True, blank=True)),
+            ('target_sample_size', self.gf('django.db.models.fields.PositiveIntegerField')(default=0)),
+            ('recruitment_status', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vocabulary.RecruitmentStatus'], null=True, blank=True)),
+            ('created', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
+            ('updated', self.gf('django.db.models.fields.DateTimeField')(null=True)),
+            ('exported', self.gf('django.db.models.fields.DateTimeField')(null=True)),
+            ('status', self.gf('django.db.models.fields.CharField')(default='processing', max_length=64)),
+            ('staff_note', self.gf('django.db.models.fields.CharField')(max_length='255', blank=True)),
+        ))
+        db.send_create_signal('repository', ['ClinicalTrial'])
+
+        # Adding M2M table for field i_code on 'ClinicalTrial'
+        db.create_table('repository_clinicaltrial_i_code', (
+            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
+            ('clinicaltrial', models.ForeignKey(orm['repository.clinicaltrial'], null=False)),
+            ('interventioncode', models.ForeignKey(orm['vocabulary.interventioncode'], null=False))
+        ))
+        db.create_unique('repository_clinicaltrial_i_code', ['clinicaltrial_id', 'interventioncode_id'])
+
+        # Adding M2M table for field recruitment_country on 'ClinicalTrial'
+        db.create_table('repository_clinicaltrial_recruitment_country', (
+            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
+            ('clinicaltrial', models.ForeignKey(orm['repository.clinicaltrial'], null=False)),
+            ('countrycode', models.ForeignKey(orm['vocabulary.countrycode'], null=False))
+        ))
+        db.create_unique('repository_clinicaltrial_recruitment_country', ['clinicaltrial_id', 'countrycode_id'])
+
+        # Adding model 'ClinicalTrialTranslation'
+        db.create_table('repository_clinicaltrialtranslation', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('language', self.gf('django.db.models.fields.CharField')(max_length=8, db_index=True)),
+            ('content_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['contenttypes.ContentType'])),
+            ('object_id', self.gf('django.db.models.fields.PositiveIntegerField')(db_index=True)),
+            ('scientific_title', self.gf('django.db.models.fields.TextField')(max_length=2000)),
+            ('scientific_acronym', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
+            ('scientific_acronym_expansion', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
+            ('public_title', self.gf('django.db.models.fields.TextField')(max_length=2000, blank=True)),
+            ('acronym', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
+            ('acronym_expansion', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
+            ('hc_freetext', self.gf('django.db.models.fields.TextField')(max_length=8000, blank=True)),
+            ('i_freetext', self.gf('django.db.models.fields.TextField')(max_length=8000, blank=True)),
+            ('inclusion_criteria', self.gf('django.db.models.fields.TextField')(max_length=8000, blank=True)),
+            ('exclusion_criteria', self.gf('django.db.models.fields.TextField')(max_length=8000, blank=True)),
+            ('study_design', self.gf('django.db.models.fields.TextField')(max_length=1000, blank=True)),
+        ))
+        db.send_create_signal('repository', ['ClinicalTrialTranslation'])
+
+        # Adding unique constraint on 'ClinicalTrialTranslation', fields ['content_type', 'object_id', 'language']
+        db.create_unique('repository_clinicaltrialtranslation', ['content_type_id', 'object_id', 'language'])
+
+        # Adding model 'TrialNumber'
+        db.create_table('repository_trialnumber', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('trial', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['repository.ClinicalTrial'])),
+            ('issuing_authority', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)),
+            ('id_number', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)),
+        ))
+        db.send_create_signal('repository', ['TrialNumber'])
+
+        # Adding model 'TrialSecondarySponsor'
+        db.create_table('repository_trialsecondarysponsor', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('trial', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['repository.ClinicalTrial'])),
+            ('institution', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['repository.Institution'])),
+        ))
+        db.send_create_signal('repository', ['TrialSecondarySponsor'])
+
+        # Adding model 'TrialSupportSource'
+        db.create_table('repository_trialsupportsource', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('trial', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['repository.ClinicalTrial'])),
+            ('institution', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['repository.Institution'])),
+        ))
+        db.send_create_signal('repository', ['TrialSupportSource'])
+
+        # Adding model 'Institution'
+        db.create_table('repository_institution', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
+            ('address', self.gf('django.db.models.fields.TextField')(max_length=1500, blank=True)),
+            ('country', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vocabulary.CountryCode'])),
+            ('creator', self.gf('django.db.models.fields.related.ForeignKey')(related_name='institution_creator', to=orm['auth.User'])),
+        ))
+        db.send_create_signal('repository', ['Institution'])
+
+        # Adding model 'Contact'
+        db.create_table('repository_contact', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('firstname', self.gf('django.db.models.fields.CharField')(max_length=50)),
+            ('middlename', self.gf('django.db.models.fields.CharField')(max_length=50, blank=True)),
+            ('lastname', self.gf('django.db.models.fields.CharField')(max_length=50)),
+            ('email', self.gf('django.db.models.fields.EmailField')(max_length=255)),
+            ('affiliation', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['repository.Institution'], null=True, blank=True)),
+            ('address', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
+            ('city', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
+            ('country', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vocabulary.CountryCode'], null=True, blank=True)),
+            ('zip', self.gf('django.db.models.fields.CharField')(max_length=50, blank=True)),
+            ('telephone', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
+            ('creator', self.gf('django.db.models.fields.related.ForeignKey')(related_name='contact_creator', to=orm['auth.User'])),
+        ))
+        db.send_create_signal('repository', ['Contact'])
+
+        # Adding model 'PublicContact'
+        db.create_table('repository_publiccontact', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('trial', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['repository.ClinicalTrial'])),
+            ('contact', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['repository.Contact'])),
+            ('status', self.gf('django.db.models.fields.CharField')(default='Active', max_length=255)),
+        ))
+        db.send_create_signal('repository', ['PublicContact'])
+
+        # Adding unique constraint on 'PublicContact', fields ['trial', 'contact']
+        db.create_unique('repository_publiccontact', ['trial_id', 'contact_id'])
+
+        # Adding model 'ScientificContact'
+        db.create_table('repository_scientificcontact', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('trial', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['repository.ClinicalTrial'])),
+            ('contact', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['repository.Contact'])),
+            ('status', self.gf('django.db.models.fields.CharField')(default='Active', max_length=255)),
+        ))
+        db.send_create_signal('repository', ['ScientificContact'])
+
+        # Adding unique constraint on 'ScientificContact', fields ['trial', 'contact']
+        db.create_unique('repository_scientificcontact', ['trial_id', 'contact_id'])
+
+        # Adding model 'SiteContact'
+        db.create_table('repository_sitecontact', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('trial', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['repository.ClinicalTrial'])),
+            ('contact', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['repository.Contact'])),
+            ('status', self.gf('django.db.models.fields.CharField')(default='Active', max_length=255)),
+        ))
+        db.send_create_signal('repository', ['SiteContact'])
+
+        # Adding unique constraint on 'SiteContact', fields ['trial', 'contact']
+        db.create_unique('repository_sitecontact', ['trial_id', 'contact_id'])
+
+        # Adding model 'Outcome'
+        db.create_table('repository_outcome', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('trial', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['repository.ClinicalTrial'])),
+            ('interest', self.gf('django.db.models.fields.CharField')(default='primary', max_length=32)),
+            ('description', self.gf('django.db.models.fields.TextField')(max_length=8000)),
+            ('_order', self.gf('django.db.models.fields.IntegerField')(default=0)),
+        ))
+        db.send_create_signal('repository', ['Outcome'])
+
+        # Adding model 'OutcomeTranslation'
+        db.create_table('repository_outcometranslation', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('language', self.gf('django.db.models.fields.CharField')(max_length=8, db_index=True)),
+            ('content_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['contenttypes.ContentType'])),
+            ('object_id', self.gf('django.db.models.fields.PositiveIntegerField')(db_index=True)),
+            ('description', self.gf('django.db.models.fields.TextField')(max_length=8000)),
+        ))
+        db.send_create_signal('repository', ['OutcomeTranslation'])
+
+        # Adding unique constraint on 'OutcomeTranslation', fields ['content_type', 'object_id', 'language']
+        db.create_unique('repository_outcometranslation', ['content_type_id', 'object_id', 'language'])
+
+        # Adding model 'Descriptor'
+        db.create_table('repository_descriptor', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('trial', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['repository.ClinicalTrial'])),
+            ('aspect', self.gf('django.db.models.fields.CharField')(max_length=255)),
+            ('vocabulary', self.gf('django.db.models.fields.CharField')(max_length=255)),
+            ('version', self.gf('django.db.models.fields.CharField')(max_length=64, blank=True)),
+            ('level', self.gf('django.db.models.fields.CharField')(max_length=64)),
+            ('code', self.gf('django.db.models.fields.CharField')(max_length=255)),
+            ('text', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
+            ('_order', self.gf('django.db.models.fields.IntegerField')(default=0)),
+        ))
+        db.send_create_signal('repository', ['Descriptor'])
+
+        # Adding model 'DescriptorTranslation'
+        db.create_table('repository_descriptortranslation', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('language', self.gf('django.db.models.fields.CharField')(max_length=8, db_index=True)),
+            ('content_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['contenttypes.ContentType'])),
+            ('object_id', self.gf('django.db.models.fields.PositiveIntegerField')(db_index=True)),
+            ('text', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
+        ))
+        db.send_create_signal('repository', ['DescriptorTranslation'])
+
+        # Adding unique constraint on 'DescriptorTranslation', fields ['content_type', 'object_id', 'language']
+        db.create_unique('repository_descriptortranslation', ['content_type_id', 'object_id', 'language'])
+
+
+    def backwards(self, orm):
+        
+        # Deleting model 'ClinicalTrial'
+        db.delete_table('repository_clinicaltrial')
+
+        # Removing M2M table for field i_code on 'ClinicalTrial'
+        db.delete_table('repository_clinicaltrial_i_code')
+
+        # Removing M2M table for field recruitment_country on 'ClinicalTrial'
+        db.delete_table('repository_clinicaltrial_recruitment_country')
+
+        # Deleting model 'ClinicalTrialTranslation'
+        db.delete_table('repository_clinicaltrialtranslation')
+
+        # Removing unique constraint on 'ClinicalTrialTranslation', fields ['content_type', 'object_id', 'language']
+        db.delete_unique('repository_clinicaltrialtranslation', ['content_type_id', 'object_id', 'language'])
+
+        # Deleting model 'TrialNumber'
+        db.delete_table('repository_trialnumber')
+
+        # Deleting model 'TrialSecondarySponsor'
+        db.delete_table('repository_trialsecondarysponsor')
+
+        # Deleting model 'TrialSupportSource'
+        db.delete_table('repository_trialsupportsource')
+
+        # Deleting model 'Institution'
+        db.delete_table('repository_institution')
+
+        # Deleting model 'Contact'
+        db.delete_table('repository_contact')
+
+        # Deleting model 'PublicContact'
+        db.delete_table('repository_publiccontact')
+
+        # Removing unique constraint on 'PublicContact', fields ['trial', 'contact']
+        db.delete_unique('repository_publiccontact', ['trial_id', 'contact_id'])
+
+        # Deleting model 'ScientificContact'
+        db.delete_table('repository_scientificcontact')
+
+        # Removing unique constraint on 'ScientificContact', fields ['trial', 'contact']
+        db.delete_unique('repository_scientificcontact', ['trial_id', 'contact_id'])
+
+        # Deleting model 'SiteContact'
+        db.delete_table('repository_sitecontact')
+
+        # Removing unique constraint on 'SiteContact', fields ['trial', 'contact']
+        db.delete_unique('repository_sitecontact', ['trial_id', 'contact_id'])
+
+        # Deleting model 'Outcome'
+        db.delete_table('repository_outcome')
+
+        # Deleting model 'OutcomeTranslation'
+        db.delete_table('repository_outcometranslation')
+
+        # Removing unique constraint on 'OutcomeTranslation', fields ['content_type', 'object_id', 'language']
+        db.delete_unique('repository_outcometranslation', ['content_type_id', 'object_id', 'language'])
+
+        # Deleting model 'Descriptor'
+        db.delete_table('repository_descriptor')
+
+        # Deleting model 'DescriptorTranslation'
+        db.delete_table('repository_descriptortranslation')
+
+        # Removing unique constraint on 'DescriptorTranslation', fields ['content_type', 'object_id', 'language']
+        db.delete_unique('repository_descriptortranslation', ['content_type_id', 'object_id', 'language'])
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'repository.clinicaltrial': {
+            'Meta': {'object_name': 'ClinicalTrial'},
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'agemax_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemax_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'agemin_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemin_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'allocation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyAllocation']", 'null': 'True', 'blank': 'True'}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'date_registration': ('django.db.models.fields.DateField', [], {'null': 'True', 'db_index': 'True'}),
+            'enrollment_end_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_end_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'expanded_access_program': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+            'exported': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'gender': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_code': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.InterventionCode']", 'symmetrical': 'False'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'intervention_assignment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.InterventionAssigment']", 'null': 'True', 'blank': 'True'}),
+            'masking': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyMasking']", 'null': 'True', 'blank': 'True'}),
+            'number_of_arms': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'phase': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPhase']", 'null': 'True', 'blank': 'True'}),
+            'primary_sponsor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'public_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'public_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.PublicContact']", 'to': "orm['repository.Contact']"}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'purpose': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPurpose']", 'null': 'True', 'blank': 'True'}),
+            'recruitment_country': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.CountryCode']", 'symmetrical': 'False'}),
+            'recruitment_status': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.RecruitmentStatus']", 'null': 'True', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'scientific_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.ScientificContact']", 'to': "orm['repository.Contact']"}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'staff_note': ('django.db.models.fields.CharField', [], {'max_length': "'255'", 'blank': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'processing'", 'max_length': '64'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'study_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyType']", 'null': 'True', 'blank': 'True'}),
+            'target_sample_size': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'trial_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'unique': 'True', 'null': 'True'}),
+            'updated': ('django.db.models.fields.DateTimeField', [], {'null': 'True'})
+        },
+        'repository.clinicaltrialtranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'ClinicalTrialTranslation'},
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'})
+        },
+        'repository.contact': {
+            'Meta': {'object_name': 'Contact'},
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'affiliation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']", 'null': 'True', 'blank': 'True'}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'contact_creator'", 'to': "orm['auth.User']"}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '255'}),
+            'firstname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'lastname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'middlename': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
+            'telephone': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'zip': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'})
+        },
+        'repository.descriptor': {
+            'Meta': {'object_name': 'Descriptor'},
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'aspect': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'code': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'level': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"}),
+            'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
+            'vocabulary': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.descriptortranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'DescriptorTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
+        },
+        'repository.institution': {
+            'Meta': {'object_name': 'Institution'},
+            'address': ('django.db.models.fields.TextField', [], {'max_length': '1500', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']"}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'institution_creator'", 'to': "orm['auth.User']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.outcome': {
+            'Meta': {'object_name': 'Outcome'},
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'interest': ('django.db.models.fields.CharField', [], {'default': "'primary'", 'max_length': '32'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.outcometranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'OutcomeTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        },
+        'repository.publiccontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'PublicContact'},
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.scientificcontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'ScientificContact'},
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.sitecontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'SiteContact'},
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialnumber': {
+            'Meta': {'object_name': 'TrialNumber'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'id_number': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'issuing_authority': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsecondarysponsor': {
+            'Meta': {'object_name': 'TrialSecondarySponsor'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsupportsource': {
+            'Meta': {'object_name': 'TrialSupportSource'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'vocabulary.countrycode': {
+            'Meta': {'object_name': 'CountryCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'submission_language': ('django.db.models.fields.CharField', [], {'max_length': '10', 'blank': 'True'})
+        },
+        'vocabulary.interventionassigment': {
+            'Meta': {'object_name': 'InterventionAssigment'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
+        },
+        'vocabulary.interventioncode': {
+            'Meta': {'object_name': 'InterventionCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
+        },
+        'vocabulary.recruitmentstatus': {
+            'Meta': {'object_name': 'RecruitmentStatus'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
+        },
+        'vocabulary.studyallocation': {
+            'Meta': {'object_name': 'StudyAllocation'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
+        },
+        'vocabulary.studymasking': {
+            'Meta': {'object_name': 'StudyMasking'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
+        },
+        'vocabulary.studyphase': {
+            'Meta': {'object_name': 'StudyPhase'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
+        },
+        'vocabulary.studypurpose': {
+            'Meta': {'object_name': 'StudyPurpose'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
+        },
+        'vocabulary.studytype': {
+            'Meta': {'object_name': 'StudyType'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
+        },
+        'vocabulary.vocabularytranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'VocabularyTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        }
+    }
+
+    complete_apps = ['repository']
Index: /tags/v1.0.23rc1/opentrials/repository/migrations/0008_auto__add_field_clinicaltrial_time_perspective.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/migrations/0008_auto__add_field_clinicaltrial_time_perspective.py (revision 956)
+++ /tags/v1.0.23rc1/opentrials/repository/migrations/0008_auto__add_field_clinicaltrial_time_perspective.py (revision 956)
@@ -0,0 +1,327 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Adding field 'ClinicalTrial.time_perspective'
+        db.add_column('repository_clinicaltrial', 'time_perspective', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vocabulary.TimePerspective'], blank=True), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'ClinicalTrial.time_perspective'
+        db.delete_column('repository_clinicaltrial', 'time_perspective_id')
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'repository.clinicaltrial': {
+            'Meta': {'ordering': "['-updated']", 'object_name': 'ClinicalTrial'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'agemax_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemax_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'agemin_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemin_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'allocation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyAllocation']", 'null': 'True', 'blank': 'True'}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'date_registration': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}),
+            'enrollment_end_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_end_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'expanded_access_program': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+            'exported': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'gender': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_code': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.InterventionCode']", 'symmetrical': 'False'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'intervention_assignment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.InterventionAssigment']", 'null': 'True', 'blank': 'True'}),
+            'is_observational': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'language': ('django.db.models.fields.CharField', [], {'default': "u'en'", 'max_length': '10'}),
+            'masking': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyMasking']", 'null': 'True', 'blank': 'True'}),
+            'number_of_arms': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'phase': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPhase']", 'null': 'True', 'blank': 'True'}),
+            'primary_sponsor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'public_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'public_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.PublicContact']", 'to': "orm['repository.Contact']"}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'purpose': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPurpose']", 'null': 'True', 'blank': 'True'}),
+            'recruitment_country': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.CountryCode']", 'symmetrical': 'False'}),
+            'recruitment_status': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.RecruitmentStatus']", 'null': 'True', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'scientific_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.ScientificContact']", 'to': "orm['repository.Contact']"}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'site_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'site_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.SiteContact']", 'to': "orm['repository.Contact']"}),
+            'staff_note': ('django.db.models.fields.CharField', [], {'max_length': "'255'", 'blank': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'processing'", 'max_length': '64'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'study_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyType']", 'null': 'True', 'blank': 'True'}),
+            'target_sample_size': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'time_perspective': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.TimePerspective']", 'blank': 'True'}),
+            'trial_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'unique': 'True', 'null': 'True'}),
+            'updated': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'utrn_number': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'null': 'True', 'blank': 'True'})
+        },
+        'repository.clinicaltrialtranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'ClinicalTrialTranslation'},
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'})
+        },
+        'repository.contact': {
+            'Meta': {'object_name': 'Contact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'affiliation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']", 'null': 'True', 'blank': 'True'}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'contact_creator'", 'to': "orm['auth.User']"}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '255'}),
+            'firstname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'lastname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'middlename': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
+            'telephone': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'zip': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'})
+        },
+        'repository.descriptor': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Descriptor'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'aspect': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'code': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'level': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"}),
+            'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
+            'vocabulary': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.descriptortranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'DescriptorTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
+        },
+        'repository.institution': {
+            'Meta': {'object_name': 'Institution'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'address': ('django.db.models.fields.TextField', [], {'max_length': '1500', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']"}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'institution_creator'", 'to': "orm['auth.User']"}),
+            'i_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.InstitutionType']", 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.outcome': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Outcome'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'interest': ('django.db.models.fields.CharField', [], {'default': "'primary'", 'max_length': '32'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.outcometranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'OutcomeTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        },
+        'repository.publiccontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'PublicContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.scientificcontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'ScientificContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.sitecontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'SiteContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialnumber': {
+            'Meta': {'object_name': 'TrialNumber'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'id_number': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'issuing_authority': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsecondarysponsor': {
+            'Meta': {'object_name': 'TrialSecondarySponsor'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsupportsource': {
+            'Meta': {'object_name': 'TrialSupportSource'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'vocabulary.countrycode': {
+            'Meta': {'ordering': "['description']", 'object_name': 'CountryCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'}),
+            'submission_language': ('django.db.models.fields.CharField', [], {'max_length': '10', 'blank': 'True'})
+        },
+        'vocabulary.institutiontype': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InstitutionType'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.interventionassigment': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionAssigment'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.interventioncode': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.recruitmentstatus': {
+            'Meta': {'object_name': 'RecruitmentStatus'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyallocation': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyAllocation'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studymasking': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyMasking'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyphase': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPhase'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studypurpose': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPurpose'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studytype': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyType'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.timeperspective': {
+            'Meta': {'ordering': "['order']", 'object_name': 'TimePerspective'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.vocabularytranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'VocabularyTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        }
+    }
+
+    complete_apps = ['repository']
Index: /tags/v1.0.23rc1/opentrials/repository/migrations/0010_auto__chg_field_clinicaltrial_time_perspective.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/migrations/0010_auto__chg_field_clinicaltrial_time_perspective.py (revision 965)
+++ /tags/v1.0.23rc1/opentrials/repository/migrations/0010_auto__chg_field_clinicaltrial_time_perspective.py (revision 965)
@@ -0,0 +1,335 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Changing field 'ClinicalTrial.time_perspective'
+        db.alter_column('repository_clinicaltrial', 'time_perspective_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vocabulary.TimePerspective'], null=True))
+
+
+    def backwards(self, orm):
+        
+        # User chose to not deal with backwards NULL issues for 'ClinicalTrial.time_perspective'
+        raise RuntimeError("Cannot reverse this migration. 'ClinicalTrial.time_perspective' and its values cannot be restored.")
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'repository.clinicaltrial': {
+            'Meta': {'ordering': "['-updated']", 'object_name': 'ClinicalTrial'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'agemax_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemax_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'agemin_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemin_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'allocation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyAllocation']", 'null': 'True', 'blank': 'True'}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'date_registration': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}),
+            'enrollment_end_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_end_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'expanded_access_program': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+            'exported': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'gender': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_code': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.InterventionCode']", 'symmetrical': 'False'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'intervention_assignment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.InterventionAssigment']", 'null': 'True', 'blank': 'True'}),
+            'is_observational': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'language': ('django.db.models.fields.CharField', [], {'default': "u'en'", 'max_length': '10'}),
+            'masking': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyMasking']", 'null': 'True', 'blank': 'True'}),
+            'number_of_arms': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'observational_study_design': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.ObservationalStudyDesign']", 'null': 'True', 'blank': 'True'}),
+            'phase': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPhase']", 'null': 'True', 'blank': 'True'}),
+            'primary_sponsor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'public_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'public_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.PublicContact']", 'to': "orm['repository.Contact']"}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'purpose': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPurpose']", 'null': 'True', 'blank': 'True'}),
+            'recruitment_country': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.CountryCode']", 'symmetrical': 'False'}),
+            'recruitment_status': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.RecruitmentStatus']", 'null': 'True', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'scientific_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.ScientificContact']", 'to': "orm['repository.Contact']"}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'site_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'site_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.SiteContact']", 'to': "orm['repository.Contact']"}),
+            'staff_note': ('django.db.models.fields.CharField', [], {'max_length': "'255'", 'blank': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'processing'", 'max_length': '64'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'study_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyType']", 'null': 'True', 'blank': 'True'}),
+            'target_sample_size': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'time_perspective': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.TimePerspective']", 'null': 'True', 'blank': 'True'}),
+            'trial_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'unique': 'True', 'null': 'True'}),
+            'updated': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'utrn_number': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'null': 'True', 'blank': 'True'})
+        },
+        'repository.clinicaltrialtranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'ClinicalTrialTranslation'},
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'})
+        },
+        'repository.contact': {
+            'Meta': {'object_name': 'Contact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'affiliation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']", 'null': 'True', 'blank': 'True'}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'contact_creator'", 'to': "orm['auth.User']"}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '255'}),
+            'firstname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'lastname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'middlename': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
+            'telephone': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'zip': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'})
+        },
+        'repository.descriptor': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Descriptor'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'aspect': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'code': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'level': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"}),
+            'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
+            'vocabulary': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.descriptortranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'DescriptorTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
+        },
+        'repository.institution': {
+            'Meta': {'object_name': 'Institution'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'address': ('django.db.models.fields.TextField', [], {'max_length': '1500', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']"}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'institution_creator'", 'to': "orm['auth.User']"}),
+            'i_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.InstitutionType']", 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.outcome': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Outcome'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'interest': ('django.db.models.fields.CharField', [], {'default': "'primary'", 'max_length': '32'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.outcometranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'OutcomeTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        },
+        'repository.publiccontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'PublicContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.scientificcontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'ScientificContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.sitecontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'SiteContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialnumber': {
+            'Meta': {'object_name': 'TrialNumber'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'id_number': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'issuing_authority': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsecondarysponsor': {
+            'Meta': {'object_name': 'TrialSecondarySponsor'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsupportsource': {
+            'Meta': {'object_name': 'TrialSupportSource'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'vocabulary.countrycode': {
+            'Meta': {'ordering': "['description']", 'object_name': 'CountryCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'}),
+            'submission_language': ('django.db.models.fields.CharField', [], {'max_length': '10', 'blank': 'True'})
+        },
+        'vocabulary.institutiontype': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InstitutionType'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.interventionassigment': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionAssigment'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.interventioncode': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.observationalstudydesign': {
+            'Meta': {'ordering': "['order']", 'object_name': 'ObservationalStudyDesign'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.recruitmentstatus': {
+            'Meta': {'object_name': 'RecruitmentStatus'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyallocation': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyAllocation'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studymasking': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyMasking'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyphase': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPhase'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studypurpose': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPurpose'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studytype': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyType'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.timeperspective': {
+            'Meta': {'ordering': "['order']", 'object_name': 'TimePerspective'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.vocabularytranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'VocabularyTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        }
+    }
+
+    complete_apps = ['repository']
Index: /tags/v1.0.23rc1/opentrials/repository/migrations/0005_ct_language.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/migrations/0005_ct_language.py (revision 794)
+++ /tags/v1.0.23rc1/opentrials/repository/migrations/0005_ct_language.py (revision 794)
@@ -0,0 +1,309 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Adding field 'ClinicalTrial.language'
+        db.add_column('repository_clinicaltrial', 'language', self.gf('django.db.models.fields.CharField')(default='pt-BR', max_length=10), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'ClinicalTrial.language'
+        db.delete_column('repository_clinicaltrial', 'language')
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'repository.clinicaltrial': {
+            'Meta': {'ordering': "['-updated']", 'object_name': 'ClinicalTrial'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'agemax_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemax_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'agemin_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemin_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'allocation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyAllocation']", 'null': 'True', 'blank': 'True'}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'date_registration': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}),
+            'enrollment_end_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_end_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'expanded_access_program': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+            'exported': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'gender': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_code': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.InterventionCode']", 'symmetrical': 'False'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'intervention_assignment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.InterventionAssigment']", 'null': 'True', 'blank': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'default': "'pt-BR'", 'max_length': '10'}),
+            'masking': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyMasking']", 'null': 'True', 'blank': 'True'}),
+            'number_of_arms': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'phase': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPhase']", 'null': 'True', 'blank': 'True'}),
+            'primary_sponsor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'public_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'public_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.PublicContact']", 'to': "orm['repository.Contact']"}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'purpose': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPurpose']", 'null': 'True', 'blank': 'True'}),
+            'recruitment_country': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.CountryCode']", 'symmetrical': 'False'}),
+            'recruitment_status': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.RecruitmentStatus']", 'null': 'True', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'scientific_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.ScientificContact']", 'to': "orm['repository.Contact']"}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'staff_note': ('django.db.models.fields.CharField', [], {'max_length': "'255'", 'blank': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'processing'", 'max_length': '64'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'study_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyType']", 'null': 'True', 'blank': 'True'}),
+            'target_sample_size': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'trial_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'unique': 'True', 'null': 'True'}),
+            'updated': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'utrn_number': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'null': 'True', 'blank': 'True'})
+        },
+        'repository.clinicaltrialtranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'ClinicalTrialTranslation'},
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'})
+        },
+        'repository.contact': {
+            'Meta': {'object_name': 'Contact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'affiliation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']", 'null': 'True', 'blank': 'True'}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'contact_creator'", 'to': "orm['auth.User']"}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '255'}),
+            'firstname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'lastname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'middlename': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
+            'telephone': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'zip': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'})
+        },
+        'repository.descriptor': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Descriptor'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'aspect': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'code': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'level': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"}),
+            'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
+            'vocabulary': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.descriptortranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'DescriptorTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
+        },
+        'repository.institution': {
+            'Meta': {'object_name': 'Institution'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'address': ('django.db.models.fields.TextField', [], {'max_length': '1500', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']"}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'institution_creator'", 'to': "orm['auth.User']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.outcome': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Outcome'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'interest': ('django.db.models.fields.CharField', [], {'default': "'primary'", 'max_length': '32'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.outcometranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'OutcomeTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        },
+        'repository.publiccontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'PublicContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.scientificcontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'ScientificContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.sitecontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'SiteContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialnumber': {
+            'Meta': {'object_name': 'TrialNumber'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'id_number': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'issuing_authority': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsecondarysponsor': {
+            'Meta': {'object_name': 'TrialSecondarySponsor'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsupportsource': {
+            'Meta': {'object_name': 'TrialSupportSource'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'vocabulary.countrycode': {
+            'Meta': {'ordering': "['description']", 'object_name': 'CountryCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'}),
+            'submission_language': ('django.db.models.fields.CharField', [], {'max_length': '10', 'blank': 'True'})
+        },
+        'vocabulary.interventionassigment': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionAssigment'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.interventioncode': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.recruitmentstatus': {
+            'Meta': {'object_name': 'RecruitmentStatus'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyallocation': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyAllocation'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studymasking': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyMasking'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyphase': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPhase'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studypurpose': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPurpose'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studytype': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyType'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.vocabularytranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'VocabularyTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        }
+    }
+
+    complete_apps = ['repository']
Index: /tags/v1.0.23rc1/opentrials/repository/migrations/0009_auto__add_field_clinicaltrial_observational_study_design.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/migrations/0009_auto__add_field_clinicaltrial_observational_study_design.py (revision 956)
+++ /tags/v1.0.23rc1/opentrials/repository/migrations/0009_auto__add_field_clinicaltrial_observational_study_design.py (revision 956)
@@ -0,0 +1,335 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Adding field 'ClinicalTrial.observational_study_design'
+        db.add_column('repository_clinicaltrial', 'observational_study_design', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vocabulary.ObservationalStudyDesign'], null=True, blank=True), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'ClinicalTrial.observational_study_design'
+        db.delete_column('repository_clinicaltrial', 'observational_study_design_id')
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'repository.clinicaltrial': {
+            'Meta': {'ordering': "['-updated']", 'object_name': 'ClinicalTrial'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'agemax_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemax_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'agemin_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemin_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'allocation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyAllocation']", 'null': 'True', 'blank': 'True'}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'date_registration': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}),
+            'enrollment_end_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_end_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'expanded_access_program': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+            'exported': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'gender': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_code': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.InterventionCode']", 'symmetrical': 'False'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'intervention_assignment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.InterventionAssigment']", 'null': 'True', 'blank': 'True'}),
+            'is_observational': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'language': ('django.db.models.fields.CharField', [], {'default': "u'en'", 'max_length': '10'}),
+            'masking': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyMasking']", 'null': 'True', 'blank': 'True'}),
+            'number_of_arms': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'observational_study_design': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.ObservationalStudyDesign']", 'null': 'True', 'blank': 'True'}),
+            'phase': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPhase']", 'null': 'True', 'blank': 'True'}),
+            'primary_sponsor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'public_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'public_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.PublicContact']", 'to': "orm['repository.Contact']"}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'purpose': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPurpose']", 'null': 'True', 'blank': 'True'}),
+            'recruitment_country': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.CountryCode']", 'symmetrical': 'False'}),
+            'recruitment_status': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.RecruitmentStatus']", 'null': 'True', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'scientific_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.ScientificContact']", 'to': "orm['repository.Contact']"}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'site_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'site_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.SiteContact']", 'to': "orm['repository.Contact']"}),
+            'staff_note': ('django.db.models.fields.CharField', [], {'max_length': "'255'", 'blank': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'processing'", 'max_length': '64'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'study_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyType']", 'null': 'True', 'blank': 'True'}),
+            'target_sample_size': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'time_perspective': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.TimePerspective']", 'blank': 'True'}),
+            'trial_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'unique': 'True', 'null': 'True'}),
+            'updated': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'utrn_number': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'null': 'True', 'blank': 'True'})
+        },
+        'repository.clinicaltrialtranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'ClinicalTrialTranslation'},
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'})
+        },
+        'repository.contact': {
+            'Meta': {'object_name': 'Contact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'affiliation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']", 'null': 'True', 'blank': 'True'}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'contact_creator'", 'to': "orm['auth.User']"}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '255'}),
+            'firstname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'lastname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'middlename': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
+            'telephone': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'zip': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'})
+        },
+        'repository.descriptor': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Descriptor'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'aspect': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'code': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'level': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"}),
+            'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
+            'vocabulary': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.descriptortranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'DescriptorTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
+        },
+        'repository.institution': {
+            'Meta': {'object_name': 'Institution'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'address': ('django.db.models.fields.TextField', [], {'max_length': '1500', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']"}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'institution_creator'", 'to': "orm['auth.User']"}),
+            'i_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.InstitutionType']", 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.outcome': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Outcome'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'interest': ('django.db.models.fields.CharField', [], {'default': "'primary'", 'max_length': '32'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.outcometranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'OutcomeTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        },
+        'repository.publiccontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'PublicContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.scientificcontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'ScientificContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.sitecontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'SiteContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialnumber': {
+            'Meta': {'object_name': 'TrialNumber'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'id_number': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'issuing_authority': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsecondarysponsor': {
+            'Meta': {'object_name': 'TrialSecondarySponsor'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsupportsource': {
+            'Meta': {'object_name': 'TrialSupportSource'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'vocabulary.countrycode': {
+            'Meta': {'ordering': "['description']", 'object_name': 'CountryCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'}),
+            'submission_language': ('django.db.models.fields.CharField', [], {'max_length': '10', 'blank': 'True'})
+        },
+        'vocabulary.institutiontype': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InstitutionType'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.interventionassigment': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionAssigment'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.interventioncode': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.observationalstudydesign': {
+            'Meta': {'ordering': "['order']", 'object_name': 'ObservationalStudyDesign'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.recruitmentstatus': {
+            'Meta': {'object_name': 'RecruitmentStatus'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyallocation': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyAllocation'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studymasking': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyMasking'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyphase': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPhase'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studypurpose': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPurpose'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studytype': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyType'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.timeperspective': {
+            'Meta': {'ordering': "['order']", 'object_name': 'TimePerspective'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.vocabularytranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'VocabularyTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        }
+    }
+
+    complete_apps = ['repository']
Index: /tags/v1.0.23rc1/opentrials/repository/migrations/0003_utrn_number.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/migrations/0003_utrn_number.py (revision 750)
+++ /tags/v1.0.23rc1/opentrials/repository/migrations/0003_utrn_number.py (revision 750)
@@ -0,0 +1,297 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Adding field 'ClinicalTrial.utrn_number'
+        db.add_column('repository_clinicaltrial', 'utrn_number', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=255, null=True, blank=True), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'ClinicalTrial.utrn_number'
+        db.delete_column('repository_clinicaltrial', 'utrn_number')
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'repository.clinicaltrial': {
+            'Meta': {'ordering': "['-updated']", 'object_name': 'ClinicalTrial'},
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'agemax_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemax_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'agemin_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemin_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'allocation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyAllocation']", 'null': 'True', 'blank': 'True'}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'date_registration': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}),
+            'enrollment_end_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_end_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'expanded_access_program': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+            'exported': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'gender': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_code': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.InterventionCode']", 'symmetrical': 'False'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'intervention_assignment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.InterventionAssigment']", 'null': 'True', 'blank': 'True'}),
+            'masking': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyMasking']", 'null': 'True', 'blank': 'True'}),
+            'number_of_arms': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'phase': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPhase']", 'null': 'True', 'blank': 'True'}),
+            'primary_sponsor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'public_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'public_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.PublicContact']", 'to': "orm['repository.Contact']"}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'purpose': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPurpose']", 'null': 'True', 'blank': 'True'}),
+            'recruitment_country': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.CountryCode']", 'symmetrical': 'False'}),
+            'recruitment_status': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.RecruitmentStatus']", 'null': 'True', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'scientific_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.ScientificContact']", 'to': "orm['repository.Contact']"}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'staff_note': ('django.db.models.fields.CharField', [], {'max_length': "'255'", 'blank': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'processing'", 'max_length': '64'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'study_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyType']", 'null': 'True', 'blank': 'True'}),
+            'target_sample_size': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'trial_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'unique': 'True', 'null': 'True'}),
+            'updated': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'utrn_number': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'null': 'True', 'blank': 'True'})
+        },
+        'repository.clinicaltrialtranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'ClinicalTrialTranslation'},
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'})
+        },
+        'repository.contact': {
+            'Meta': {'object_name': 'Contact'},
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'affiliation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']", 'null': 'True', 'blank': 'True'}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'contact_creator'", 'to': "orm['auth.User']"}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '255'}),
+            'firstname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'lastname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'middlename': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
+            'telephone': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'zip': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'})
+        },
+        'repository.descriptor': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Descriptor'},
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'aspect': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'code': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'level': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"}),
+            'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
+            'vocabulary': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.descriptortranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'DescriptorTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
+        },
+        'repository.institution': {
+            'Meta': {'object_name': 'Institution'},
+            'address': ('django.db.models.fields.TextField', [], {'max_length': '1500', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']"}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'institution_creator'", 'to': "orm['auth.User']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.outcome': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Outcome'},
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'interest': ('django.db.models.fields.CharField', [], {'default': "'primary'", 'max_length': '32'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.outcometranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'OutcomeTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        },
+        'repository.publiccontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'PublicContact'},
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.scientificcontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'ScientificContact'},
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.sitecontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'SiteContact'},
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialnumber': {
+            'Meta': {'object_name': 'TrialNumber'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'id_number': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'issuing_authority': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsecondarysponsor': {
+            'Meta': {'object_name': 'TrialSecondarySponsor'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsupportsource': {
+            'Meta': {'object_name': 'TrialSupportSource'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'vocabulary.countrycode': {
+            'Meta': {'ordering': "['description']", 'object_name': 'CountryCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'}),
+            'submission_language': ('django.db.models.fields.CharField', [], {'max_length': '10', 'blank': 'True'})
+        },
+        'vocabulary.interventionassigment': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionAssigment'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.interventioncode': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.recruitmentstatus': {
+            'Meta': {'object_name': 'RecruitmentStatus'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyallocation': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyAllocation'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studymasking': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyMasking'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyphase': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPhase'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studypurpose': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPurpose'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studytype': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyType'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.vocabularytranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'VocabularyTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        }
+    }
+
+    complete_apps = ['repository']
Index: /tags/v1.0.23rc1/opentrials/repository/migrations/0006_added_new_field_for_institution_type.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/migrations/0006_added_new_field_for_institution_type.py (revision 813)
+++ /tags/v1.0.23rc1/opentrials/repository/migrations/0006_added_new_field_for_institution_type.py (revision 813)
@@ -0,0 +1,317 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Adding field 'Institution.i_type'
+        db.add_column('repository_institution', 'i_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['vocabulary.InstitutionType'], null=True, blank=True), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'Institution.i_type'
+        db.delete_column('repository_institution', 'i_type_id')
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'repository.clinicaltrial': {
+            'Meta': {'ordering': "['-updated']", 'object_name': 'ClinicalTrial'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'agemax_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemax_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'agemin_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemin_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'allocation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyAllocation']", 'null': 'True', 'blank': 'True'}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'date_registration': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}),
+            'enrollment_end_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_end_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'expanded_access_program': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+            'exported': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'gender': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_code': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.InterventionCode']", 'symmetrical': 'False'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'intervention_assignment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.InterventionAssigment']", 'null': 'True', 'blank': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'default': "u'en'", 'max_length': '10'}),
+            'masking': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyMasking']", 'null': 'True', 'blank': 'True'}),
+            'number_of_arms': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'phase': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPhase']", 'null': 'True', 'blank': 'True'}),
+            'primary_sponsor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'public_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'public_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.PublicContact']", 'to': "orm['repository.Contact']"}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'purpose': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPurpose']", 'null': 'True', 'blank': 'True'}),
+            'recruitment_country': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.CountryCode']", 'symmetrical': 'False'}),
+            'recruitment_status': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.RecruitmentStatus']", 'null': 'True', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'scientific_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.ScientificContact']", 'to': "orm['repository.Contact']"}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'staff_note': ('django.db.models.fields.CharField', [], {'max_length': "'255'", 'blank': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'processing'", 'max_length': '64'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'study_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyType']", 'null': 'True', 'blank': 'True'}),
+            'target_sample_size': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'trial_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'unique': 'True', 'null': 'True'}),
+            'updated': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'utrn_number': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'null': 'True', 'blank': 'True'})
+        },
+        'repository.clinicaltrialtranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'ClinicalTrialTranslation'},
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'})
+        },
+        'repository.contact': {
+            'Meta': {'object_name': 'Contact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'affiliation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']", 'null': 'True', 'blank': 'True'}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'contact_creator'", 'to': "orm['auth.User']"}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '255'}),
+            'firstname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'lastname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'middlename': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
+            'telephone': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'zip': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'})
+        },
+        'repository.descriptor': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Descriptor'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'aspect': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'code': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'level': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"}),
+            'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
+            'vocabulary': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.descriptortranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'DescriptorTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
+        },
+        'repository.institution': {
+            'Meta': {'object_name': 'Institution'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'address': ('django.db.models.fields.TextField', [], {'max_length': '1500', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']"}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'institution_creator'", 'to': "orm['auth.User']"}),
+            'i_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.InstitutionType']", 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.outcome': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Outcome'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'interest': ('django.db.models.fields.CharField', [], {'default': "'primary'", 'max_length': '32'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.outcometranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'OutcomeTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        },
+        'repository.publiccontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'PublicContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.scientificcontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'ScientificContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.sitecontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'SiteContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialnumber': {
+            'Meta': {'object_name': 'TrialNumber'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'id_number': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'issuing_authority': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsecondarysponsor': {
+            'Meta': {'object_name': 'TrialSecondarySponsor'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsupportsource': {
+            'Meta': {'object_name': 'TrialSupportSource'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'vocabulary.countrycode': {
+            'Meta': {'ordering': "['description']", 'object_name': 'CountryCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'}),
+            'submission_language': ('django.db.models.fields.CharField', [], {'max_length': '10', 'blank': 'True'})
+        },
+        'vocabulary.institutiontype': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InstitutionType'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.interventionassigment': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionAssigment'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.interventioncode': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.recruitmentstatus': {
+            'Meta': {'object_name': 'RecruitmentStatus'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyallocation': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyAllocation'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studymasking': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyMasking'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyphase': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPhase'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studypurpose': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPurpose'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studytype': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyType'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.vocabularytranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'VocabularyTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        }
+    }
+
+    complete_apps = ['repository']
Index: /tags/v1.0.23rc1/opentrials/repository/migrations/0007_auto__add_field_clinicaltrial_is_observational.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/migrations/0007_auto__add_field_clinicaltrial_is_observational.py (revision 956)
+++ /tags/v1.0.23rc1/opentrials/repository/migrations/0007_auto__add_field_clinicaltrial_is_observational.py (revision 956)
@@ -0,0 +1,319 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Adding field 'ClinicalTrial.is_observational'
+        db.add_column('repository_clinicaltrial', 'is_observational', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'ClinicalTrial.is_observational'
+        db.delete_column('repository_clinicaltrial', 'is_observational')
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'repository.clinicaltrial': {
+            'Meta': {'ordering': "['-updated']", 'object_name': 'ClinicalTrial'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'agemax_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemax_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'agemin_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemin_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'allocation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyAllocation']", 'null': 'True', 'blank': 'True'}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'date_registration': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}),
+            'enrollment_end_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_end_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'expanded_access_program': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+            'exported': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'gender': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_code': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.InterventionCode']", 'symmetrical': 'False'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'intervention_assignment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.InterventionAssigment']", 'null': 'True', 'blank': 'True'}),
+            'is_observational': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'language': ('django.db.models.fields.CharField', [], {'default': "u'en'", 'max_length': '10'}),
+            'masking': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyMasking']", 'null': 'True', 'blank': 'True'}),
+            'number_of_arms': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'phase': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPhase']", 'null': 'True', 'blank': 'True'}),
+            'primary_sponsor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'public_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'public_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.PublicContact']", 'to': "orm['repository.Contact']"}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'purpose': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPurpose']", 'null': 'True', 'blank': 'True'}),
+            'recruitment_country': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.CountryCode']", 'symmetrical': 'False'}),
+            'recruitment_status': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.RecruitmentStatus']", 'null': 'True', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'scientific_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.ScientificContact']", 'to': "orm['repository.Contact']"}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'site_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'site_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.SiteContact']", 'to': "orm['repository.Contact']"}),
+            'staff_note': ('django.db.models.fields.CharField', [], {'max_length': "'255'", 'blank': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'processing'", 'max_length': '64'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'study_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyType']", 'null': 'True', 'blank': 'True'}),
+            'target_sample_size': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'trial_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'unique': 'True', 'null': 'True'}),
+            'updated': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'utrn_number': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'null': 'True', 'blank': 'True'})
+        },
+        'repository.clinicaltrialtranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'ClinicalTrialTranslation'},
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'})
+        },
+        'repository.contact': {
+            'Meta': {'object_name': 'Contact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'affiliation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']", 'null': 'True', 'blank': 'True'}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'contact_creator'", 'to': "orm['auth.User']"}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '255'}),
+            'firstname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'lastname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'middlename': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
+            'telephone': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'zip': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'})
+        },
+        'repository.descriptor': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Descriptor'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'aspect': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'code': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'level': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"}),
+            'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
+            'vocabulary': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.descriptortranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'DescriptorTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
+        },
+        'repository.institution': {
+            'Meta': {'object_name': 'Institution'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'address': ('django.db.models.fields.TextField', [], {'max_length': '1500', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']"}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'institution_creator'", 'to': "orm['auth.User']"}),
+            'i_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.InstitutionType']", 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.outcome': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Outcome'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'interest': ('django.db.models.fields.CharField', [], {'default': "'primary'", 'max_length': '32'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.outcometranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'OutcomeTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        },
+        'repository.publiccontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'PublicContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.scientificcontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'ScientificContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.sitecontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'SiteContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialnumber': {
+            'Meta': {'object_name': 'TrialNumber'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'id_number': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'issuing_authority': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsecondarysponsor': {
+            'Meta': {'object_name': 'TrialSecondarySponsor'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsupportsource': {
+            'Meta': {'object_name': 'TrialSupportSource'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'vocabulary.countrycode': {
+            'Meta': {'ordering': "['description']", 'object_name': 'CountryCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'}),
+            'submission_language': ('django.db.models.fields.CharField', [], {'max_length': '10', 'blank': 'True'})
+        },
+        'vocabulary.institutiontype': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InstitutionType'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.interventionassigment': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionAssigment'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.interventioncode': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.recruitmentstatus': {
+            'Meta': {'object_name': 'RecruitmentStatus'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyallocation': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyAllocation'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studymasking': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyMasking'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyphase': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPhase'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studypurpose': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPurpose'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studytype': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyType'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.vocabularytranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'VocabularyTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        }
+    }
+
+    complete_apps = ['repository']
Index: /tags/v1.0.23rc1/opentrials/repository/migrations/0004_deletion_control.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/migrations/0004_deletion_control.py (revision 768)
+++ /tags/v1.0.23rc1/opentrials/repository/migrations/0004_deletion_control.py (revision 768)
@@ -0,0 +1,368 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Adding field 'ClinicalTrial._deleted'
+        db.add_column('repository_clinicaltrial', '_deleted', self.gf('django.db.models.fields.BooleanField')(default=False, db_index=True), keep_default=False)
+
+        # Adding field 'Descriptor._deleted'
+        db.add_column('repository_descriptor', '_deleted', self.gf('django.db.models.fields.BooleanField')(default=False, db_index=True), keep_default=False)
+
+        # Adding field 'Contact._deleted'
+        db.add_column('repository_contact', '_deleted', self.gf('django.db.models.fields.BooleanField')(default=False, db_index=True), keep_default=False)
+
+        # Adding field 'Institution._deleted'
+        db.add_column('repository_institution', '_deleted', self.gf('django.db.models.fields.BooleanField')(default=False, db_index=True), keep_default=False)
+
+        # Adding field 'TrialNumber._deleted'
+        db.add_column('repository_trialnumber', '_deleted', self.gf('django.db.models.fields.BooleanField')(default=False, db_index=True), keep_default=False)
+
+        # Adding field 'TrialSecondarySponsor._deleted'
+        db.add_column('repository_trialsecondarysponsor', '_deleted', self.gf('django.db.models.fields.BooleanField')(default=False, db_index=True), keep_default=False)
+
+        # Adding field 'ScientificContact._deleted'
+        db.add_column('repository_scientificcontact', '_deleted', self.gf('django.db.models.fields.BooleanField')(default=False, db_index=True), keep_default=False)
+
+        # Adding field 'TrialSupportSource._deleted'
+        db.add_column('repository_trialsupportsource', '_deleted', self.gf('django.db.models.fields.BooleanField')(default=False, db_index=True), keep_default=False)
+
+        # Adding field 'PublicContact._deleted'
+        db.add_column('repository_publiccontact', '_deleted', self.gf('django.db.models.fields.BooleanField')(default=False, db_index=True), keep_default=False)
+
+        # Adding field 'Outcome._deleted'
+        db.add_column('repository_outcome', '_deleted', self.gf('django.db.models.fields.BooleanField')(default=False, db_index=True), keep_default=False)
+
+        # Adding field 'SiteContact._deleted'
+        db.add_column('repository_sitecontact', '_deleted', self.gf('django.db.models.fields.BooleanField')(default=False, db_index=True), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'ClinicalTrial._deleted'
+        db.delete_column('repository_clinicaltrial', '_deleted')
+
+        # Deleting field 'Descriptor._deleted'
+        db.delete_column('repository_descriptor', '_deleted')
+
+        # Deleting field 'Contact._deleted'
+        db.delete_column('repository_contact', '_deleted')
+
+        # Deleting field 'Institution._deleted'
+        db.delete_column('repository_institution', '_deleted')
+
+        # Deleting field 'TrialNumber._deleted'
+        db.delete_column('repository_trialnumber', '_deleted')
+
+        # Deleting field 'TrialSecondarySponsor._deleted'
+        db.delete_column('repository_trialsecondarysponsor', '_deleted')
+
+        # Deleting field 'ScientificContact._deleted'
+        db.delete_column('repository_scientificcontact', '_deleted')
+
+        # Deleting field 'TrialSupportSource._deleted'
+        db.delete_column('repository_trialsupportsource', '_deleted')
+
+        # Deleting field 'PublicContact._deleted'
+        db.delete_column('repository_publiccontact', '_deleted')
+
+        # Deleting field 'Outcome._deleted'
+        db.delete_column('repository_outcome', '_deleted')
+
+        # Deleting field 'SiteContact._deleted'
+        db.delete_column('repository_sitecontact', '_deleted')
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'repository.clinicaltrial': {
+            'Meta': {'ordering': "['-updated']", 'object_name': 'ClinicalTrial'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'agemax_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemax_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'agemin_unit': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'agemin_value': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True'}),
+            'allocation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyAllocation']", 'null': 'True', 'blank': 'True'}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'date_registration': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}),
+            'enrollment_end_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_end_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_actual': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'enrollment_start_planned': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'expanded_access_program': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+            'exported': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'gender': ('django.db.models.fields.CharField', [], {'default': "'-'", 'max_length': '1'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_code': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.InterventionCode']", 'symmetrical': 'False'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'intervention_assignment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.InterventionAssigment']", 'null': 'True', 'blank': 'True'}),
+            'masking': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyMasking']", 'null': 'True', 'blank': 'True'}),
+            'number_of_arms': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'phase': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPhase']", 'null': 'True', 'blank': 'True'}),
+            'primary_sponsor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'public_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'public_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.PublicContact']", 'to': "orm['repository.Contact']"}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'purpose': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyPurpose']", 'null': 'True', 'blank': 'True'}),
+            'recruitment_country': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['vocabulary.CountryCode']", 'symmetrical': 'False'}),
+            'recruitment_status': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.RecruitmentStatus']", 'null': 'True', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_contact': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'scientific_contact_of_set'", 'symmetrical': 'False', 'through': "orm['repository.ScientificContact']", 'to': "orm['repository.Contact']"}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'staff_note': ('django.db.models.fields.CharField', [], {'max_length': "'255'", 'blank': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'processing'", 'max_length': '64'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'}),
+            'study_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.StudyType']", 'null': 'True', 'blank': 'True'}),
+            'target_sample_size': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+            'trial_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'unique': 'True', 'null': 'True'}),
+            'updated': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+            'utrn_number': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'null': 'True', 'blank': 'True'})
+        },
+        'repository.clinicaltrialtranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'ClinicalTrialTranslation'},
+            'acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'exclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'hc_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'i_freetext': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'inclusion_criteria': ('django.db.models.fields.TextField', [], {'max_length': '8000', 'blank': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'public_title': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'scientific_acronym': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_acronym_expansion': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'scientific_title': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+            'study_design': ('django.db.models.fields.TextField', [], {'max_length': '1000', 'blank': 'True'})
+        },
+        'repository.contact': {
+            'Meta': {'object_name': 'Contact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'affiliation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']", 'null': 'True', 'blank': 'True'}),
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']", 'null': 'True', 'blank': 'True'}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'contact_creator'", 'to': "orm['auth.User']"}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '255'}),
+            'firstname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'lastname': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'middlename': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
+            'telephone': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'zip': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'})
+        },
+        'repository.descriptor': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Descriptor'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'aspect': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'code': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'level': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"}),
+            'version': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
+            'vocabulary': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.descriptortranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'DescriptorTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+            'text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
+        },
+        'repository.institution': {
+            'Meta': {'object_name': 'Institution'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'address': ('django.db.models.fields.TextField', [], {'max_length': '1500', 'blank': 'True'}),
+            'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['vocabulary.CountryCode']"}),
+            'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'institution_creator'", 'to': "orm['auth.User']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'repository.outcome': {
+            'Meta': {'ordering': "('_order',)", 'object_name': 'Outcome'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            '_order': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'interest': ('django.db.models.fields.CharField', [], {'default': "'primary'", 'max_length': '32'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.outcometranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'OutcomeTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '8000'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        },
+        'repository.publiccontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'PublicContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.scientificcontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'ScientificContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.sitecontact': {
+            'Meta': {'unique_together': "(('trial', 'contact'),)", 'object_name': 'SiteContact'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'contact': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Contact']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Active'", 'max_length': '255'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialnumber': {
+            'Meta': {'object_name': 'TrialNumber'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'id_number': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'issuing_authority': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsecondarysponsor': {
+            'Meta': {'object_name': 'TrialSecondarySponsor'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'repository.trialsupportsource': {
+            'Meta': {'object_name': 'TrialSupportSource'},
+            '_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'institution': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.Institution']"}),
+            'trial': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['repository.ClinicalTrial']"})
+        },
+        'vocabulary.countrycode': {
+            'Meta': {'ordering': "['description']", 'object_name': 'CountryCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'}),
+            'submission_language': ('django.db.models.fields.CharField', [], {'max_length': '10', 'blank': 'True'})
+        },
+        'vocabulary.interventionassigment': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionAssigment'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.interventioncode': {
+            'Meta': {'ordering': "['order']", 'object_name': 'InterventionCode'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.recruitmentstatus': {
+            'Meta': {'object_name': 'RecruitmentStatus'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyallocation': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyAllocation'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studymasking': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyMasking'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studyphase': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPhase'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studypurpose': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyPurpose'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.studytype': {
+            'Meta': {'ordering': "['order']", 'object_name': 'StudyType'},
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+            'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'})
+        },
+        'vocabulary.vocabularytranslation': {
+            'Meta': {'unique_together': "(('content_type', 'object_id', 'language'),)", 'object_name': 'VocabularyTranslation'},
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'language': ('django.db.models.fields.CharField', [], {'max_length': '8', 'db_index': 'True'}),
+            'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+        }
+    }
+
+    complete_apps = ['repository']
Index: /tags/v1.0.23rc1/opentrials/repository/management/commands/dropdb.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/management/commands/dropdb.py (revision 357)
+++ /tags/v1.0.23rc1/opentrials/repository/management/commands/dropdb.py (revision 357)
@@ -0,0 +1,19 @@
+from django.conf import settings
+from django.core.management.base import NoArgsCommand
+
+class Command(NoArgsCommand):
+    help = "Drop and re-create the database"
+
+    def handle_noargs(self, **options):
+        import MySQLdb
+        # print "Connecting..."
+        db=MySQLdb.connect(host=settings.DATABASES['default']['HOST'] or "localhost",
+                           user=settings.DATABASES['default']['USER'],
+                           passwd=settings.DATABASES['default']['PASSWORD'],
+                           port=int(settings.DATABASES['default']['PORT'] or 3306))
+        cursor = db.cursor()
+        print "Dropping database %s..." % settings.DATABASES['default']['NAME'],
+        cursor.execute("drop database %s; create database %s;" % 
+                       (settings.DATABASES['default']['NAME'], settings.DATABASES['default']['NAME']))
+        print "dropped and re-created."
+
Index: /tags/v1.0.23rc1/opentrials/repository/management/commands/dump_trial_xml.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/management/commands/dump_trial_xml.py (revision 814)
+++ /tags/v1.0.23rc1/opentrials/repository/management/commands/dump_trial_xml.py (revision 814)
@@ -0,0 +1,30 @@
+from optparse import make_option
+from django.conf import settings
+from django.core.management.base import BaseCommand
+
+from repository.xml import generate
+
+class Command(BaseCommand):
+    help = "Dumps a string for a given function with XML for clinical trials."
+
+    option_list = BaseCommand.option_list + (
+            make_option('--function',
+                dest='func',
+                default='xml_opentrials',
+                help="""Valid functions: %s"""%', '.join(generate.VALID_FUNCTIONS),
+                ),
+            )
+
+    def handle(self, func, **options):
+        try:
+            func = getattr(generate, func)
+        except AttributeError:
+            print 'Invalid function "%s" not found in "repository.xml.generate".' % func
+            print 'Valid functions are:'
+            for f in generate.VALID_FUNCTIONS:
+                print '\t', f
+            return
+
+        # Calls the given function with given arguments
+        print func(**options)
+
Index: /tags/v1.0.23rc1/opentrials/repository/management/commands/update_most_recent_fossils.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/repository/management/commands/update_most_recent_fossils.py (revision 760)
+++ /tags/v1.0.23rc1/opentrials/repository/management/commands/update_most_recent_fossils.py (revision 760)
@@ -0,0 +1,26 @@
+from django.conf import settings
+from django.core.management.base import NoArgsCommand
+from django.contrib.contenttypes.models import ContentType
+
+from repository.models import ClinicalTrial
+from fossil.models import Fossil
+
+class Command(NoArgsCommand):
+    help = "Delete and generate again the fossils for published Clinical Trials"
+
+    def handle_noargs(self, **options):
+        c_type = ContentType.objects.get_for_model(ClinicalTrial)
+        trials = ClinicalTrial.published.all()
+
+        # Loops published ClinicalTrials
+        for trial in trials:
+            # Delete most recent fossil
+            Fossil.objects.filter(
+                    content_type=c_type,
+                    object_id=trial.pk,
+                    is_most_recent=True,
+                    ).delete()
+
+            # Update clinical trial to generate fossil again
+            trial.save()
+
Index: /tags/v1.0.23rc1/opentrials/diagnostic/views.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/diagnostic/views.py (revision 834)
+++ /tags/v1.0.23rc1/opentrials/diagnostic/views.py (revision 834)
@@ -0,0 +1,171 @@
+import os
+from subprocess import Popen, PIPE
+from datetime import date, datetime
+from django.conf import settings
+from django.http import HttpResponse
+from django.contrib.auth.decorators import user_passes_test
+from django.contrib.admin.views.decorators import staff_member_required
+
+from django.core import serializers
+from django.core.exceptions import ImproperlyConfigured
+from django.core.management.commands.dumpdata import sort_dependencies
+from django.db import router, DEFAULT_DB_ALIAS
+from django.db.models import get_apps, get_app
+
+from django.shortcuts import render_to_response
+from django.utils.datastructures import SortedDict
+from django.template.context import RequestContext
+from django.core.files.storage import default_storage
+from django.core.files.base import ContentFile
+
+BACKUP_DIR = getattr(settings, 'BACKUP_DIR', os.path.join(settings.MEDIA_ROOT, 'backup'))
+
+@staff_member_required
+def backup_database(request):
+
+    if request.method == 'POST':
+
+        output = Popen(['which', 'mysqldump'], stdout=PIPE, close_fds=True).communicate()[0]
+
+        mysqldump_bin = output.replace('\n','')
+
+        cmd = mysqldump_bin+' -h %s --opt --compact --skip-add-locks -u %s -p%s %s' % \
+                    (getattr(settings.DATABASES['default'], 'HOST', 'localhost'),
+                     settings.DATABASES['default']['USER'],
+                     settings.DATABASES['default']['PASSWORD'],
+                     settings.DATABASES['default']['NAME'])
+
+        pop1 = Popen(cmd.split(" "), stdout=PIPE, close_fds=True)
+        pop2 = Popen(["bzip2", "-c"], stdin=pop1.stdout, stdout=PIPE, close_fds=True)
+        output = pop2.communicate()[0]
+        
+        default_storage.save(BACKUP_DIR+"/"+datetime.today().strftime("%Y-%m-%d_%H:%M:%S")+"_db.sql.bz2", ContentFile(output))
+    
+    files = default_storage.listdir(BACKUP_DIR)[1]
+    files.sort(reverse=True)
+    return render_to_response('diagnostic/backupdb.html', 
+                                {'files':files,}, 
+                                context_instance=RequestContext(request))
+
+@staff_member_required
+def export_database(request):
+    output = Popen(['which', 'mysqldump'], stdout=PIPE, close_fds=True).communicate()[0]
+
+    mysqldump_bin = output.replace('\n','')
+
+    cmd = mysqldump_bin+' -h %s --opt --compact --skip-add-locks -u %s -p%s %s' % \
+                (getattr(settings.DATABASES['default'], 'HOST', 'localhost'),
+                 settings.DATABASES['default']['USER'],
+                 settings.DATABASES['default']['PASSWORD'],
+                 settings.DATABASES['default']['NAME'])
+
+    pop1 = Popen(cmd.split(" "), stdout=PIPE, close_fds=True)
+    pop2 = Popen(["bzip2", "-c"], stdin=pop1.stdout, stdout=PIPE, close_fds=True)
+    output = pop2.communicate()[0]
+    
+    response = HttpResponse(output, mimetype="application/octet-stream")
+    response['Content-Disposition'] = 'attachment; filename=%s' % date.today().__str__()+'_db.sql.bz2'
+    return response
+
+@staff_member_required
+def dump_data(request,appname):
+    app_list = SortedDict()
+    
+    try:
+        if request.method == 'POST':
+            for appname in request.POST.getlist('apps'):
+                app = get_app(appname)
+                app_list[app] = None
+            appname = 'choices'
+        else:
+            app = get_app(appname)
+            app_list[app] = None
+    except ImproperlyConfigured:
+        if appname == 'all':
+            for app in get_apps():
+                app_list[app] = None
+
+    if(len(app_list) > 0):
+        objects = []
+        for model in sort_dependencies(app_list.items()):
+            if not model._meta.proxy and router.allow_syncdb(DEFAULT_DB_ALIAS, model):
+                objects.extend(model._default_manager.using(DEFAULT_DB_ALIAS).all())
+        serializers.get_serializer('json')
+        json = serializers.serialize('json', objects, indent=2,use_natural_keys=True)
+        response = HttpResponse(json, mimetype='application/json');
+        response['Content-Disposition'] = 'attachment; filename=%s_%s_fixture.json' % (date.today().__str__(),appname)
+        return response
+
+    return render_to_response('diagnostic/dumpdata.html',context_instance=RequestContext(request))
+
+def smoke_test(request):
+    from datetime import datetime
+    return HttpResponse(datetime.now().strftime('%H:%M:%S'))
+
+@user_passes_test(lambda u: u.is_staff)
+def req_dump(request):
+    template = '''
+    <form action="./" method="POST">
+    <input type="text" name="word" value="mitochondrial">
+    <input type="submit" name="btn1" value="one">
+    <input type="submit" name="btn2" value="two">
+    </form>
+    <table border="1">
+       <tr><th>key</th><th>POST[key]</th></tr>
+    %s
+    </table>
+    <hr>
+    <p>
+      <a href="this_is_a_broken_link">Click to test broken link notification</a>
+    </p>
+    '''
+    rows = []
+    for k in request.POST.keys():
+        rows.append('<tr><th>%s</th><td>%s</td></tr>' % (k, request.POST[k]))
+    return HttpResponse(template % ('\n'.join(rows)))
+
+@user_passes_test(lambda u: u.is_staff)
+def sys_info(request):
+    template = u'''
+    <h1>Revision</h1>
+    %(svn_version)s
+    <h1>settings path</h1>
+    <pre>%(settingspath)s</pre>
+    <h1>Site.objects.get_current()</h1>
+    <table>
+       <tr><th>id</th><td>%(site.pk)s</td></tr>
+       <tr><th>domain</th><td>%(site.domain)s</td></tr>
+       <tr><th>name</th><td>%(site.name)s</td></tr>
+    </table>
+    <h1>svn info</h1>
+    <pre>%(svninfo)s</pre>
+    <h1>sys.path</h1>
+    <pre>%(syspath)s</pre>
+    '''
+    import sys
+    import settings
+    from django.contrib.sites.models import Site
+    from subprocess import Popen, PIPE
+    svn_version, svn_version_err = Popen(['svnversion', settings.PROJECT_PATH], stdout=PIPE).communicate()
+    svn_version = svn_version.decode('utf-8') if svn_version else u''
+    svn_version_err = svn_version_err.decode('utf-8') if svn_version_err else u''
+    site = Site.objects.get_current()
+    svnout, svnerr = Popen(['svn', 'info','--non-interactive','--username=anonymous','--password=4guests@','-r', 'HEAD', settings.PROJECT_PATH], stdout=PIPE).communicate()
+    svnout = svnout.decode('utf-8') if svnout else u''
+    svnerr = svnerr.decode('utf-8') if svnerr else u''
+    return HttpResponse(template % {'site.pk':site.pk,
+                                    'site.domain':site.domain,
+                                    'site.name':site.name,
+                                    'svn_version': svn_version + svn_version_err,
+                                    'settingspath': settings.PROJECT_PATH,
+                                    'syspath':'\n'.join(sys.path),
+                                    'svninfo':svnout + svnerr})
+
+@user_passes_test(lambda u: u.is_staff)
+def raise_error(request):
+    class FakeError(StandardError):
+        ''' this is just to test error e-mails and logging '''
+    raise FakeError('This is not really an error')
+
+
+
Index: /tags/v1.0.23rc1/opentrials/diagnostic/urls.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/diagnostic/urls.py (revision 834)
+++ /tags/v1.0.23rc1/opentrials/diagnostic/urls.py (revision 834)
@@ -0,0 +1,14 @@
+from django.conf.urls.defaults import *
+
+from diagnostic.views import *
+
+urlpatterns = patterns('',
+    # Diagnostic views
+    url(r'^smoke/$', smoke_test),
+    url(r'^reqdump/$', req_dump),
+    url(r'^sysinfo/$', sys_info),
+    url(r'^error/$', raise_error),
+    url(r'^dumpdb/$', export_database),
+    url(r'^backupdb/$', backup_database, name='backup_database'),
+    url(r'^dumpdata/(?P<appname>[a-z_]+)?/?$', dump_data, name='dumpdata'),
+)
Index: /tags/v1.0.23rc1/opentrials/diagnostic/templates/diagnostic/dumpdata.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/diagnostic/templates/diagnostic/dumpdata.html (revision 642)
+++ /tags/v1.0.23rc1/opentrials/diagnostic/templates/diagnostic/dumpdata.html (revision 642)
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+    <head>
+        <title>Dump fixtures</title>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    </head>
+    <body>
+        <h1>Available fixtures</h1>
+        <form action="/diag/dumpdata/" method="post">{% csrf_token %}
+            <ul>
+                <li><input type="checkbox" name="apps" value="auth"/><a href="/diag/dumpdata/auth">auth</a></li>
+                <li><input type="checkbox" name="apps" value="contenttypes"/><a href="/diag/dumpdata/contenttypes">contenttypes</a></li>
+                <li><input type="checkbox" name="apps" value="sessions"/><a href="/diag/dumpdata/sessions">sessions</a></li>
+                <li><input type="checkbox" name="apps" value="sites"/><a href="/diag/dumpdata/sites">sites</a></li>
+                <li><input type="checkbox" name="apps" value="admin"/><a href="/diag/dumpdata/admin">admin</a></li>
+                <li><input type="checkbox" name="apps" value="flatpages"/><a href="/diag/dumpdata/flatpages">flatpages</a></li>
+                <li><input type="checkbox" name="apps" value="repository"/><a href="/diag/dumpdata/repository">repository</a></li>
+                <li><input type="checkbox" name="apps" value="vocabulary"/><a href="/diag/dumpdata/vocabulary">vocabulary</a></li>
+                <li><input type="checkbox" name="apps" value="reviewapp"/><a href="/diag/dumpdata/reviewapp">reviewapp</a></li>
+                <li><input type="checkbox" name="apps" value="tickets"/><a href="/diag/dumpdata/tickets">tickets</a></li>
+                <li><input type="checkbox" name="apps" value="assistance"/><a href="/diag/dumpdata/assistance">assistance</a></li>
+                <li><input type="checkbox" name="apps" value="polyglot"/><a href="/diag/dumpdata/polyglot">polyglot</a></li>
+                <li><input type="checkbox" name="apps" value="flatpages_polyglot"/><a href="/diag/dumpdata/flatpages_polyglot">flatpages_polyglot</a></li>
+                <li><input type="checkbox" name="apps" value="registration"/><a href="/diag/dumpdata/registration">registration</a></li>
+            </ul>
+            <input type="submit" value="Export"/>
+        </form>
+    </body>
+</html>
Index: /tags/v1.0.23rc1/opentrials/diagnostic/templates/diagnostic/backupdb.html
===================================================================
--- /tags/v1.0.23rc1/opentrials/diagnostic/templates/diagnostic/backupdb.html (revision 834)
+++ /tags/v1.0.23rc1/opentrials/diagnostic/templates/diagnostic/backupdb.html (revision 834)
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+    <head>
+        <title>Database backup</title>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    </head>
+    <body>
+        <h1>Database backup</h1>
+        <form action="{% url backup_database %}" method="post">{% csrf_token %}
+            <input type="submit" value="Generate backup"/>
+        </form>
+        <table>
+        {% for f in files %}
+           <tr><th>{{ f }}</th><td><a href="/static/backup/{{ f }}">download</a></td></tr>
+        {% endfor %}
+        </table>
+    </body>
+</html>
Index: /tags/v1.0.23rc1/opentrials/settings.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/settings.py (revision 994)
+++ /tags/v1.0.23rc1/opentrials/settings.py (revision 994)
@@ -0,0 +1,241 @@
+# -*- encoding: utf-8 -*-
+
+# OpenTrials: a clinical trials registration system
+#
+# Copyright (C) 2010 BIREME/PAHO/WHO, ICICT/Fiocruz e
+#                    Ministério da Saúde do Brasil
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 2.1 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+
+DEBUG = False
+TEMPLATE_DEBUG = DEBUG
+PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
+
+ADMINS = (
+    ('Luciano Ramalho', 'luciano.ramalho@bireme.org'),
+    ('Antonio Ribeiro Alves', 'antonio.alves@bireme.org')
+)
+
+MANAGERS = ADMINS
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = 'America/Sao_Paulo'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'pt-BR'
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+USE_L10N = True
+
+# Absolute path to the directory that holds media.
+# Example: "/home/media/media.lawrence.com/"
+
+MEDIA_ROOT = os.path.join(PROJECT_PATH, 'static')
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash if there is a path component (optional in other cases).
+# Examples: "http://media.lawrence.com", "http://example.com/media/"
+MEDIA_URL = '/static/'
+
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
+# trailing slash.
+# Examples: "http://foo.com/media/", "/media/".
+ADMIN_MEDIA_PREFIX = '/static/media/'
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = '*06=j&&^n71^a&%%3rs%7lla+^(n^v1w@@dp_rxvi#&(xo7meq'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+    'django.template.loaders.filesystem.load_template_source',
+    'django.template.loaders.app_directories.load_template_source',
+#     'django.template.loaders.eggs.load_template_source',
+)
+
+MIDDLEWARE_CLASSES = (
+    'django.middleware.gzip.GZipMiddleware',
+    'django.middleware.common.CommonMiddleware',
+    'django.middleware.http.ConditionalGetMiddleware',
+    'django.contrib.sessions.middleware.SessionMiddleware',
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.contrib.messages.middleware.MessageMiddleware',
+
+    #'debug_toolbar.middleware.DebugToolbarMiddleware',
+
+    'django.middleware.csrf.CsrfViewMiddleware',
+    'middleware.scriptprefix.ScriptPrefixMiddleware',
+    'django.middleware.locale.LocaleMiddleware',
+    'django.middleware.transaction.TransactionMiddleware',
+    'middleware.user_locale.UserLocaleMiddleware',
+    #'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
+    'flatpages_polyglot.middleware.FlatPagePolyglotMiddleware',
+)
+
+ROOT_URLCONF = 'opentrials.urls'
+LOGIN_REDIRECT_URL = '/accounts/dashboard/'
+
+TEMPLATE_DIRS = (
+    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
+    # Always use forward slashes, even on Windows.
+    # Don't forget to use absolute paths, not relative paths.
+
+    os.path.join(PROJECT_PATH, 'templates'),
+)
+
+INSTALLED_APPS = (
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.sites',
+    'django.contrib.admin',
+    'django.contrib.admindocs',
+    'django.contrib.flatpages',
+    'django.contrib.markup',
+    'django.contrib.messages',
+    'deleting',
+    'vocabulary',
+    'repository',
+    'reviewapp',
+    'tickets',
+    'assistance',
+    'decsclient',
+    'icd10client',
+    'diagnostic',
+    'polyglot',
+    'registration',  # django-registration package
+    'flatpages_polyglot',
+    'south',
+    'fossil',
+    #'rosetta',
+
+    #'debug_toolbar',
+    'compressor',
+)
+
+TEMPLATE_CONTEXT_PROCESSORS =(
+    'django.core.context_processors.auth',
+    'django.core.context_processors.i18n',
+    'django.core.context_processors.csrf',
+    'django.core.context_processors.media',
+    'django.core.context_processors.request',
+    'context_processors.opentrials.polyglot',
+    'context_processors.opentrials.google_analytics',
+    'context_processors.opentrials.latest_tweets',
+    'context_processors.opentrials.debug',
+    'context_processors.opentrials.default_from_email',
+    'context_processors.opentrials.opentrials_version',
+)
+
+AUTH_PROFILE_MODULE = "reviewapp.UserProfile"
+
+#################################################################
+### BEGIN Clinical Trials Repository customization settings
+###
+### see also settings_local-SAMPLE.py for private customization settings.
+
+# this id must match the record with the correct domain name in the
+# django_site table; the initial values for that table are defined
+# in opentrials/fixtures/initial_data.json
+SITE_ID = 2 # change if necessary to match a record in django_site
+
+SITE_TITLE = u'Registro Brasileiro de Ensaios Clínicos'
+SEND_BROKEN_LINK_EMAILS = True
+DECS_SERVICE = 'http://decs.bvs.br/cgi-bin/mx/cgi=@vmx/decs'
+ICD10_SERVICE = 'http://bases.bireme.br/cgi-bin/mxlindG4.exe/cgi=@cid10/cid10'
+
+TRIAL_ID_PREFIX = 'RBR'
+TRIAL_ID_DIGITS = 6
+
+# Notes:
+# 1) source: http://www.i18nguy.com/unicode/language-identifiers.html
+# 2) the first managed language is considered the default and is
+#    also the source language for content translation purposes
+MANAGED_LANGUAGES_CHOICES = (
+    (u'en', u'English'),
+    (u'es', u'Español'),
+    (u'pt-br', u'Português'),
+)
+TARGET_LANGUAGES = MANAGED_LANGUAGES_CHOICES[1:] # exlude source language
+MANAGED_LANGUAGES = [code for code, label in MANAGED_LANGUAGES_CHOICES]
+# TODO: implement this as default on new submission forms
+#LANGUAGES = MANAGED_LANGUAGES_CHOICES
+DEFAULT_SUBMISSION_LANGUAGE = u'en'
+
+# django-registration: for how long the activation link is valid
+ACCOUNT_ACTIVATION_DAYS = 7
+
+# django-registration: set to False to suspend new user registrations
+REGISTRATION_OPEN = True
+
+ATTACHMENTS_DIR = 'attachments'
+SUBMISSIONS_XML_PATH = 'submissions_xml'
+
+# Name of Primary Registry
+REG_NAME = 'REBEC'
+
+FIXTURE_DIRS = ('fixtures',)
+
+PAGINATOR_CT_PER_PAGE = 10
+
+TWITTER = 'ensaiosclinicos'
+TWITTER_TIMEOUT = 18000 # expires in 5 min
+
+TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
+NOSE_ARGS = ['--with-coverage', '--with-doctest', '--doctest-tests', '--doctest-extension=txt'] # --doctest-fixtures, --with-profile
+#NOSE_PLUGINS = []
+SKIP_SOUTH_TESTS = True
+SOUTH_TESTS_MIGRATE = False
+
+SESSION_EXPIRE_AT_BROWSER_CLOSE = True
+
+FORMAT_MODULE_PATH = 'formats'
+
+# Backup directory
+BACKUP_DIR = os.path.join(MEDIA_ROOT, 'backup')
+
+INTERNAL_IPS = ('127.0.0.1',)
+USE_ETAGS = True
+
+COMPRESS = True
+COMPRESS_OUTPUT_DIR = 'compressor-cache'
+#COMPRESS_CSS_FILTERS = ['compressor.filters.cssmin.CSSMinFilter']
+#COMPRESS_JS_FILTERS = ['compressor.filters.jsmin.JSMinFilter']
+
+### END Clinical Trials Repository customization settings
+#################################################################
+
+# Deployment settings: there *must* be an unversioned settings_local.include
+# file in the current directory. See sample file at settings_local-SAMPLE.include
+# FIXME: why not use a simple "try: from settings_local import * except ImportError: pass" ?
+execfile(os.path.join(PROJECT_PATH,'settings_local.include'))
+
+#check for write permission in static/attachments, for user's uploads
+ATTACHMENTS_PATH = os.path.join(MEDIA_ROOT, ATTACHMENTS_DIR)
+if os.path.exists(ATTACHMENTS_PATH):
+    if not os.access(ATTACHMENTS_PATH, os.W_OK):
+        raise IOError('Attachments folder "%s" must be writeable' %
+                                (ATTACHMENTS_PATH))
+else:
+    raise IOError('Attachments folder "%s" not found' % (ATTACHMENTS_PATH))
+
+OPENTRIALS_VERSION = 'v1.0.22rc4' # this should be the deployed tag number
Index: /tags/v1.0.23rc1/opentrials/deleting/tests/01-models.txt
===================================================================
--- /tags/v1.0.23rc1/opentrials/deleting/tests/01-models.txt (revision 766)
+++ /tags/v1.0.23rc1/opentrials/deleting/tests/01-models.txt (revision 766)
@@ -0,0 +1,104 @@
+CONTROLLED DELETION MODELS
+==========================
+
+    >>> from deleting.tests.test_models import MyClass, create_tables
+
+Create the table in database
+
+    >>> create_tables()
+
+Test table created with successful
+
+    >>> MyClass.objects.count()
+    0
+
+Creating some objects
+
+    >>> obj1 = MyClass.objects.create(title='Title 1', content='My content')
+    >>> obj2 = MyClass.objects.create(title='Title 2', content='My content')
+    >>> obj3 = MyClass.objects.create(title='Title 3', content='My content')
+
+    >>> MyClass.objects.count()
+    3
+
+Single methods
+--------------
+
+Deleting some ones
+
+    >>> obj1.delete()
+    >>> obj1._deleted
+    True
+
+    >>> MyClass.objects.count()
+    2
+
+    >>> MyClass.deleted_objects.count()
+    1
+
+    >>> MyClass.all_objects.count()
+    3
+
+Recovering object
+
+    >>> obj1.recover()
+    >>> obj1._deleted
+    False
+
+    >>> MyClass.objects.count()
+    3
+
+    >>> MyClass.deleted_objects.count()
+    0
+
+    >>> MyClass.all_objects.count()
+    3
+
+QuerySet methods
+----------------
+
+Deleting by QuerySet method (by manager isn't possible)
+
+    >>> MyClass.objects.filter(pk__lte=2).delete()
+
+    >>> MyClass.objects.count()
+    1
+
+    >>> MyClass.deleted_objects.count()
+    2
+
+    >>> MyClass.all_objects.count()
+    3
+
+Recovering by QuerySet method
+
+    >>> MyClass.objects.count()
+    1
+
+    >>> MyClass.deleted_objects.filter(pk__lte=2).count()
+    2
+
+    >>> MyClass.deleted_objects.filter(pk__lte=2).recover()
+
+    >>> MyClass.objects.count()
+    3
+
+    >>> MyClass.deleted_objects.count()
+    0
+
+    >>> MyClass.all_objects.count()
+    3
+
+Recovering by Manager method
+
+    >>> MyClass.deleted_objects.recover()
+
+    >>> MyClass.objects.count()
+    3
+
+    >>> MyClass.deleted_objects.count()
+    0
+
+    >>> MyClass.all_objects.count()
+    3
+
Index: /tags/v1.0.23rc1/opentrials/deleting/tests/test_models.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/deleting/tests/test_models.py (revision 766)
+++ /tags/v1.0.23rc1/opentrials/deleting/tests/test_models.py (revision 766)
@@ -0,0 +1,33 @@
+from django.db import models, connection
+from django.core.management.color import no_style
+from django.contrib.contenttypes import generic
+from django.db.models.sql.query import setup_join_cache
+
+from deleting.models import ControlledDeletion
+
+class MyClass(ControlledDeletion):
+    class Meta:
+        app_label = 'temporary_test'
+
+    title = models.CharField(max_length=255, blank=True)
+    content = models.TextField(max_length=2000, blank=True)
+
+setup_join_cache(MyClass)
+
+def create_tables():
+    cursor = connection.cursor()
+    style = no_style()
+    tables = connection.introspection.table_names()
+    seen_models = connection.introspection.installed_models(tables)
+
+    sql, references = connection.creation.sql_create_model(MyClass, style, seen_models)
+
+    pending_references = {}
+    for refto, refs in references.items():
+        pending_references.setdefault(refto, []).extend(refs)
+        if refto in seen_models:
+            sql.extend(connection.creation.sql_for_pending_references(refto, style, pending_references))
+    sql.extend(connection.creation.sql_for_pending_references(MyClass, style, pending_references))
+    for statement in sql:
+        cursor.execute(statement)
+
Index: /tags/v1.0.23rc1/opentrials/deleting/models.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/deleting/models.py (revision 766)
+++ /tags/v1.0.23rc1/opentrials/deleting/models.py (revision 766)
@@ -0,0 +1,77 @@
+from django.db import models
+from django.db.models.query import QuerySet
+
+class NotDeletedQuerySet(QuerySet):
+    def delete(self):
+        self.update(_deleted=True)
+
+class NotDeletedManager(models.Manager):
+    """
+    Returns only objects with _deleted=False
+    """
+    def get_query_set(self):
+        qs = NotDeletedQuerySet(self.model) #, using=self._db)
+
+        return qs.filter(_deleted=False)
+
+class DeletedQuerySet(QuerySet):
+    def recover(self):
+        self.update(_deleted=False)
+
+class DeletedManager(models.Manager):
+    """
+    Returns only objects with _deleted=True
+    """
+    def get_query_set(self):
+        qs = DeletedQuerySet(self.model) #, using=self._db)
+
+        return qs.filter(_deleted=True)
+
+    def recover(self):
+        return self.get_query_set().recover()
+
+class AllObjectsQuerySet(QuerySet):
+    def delete(self):
+        self.update(_deleted=True)
+
+    def recover(self):
+        self.update(_deleted=False)
+
+class AllObjectsManager(DeletedManager):
+    """
+    Returns all objects not matters if _deleted or not
+    """
+    def get_query_set(self):
+        return AllObjectsQuerySet(self.model) #, using=self._db)
+
+class ControlledDeletion(models.Model):
+    """
+    This class implements the inheritance deletion functions to avoid real deletion
+    and just set field '_deleted' as True
+    """
+
+    class Meta:
+        abstract = True
+
+    # Managers
+    objects = NotDeletedManager()
+    deleted_objects = DeletedManager()
+    all_objects = AllObjectsManager()
+
+    # Fields
+    _deleted = models.BooleanField(default=False, blank=True, db_index=True, editable=False)
+
+    def delete(self, *args, **kwargs):
+        """
+        Instead of delete the object, just changes field _deleted to True
+        """
+        self._deleted = True
+        self.save()
+
+    def recover(self, *args, **kwargs):
+        """
+        Sets _deleted to False to recover object
+        """
+        self._deleted = False
+        self.save()
+
Index: /tags/v1.0.23rc1/opentrials/deleting/migrations/0001_initial.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/deleting/migrations/0001_initial.py (revision 768)
+++ /tags/v1.0.23rc1/opentrials/deleting/migrations/0001_initial.py (revision 768)
@@ -0,0 +1,21 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        pass
+
+
+    def backwards(self, orm):
+        pass
+
+
+    models = {
+        
+    }
+
+    complete_apps = ['deleting']
Index: /tags/v1.0.23rc1/opentrials/assistance/admin.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/assistance/admin.py (revision 736)
+++ /tags/v1.0.23rc1/opentrials/assistance/admin.py (revision 736)
@@ -0,0 +1,53 @@
+from django.contrib import admin
+from assistance.models import *
+from utilities import safe_truncate, export_json
+
+from polyglot.admin import TranslationInline, TranslationAdmin
+
+class FieldHelpTranslationInline(TranslationInline):
+    model = FieldHelpTranslation
+
+class FieldHelpAdmin(TranslationAdmin):
+    list_display = ('form','field','short_text',
+                    'translation_completed', 'missing_translations')
+    list_display_links = ('form','field')
+    search_fields = ('form','field')
+    list_filter = ('form',)
+    inlines = [FieldHelpTranslationInline]
+    actions = [export_json]
+
+    def short_text(self, obj):
+        return safe_truncate(obj.text)
+
+class CategoryTranslationInline(TranslationInline):
+    model = CategoryTranslation
+
+class CategoryAdmin(TranslationAdmin):
+    inlines = [CategoryTranslationInline]
+    list_display = ('label',
+                    'translation_completed', 'missing_translations')
+    actions = [export_json]
+
+class QuestionTranslationInline(TranslationInline):
+    model = QuestionTranslation
+
+class QuestionAdmin(TranslationAdmin):
+    inlines = [QuestionTranslationInline]
+    list_display = ('title','short_text',
+                    'translation_completed', 'missing_translations')
+    list_filter = ('category', )
+    actions = [export_json]
+
+    def short_text(self, obj):
+        return safe_truncate(obj.answer)
+        
+if FieldHelp not in admin.site._registry:
+    admin.site.register(FieldHelp, FieldHelpAdmin)
+
+if Category not in admin.site._registry:
+    admin.site.register(Category, CategoryAdmin)
+
+if Question not in admin.site._registry:
+    admin.site.register(Question, QuestionAdmin)
+    
+
Index: /tags/v1.0.23rc1/opentrials/assistance/views.py
===================================================================
--- /tags/v1.0.23rc1/opentrials/assistance/views.py (revision 671)
+++ /tags/v1.0.23rc1/opentrials/assistance/views.py (revision 671)
@@ -0,0 +1,52 @@
+# coding: utf-8
+
+from django.shortcuts import render_to_response
+from django.template.context import RequestContext
+
+from assistance.models import Question, QuestionTranslation
+from assistance.models import Category, CategoryTranslation
+
+
+def faq(request):
+    """
+    ATTENTION: This view has a complexity of O(question * N * 2) on database load, because each
+    question does 1 or 2 calls to database to get question and category translations.
+
+    It is prepared to get questions including category fields at once SQL call and using cache
+    to get translations as far as possible.
+
+    If the questions quantity grow a lot, this logic should be replaced to something that gets
+    all translations from database at once.
+    """
+    questions = Question.objects.select_related('category').order_by('category', 'order')
+
+    if len(questions) < 1:
+        object_list = None
+    else:
+        object_list = []
+        for question in questions:
+            q = Question()
+            c = Category()
+            try:
+                #trans = question.translations.get(language__iexact=request.LANGUAGE_CODE)
+                trans = QuestionTranslation.objects.get_translation_for_object(request.LANGUAGE_CODE, question)
+                q.title = trans.title
+                q.answer = trans.answer
+                q.order = question.order
+                q.created = question.created
+                q.pk = question.pk
+            except QuestionTranslation.DoesNotExist:
+                q = question
+            try:
+                #trans = question.category.translations.get(language__iexact=request.LANGUAGE_CODE)
+                trans = CategoryTranslation.objects.get_translation_for_object(request.LANGUAGE_CODE, question.category)
+                c.label = trans.label
+            except CategoryTranslation.DoesNotExist:
+                c = question.category
+            
+            q.category = c
+            object_list.append(q)
+
+    return render_to_response('assistance/question_list.html', {
+                          'object_list': object_list,},
+                          context_instance=RequestContext(request))
Index: /tags/v1.0.23rc1/opentrials/assistance/fixtures/initial_data.json
===================================================================
--- /tags/v1.0.23rc1/opentrials/assistance/fixtures/initial_data.json (revision 858)
+++ /tags/v1.0.23rc1/opentrials/assistance/fixtures/initial_data.json (revision 858)
@@ -0,0 +1,2241 @@
+[
+  {
+    "pk": 4, 
+    "model": "assistance.categorytranslation", 
+    "fields": {
+      "label": "Ambiente operacional", 
+      "content_type": [
+        "assistance", 
+        "category"
+      ], 
+      "language": "pt-br", 
+      "object_id": 1
+    }
+  }, 
+  {
+    "pk": 2, 
+    "model": "assistance.categorytranslation", 
+    "fields": {
+      "label": "Registro do estudo", 
+      "content_type": [
+        "assistance", 
+        "category"
+      ], 
+      "language": "pt-br", 
+      "object_id": 6
+    }
+  }, 
+  {
+    "pk": 3, 
+    "model": "assistance.categorytranslation", 
+    "fields": {
+      "label": "Registro del estudio", 
+      "content_type": [
+        "assistance", 
+        "category"
+      ], 
+      "language": "es", 
+      "object_id": 6
+    }
+  }, 
+  {
+    "pk": 5, 
+    "model": "assistance.categorytranslation", 
+    "fields": {
+      "label": "Sistema operacional", 
+      "content_type": [
+        "assistance", 
+        "category"
+      ], 
+      "language": "es", 
+      "object_id": 1
+    }
+  }, 
+  {
+    "pk": 6, 
+    "model": "assistance.categorytranslation", 
+    "fields": {
+      "label": "Interface", 
+      "content_type": [
+        "assistance", 
+        "category"
+      ], 
+      "language": "pt-br", 
+      "object_id": 2
+    }
+  }, 
+  {
+    "pk": 7, 
+    "model": "assistance.categorytranslation", 
+    "fields": {
+      "label": "Interfaz", 
+      "content_type": [
+        "assistance", 
+        "category"
+      ], 
+      "language": "es", 
+      "object_id": 2
+    }
+  }, 
+  {
+    "pk": 3, 
+    "model": "assistance.questiontranslation", 
+    "fields": {
+      "answer": "Ensaios devem ser registrados ap\u00f3s a aprova\u00e7\u00e3o de um comit\u00ea de \u00e9tica nacional e antes do recrutamento do primeiro paciente\r\n", 
+      "title": "Quando os estudos devem ser registrados?", 
+      "content_type": [
+        "assistance", 
+        "question"
+      ], 
+      "language": "pt-br", 
+      "object_id": 14
+    }
+  }, 
+  {
+    "pk": 2, 
+    "model": "assistance.questiontranslation", 
+    "fields": {
+      "answer": "Todos os ensaios cl\u00ednicos com participantes brasileiros, em todas as \u00e1reas da sa\u00fade, e com testes de todas as formas de interven\u00e7\u00f5es, devem ser registrados. \r\nEstudos devem atender a defini\u00e7\u00e3o <a href=\"http://www.who.int/ictrp/en/\" title=\"World Health Organization\" target=\"_blank\">WHO</a> / ICMJE 2008 de um ensaio cl\u00ednico para serem registrados. Ou seja, qualquer pesquisa que prospectivamente designa participantes humanos ou grupos de seres humanos, para uma ou mais interven\u00e7\u00f5es relacionadas \u00e0 sa\u00fade, para avaliar os efeitos na sa\u00fade. Interven\u00e7\u00f5es m\u00e9dicas incluem qualquer interven\u00e7\u00e3o usada para modificar um desfecho de sa\u00fade e incluem drogas, procedimentos cir\u00fargicos, aparelhos, tratamentos comportamentais, etc. Em caso de d\u00favida se um ensaio cl\u00ednico deve ser registrado ou n\u00e3o, recomenda-se o registro desse estudo.\r\n", 
+      "title": "Quais estudos precisam ser registrados?", 
+      "content_type": [
+        "assistance", 
+        "question"
+      ], 
+      "language": "pt-br", 
+      "object_id": 13
+    }
+  }, 
+  {
+    "pk": 4, 
+    "model": "assistance.questiontranslation", 
+    "fields": {
+      "answer": "O coordenador, patrocinador do estudo ou um representante adequado pode ser respons\u00e1vel pelo registro de um estudo. O patrocinador \u00e9 um indiv\u00edduo ou empresa, p\u00fablica ou privada, que ap\u00f3ia financeiramente a pesquisa, conforme definido pela resolu\u00e7\u00e3o RDC 39 da Ag\u00eancia Nacional de Vigil\u00e2ncia Sanit\u00e1ria.\r\nPara os estudos cl\u00ednicos patrocinados por ag\u00eancias nacionais ou internacionais de fomento \u00e0 pesquisa, entidades filantr\u00f3picas, organiza\u00e7\u00f5es n\u00e3o governamentais (ONGs) ou outras entidades sem fins lucrativos, o(s) investigador(es) respons\u00e1vel(ies) pela coordena\u00e7\u00e3o da pesquisa assumem o papel de representante do patrocinador, caso n\u00e3o haja uma Organiza\u00e7\u00e3o Representativa para Pesquisa Cl\u00ednica (ORPC) respons\u00e1vel pela condu\u00e7\u00e3o da mesma.\r\nNo caso de estudos independentes, em que o investigador n\u00e3o tem apoio financeiro de um patrocinador espec\u00edfico, incluindo os casos que recebem os medicamentos de investiga\u00e7\u00e3o sob a forma de doa\u00e7\u00e3o onde o doador n\u00e3o deseja ser caracterizado como patrocinador do estudo, o investigador principal assume a responsabilidade pelo registro do estudo.\r\n", 
+      "title": "Quem \u00e9 respons\u00e1vel pelo registro de um estudo?", 
+      "content_type": [
+        "assistance", 
+        "question"
+      ], 
+      "language": "pt-br", 
+      "object_id": 15
+    }
+  }, 
+  {
+    "pk": 5, 
+    "model": "assistance.questiontranslation", 
+    "fields": {
+      "answer": "Na primeira vez, os usu\u00e1rios precisam criar um nome de login e uma senha, clicando no bot\u00e3o \u201cRegistrar-se\u201d. Um email de confirma\u00e7\u00e3o ser\u00e1 enviado para a conta de e-mail informado.\r\nO bot\u00e3o de \u201cNova Submiss\u00e3o\u201d levar\u00e1 o requerente para as telas que precisam ser preenchidas. Isso inclui informa\u00e7\u00f5es b\u00e1sicas, como os tipos de participantes, as interven\u00e7\u00f5es que est\u00e3o sendo testadas e os desfechos a serem avaliados. Outras informa\u00e7\u00f5es requeridas incluem detalhes do desenho do estudo, tamanho da amostra e informa\u00e7\u00f5es dos contatos. Cada campo tem uma op\u00e7\u00e3o de ajuda (\u00edcone \u201c?\u201d) para auxiliar os requerentes a inserirem os dados corretos. Uma vez que cada formul\u00e1rio \u00e9 preenchido, o requerente deve clicar no bot\u00e3o \"Salvar\" para salvar as informa\u00e7\u00f5es no Registro Brasileiro de Ensaios Cl\u00ednicos. Uma vez que todas as informa\u00e7\u00f5es obrigat\u00f3rias estiverem sido preenchidas nos formul\u00e1rios, o requerente deve clicar no bot\u00e3o \u201cEnviar para revis\u00e3o\u201d.\r\nAp\u00f3s a submiss\u00e3o dos dados, a equipe do REBEC ir\u00e1 verificar os dados submetidos e consultar o requerente se necessitar que alguma informa\u00e7\u00e3o seja esclarecida. Uma vez que todas as d\u00favidas sejam esclarecidas, os estudos s\u00e3o oficialmente registrados e ser\u00e1 atribu\u00eddo um n\u00famero de registro \u00fanico. Tanto a data da submiss\u00e3o e a data de registro s\u00e3o armazenados. ", 
+      "title": "Como fa\u00e7o para registrar um estudo?", 
+      "content_type": [
+        "assistance", 
+        "question"
+      ], 
+      "language": "pt-br", 
+      "object_id": 16
+    }
+  }, 
+  {
+    "pk": 6, 
+    "model": "assistance.questiontranslation", 
+    "fields": {
+      "answer": "Segundo as diretrizes do modelo de refer\u00eancia Vancouver para \"Part of a database on the internet\" (veja http://www.nlm.nih.gov/bsd/uniform_requirements.html) e as diretrizes de cita\u00e7\u00e3o da National Library of Medicine (NLM) http://www.ncbi.nlm.nih.gov/books/bv.fcgi?rid=citmed.section.57708) i\u00e9 recoimendado que a cita\u00e7\u00e3o de um registro em um registro de ensaios cl\u00ednicops consista de:\r\n\r\n * nome da base de dados\r\n * localiza\u00e7\u00e3o e nome do respons\u00e1vel pela base de dados - o ano que o s\u00edtio foi desenvolvido/online\r\n * o n\u00famero de identifica\u00e7\u00e3o \u00fanico (ID)\r\n * t\u00edtulo do registro\r\n * data do registro\r\n * data quando foi citado\r\n * n\u00famero aproximado de p\u00e1ginas - o endere\u00e7o web do registro\r\n\r\n Exemplo:\r\n\r\n RBEC\r\n Registro Brasileiro de Ensaios Cl\u00ednicos[Internet]: Rio de Janeiro (RJ): Instituto de Informa\u00e7\u00e3o Cient\u00edfica e Tecnol\u00f3gica em Sa\u00fade (Brazil); 2010 - . Identifier BCTR12345678. A multi-centre, randomised, double-blind, placebo-controlled clinical trial examining the efficacy and safety of low-dose aspirin after initial anticoagulation to prevent recurrent venous thromboembolism; 2010 Jul 12 [cited 2008 June 18]; [1 page]. Available from http://www.ensaiosclinocos.gov.br/BCTR12345678.aspx.", 
+      "title": "Como citar um registro em um Registro de Ensaios Cl\u00ednicos", 
+      "content_type": [
+        "assistance", 
+        "question"
+      ], 
+      "language": "pt-br", 
+      "object_id": 17
+    }
+  }, 
+  {
+    "pk": 7, 
+    "model": "assistance.questiontranslation", 
+    "fields": {
+      "answer": "O registro de um ensaio ser\u00e1 o \u00fanico documento dispon\u00edvel publicamente at\u00e9 que os resultados desse estudo sejam publicados. Alguns exemplos de situa\u00e7\u00f5es nas quais os estudos poderiam ser citados s\u00e3o:\r\n\r\nQuando um manuscrito relatando os resultados do ensaio \u00e9 publicado ou reportado\r\n\r\nQuando um manuscrito com relatos de quest\u00f5es metodol\u00f3gicas a respeito de um ensaios espec\u00edfico \u00e9 publicado ou reportado\r\n\r\nEm protocolos para revis\u00f5es sistem\u00e1ticas ou revis\u00f5es sistem\u00e1ticas conclu\u00eddas (p.ex. quando uma lista de ensaios em curso \u00e9 inclu\u00edda)\r\n\r\nEm protocolos para metan\u00e1lises prospectives que ir\u00e3o listar os ensaios em curso a serem inclu\u00eddos\r\n\r\nEm qualquer manuscrito quando a refer\u00eancia a um ensaio em curso ou n\u00e3o-publicado (ou mesmo quando publicado) poderia ser relevante\r\n", 
+      "title": "Quando citar um registro de um ensaio clinico", 
+      "content_type": [
+        "assistance", 
+        "question"
+      ], 
+      "language": "pt-br", 
+      "object_id": 18
+    }
+  }, 
+  {
+    "pk": 8, 
+    "model": "assistance.questiontranslation", 
+    "fields": {
+      "answer": "N\u00e3o. Apenas os estudos de confirma\u00e7\u00e3o terap\u00eautica (fase III) que poder\u00e3o subsidiar o registro\u00b9 na Ag\u00eancia Nacional de Vigil\u00e2ncia Sanit\u00e1ria (Anvisa), devem ser registrados em um dos registros prim\u00e1rios da rede de registros do International Clinical Trials Registration Plataform (ICTRP/WHO). Os demais projetos de pesquisa de ensaios cl\u00ednicos com medicamentos, produtos para sa\u00fade\u00b2 ou interven\u00e7\u00f5es Diet\u00e9ticas, fases I, II e VI, assim como os ensaios cl\u00ednicos em farmacogen\u00f4mica ou farmacogen\u00e9tica entre outros aprovados pela CTNBio ou pelo CGEN, que envolvam importa\u00e7\u00e3o e/ou exporta\u00e7\u00e3o dever\u00e3o ser registrado apenas na ANVISA.\r\nAtualmente os projetos de pesquisa de Biodisponibilidade e Bioequival\u00eancia para registro de medicamentos gen\u00e9ricos n\u00e3o devem ser submetidos \u00e0 avalia\u00e7\u00e3o pela ANVISA.\r\n\r\nNota: (1) produto inovador , nova indica\u00e7\u00e3o terap\u00eautica ou altera\u00e7\u00f5es de registro\r\n         (2) inclui materiais (\u00f3rteses; pr\u00f3teses), artigos, dispositivos, equipamentos", 
+      "title": "\u00c9 obrigat\u00f3rio o registro de todos os ensaios cl\u00ednicos no Registro Brasileiro de Ensaios Cl\u00ednicos \u00e9 obrigat\u00f3rio para obter a anu\u00eancia em pesquisa cl\u00ednica da ANVISA?", 
+      "content_type": [
+        "assistance", 
+        "question"
+      ], 
+      "language": "pt-br", 
+      "object_id": 19
+    }
+  }, 
+  {
+    "pk": 9, 
+    "model": "assistance.questiontranslation", 
+    "fields": {
+      "answer": "Estabelecer um registro amplo e atualizado dos estudos de interven\u00e7\u00e3o e observacionais do Brasil, Am\u00e9rica Latina & Caribe\r\n\r\nProver aos stakeholders interessados o acesso a estudos em curso ou conclu\u00eddos \u2013 dados confi\u00e1veis e sem \u00f4nus para revis\u00f5es/metan\u00e1lises, diretrizes e pol\u00edticas de pesquisa\r\n\r\nAumentar a transpar\u00eancia na pesquisa, fortalecendo o valor \u00e9tico e cient\u00edfico dos estudos de interven\u00e7\u00e3o e observacionais\r\n\r\nFacilitar a descoberta e o controle de vi\u00e9ses de desenho, de publica\u00e7\u00e3o e reduzir o vi\u00e9s de idioma\r\n\r\nIntegrar aos processos \u00e9ticos e regulat\u00f3rios\r\n\r\nAtender \u00e0s necessidades nacionais e regionais de informa\u00e7\u00e3o\r\n", 
+      "title": "Quais s\u00e3o os objetivos do Registro Brasileiro de Ensaios Cl\u00ednicos?", 
+      "content_type": [
+        "assistance", 
+        "question"
+      ], 
+      "language": "pt-br", 
+      "object_id": 20
+    }
+  }, 
+  {
+    "pk": 10, 
+    "model": "assistance.questiontranslation", 
+    "fields": {
+      "answer": "Um registro de ensaios cl\u00ednicos pode aumentar a efic\u00e1cia dos esfor\u00e7os dos ensaios cl\u00ednicos atuais ao:\r\n\r\nReduzir a duplica\u00e7\u00e3o desnecess\u00e1ria de esfor\u00e7os de pesquisa, porque os profissionais que planejam novos estudos estar\u00e3o cientes de todos os ensaios existentes;\r\n\r\nAumentar as taxas de recrutamento de participantes para ensaios cl\u00ednicos (especialmente para doen\u00e7as raras ou condi\u00e7\u00f5es de alto risco), desse modo aumentando as chances de desfechos bem-sucedidos de alguns ensaios cl\u00ednicos;\r\n\r\nDar valor agregado aos resultados da pesquisa ao prover uma fonte de informa\u00e7\u00e3o confi\u00e1vel e n\u00e3o-enviesada sobre ensaios cl\u00ednicos para revis\u00f5es sistem\u00e1ticas, metan\u00e1lises e diretrizes baseadas em evid\u00eancias;\r\n\r\nAprimorar as evid\u00eancias dispon\u00edveis que orientem as pr\u00e1ticas de sa\u00fade.\r\n", 
+      "title": "Quais s\u00e3o os benef\u00edcios de um Registro de Ensaios Cl\u00ednicos?", 
+      "content_type": [
+        "assistance", 
+        "question"
+      ], 
+      "language": "pt-br", 
+      "object_id": 21
+    }
+  }, 
+  {
+    "pk": 11, 
+    "model": "assistance.questiontranslation", 
+    "fields": {
+      "answer": "N\u00e3o. O registro do estudo na Plataforma Brasil dever\u00e1 ser feito antes do seu registro no Registro Brasileiro de Ensaios Cl\u00ednicos (REBEC). Embora o formul\u00e1rio do RBEC compartilhe v\u00e1rios campos comuns \u00e0 Plataforma Brasil, o objetivo do REBEC \u00e9 informar a todos os interessados nacionais e internacionais acerca dos ensaios cl\u00ednicos realizados no Brasil atrav\u00e9s da integra\u00e7\u00e3o do RBEC e a Plataforma Internacional de Registro de Ensaios Cl\u00ednicos (ICTRP / Organiza\u00e7\u00e3o Mundial da Sa\u00fade). Esta integra\u00e7\u00e3o est\u00e1 baseada na ado\u00e7\u00e3o de procedimentos operacionais padr\u00f5es definidos pelo Secretariado do ICTRP.", 
+      "title": "O registro de um ensaio cl\u00ednico na Plataforma Brasil equivale a um registro no Registro Brasileiro de Ensaios Clinicos?", 
+      "content_type": [
+        "assistance", 
+        "question"
+      ], 
+      "language": "pt-br", 
+      "object_id": 22
+    }
+  }, 
+  {
+    "pk": 12, 
+    "model": "assistance.questiontranslation", 
+    "fields": {
+      "answer": "Antes de iniciar o registro do seu estudo certifique-se que voc\u00ea tem em m\u00e3os o protocolo do seu estudo, bem como uma c\u00f3pia do documento de aprova\u00e7\u00e3o (no formato PDF) emitido por um comit\u00ea de \u00e9tica brasileiro e o n\u00famero UTN. Esses documentos ser\u00e3o as fontes de informa\u00e7\u00e3o necess\u00e1rias para preencher todos os campos obrigat\u00f3rios requeridos para o registro do seu estudo. \r\nO documento de aprova\u00e7\u00e3o deve ser anexado na se\u00e7\u00e3o Anexos do registro. Este documento \u00e9 a prova da exist\u00eancia do seu estudo e de que foi aprovado por um comit\u00ea de \u00e9tica brasileiro.  Caso voc\u00ea queira que este documento seja p\u00fablico, o que significa que ser\u00e1 visto por todos os usu\u00e1rios, marque o campo P\u00fablico na se\u00e7\u00e3o Anexos. Caso contr\u00e1rio, ele s\u00f3 ser\u00e1 visto pela equipe do REBEC.\r\nO UTN \u00e9 um n\u00famero obtido pelo patrocinador ou proponente do estudo como primeiro passo no registro do ensaio no REBEC.  O UTN tornar-se-\u00e1 ent\u00e3o parte da identidade internacional do ensiao junto com o n\u00famero de registro do REBEC. Se o seu estudo \u00e9 um ensaio \u00e9 multic\u00eantrico internacional, verifique se j\u00e1 possui o UTN. \r\nPara obter o UTRN voc\u00ea deve acessar o site http://apps.who.int/trialsearch/utn.aspx ", 
+      "title": "Que documentos voc\u00ea deve ter em m\u00e3os antes de iniciar o registro do seu estudo?", 
+      "content_type": [
+        "assistance", 
+        "question"
+      ], 
+      "language": "pt-br", 
+      "object_id": 23
+    }
+  }, 
+  {
+    "pk": 1, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o t\u00edtulo cient\u00edfico do estudo, tal como consta no protocolo submetido para financiamento e avalia\u00e7\u00e3o do comit\u00ea de \u00e9tica. \r\nRecomendamos que n\u00e3o utilize caixa alta no preenchimento do campo.", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 1
+    }
+  }, 
+  {
+    "pk": 2, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique aqui qual \u00e9 o t\u00edtulo cient\u00edfico do estudo.", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "es", 
+      "object_id": 1
+    }
+  }, 
+  {
+    "pk": 3, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, insira o acr\u00f4nimo cient\u00edfico do ensaio, se disponivel.", 
+      "example": "MONICA \u00e9 o acr\u00f4nimo cient\u00edfico do estudo \"MONItoramento das Tend\u00eancias e Determinantes em Doen\u00e7as CArdiovasculares\"", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 2
+    }
+  }, 
+  {
+    "pk": 4, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o t\u00edtulo do estudo destinado ao p\u00fablico leigo e que seja de f\u00e1cil compreens\u00e3o.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 4
+    }
+  }, 
+  {
+    "pk": 5, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique a condi\u00e7\u00e3o de sa\u00fade ou problema estudado.\r\n", 
+      "example": "Tuberculose, c\u00e2ncer de mama, manuten\u00e7\u00e3o da perda de peso\r\n", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 25
+    }
+  }, 
+  {
+    "pk": 6, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o acr\u00f4nimo publico do ensaio, se dispon\u00edvel.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 5
+    }
+  }, 
+  {
+    "pk": 7, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique qual \u00e9 a situa\u00e7\u00e3o do recrutamento do estudo:\r\n\r\n    * Pendente: participantes ainda n\u00e3o est\u00e3o sendo recrutados ou inscritos em qualquer local\r\n    * Recrutando: participantes est\u00e3o sendo recrutados e inscritos\r\n    * Suspenso: h\u00e1 uma parada tempor\u00e1ria no recrutamento e inscri\u00e7\u00e3o\r\n    * Completo: participantes n\u00e3o est\u00e3o sendo mais recrutados ou inscritos\r\n    * Outros \r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 9
+    }
+  }, 
+  {
+    "pk": 8, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique os pa\u00edses onde os participantes ser\u00e3o, podem ser ou foram recrutados.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 10
+    }
+  }, 
+  {
+    "pk": 9, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique a data prevista ou real da inscri\u00e7\u00e3o do primeiro participante.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 11
+    }
+  }, 
+  {
+    "pk": 10, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o n\u00famero de participantes que este estudo pretende inscrever.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 12
+    }
+  }, 
+  {
+    "pk": 11, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique quais os crit\u00e9rios de exclus\u00e3o para sele\u00e7\u00e3o dos participantes, incluindo idade m\u00e1xima e m\u00ednima e sexo.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 19
+    }
+  }, 
+  {
+    "pk": 12, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique os crit\u00e9rios de inclus\u00e3o para sele\u00e7\u00e3o dos participantes.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 13
+    }
+  }, 
+  {
+    "pk": 13, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique qual \u00e9 o patrocinador prim\u00e1rio. \r\nUm patrocinador \u00e9 o indiv\u00edduo, organiza\u00e7\u00e3o (em geral, institui\u00e7\u00e3o proponente), grupo ou outra entidade legal que assume a responsabilidade de iniciar, gerenciar e/ou financiar um estudo. \r\nO patrocinador prim\u00e1rio \u00e9 respons\u00e1vel por garantir que o ensaio est\u00e1 devidamente registrado. O patrocinador prim\u00e1rio pode ou n\u00e3o ser o principal financiador.\r\nNos estudos independentes, nos quais o investigador n\u00e3o tem aux\u00edlio financeiro de um patrocinador espec\u00edfico, incluindo os casos de medicamentos doados cujo doador n\u00e3o quer ser caracterizado como um patrocinador do estudo, o investigador \u00e9 considerado o patrocinador do estudo. \r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 20
+    }
+  }, 
+  {
+    "pk": 14, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o g\u00eanero selecionado nos crit\u00e9rio de inclus\u00e3o (feminino, masculino ou ambos) dos participantes.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 14
+    }
+  }, 
+  {
+    "pk": 15, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique qual \u00e9 a idade m\u00e1xima no crit\u00e9rio de inclus\u00e3o dos participantes.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 17
+    }
+  }, 
+  {
+    "pk": 16, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique a idade m\u00ednima no crit\u00e9rio de inclus\u00e3o dos participantes.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 15
+    }
+  }, 
+  {
+    "pk": 17, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique a unidade de tempo da idade maxima do criterio de inclus\u00e3o.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 18
+    }
+  }, 
+  {
+    "pk": 18, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique qual \u00e9 a unidade de tempo da idade m\u00ednima no criterio de inclus\u00e3o dos participantes.\r\n\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 16
+    }
+  }, 
+  {
+    "pk": 19, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique se o ensaio \u00e9 um estudo de bra\u00e7o \u00fanico, um ensaio cl\u00ednico controlado n\u00e3o aleat\u00f3rio ou um ensaio cl\u00ednico controlado aleat\u00f3rio.\r\n\r\nUm estudo de bra\u00e7o \u00fanico \u00e9 aquele no qual todos os participantes tenham a mesma interven\u00e7\u00e3o. Ensaios em que os participantes s\u00e3o designados para receber uma de duas ou mais interven\u00e7\u00f5es N\u00c3O s\u00e3o estudos de bra\u00e7o \u00fanico. Ensaios do tipo seq\u00fcencial (Crossover) N\u00c3O s\u00e3o estudos de bra\u00e7o \u00fanico.\r\n\r\nUm estudo \u00e9 aleat\u00f3rio se os participantes s\u00e3o atribu\u00eddos a grupos de interven\u00e7\u00e3o utilizando um m\u00e9todo baseado na possibilidade (p. ex., tabela de n\u00fameros aleat\u00f3rios, seq\u00fc\u00eancia aleat\u00f3rio gerada por computador, minimiza\u00e7\u00e3o, randomiza\u00e7\u00e3o adaptativa).\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 32
+    }
+  }, 
+  {
+    "pk": 20, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique a fase do estudo.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 39
+    }
+  }, 
+  {
+    "pk": 21, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione o principal enfoque do seu estudo. Apenas escolha a op\u00e7\u00e3o \"Outros se nenhuma das categorias mencionadas forem suficientes para definir o enfoque do seu estudo.\r\n\r\n   * Diagn\u00f3stico: realizado para encontrar melhores testes ou procedimentos para o diagn\u00f3stico de uma determinada doen\u00e7a ou condi\u00e7\u00e3o.\r\n   * Etiol\u00f3gicos: identificar causas de doen\u00e7as.\r\n   * Progn\u00f3stico: estima o prov\u00e1vel curso cl\u00ednico da doen\u00e7a no tempo e antecipar suas prov\u00e1veis complica\u00e7\u00f5es.\r\n   * Preven\u00e7\u00e3o: procura melhores formas de prevenir a doen\u00e7a em pessoas que nunca tiveram a doen\u00e7a ou prevenir uma doen\u00e7a de regressar. Estas abordagens podem incluir medicamentos, vitaminas, vacinas, sais minerais, ou mudan\u00e7as de estilo de vida.\r\n    * Tratamento: testa tratamentos experimentais, novas combina\u00e7\u00f5es de drogas, ou novas abordagens para a cirurgia ou radioterapia.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 34
+    }
+  }, 
+  {
+    "pk": 22, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o desenho da interven\u00e7\u00e3o do ensaio.\r\n\r\n* Grupo \u00danico: estudo de bra\u00e7o \u00fanico\r\n* Paralelo: os participantes s\u00e3o atribu\u00eddos a um dos dois ou mais grupos em paralelo para a dura\u00e7\u00e3o do estudo\r\n* Cross-over: os participantes recebem uma das duas interven\u00e7\u00f5es alternativas durante a fase inicial do estudo e recebe a outra interven\u00e7\u00e3o durante a segunda fase do estudo\r\n* Fatorial: dois ou mais interven\u00e7\u00f5es, cada uma isoladamente e em combina\u00e7\u00e3o, s\u00e3o avaliadas em paralelo contra um grupo de controle.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 35
+    }
+  }, 
+  {
+    "pk": 23, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor insira o n\u00famero de grupos de interven\u00e7\u00e3o (digite 1 para um estudo de bra\u00e7o \u00fanico).\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 36
+    }
+  }, 
+  {
+    "pk": 24, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Cegamento se refere aos m\u00e9todos usados para impedir que os participantes e investigadores saibam quais interven\u00e7\u00f5es est\u00e3o sendo usadas. Mascaramento se refere aos m\u00e9todos usados na camuflagem das interven\u00e7\u00f5es para alcan\u00e7ar o cegamento.\r\n\r\nPor favor, selecione na lista o mascaramento/cegamento utilizados no estudo:\r\n\r\n    * Aberto: nenhum mascaramento/cegueira \u00e9 usado. Todos os envolvidos sabem qual \u00e9 o trabalho de interven\u00e7\u00e3o.\r\n    * Unicego: os participantes n\u00e3o tem conhecimento do tipo de interven\u00e7\u00e3o.\r\n    * Duplo-cego: tanto o pesquisador como participante partes n\u00e3o t\u00eam conhecimento da interven\u00e7\u00e3o que cada participante est\u00e1 recebendo.\r\n    * Triplo-cego: al\u00e9m do pesquisador e do paciente, o analisador dos resultados n\u00e3o sabe o tratamento que cada participante est\u00e1 recebendo.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 37
+    }
+  }, 
+  {
+    "pk": 25, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique a aloca\u00e7\u00e3o dos participantes aos grupos de interven\u00e7\u00e3o:\r\n\r\n    * N/A: estudo de um \u00fanico bra\u00e7o\r\n    * Aleat\u00f3rio controlado: os participantes s\u00e3o atribu\u00eddos a grupos de interven\u00e7\u00e3o por chance.\r\n    * N\u00e3o Aleat\u00f3rio: os participantes s\u00e3o expressamente atribu\u00eddas a grupos de interven\u00e7\u00e3o atrav\u00e9s de um m\u00e9todo n\u00e3o-aleat\u00f3rio, como a escolha do m\u00e9dico.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 38
+    }
+  }, 
+  {
+    "pk": 26, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique se houver um programa de acesso expandido ou n\u00e3o ou se \u00e9 desconhecido. O acesso expandido \u00e9 um processo patrocinado de disponibiliza\u00e7\u00e3o de produto novo, promissor, ainda sem registro na Ag\u00eancia Nacional de Vigil\u00e2ncia Sanit\u00e1ria - ANIVSA para pacientes com doen\u00e7as graves e que amea\u00e7am \u00e0 vida, na aus\u00eancia de alternativas terap\u00eauticas satisfat\u00f3rias disponibilizadas no Pa\u00eds, sem \u00f4nus adicional para o paciente. O produto deve estar em estudo de fase III em desenvolvimento no Brasil ou no pa\u00eds de origem e com programa de acesso expandido aprovado no pa\u00eds de origem, ou com registro do produto no pa\u00eds de origem (RDC.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 33
+    }
+  }, 
+  {
+    "pk": 27, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique aqui qual \u00e9 o tipo de desfecho: prim\u00e1rio ou secund\u00e1rio. Desfecho prim\u00e1rio s\u00e3o eventos, vari\u00e1veis ou experi\u00eancias que s\u00e3o medidas porque se sup\u00f5e que seriam influenciadas pela interven\u00e7\u00e3o sob estudo. O desfecho prim\u00e1rio deveria ser o desfecho utilizado para calacular o tamanho da amostra ou os principais desfechos utilizados para determinat os efeitos das interven\u00e7\u00f5es. \r\n\r\nEntre o nome de todos os desfechos prim\u00e1rios do estudo bem como os per\u00edodos de tempo pr\u00e9-especificados do desfecho prim\u00e1rio de interesse. Seja o mais espec\u00edfico poss\u00edvel com as m\u00e9tricas utiliadas (p.ex. \"% com, escore de depress\u00e3o de Beck? 10\" ao inv\u00e9s de simplesmente \"depress\u00e3o\"). \r\n\r\nDados sobre desfechos secund\u00e1rios s\u00e3o usados para avaliar efeitos adicionais da interven\u00e7\u00e3o. Um desfecho secund\u00e1rio pode envolver o mesmo evento, vari\u00e1vel ou experi\u00eancia do desfecho prim\u00e1rio, mas medido em um per\u00edodo de tempo distinto do desfecho prim\u00e1rio (p.ex., desfecho prim\u00e1rio: mortalidade por todas as causas em 5 anos; Desfecho secund\u00e1rio: mortalidade por todas as causas em 1 ano e 3 anos) ou pode estar relacionado a um evento, vari\u00e1vel ou experi\u00eancia distinta (p.ex., desfecho prim\u00e1rio: mortalidade por todas as causas ap\u00f3s 5 anos; Desfecho secund\u00e1rio: taxa de hospitaliza\u00e7\u00e3o em 5 anos). \r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 40
+    }
+  }, 
+  {
+    "pk": 28, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique a descri\u00e7\u00e3o do desfecho.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 41
+    }
+  }, 
+  {
+    "pk": 29, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione esse campo para excluir o desfecho correspondente.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 42
+    }
+  }, 
+  {
+    "pk": 30, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione esse campo para excluir o identificador secund\u00e1rio correspondente.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 8
+    }
+  }, 
+  {
+    "pk": 31, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione esse campo para excluir o patrocinador secund\u00e1rio correspondente.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 22
+    }
+  }, 
+  {
+    "pk": 32, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione esse campo para excluir a fonte de apoio financeiro ou material correspondente.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 24
+    }
+  }, 
+  {
+    "pk": 33, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione esse campo para excluir o contato para a comunidade cient\u00edfica correspondente.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 46
+    }
+  }, 
+  {
+    "pk": 34, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione esse campo para excluir o contato de rela\u00e7\u00f5es p\u00fablicas correspondente.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 44
+    }
+  }, 
+  {
+    "pk": 35, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione esse campo para excluir o correspondente contato para quest\u00f5es relativas ao site.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 48
+    }
+  }, 
+  {
+    "pk": 36, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione o tipo de relacionamento do contato: um contato para perguntas p\u00fablicas, para perguntas cient\u00edficas ou para perguntas sobre o site.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 59
+    }
+  }, 
+  {
+    "pk": 37, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o numero do telefone do contato.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 58
+    }
+  }, 
+  {
+    "pk": 38, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o c\u00f3digo postal (CEP) do contato.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 57
+    }
+  }, 
+  {
+    "pk": 39, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o pa\u00eds do contato.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 56
+    }
+  }, 
+  {
+    "pk": 40, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique a cidade do contato.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 55
+    }
+  }, 
+  {
+    "pk": 41, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o endere\u00e7o do contato.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 54
+    }
+  }, 
+  {
+    "pk": 42, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique a afilia\u00e7\u00e3o do contato.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 53
+    }
+  }, 
+  {
+    "pk": 43, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o email do contato.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 52
+    }
+  }, 
+  {
+    "pk": 44, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o sobrenome do contato.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 51
+    }
+  }, 
+  {
+    "pk": 45, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o nome do meio do contato.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 50
+    }
+  }, 
+  {
+    "pk": 46, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o primeiro nome do contato.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 49
+    }
+  }, 
+  {
+    "pk": 47, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione, de um dos contatos inclu\u00eddos anteriormente, quem \u00e9 o contato(s) para perguntas sobre o site (ver abaixo o formul\u00e1rio para um novo contato).\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 47
+    }
+  }, 
+  {
+    "pk": 48, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione, de um dos contatos inclu\u00eddos anteriormente, quem \u00e9 o contato(s) de rela\u00e7\u00f5es p\u00fablicas (ver abaixo o formul\u00e1rio para um novo contato).\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 43
+    }
+  }, 
+  {
+    "pk": 49, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione, de um dos contatos inclu\u00eddos anteriormente, quem \u00e9 o contato(s) para a comunidade cient\u00edfica (ver abaixo o formul\u00e1rio para um novo contato).\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 45
+    }
+  }, 
+  {
+    "pk": 50, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, insira a expans\u00e3o do acr\u00f4nimo cient\u00edfico do ensaio, se disponivel.\r\n", 
+      "example": "A expans\u00e3o do acr\u00f4nimo cient\u00edfico MONICA \u00e9 MONItoramento das Tend\u00eancias e Determinantes em Doen\u00e7as CArdiovasculares", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 3
+    }
+  }, 
+  {
+    "pk": 51, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique a expans\u00e3o do acr\u00f4nimo cient\u00edfico do ensaio, se disponivel.\r\n", 
+      "example": "A expans\u00e3o do acr\u00f4nimo OMS \u00e9 Organiza\u00e7\u00e3o Mundial de Sa\u00fade.\r\n", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 60
+    }
+  }, 
+  {
+    "pk": 52, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o nome de individuos, organiza\u00e7\u00f5es ou outros entes legais, se houver, que concordaram com o patrocinador prim\u00e1rio em assumir responsabilidades de patroc\u00ednio.\r\nUm patrocinador secund\u00e1rio pode ter:\r\n\u2022 concordado em assumir todas as responsabilidades de patroc\u00ednio juntamente com o patrocinador prim\u00e1rio;\r\n\u2022 formar um grupo com o patrocinador prim\u00e1rio no qual as responsabilidades s\u00e3o alocadas entre os membros do grupo;\r\n\u2022 atuar como representante legal do patrocinador em rela\u00e7\u00e3o a alguns ou todos os sitios do estudo; ou assumior a responsabildade pela acur\u00e1cia das informa\u00e7\u00f5es do ensaio submetido para registro.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 21
+    }
+  }, 
+  {
+    "pk": 53, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, inique quais as principais fontes de apoio financeiro ou material para o estudo (ag\u00eanciaa financiadora, funda\u00e7\u00e3o, companhia, hospital, universidade, etc).\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 23
+    }
+  }, 
+  {
+    "pk": 54, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione o vocabulario usado para escolher o descritor da condi\u00e7\u00e3o de sa\u00fade: \r\nDeCS: Descritores em Ci\u00eancias da Sa\u00fade ou\r\nICD-10: Classifica\u00e7\u00e3o Internacional de Doen\u00e7as ou\r\nChemical Abstracts Service\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 26
+    }
+  }, 
+  {
+    "pk": 55, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o c\u00f3digo do descritor da condi\u00e7\u00e3o de sa\u00fade.\r\nSe voc\u00ea escolher um descritor dos vocabularios DeCS, CID-10 ou CAS, este campo ser\u00e1 preenchido automaticamente.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 28
+    }
+  }, 
+  {
+    "pk": 56, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o texto do descritor da condi\u00e7\u00e3o de sa\u00fade.\r\nSe voc\u00ea escolher um descritor dos vocabularios DeCS, CID-10 ou CAS, este campo ser\u00e1 automaticamente preenchido.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 29
+    }
+  }, 
+  {
+    "pk": 57, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione a categoria da interven\u00e7\u00e3o:\r\n\r\n* droga\r\n* dispositivo\r\n* biologico/vacina\r\n* procedimento/cirurgia\r\n* radia\u00e7\u00e3o\r\n* comportamental\r\n* genetica\r\n* suplemento diet\u00e9tico\r\n* outro\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 31
+    }
+  }, 
+  {
+    "pk": 58, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, descreva todas as interven\u00e7\u00f5es e os comparadores/controles que est\u00e3o sendo estudados. Para cada interven\u00e7\u00e3o, descreva outros detalhes quando pertinentes (dose, dura\u00e7\u00e3o, modo de administra\u00e7\u00e3o, etc).\r\nA interven\u00e7\u00e3o de controle \u00e9 a interven\u00e7\u00e3o contra a qual a interven\u00e7\u00e3o de estudo \u00e9 avaliada (p.ex. placebo, sem tratamento, controle ativo). Se um controle ativo \u00e9 usado, assegure de incluir o nome da interven\u00e7\u00e3o ou inclua \"placebo\" ou \"sem tratamento\" se aplic\u00e1vel.\r\nUtilize nome internacional n\u00e3o-propriet\u00e1rio se poss\u00edvel (n\u00e3o use nomes comerciais). Para drogas n\u00e3o registradas, o nome gen\u00e9rico, oa denomina\u00e7\u00e3o qu\u00edmica ou n\u00famero serial da companhia \u00e9 aceit\u00e1vel. Se a interven\u00e7\u00e3o consiste de v\u00e1rios tratamentos, liste-os todos em uma \u00fanica linha separados por v\u00edrgula (e.g. \"baixo teor de gordura, dieta, exerc\u00edcio).\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 30
+    }
+  }, 
+  {
+    "pk": 59, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o nome da nova institui\u00e7\u00e3o.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 61
+    }
+  }, 
+  {
+    "pk": 60, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o endere\u00e7o da nova institui\u00e7\u00e3o.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 62
+    }
+  }, 
+  {
+    "pk": 61, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique qual \u00e9 o pa\u00eds da nova institui\u00e7\u00e3o.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 63
+    }
+  }, 
+  {
+    "pk": 62, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, inclua o arquivo a ser anexado a este estudo.\r\n", 
+      "example": "Carta de aprova\u00e7\u00e3o do Comit\u00ea de \u00c9tica (formato do arquivo: jpeg, tif, bmp) e consentimento informado do seu estudo\r\n", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 66
+    }
+  }, 
+  {
+    "pk": 63, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique a descri\u00e7\u00e3o do arquivo anexado a este estudo.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 67
+    }
+  }, 
+  {
+    "pk": 64, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione esse campo se desejar que o arquivo anexado a este estudo esteja publico para todos que acessarem a plataforma de ensaios clinicos.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 68
+    }
+  }, 
+  {
+    "pk": 65, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique a data, prevista ou real, de inicio do recrutamento do primeiro participante.\r\nPor favor, use o formato dd/mm/yyyy.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 65
+    }
+  }, 
+  {
+    "pk": 66, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione esse campo para excluir o descritor correspondente.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 64
+    }
+  }, 
+  {
+    "pk": 67, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique a institui\u00e7\u00e3o ou org\u00e3o que tenha emitido um n\u00famero de identifica\u00e7\u00e3o secund\u00e1rio, al\u00e9m do registro principal, se houver.\r\n", 
+      "example": "exemplo 1 (UTN)\r\n    \u00d3rg\u00e3o emissor: WHO/ICTRP \r\n\r\nsample 2 (Plataforma Brasil)\r\n    \u00d3rg\u00e3o emissor: Comiss\u00e3o Nacional de \u00c9tica em Pesquisa (CONEP) \r\n\r\nsample 3\r\n    \u00d3rg\u00e3o emissor: ANVISA (comunicado especial)\r\n", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 6
+    }
+  }, 
+  {
+    "pk": 68, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique qualquer outro n\u00famero de identifica\u00e7\u00e3o secund\u00e1rio, como o n\u00famero do protocolo, n\u00famero da aprova\u00e7\u00e3o do comit\u00ea de \u00e9tica, n\u00famero de inscri\u00e7\u00e3o nas ag\u00eancias reguladoras ou qualquer outro n\u00famero de Registro de Ensaio Cl\u00ednico, se tiver sido registrado em outro registro, tais como ClinicalTrials.gov, ANZCTR, ISRCTN, etc.\r\nN\u00e3o h\u00e1 limite na quantidade de n\u00fameros de identifica\u00e7\u00e3o secund\u00e1rias que podem ser informados.\r\n", 
+      "example": "exemplo 1 (UTN)\r\n    \u00d3rg\u00e3o emissor: WHO/ICTRP \r\n    Identificador secund\u00e1rio: U1111-1111-4101\r\n\r\nsample 2 (Plataforma Brasil)\r\n    \u00d3rg\u00e3o emissor: Comiss\u00e3o Nacional de \u00c9tica em Pesquisa (CONEP) \r\n    Identificador secund\u00e1rio: 1234567890\r\n\r\nsample 3\r\n    \u00d3rg\u00e3o emissor: ANVISA (comunicado especial)\r\n    Identificador secund\u00e1rio: 9876543210\r\n", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 7
+    }
+  }, 
+  {
+    "pk": 69, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique a data, prevista ou real, de t\u00e9rmino do recrutamento do ultimo participante.\r\nPor favor, use o formato dd/mm/aaaa.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 69
+    }
+  }, 
+  {
+    "pk": 70, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, selecione o idioma da submiss\u00e3o", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 70
+    }
+  }, 
+  {
+    "pk": 71, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique o t\u00edtulo cient\u00edfico do estudo, tal como consta no protocolo submetido para financiamento e avalia\u00e7\u00e3o do comit\u00ea de \u00e9tica.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 71
+    }
+  }, 
+  {
+    "pk": 72, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique os pa\u00edses onde os participantes ser\u00e3o, podem ser ou foram recrutados.\r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 72
+    }
+  }, 
+  {
+    "pk": 73, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique qual \u00e9 o patrocinador prim\u00e1rio. \r\nUm patrocinador \u00e9 o indiv\u00edduo, organiza\u00e7\u00e3o, grupo ou outra entidade legal que assume a responsabilidade de iniciar, gerenciar e/ou financiar um estudo. \r\nO patrocinador prim\u00e1rio \u00e9 respons\u00e1vel por garantir que o ensaio est\u00e1 devidamente registrado. O patrocinador prim\u00e1rio pode ou n\u00e3o ser o principal financiador.\r\nNos estudos independentes, nos quais o investigador n\u00e3o tem aux\u00edlio financeiro de um patrocinador espec\u00edfico, incluindo os casos de medicamentos doados cujo doador n\u00e3o quer ser caracterizado como um patrocinador do estudo, o investigador \u00e9 considerado o patrocinador do estudo. \r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 73
+    }
+  }, 
+  {
+    "pk": 74, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor, indique qual \u00e9 o pa\u00eds do patrocinador prim\u00e1rio. \r\n", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 74
+    }
+  }, 
+  {
+    "pk": 75, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 27
+    }
+  }, 
+  {
+    "pk": 76, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "Por favor inclua o N\u00famero Universal do Ensaio (Universal Trial Number ou UTN). O UTN \u00e9 um n\u00famero obtido pelo patrocinador ou proponente do estudo como primeiro passo no registro do ensaio no REBEC.  \r\nO UTN tornar-se-\u00e1 ent\u00e3o parte da identidade internacional do ensiao junto com o n\u00famero de registro do REBEC. \r\nSe o seu estudo \u00e9 um ensaio \u00e9 multic\u00eantrico internacional, verifique se j\u00e1 possui o UTN. \r\nPara obter o UTRN voc\u00ea deve acessar o site http://apps.who.int/trialsearch/utn.aspx ", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "pt-br", 
+      "object_id": 77
+    }
+  }, 
+  {
+    "pk": 77, 
+    "model": "assistance.fieldhelptranslation", 
+    "fields": {
+      "text": "", 
+      "example": "", 
+      "content_type": [
+        "assistance", 
+        "fieldhelp"
+      ], 
+      "language": "es", 
+      "object_id": 77
+    }
+  }, 
+  {
+    "pk": 1, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "scientific_title", 
+      "example": "", 
+      "form": "TrialIdentificationForm", 
+      "text": "Please enter the scientific title of the study as it appears in the protocol submitted for funding and ethical review.\r\nIt\u00b4s recommended not to use caps lock while writing filling out the field. "
+    }
+  }, 
+  {
+    "pk": 2, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "scientific_acronym", 
+      "example": "MONICA is the scientific acronym for the study \"Multinational MONItoring of trends and determinants in CArdiovascular disease\"", 
+      "form": "TrialIdentificationForm", 
+      "text": "Please enter the trial scientific acronym if available."
+    }
+  }, 
+  {
+    "pk": 3, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "scientific_acronym_expansion", 
+      "example": "The expansion of the scientifi acronym MONICA is Multinational MONItoring of trends and determinants in CArdiovascular disease", 
+      "form": "TrialIdentificationForm", 
+      "text": "Please enter the expansion of the trial scientific acronym if available.\r\n"
+    }
+  }, 
+  {
+    "pk": 4, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "public_title", 
+      "example": "", 
+      "form": "TrialIdentificationForm", 
+      "text": "Please enter the title intended for the lay public in easily understood language.\r\n"
+    }
+  }, 
+  {
+    "pk": 5, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "acronym", 
+      "example": "", 
+      "form": "TrialIdentificationForm", 
+      "text": "Please enter the trial public acronym if available.\r\n"
+    }
+  }, 
+  {
+    "pk": 6, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "issuing_authority", 
+      "example": "sample 1 (UTN)\r\n    issuing organization: WHO/ICTRP \r\n\r\nsample 2 (Plataforma Brasil)\r\n    issuing organization: Comiss\u00e3o Nacional de \u00c9tica em Pesquisa (CONEP) \r\n\r\nsample 3\r\n    issuing number: ANVISA (comunicado especial)\r\n", 
+      "form": "TrialNumberForm", 
+      "text": "Please enter the institution or organization that assigned a secondary identification number, besides the Primary Registry, if any.\r\n"
+    }
+  }, 
+  {
+    "pk": 7, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "id_number", 
+      "example": "sample 1 (UTN)\r\n    issuing organization: WHO/ICTRP \r\n    secondary identification number: U1111-1111-4101\r\n\r\nsample 2 (Plataforma Brasil)\r\n    issuing organization: Comiss\u00e3o Nacional de \u00c9tica em Pesquisa (CONEP) \r\n    secondary identification number: 1234567890\r\n\r\nsample 3\r\n    issuing number: ANVISA (comunicado especial)\r\n    secondary identification number: 9876543210\r\n", 
+      "form": "TrialNumberForm", 
+      "text": "Please enter any other secondary identifying numbers, such as protocol number, institutional review board/ethics committee approval, registration number at regulatory agencies or any other Trial Registry Number, if registered in another Clinical Trials Registry, such as ClinicalTrials.gov, ANZCTR, ISRCTN etc. \r\nThere is no limit on the number of secondary identifying numbers that can be provided.\r\n"
+    }
+  }, 
+  {
+    "pk": 8, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "DELETE", 
+      "example": "", 
+      "form": "TrialNumberForm", 
+      "text": "Please select this field to delete the corresponding secondary trial number.\r\n"
+    }
+  }, 
+  {
+    "pk": 9, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "recruitment_status", 
+      "example": "", 
+      "form": "RecruitmentForm", 
+      "text": "Please enter the recruitment status of this trial:\r\n\r\n    * Pending: participants are not yet being recruited or enrolled at any site\r\n    * Recruiting: participants are currently being recruited and enrolled\r\n    * Suspended: there is a temporary halt in recruitment and enrollment\r\n    * Complete: participants are no longer being recruited or enrolled\r\n    * Other \r\n"
+    }
+  }, 
+  {
+    "pk": 10, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "recruitment_country", 
+      "example": "", 
+      "form": "RecruitmentForm", 
+      "text": "Please enter the countries from which participants will be, are intended to be, or have been recruited.\r\n"
+    }
+  }, 
+  {
+    "pk": 11, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "date_enrollment", 
+      "example": "", 
+      "form": "RecruitmentForm", 
+      "text": "Please enter the anticipated or actual date of enrollment of the first participant.\r\n"
+    }
+  }, 
+  {
+    "pk": 12, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "target_sample_size", 
+      "example": "", 
+      "form": "RecruitmentForm", 
+      "text": "Please enter the number of participants that this trial plans to enroll.\r\n"
+    }
+  }, 
+  {
+    "pk": 13, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "inclusion_criteria", 
+      "example": "", 
+      "form": "RecruitmentForm", 
+      "text": "Please enter the inclusion criteria for participant selection.\r\n"
+    }
+  }, 
+  {
+    "pk": 14, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "gender", 
+      "example": "", 
+      "form": "RecruitmentForm", 
+      "text": "Please enter the gender selected in the inclusion criteria (female, male or both) of participants.\r\n"
+    }
+  }, 
+  {
+    "pk": 15, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "agemin_value", 
+      "example": "", 
+      "form": "RecruitmentForm", 
+      "text": "Please enter the minimal age in the inclusion criteria of participants.\r\n"
+    }
+  }, 
+  {
+    "pk": 16, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "agemin_unit", 
+      "example": "", 
+      "form": "RecruitmentForm", 
+      "text": "Please enter the temporal unit of minimal age in the inclusion criteria of participants.\r\n\r\n"
+    }
+  }, 
+  {
+    "pk": 17, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "agemax_value", 
+      "example": "", 
+      "form": "RecruitmentForm", 
+      "text": "Please enter the maximal age in inclusion criteria of participants.\r\n"
+    }
+  }, 
+  {
+    "pk": 18, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "agemax_unit", 
+      "example": "", 
+      "form": "RecruitmentForm", 
+      "text": "Please enter the temporal unit of maximal age in inclusion criteria.\r\n"
+    }
+  }, 
+  {
+    "pk": 19, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "exclusion_criteria", 
+      "example": "", 
+      "form": "RecruitmentForm", 
+      "text": "Please enter the exclusion criteria for participant selection, including age and sex.\r\n"
+    }
+  }, 
+  {
+    "pk": 20, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "primary_sponsor", 
+      "example": "", 
+      "form": "PrimarySponsorForm", 
+      "text": "Please enter the primary spondor.\r\nThe Primary Sponsor is the individual, organization (e.g. proponent institution), group or other legal entity which takes responsibility for initiating, managing and/or financing the study.  \r\nThe Primary Spondor is responsible for ensuring that the trial is properly registered. \r\nThe Primary Sponsor may or may not be the main funder.\r\nIn independent studies, for which the investigator has no financial assistance from a specific sponsor, including cases of medicines donated where the donor does not want to be characterized as a sponsor of the study, the researcher is considered the sponsor of the study. \r\n"
+    }
+  }, 
+  {
+    "pk": 21, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "institution", 
+      "example": "", 
+      "form": "TrialSecondarySponsorForm", 
+      "text": "Please enter the name of additional individuals, organizations or other legal persons, if any, that have agreed with the primary sponsor to take on responsibilities of sponsorship.\r\nA secondary sponsor may have:\r\n\u2022 agreed to take on all the responsibilities of sponsorship jointly with the primary sponsor;\r\n\u2022 to form a group with the primary sponsor in which the responsibilities of sponsorship are allocated among the members of the group;\r\n\u2022 to act as the sponsor\u2019s legal representative in relation to some or all of the trial sites; or to take responsibility for the accuracy of trial registration information submitted.\r\n"
+    }
+  }, 
+  {
+    "pk": 22, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "DELETE", 
+      "example": "", 
+      "form": "TrialSecondarySponsorForm", 
+      "text": "Please select this field to delete the corresponding secondary sponsor.\r\n"
+    }
+  }, 
+  {
+    "pk": 23, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "institution", 
+      "example": "", 
+      "form": "TrialSupportSourceForm", 
+      "text": "Please enter the major source(s) of monetary or material or infrastructural support for the trial (e.g., funding agency, foundation, company, hospital, university, etc).\r\n"
+    }
+  }, 
+  {
+    "pk": 24, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "DELETE", 
+      "example": "", 
+      "form": "TrialSupportSourceForm", 
+      "text": "Please select this field to delete the corresponding support source.\r\n"
+    }
+  }, 
+  {
+    "pk": 25, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "hc_freetext", 
+      "example": "Tuberculosis, breast cancer, weight loss maintenance\r\n", 
+      "form": "HealthConditionsForm", 
+      "text": "Please enter the primary health condition(s) or problem(s) studied. If the study is conducted in healthy human volunteers belonging to the target population of the intervention (e.g., preventive or screening interventions), enter the particular health condition(s) or problem(s) being prevented or screened\r\nExample: Type 2 Diabetes Mellitus; Hypertension\r\n"
+    }
+  }, 
+  {
+    "pk": 26, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "vocabulary", 
+      "example": "", 
+      "form": "DescriptorForm", 
+      "text": "Please select the vocabulary will be used to choose the descriptor of the health condition: \r\nDeCS: Health Sciences Descriptors or\r\nICD-10: International Classification of Diseases or\r\nChemical Abstracts Service\r\n"
+    }
+  }, 
+  {
+    "pk": 27, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "version", 
+      "example": "", 
+      "form": "DescriptorForm", 
+      "text": ""
+    }
+  }, 
+  {
+    "pk": 28, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "code", 
+      "example": "", 
+      "form": "DescriptorForm", 
+      "text": "Please enter the health condition descriptor code.\r\nIf you choose one descriptor of the DeCS, ICD-10 or CAS vocabularies, then this field will be automatically filled.\r\n"
+    }
+  }, 
+  {
+    "pk": 29, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "text", 
+      "example": "", 
+      "form": "DescriptorForm", 
+      "text": "Please enter the health condition descriptor text.\r\nIf you choose one descriptor of the DeCS, ICD-10 or CAS vocabularies, then this field will automatically filled.\r\n"
+    }
+  }, 
+  {
+    "pk": 30, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "i_freetext", 
+      "example": "", 
+      "form": "InterventionForm", 
+      "text": "Please describe all the interventions and the comparator/control(s) being studied. For each intervention, describe other intervention details as applicable (dose, duration, mode of administration, etc).\r\nThe control intervention(s) is/are the interventions against which the study intervention is evaluated (e.g., placebo, no treatment, active control). If an active control is used, be sure to enter in the name(s) of that intervention, or enter \"placebo\" or \"no treatment\" as applicable.\r\nUse the International Non-Proprietary Name if possible (not brand/trade names). For an unregistered drug, the generic name, chemical name, or company serial number is acceptable. If the intervention consists of several separate treatments, list them all in one line separated by commas (e.g., \"low-fat diet, exercise\").\r\n"
+    }
+  }, 
+  {
+    "pk": 31, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "i_code", 
+      "example": "", 
+      "form": "InterventionForm", 
+      "text": "Please select the intervention category:\r\n\r\n* drug\r\n* device\r\n* biological/vaccine\r\n* procedure/surgery\r\n* radiation\r\n* behavioural\r\n* genetics\r\n* dietary supplement\r\n* other\r\n\r\n"
+    }
+  }, 
+  {
+    "pk": 32, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "study_design", 
+      "example": "", 
+      "form": "StudyTypeForm", 
+      "text": "Please enter whether the trial is a  single arm study, a controlled non-randomized trial or a randomized controlled trial. \r\n\r\nA single arm study is one in which all participants are given the same intervention. Trials in which participants are assigned to receive one of two or more interventions are NOT single arm studies. Crossover trials are NOT single arm studies.\r\n\r\nA trial is \"randomized\" if participants are randomly assigned to intervention groups using a method based on chance (e.g., random number table, random computer-generated sequence, minimization, adaptive randomization). \r\n"
+    }
+  }, 
+  {
+    "pk": 33, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "expanded_access_program", 
+      "example": "", 
+      "form": "StudyTypeForm", 
+      "text": "Please enter if there is an expanded access program or not or if it is unknown. The expanded access is a sponsored process of making available new, promising products, without registration at Ag\u00eancia Nacional de Vigil\u00e2ncia Sanit\u00e1ria - ANIVSA for patients with serious life-threating diseases and absence of satisfactory alternative treatments in the country and no aditional charges for the patient. The product must be under phase III study in Brazil or country of origin, expanded access program approved or registration at the country of origin (RDC 26).\r\n\r\n"
+    }
+  }, 
+  {
+    "pk": 34, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "purpose", 
+      "example": "", 
+      "form": "StudyTypeForm", 
+      "text": "Please select the most apropriate purpose of your study. Only choose \"Other\" option if none of the listed categories are adequate to define the purpose of your study.\r\n\r\n   * Diagnostic: conducted to find better tests or procedures for diagnosing a particular disease or condition.\r\n   * Etiological: identify causes of diseases\r\n   * Prognostic: estimate the possible clinical course of disease in time and anticipate their probable complications.\r\n    * Prevention: look for better ways to prevent disease in people who have never had the disease or to prevent a disease from returning. These approaches may include medicines, vitamins, vaccines, minerals, or lifestyle changes.\r\n    * Treatment: test experimental treatments, new combinations of drugs, or new approaches to surgery or radiation therapy.\r\n"
+    }
+  }, 
+  {
+    "pk": 35, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "intervention_assignment", 
+      "example": "", 
+      "form": "StudyTypeForm", 
+      "text": "Please enter the intervention assignment of the trial.\r\n\r\n* Single Group: single arm study\r\n* Parallel: participants are assigned to one of two or more groups in parallel for the duration of the study\r\n* Cross-over: participants receive one of two alternative interventions during the initial phase of the study and receive the other intervention during the second phase of the study\r\n* Factorial: two or more interventions, each alone and in combination, are evaluated in parallel against a control group \r\n"
+    }
+  }, 
+  {
+    "pk": 36, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "number_of_arms", 
+      "example": "", 
+      "form": "StudyTypeForm", 
+      "text": "Please enter the number of intervention groups (enter 1 for single-arm study). \r\n"
+    }
+  }, 
+  {
+    "pk": 37, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "masking", 
+      "example": "", 
+      "form": "StudyTypeForm", 
+      "text": "Blinding refers to methods used to prevent participants and investigators from knowing what interventions are being used. Masking refers to the methods used to camouflage interventions to achieve blinding.\r\n\r\nPlease select from the list which masking/blinding is used on the study:\r\n\r\n    * Open: no masking/blinding is used. All involved know the identity of the intervention assignment.\r\n    * Single Blind: only participants is unaware of the intervention assignment; also called single-masked study.\r\n    * Double Blind: both investigator and participant parties are unaware of the intervention that each participant is receiving.\r\n    * Triple Blind: besides the researcher and the patient, the analyzer of the results does known treatment that each participant is receiving.\r\n"
+    }
+  }, 
+  {
+    "pk": 38, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "allocation", 
+      "example": "", 
+      "form": "StudyTypeForm", 
+      "text": "Please enter the participant assignment to the intervention groups:\r\n\r\n    * N/A: single arm study\r\n    * Randomized Controlled Trial: participants are assigned to intervention groups by chance\r\n    * Nonrandomized Trial: participants are expressly assigned to intervention groups through a non-random method, such as physician choice\r\n"
+    }
+  }, 
+  {
+    "pk": 39, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "phase", 
+      "example": "", 
+      "form": "StudyTypeForm", 
+      "text": "Please enter the phase of the study.\r\n"
+    }
+  }, 
+  {
+    "pk": 40, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "interest", 
+      "example": "", 
+      "form": "OutcomeForm", 
+      "text": "Please enter the type of outcome: primary or secondary. Primary outcomes are events, variables, or experiences that are measured because it is believed that they may be influenced by the intervention. The Primary Outcome should be the outcome used in sample size calculations, or the main outcome(s) used to determine the effects of the intervention(s).\r\n\r\nEnter the names of all primary outcomes in the trial as well as the pre-specified timepoint(s) of primary interest. Be as specific as possible with the metric used (e.g., \u201c% with Beck Depression Score > 10 \u201drather than just \u201cdepression\u201d).\r\n\r\nData on secondary ourtcomes are used to evaluate aditional effects of the intervention. A secondary outcome may involve the same event, variable, or experience as the primary outcome, but measured at timepoints other than those of primary interest (e.g., Primary outcome: all-cause mortality at 5 years; Secondary outcome: all-cause mortality at 1 year, 3 years), or may involve a different event, variable, or experience altogether (e.g., Primary outcome: all-cause mortality at 5 years; Secondary outcome: hospitalization rate at 5 years). \r\n"
+    }
+  }, 
+  {
+    "pk": 41, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "description", 
+      "example": "", 
+      "form": "OutcomeForm", 
+      "text": "Please enter the description of outcome measure.\r\n"
+    }
+  }, 
+  {
+    "pk": 42, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "DELETE", 
+      "example": "", 
+      "form": "OutcomeForm", 
+      "text": "Please select this field to delete the corresponding outcome.\r\n"
+    }
+  }, 
+  {
+    "pk": 43, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "contact", 
+      "example": "", 
+      "form": "PublicContactForm", 
+      "text": "Please select from one of the contacts included previously who is the contact(s) for public queries (see form bellow for a new contact).\r\n"
+    }
+  }, 
+  {
+    "pk": 44, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "DELETE", 
+      "example": "", 
+      "form": "PublicContactForm", 
+      "text": "Please select this field to delete the corresponding public contact.\r\n"
+    }
+  }, 
+  {
+    "pk": 45, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "contact", 
+      "example": "", 
+      "form": "ScientificContactForm", 
+      "text": "Please select from one of the contacts included previously who is the contact(s) for scientific queries (see form bellow for a new contact).\r\n"
+    }
+  }, 
+  {
+    "pk": 46, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "DELETE", 
+      "example": "", 
+      "form": "ScientificContactForm", 
+      "text": "Please select this field to delete the corresponding scientific contact.\r\n"
+    }
+  }, 
+  {
+    "pk": 47, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "contact", 
+      "example": "", 
+      "form": "SiteContactForm", 
+      "text": "Please select from one of the contacts included previously who is the contact(s) for site queries (see form bellow for a new contact).\r\n"
+    }
+  }, 
+  {
+    "pk": 48, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "DELETE", 
+      "example": "", 
+      "form": "SiteContactForm", 
+      "text": "Please select this field to delete the corresponding site queries contact.\r\n"
+    }
+  }, 
+  {
+    "pk": 49, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "firstname", 
+      "example": "", 
+      "form": "ContactForm", 
+      "text": "Please enter the first name of the contact.\r\n"
+    }
+  }, 
+  {
+    "pk": 50, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "middlename", 
+      "example": "", 
+      "form": "ContactForm", 
+      "text": "Please enter the middle name of the contact.\r\n"
+    }
+  }, 
+  {
+    "pk": 51, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "lastname", 
+      "example": "", 
+      "form": "ContactForm", 
+      "text": "Please enter the last name of the contact.\r\n"
+    }
+  }, 
+  {
+    "pk": 52, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "email", 
+      "example": "", 
+      "form": "ContactForm", 
+      "text": "Please enter the email of the contact.\r\n"
+    }
+  }, 
+  {
+    "pk": 53, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "affiliation", 
+      "example": "", 
+      "form": "ContactForm", 
+      "text": "Please enter the affiliation of the contact.\r\n"
+    }
+  }, 
+  {
+    "pk": 54, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "address", 
+      "example": "", 
+      "form": "ContactForm", 
+      "text": "Please enter the address of the contact.\r\n"
+    }
+  }, 
+  {
+    "pk": 55, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "city", 
+      "example": "", 
+      "form": "ContactForm", 
+      "text": "Please enter the city of the contact.\r\n"
+    }
+  }, 
+  {
+    "pk": 56, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "country", 
+      "example": "", 
+      "form": "ContactForm", 
+      "text": "Please enter the country of the contact.\r\n"
+    }
+  }, 
+  {
+    "pk": 57, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "zip", 
+      "example": "", 
+      "form": "ContactForm", 
+      "text": "Please enter the zip code of the contact.\r\n"
+    }
+  }, 
+  {
+    "pk": 58, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "telephone", 
+      "example": "", 
+      "form": "ContactForm", 
+      "text": "Please enter the telephone number of the contact.\r\n"
+    }
+  }, 
+  {
+    "pk": 59, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "relation", 
+      "example": "", 
+      "form": "ContactForm", 
+      "text": "Select the relation of the contact: a contact for Public Queries, for Scientific Queries or for Site Queries.\r\n"
+    }
+  }, 
+  {
+    "pk": 60, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "acronym_expansion", 
+      "example": "The expansion of the acronym WHO is World Health Organization.\r\n", 
+      "form": "TrialIdentificationForm", 
+      "text": "Please enter the expansion of the trial public acronym, if available.\r\n"
+    }
+  }, 
+  {
+    "pk": 61, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "name", 
+      "example": "", 
+      "form": "NewInstitution", 
+      "text": "Please enter the name of the new institution.\r\n"
+    }
+  }, 
+  {
+    "pk": 62, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "address", 
+      "example": "", 
+      "form": "NewInstitution", 
+      "text": "Please enter the address of the new institution.\r\n"
+    }
+  }, 
+  {
+    "pk": 63, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "country", 
+      "example": "", 
+      "form": "NewInstitution", 
+      "text": "Please enter which is the country of the new institution.\r\n"
+    }
+  }, 
+  {
+    "pk": 64, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "DELETE", 
+      "example": "", 
+      "form": "DescriptorForm", 
+      "text": "Please select this field to delete the corresponding descriptor.\r\n"
+    }
+  }, 
+  {
+    "pk": 65, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "enrollment_start_planned", 
+      "example": "", 
+      "form": "RecruitmentForm", 
+      "text": "Please enter the anticipated or actual date of enrollment of the first participant. \r\nPlease use the format dd/mm/yyyy.\r\n"
+    }
+  }, 
+  {
+    "pk": 66, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "file", 
+      "example": "Copy of letter of approval from the Ethics Committee or Institutional Review Board (file format - jpeg, tif, bmp) and consent form of your study\r\n", 
+      "form": "AttachmentForm", 
+      "text": "Please enter the file to be attached to this study.\r\n"
+    }
+  }, 
+  {
+    "pk": 67, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "description", 
+      "example": "", 
+      "form": "AttachmentForm", 
+      "text": "Please enter the description of the file attached to this study.\r\n"
+    }
+  }, 
+  {
+    "pk": 68, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "public", 
+      "example": "", 
+      "form": "AttachmentForm", 
+      "text": "Please select this field if the file attached to this study will be public to every user of the EnsaiosClinicos.gov.br.\r\n"
+    }
+  }, 
+  {
+    "pk": 69, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "enrollment_end_planned", 
+      "example": "", 
+      "form": "RecruitmentForm", 
+      "text": "Please enter the anticipated or actual date of enrollment of the last participant. \r\nPlease use the format dd/mm/yyyy.\r\n"
+    }
+  }, 
+  {
+    "pk": 70, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "language", 
+      "example": "", 
+      "form": "InitialTrialForm", 
+      "text": "Please, select the submission language.\r\n"
+    }
+  }, 
+  {
+    "pk": 71, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "scientific_title", 
+      "example": "", 
+      "form": "InitialTrialForm", 
+      "text": "Please enter the scientific title of the study as it appears in the protocol submitted for funding and ethical review.\r\n"
+    }
+  }, 
+  {
+    "pk": 72, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "recruitment_country", 
+      "example": "", 
+      "form": "InitialTrialForm", 
+      "text": "Please enter the countries from which participants will be, are intended to be, or have been recruited.\r\n"
+    }
+  }, 
+  {
+    "pk": 73, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "name", 
+      "example": "", 
+      "form": "PrimarySponsorForm", 
+      "text": "Please enter the primary sponsor.\r\nThe Primary Sponsor is the individual, organization, group or other legal entity which takes responsibility for initiating, managing and/or financing the study.  \r\nThe Primary Spondor is responsible for ensuring that the trial is properly registered. \r\nThe Primary Sponsor may or may not be the main funder.\r\nIn independent studies, for which the investigator has no financial assistance from a specific sponsor, including cases of medicines donated where the donor does not want to be characterized as a sponsor of the study, the researcher is considered the sponsor of the study. \r\n"
+    }
+  }, 
+  {
+    "pk": 74, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "country", 
+      "example": "", 
+      "form": "PrimarySponsorForm", 
+      "text": "Please enter the primary sponsor country.\r\n"
+    }
+  }, 
+  {
+    "pk": 75, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "enrollment_start_date", 
+      "example": "", 
+      "form": "RecruitmentForm", 
+      "text": ""
+    }
+  }, 
+  {
+    "pk": 76, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "enrollment_end_date", 
+      "example": "", 
+      "form": "RecruitmentForm", 
+      "text": ""
+    }
+  }, 
+  {
+    "pk": 77, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "utrn_number", 
+      "example": "", 
+      "form": "TrialIdentificationForm", 
+      "text": "Please enter the Universal Trial Number (UTN). The UTN is a number, obtained by the trial's sponsor, proponent institution or principal investigator as the first step in registering a trial on the REBEC.  \r\nThe UTN will then become part of the trial's international identity along with the REBEC registration number.\r\nIf your study is internationally multicentric trial, check out if it has a UTN. \r\nTo obtain the UTRN you must acces the site http://apps.who.int/trialsearch/utn.aspx"
+    }
+  }, 
+  {
+    "pk": 78, 
+    "model": "assistance.fieldhelp", 
+    "fields": {
+      "field": "primary_sponsor", 
+      "example": "Por favor, inclua o nome do patrocinador prim\u00e1rio, endere\u00e7o postal completo com telefones e e-mail para contato e pa\u00eds de localiza\u00e7\u00e3o do patrocinador prim\u00e1rio. \r\nUm patrocinador \u00e9 o indiv\u00edduo, organiza\u00e7\u00e3o, grupo ou outra entidade legal que assume a responsabilidade de iniciar, gerenciar e/ou financiar um estudo. \r\nO patrocinador prim\u00e1rio \u00e9 respons\u00e1vel por garantir que o ensaio est\u00e1 devidamente registrado. O patrocinador prim\u00e1rio pode ou n\u00e3o ser o principal financiador.\r\nNos estudos independentes, nos quais o investigador n\u00e3o tem aux\u00edlio financeiro de um patrocinador espec\u00edfico, incluindo os casos de medicamentos doados cujo doador n\u00e3o quer ser caracterizado como um patrocinador do estudo, o investigador \u00e9 considerado o patrocinador do estudo. \r\n", 
+      "form": "InitialTrialForm", 
+      "text": "Please enter the primary sponsor name, complete postal address including telephone numbers and e-mail for contact and country of sponsor\u00b4s location. \r\nThe Primary Sponsor is the individual, organization, group or other legal entity which takes responsibility for initiating, managing and/or financing the study.  \r\nThe Primary Spondor is responsible for ensuring that the trial is properly registered. \r\nThe Primary Sponsor may or may not be the main funder.\r\nIn independent studies, for which the investigator has no financial assistance from a specific sponsor, including cases of medicines donated where the donor does not want to be characterized as a sponsor of the study, the researcher is considered the sponsor of the study. \r\n"
+    }
+  }, 
+  {
+    "pk": 23, 
+    "model": "assistance.question", 
+    "fields": {
+      "category": 6, 
+      "answer": "Before initianting your registration, be sure you have on hand the protocol of your study, as well as a copy (in PDF format) of the letter of approval from a brazilian ethics committee/institutional review board and the UTN number. Those documents will be the sources of information necessary to fill all the obligatory fields required for the registration of your study. \r\nThe letter of approval must be uploaded in the attachments section of the registration form. This document is a proof of the existence of the study and that it was approved by a brazilian EC/IRB. If you wish to make it public, that meansit will be viewed by all users, mark the Public field. Otherwise, it will be viewed only by the REBEC staff.\r\nThe UTN is a number, obtained by the trial's sponsor, proponent institution or principal investigator as the first step in registering a trial on the REBEC. The UTRN will then become part of the trial's international identity along with the REBEC registration number.  If your study is internationally multicentric trial, check out if it has a UTRN. \r\nTo obtain the UTRN you must acces the site http://apps.who.int/trialsearch/utn.aspx", 
+      "created": "2011-01-20 08:01:42", 
+      "order": 230, 
+      "title": "What documents I must have on hand before registration?"
+    }
+  }, 
+  {
+    "pk": 1, 
+    "model": "assistance.category", 
+    "fields": {
+      "label": "System"
+    }
+  }, 
+  {
+    "pk": 2, 
+    "model": "assistance.category", 
+    "fields": {
+      "label": "Interface"
+    }
+  }, 
+  {
+    "pk": 3, 
+    "model": "assistance.category", 
+    "fields": {
+      "label": "WorkFlow"
+    }
+  }, 
+  {
+    "pk": 6, 
+    "model": "assistance.category", 
+    "fields": {
+      "label": "Study registration"
+    }
+  }, 
+  {
+    "pk": 16, 
+    "model": "assistance.question", 
+    "fields": {
+      "category": 6, 
+      "answer": "First time users need to create a login name and password by clicking on the Register button. A confirmation e-mail will be sent to the informed e-mail account.\r\nThe New Submission button will take the registrant to the screens that need to be completed. This includes basic trial information such as the types of participants, the interventions being tested and the outcomes to be assessed. Other information required includes details of the study design, sample size and contact information. Each field has an information button to assist registrants in entering the correct data. Once each screen is completed, the registrant should click the 'Save' button to save the information to the online registry database. Once all the mandatory information has been entered, the registrant should click the 'Send to review' button. \r\nFollowing submission of the data, the REBEC staff will check the data submitted and query the contact person should anything need clarification. Once any queries are confirmed, trials are officially 'registered' and allocated a unique registration number. Both date of submission and date of registration are recorded. ", 
+      "created": "2010-07-21 21:29:01", 
+      "order": 160, 
+      "title": "How do I register a trial?"
+    }
+  }, 
+  {
+    "pk": 15, 
+    "model": "assistance.question", 
+    "fields": {
+      "category": 6, 
+      "answer": "The study's coordinator, sponsor or an appropriate representative is responsible for registering a trial. The sponsor is an individual or company, public or private, which financially supports the research as defined by the resolution RDC 39 from ANVISA. \r\nIn clinical studies regulated by this rule and sponsored by national or international agencies to promote the research, philanthropic entities, non-governmental organizations (NGOs) or other non-profit organizations, it is assumed that investigator assumes the role of representative of the sponsor, if there is a Clinical Research Organization (CRO) responsible for the conduct of it, should meet as a representative of the study. \r\nIn the case of independent studies, for which the investigator has no financial assistance from a specific sponsor, including cases in receiving the medicines of research in the form of donation where the donor does not want to be characterized as a sponsor of the study, the researcher additionally assume the responsibilities of registering the study.\r\nFor the cases referred to in the preceding paragraph, the researcher is now called \"investigator-sponsor.\" \r\n", 
+      "created": "2010-07-21 21:23:10", 
+      "order": 150, 
+      "title": "Who is responsible for registering a trial?"
+    }
+  }, 
+  {
+    "pk": 14, 
+    "model": "assistance.question", 
+    "fields": {
+      "category": 6, 
+      "answer": "Trials should be registered after approval from a national ethics committee and before enrolment of the first patient.\r\n", 
+      "created": "2010-07-21 18:27:19", 
+      "order": 14