Пример #1
0
 def __init__(self, *args, **kwargs):
     super(SourceNewForm, self).__init__(*args, **kwargs)
     # create widgets here to delay calls to api until initialization of the form
     self.fields['source_type'].widget = ComboBoxWidget(
         data_list=[(v) for v in _get_source_type_list()],
         name="source_type_list")
     self.fields['default_locale'].widget = ComboBoxWidget(
         data_list=[[l['code'], l['name']] for l in _get_locale_list()],
         name="default_locale_list")
     self.fields['supported_locales'].widget = MultipleInputWidget(
         data_list=[l['name'] for l in _get_locale_list()],
         name="supported_locale_list")
Пример #2
0
    def get_context_data(self, *args, **kwargs):
        """ Supply related data for the add form """
        context = super(ConceptEditView, self).get_context_data(*args, **kwargs)

        self.concept['names'] = json.dumps(self.concept['names'])
        self.concept['descriptions'] = json.dumps(self.concept['descriptions'])

        self.get_args()
        temp = []
        if 'extras' in self.concept and self.concept['extras']:
            for key, value in self.concept.get('extras').iteritems():
                temp.append({'key': key, 'value': value})
            self.concept['extras'] = temp

        if self.request.method == 'POST':
            self.concept['names'] = self.request.POST.get('names')
            self.concept['descriptions'] = self.request.POST.get('descriptions')
            temp = json.loads(self.request.POST.get('extras'))

        context['kwargs'] = self.kwargs
        context['source'] = self.source
        context['concept'] = self.concept
        context['extras'] = json.dumps(temp)
        context['locales'] = json.dumps(_get_locale_list())
        context['name_types'] = json.dumps(_get_name_type_list())
        context['description_types'] = json.dumps(_get_description_type_list())

        return context
Пример #3
0
    def get_context_data(self, *args, **kwargs):
        """ Supply related data for the add form """
        context = super(ConceptEditView, self).get_context_data(*args, **kwargs)

        self.concept['names'] = json.dumps(self.concept['names'])
        self.concept['descriptions'] = json.dumps(self.concept['descriptions'])

        self.get_args()
        temp = []
        if 'extras' in self.concept and self.concept['extras']:
            for key, value in self.concept.get('extras').iteritems():
                temp.append({'key': key, 'value': value})
            self.concept['extras'] = temp

        if self.request.method == 'POST':
            self.concept['names'] = self.request.POST.get('names')
            self.concept['descriptions'] = self.request.POST.get('descriptions')
            temp = json.loads(self.request.POST.get('extras'))

        context['kwargs'] = self.kwargs
        context['source'] = self.source
        context['concept'] = self.concept
        context['extras'] = json.dumps(temp)
        context['locales'] = json.dumps(_get_locale_list())
        context['name_types'] = json.dumps(_get_name_type_list())
        context['description_types'] = json.dumps(_get_description_type_list())

        return context
Пример #4
0
    def get_context_data(self, *args, **kwargs):
        """ Loads the context data for creating a new concept. """

        # Setup the form context
        context = super(ConceptNewView, self).get_context_data(*args, **kwargs)
        self.get_args()

        # Load the source that the new concept will belong to
        api = OclApi(self.request, debug=True)
        source = api.get(self.owner_type, self.owner_id, 'sources',
                         self.source_id).json()

        # TODO: Load list of names types
        # TODO: Load list of description types
        # TODO: Load list of locales
        # TODO: Load list of datatypes
        # TODO: Load list of concept classes

        # Set the context
        context['kwargs'] = self.kwargs
        context['source'] = source
        context['locales'] = json.dumps(_get_locale_list())
        context['name_types'] = json.dumps(_get_name_type_list())
        context['description_types'] = json.dumps(_get_description_type_list())

        return context
 def __init__(self):
     super(Command, self).__init__()
     self.ocl = None
     self.username = None
     self.password = None
     self.web_host = os.environ['OCL_WEB_HOST']
     self.ORG_ID = None
     self.locale_list = [d['code'] for d in _get_locale_list()]
     self.source_type_list = _get_source_type_list()
     self.concept_class_list = _get_concept_class_list()
     self.datatype_list = _get_datatype_list()
Пример #6
0
 def __init__(self):
     super(Command, self).__init__()
     self.ocl = None
     self.username = None
     self.password = None
     self.api_host = os.environ['OCL_API_HOST']
     self.web_host = os.environ['OCL_WEB_HOST']
     self.ORG_ID = None
     self.SOURCE_ID = None
     self.locale_list = [d['code'] for d in _get_locale_list()]
     self.source_type_list = _get_source_type_list()
     self.concept_class_list = _get_concept_class_list()
     self.datatype_list = _get_datatype_list()
