2020-11-16 16:30:41 +01:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
2020-11-13 15:31:14 +01:00
|
|
|
from django.forms import ModelForm
|
|
|
|
from django import forms
|
|
|
|
|
|
|
|
from apps.synthea.models import Synthea
|
|
|
|
|
|
|
|
from .lib.utils import available_states, available_modules
|
|
|
|
|
|
|
|
class SyntheaForm(ModelForm):
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Synthea
|
|
|
|
fields = ['state', 'population', 'gender', 'age', 'module']
|
|
|
|
|
|
|
|
# This is loaded only once during startup. So changing the state data will not be picked up after a restart
|
2020-11-16 16:30:41 +01:00
|
|
|
state_options = [('',_('Select'))]
|
2020-11-13 15:31:14 +01:00
|
|
|
for item in available_states():
|
2020-11-16 16:30:41 +01:00
|
|
|
state_options.append((item['id'],item['name']))
|
2020-11-13 15:31:14 +01:00
|
|
|
|
2020-11-16 16:30:41 +01:00
|
|
|
module_options = [('',_('Any'))]
|
2020-11-13 15:31:14 +01:00
|
|
|
for item in available_modules():
|
2020-11-16 16:30:41 +01:00
|
|
|
module_options.append((item['id'],item['name']))
|
2020-11-13 15:31:14 +01:00
|
|
|
|
|
|
|
widgets = {
|
|
|
|
'state': forms.Select(choices=state_options),
|
2020-11-16 16:30:41 +01:00
|
|
|
'gender': forms.Select(choices=[('',_('Any')),('m',_('Male')),('f',_('Female'))]),
|
2020-11-13 15:31:14 +01:00
|
|
|
'module': forms.Select(choices=module_options)
|
|
|
|
}
|