Пример #7
0
class ConceptNameForm(forms.Form):
    """
        Form for a single concept name.
    """
    required_css_class = 'required'

    name = forms.CharField(max_length=30, label=_('Name'), required=True)
    locale = forms.ChoiceField(choices=[(d['code'], d['name'])
                                        for d in _get_locale_list()],
                               label=_('Locale'),
                               required=True)

    preferred_locale = forms.BooleanField(label=_('Preferred Locale'),
                                          required=False,
                                          initial=False)
    name_type = forms.CharField(max_length=30,
                                label=_('Name Datatype'),
                                required=False)
Пример #8
0
    def get_context_data(self, *args, **kwargs):
        """ Loads the context data for creating a new concept. """

        # Setup the form context
        context = super(ConceptNewView, self).get_context_data(*args, **kwargs)
        self.get_args()

        # Load the source that the new concept will belong to
        api = OclApi(self.request, debug=True)
        source = api.get(self.owner_type, self.owner_id, 'sources', self.source_id).json()

        # TODO: Load list of names types
        # TODO: Load list of description types
        # TODO: Load list of locales
        # TODO: Load list of datatypes
        # TODO: Load list of concept classes

        # Set the context
        context['kwargs'] = self.kwargs
        context['source'] = source
        context['locales'] = json.dumps(_get_locale_list())
        context['name_types'] = json.dumps(_get_name_type_list())
        context['description_types'] = json.dumps(_get_description_type_list())

        names = [
            {'name': '', 'locale': source['default_locale'], 'locale_preferred': True, 'name_type': 'Fully Specified'}]

        descriptions = [{'description': '', 'locale': source['default_locale'], 'locale_preferred': True,
                         'description_type': 'None'}]

        extras = [{'key': '', 'value': ''}]

        if self.request.method == 'POST':
            names = json.loads(self.request.POST.get('names'))
            descriptions = json.loads(self.request.POST.get('descriptions'))
            extras = json.loads(self.request.POST.get('extras'))

        context['names'] = json.dumps(names)
        context['descriptions'] = json.dumps(descriptions)
        context['extras'] = json.dumps(extras)

        return context
Пример #9
0
    def get_context_data(self, *args, **kwargs):
        """ Loads the context data for creating a new concept. """

        # Setup the form context
        context = super(ConceptNewView, self).get_context_data(*args, **kwargs)
        self.get_args()

        # Load the source that the new concept will belong to
        api = OclApi(self.request, debug=True)
        source = api.get(self.owner_type, self.owner_id, 'sources', self.source_id).json()

        # TODO: Load list of names types
        # TODO: Load list of description types
        # TODO: Load list of locales
        # TODO: Load list of datatypes
        # TODO: Load list of concept classes

        # Set the context
        context['kwargs'] = self.kwargs
        context['source'] = source
        context['locales'] = json.dumps(_get_locale_list())
        context['name_types'] = json.dumps(_get_name_type_list())
        context['description_types'] = json.dumps(_get_description_type_list())

        names = [
            {'name': '', 'locale': source['default_locale'], 'locale_preferred': True, 'name_type': 'Fully Specified'}]

        descriptions = [{'description': '', 'locale': source['default_locale'], 'locale_preferred': True,
                         'description_type': 'None'}]

        extras = [{'key': '', 'value': ''}]

        if self.request.method == 'POST':
            names = json.loads(self.request.POST.get('names'))
            descriptions = json.loads(self.request.POST.get('descriptions'))
            extras = json.loads(self.request.POST.get('extras'))

        context['names'] = json.dumps(names)
        context['descriptions'] = json.dumps(descriptions)
        context['extras'] = json.dumps(extras)

        return context
Пример #10
0
 def __init__(self, *args, **kwargs):
     super(ConceptNameForm, self).__init__(*args, **kwargs)
     self.fields['locale'].choices = [(l['code'], l['name']) for l in _get_locale_list()]
Пример #11
0
class CollectionCreateForm(forms.Form):
    """ collection create form """
    required_css_class = 'required'

    short_code = forms.CharField(
        label=_('Collection Short Code'),
        max_length=128,
        required=True,
        help_text=
        _('Allowed characters are : Alphabets(a-z,A-Z), Numbers(0-9) and Hyphen(-) <br/> '
          'Your new collection will live at: https://www.openconceptlab.org'
          '<span id="new_repository_base_url">[OwnerType]/[Owner]/collections/</span>'
          '<span id="new_repository_id" style>[CollectionCode]</span>'),
        widget=forms.TextInput(
            attrs={'placeholder': "e.g. c80-practice-codes"}))
    name = forms.CharField(label=_('Collection Name'),
                           max_length=128,
                           required=True)
    full_name = forms.CharField(
        label=_('Collection Full Name'),
        required=True,
        widget=forms.TextInput(
            attrs={
                'placeholder': "e.g. HL7 FHIR Practice Setting Code Value Set"
            }))
    website = forms.URLField(
        label=_('Website'),
        required=False,
        widget=forms.TextInput(
            attrs={
                'placeholder':
                "e.g. https://www.hl7.org/fhir/valueset-c80-practice-codes.html"
            }))
    collection_type = forms.ChoiceField(choices=[
        (v, v) for v in _get_collection_type_list()
    ],
                                        label=_('Collection Type'),
                                        required=False)
    public_access = forms.ChoiceField(label=_('Public Access'),
                                      required=False,
                                      initial='View',
                                      choices=(('View', 'View (default)'),
                                               ('Edit', 'Edit'), ('None',
                                                                  'None')))
    default_locale = forms.ChoiceField(label=_('Default Locale'),
                                       choices=[
                                           (d['code'],
                                            d['name'] + ' (' + d['code'] + ')')
                                           for d in _get_locale_list()
                                       ],
                                       required=True)
    supported_locales = forms.CharField(
        max_length=30,
        label=_('Supported Locales'),
        required=True,
        widget=forms.TextInput(attrs={'placeholder': "e.g. en,fr,es"}))
    description = forms.CharField(max_length=512,
                                  label=_('Description'),
                                  required=False)
    external_id = forms.CharField(
        label=_('External ID'),
        required=False,
        widget=forms.TextInput(
            attrs={'placeholder': "e.g. UUID from external system"}))

    def clean_concept_id(self):
        """ concept ID must be unique """
        concept_id = self.cleaned_data['concept_id']
        collection = self.initial['collection']
        request = self.initial['request']
        api = OclApi(request, debug=True)
        result = api.get('orgs', collection['owner'], 'collections',
                         collection['id'], 'concepts', concept_id)
        if result.status_code == 200:
            raise forms.ValidationError(_('This Concept ID is already used.'))
        return concept_id
Пример #12
0
class SourceNewForm(forms.Form):
    """ source create form """
    required_css_class = 'required'

    short_name = forms.CharField(
        label=_('Source Short Code'),
        max_length=128,
        required=True,
        help_text=
        _('Allowed characters are : Alphabets(a-z,A-Z), Numbers(0-9) and Hyphen(-) <br/> Your new source will live at: http://www.openconceptlab.org'
          '<span id="new_repository_base_url">/[OwnerType]/[Owner]/sources/</span>'
          '<span id="new_repository_id" style="font-weight:bold;">[SourceCode]</span>/'
          ),
        widget=forms.TextInput(attrs={'placeholder': "e.g. ICD-10"}))
    full_name = forms.CharField(
        label=_('Source Full Name'),
        max_length=256,
        required=True,
        widget=forms.TextInput(attrs={
            'placeholder':
            "e.g. International Classification for Diseases v10"
        }))
    website = forms.URLField(
        label=_('Website'),
        required=False,
        widget=forms.TextInput(attrs={
            'placeholder':
            "e.g. http://apps.who.int/classifications/icd10/"
        }))
    source_type = forms.ChoiceField(choices=[(v, v)
                                             for v in _get_source_type_list()],
                                    label=_('Source Type'),
                                    required=False)
    public_access = forms.ChoiceField(label=_('Public Access'),
                                      required=False,
                                      initial='View',
                                      choices=(('View', 'View (default)'),
                                               ('Edit', 'Edit'), ('None',
                                                                  'None')))
    default_locale = forms.ChoiceField(label=_('Default Locale'),
                                       choices=[
                                           (d['code'],
                                            d['name'] + ' (' + d['code'] + ')')
                                           for d in _get_locale_list()
                                       ],
                                       required=True)
    supported_locales = forms.CharField(
        max_length=30,
        label=_('Supported Locales'),
        required=True,
        widget=forms.TextInput(attrs={'placeholder': "e.g. en,fr,es"}))
    custom_validation_schema = forms.ChoiceField(
        label=_('Custom Validation Schema'),
        choices=[(v, v) for v in _get_custom_validation_schema_list()],
        required=False)
    description = forms.CharField(max_length=512,
                                  label=_('Description'),
                                  required=False)
    external_id = forms.CharField(
        label=_('External ID'),
        required=False,
        widget=forms.TextInput(
            attrs={'placeholder': "e.g. UUID from external system"}))

    # TODO([email protected]): Is this mis-named or not used?
    def clean_concept_id(self):
        """ concept ID must be unique """
        concept_id = self.cleaned_data['concept_id']
        source = self.initial['source']
        request = self.initial['request']
        api = OclApi(request, debug=True)
        result = api.get('orgs', source['owner'], 'sources', source['id'],
                         'concepts', concept_id)
        if result.status_code == 200:
            raise forms.ValidationError(_('This Concept ID is already used.'))
        return concept_id
Пример #13
0
 def __init__(self, *args, **kwargs):
     super(CollectionCreateForm, self).__init__(*args, **kwargs)
     self.fields['default_locale'].choices = [(l['code'], l['name']) for l in _get_locale_list()]
Пример #14
0
 def __init__(self, *args, **kwargs):
     super(CollectionCreateForm, self).__init__(*args, **kwargs)
     # create widgets here to delay calls to api until initialization of the form
     self.fields['collection_type'].widget=ComboBoxWidget(data_list=[v for v in _get_collection_type_list()], name="collection_type_list")
     self.fields['default_locale'].widget=ComboBoxWidget(data_list=[[l['code'], l['name']] for l in _get_locale_list()], name="default_locale_list")
     self.fields['supported_locales'].widget=MultipleInputWidget(data_list=[l['name'] for l in _get_locale_list()], name="supported_locale_list")
Пример #15
0
 def __init__(self, *args, **kwargs):
     super(CollectionCreateForm, self).__init__(*args, **kwargs)
     self.fields['default_locale'].choices = [(l['code'], l['name'])
                                              for l in _get_locale_list()]
Пример #16
0
 def __init__(self, *args, **kwargs):
     super(ConceptNameForm, self).__init__(*args, **kwargs)
     self.fields['locale'].choices = [(l['code'], l['name']) for l in _get_locale_list()]
Пример #17
0
class ConceptNewForm(forms.Form):
    """
    Concept new form
    """
    # TODO([email protected]): Populate all dropdowns dynamically

    required_css_class = 'required'

    # TODO: Validate concept ID is unique
    concept_id = forms.CharField(
        label=_('Concept ID'),
        max_length=256,
        required=True,
        help_text=_(
            '<small>Allowed characters are : Alphabets(a-z,A-Z), Numbers(0-9) and Hyphen(-) </small><br/>'
            '<small>Your new concept will live at: '
            '<span id="new_concept_base_url">/[owner-type]/[owner]/sources/'
            '[source]/concepts/</span>'
            '<span id="new_concept_id" style="font-weight:bold;">'
            '[concept-id]</span></small>'),
        widget=forms.TextInput(attrs={'placeholder': "e.g. A15.0"}))

    # TODO: Populate this dynamically
    concept_class = forms.ChoiceField(choices=[
        (v, v) for v in _get_concept_class_list()
    ],
                                      label=_('Concept Class'),
                                      required=True)

    # TODO: Populate this dynamically
    datatype = forms.ChoiceField(choices=[(v, v)
                                          for v in _get_datatype_list()],
                                 label=_('Datatype'),
                                 initial='None',
                                 required=True)

    # TODO: Put locale, name, and name_type on the same row

    # TODO: Populate this dynamically
    locale = forms.ChoiceField(
        label=_('Name Locale'),
        required=True,
        help_text=
        _('<small>Choose the locale for the initial name and description</small>'
          ),
        choices=[(d['code'], d['name']) for d in _get_locale_list()])

    name = forms.CharField(
        label=_('Name'),
        max_length=256,
        required=True,
        widget=forms.TextInput(
            attrs={
                'placeholder':
                _("e.g. Tuberculosis of lung, confirmed by sputum "
                  "microscopy with or without culture")
            }))

    # TODO: Populate this dynamically
    name_type = forms.CharField(
        label=_('Name Type'),
        max_length=256,
        required=True,
        widget=forms.TextInput(attrs={'placeholder': "e.g. FULLY_SPECIFIED"}))

    # TODO: Put locale, description, and description_type on the same row

    description = forms.CharField(label=_('Description'),
                                  max_length=1024,
                                  required=False)

    # TODO: Populate this dynamically
    description_type = forms.CharField(label=_('Description Type'),
                                       max_length=128,
                                       required=False)

    external_id = forms.CharField(
        label=_('Concept External ID'),
        required=False,
        widget=forms.TextInput(
            attrs={'placeholder': "e.g. UUID from external system"}))