コード例 #1
0
 class Patient_other(FlaskForm):
     medical_aid = StringField('Medical Aid',validators = [DataRequired(),
         Regexp('^\w+$', message="Please delete all white spaces before & after the word")])
     patient_name = StringField(u'Full Name', validators=[DataRequired()])
     main_member = StringField(u'Main Member', validators=[DataRequired()])
     medical_number = IntegerField(u'Medical Aid No:', validators=[DataRequired()])
     patient_birth_date = StringField(u'Date of Birth', validators=[DataRequired()])
     date_created =  StringField(u'Invoice created', validators=[DataRequired()])
     tariffs = getTariffs(namaf_profession)
     choices = []
     for x in tariffs:
         _tariff = x['tariff']
         tariff_ = _tariff.replace('_', ' ')
         _tariff_ = tariff_.upper()
         choices.append((_tariff, _tariff_))
     choices.append(('', 'Choose Tariff'))
     tariff = SelectField(u'Tariff', choices = choices,
                      validators=[DataRequired()] , default='')
     hospital_name = StringField('Hospital')
     admission_date = StringField('Date of admission')
     discharge_date = StringField('Date of discharge')
     diagnosis = StringField('Diagnosis')
     diagnosis_date = StringField('Date of diagnosis')
     procedure = StringField('Procedure')
     procedure_date = StringField('Date of procedure')
     implants = StringField('Implants')
     intra_op = SelectField('Intra-OP imaging',
         choices = [('', 'Select Intra-op'),('yes','Yes'),
             ('no','No')], default='')
     post_op =  StringField('Post-OP imaging')
     status = TextField('Status')
     submit = SubmitField('Create invoice')
コード例 #2
0
 class Patient_mva(FlaskForm):
     medical_aid = StringField('Medical Aid')
     tariffs = getTariffs(namaf_profession)
     choices = []
     for x in tariffs:
         _tariff = x['tariff']
         tariff_ = _tariff.replace('_', ' ')
         _tariff_ = tariff_.upper()
         choices.append((_tariff, _tariff_))
     choices.append(('', 'Choose Tariff'))
     patient_name = StringField(u'Full Name', validators=[DataRequired()])
     case_number = StringField(u'Case Number', validators=[DataRequired()])
     po_number = IntegerField(u'PO', validators=[DataRequired()]) #widget=NumberInput(min=111111,max=999999))
     tariff = SelectField(u'Tariff', choices = choices,
         validators=[DataRequired()], default='')
     date_created =  StringField(u'Invoice created', validators=[DataRequired()])
     hospital_name = StringField('Hospital')
     admission_date = StringField('Date of admission')
     discharge_date = StringField('Date of discharge')
     diagnosis = StringField('Diagnosis')
     diagnosis_date = StringField('Date of diagnosis')
     procedure = StringField('Procedure')
     procedure_date = StringField('Date of procedure')
     implants = StringField('Implants')
     intra_op = SelectField('Intra-OP imaging', choices = [('',
     'Select Intra-OP'),('yes','Yes'),('no','No')], default='')
     post_op =  StringField('Post-OP imaging')
     status = TextField('Status')
     submit = SubmitField('Create invoice')
コード例 #3
0
class PlanManualForm(ModelForm):

    telescope = SelectField(default='ZTF')

    validity_window_start = DateTimeField(
        format='%Y-%m-%d %H:%M:%S',
        default=lambda: datetime.datetime.utcnow(),
        validators=[validators.DataRequired()])

    validity_window_end = DateTimeField(
        format='%Y-%m-%d %H:%M:%S',
        default=lambda: datetime.datetime.utcnow() + datetime.timedelta(1),
        validators=[validators.DataRequired()])

    filters = TextField('filters', validators=[validators.DataRequired()])

    dither = BooleanField(default=False)

    references = BooleanField(default=False)

    field_ids = TextField('field_ids', validators=[validators.DataRequired()])

    exposure_time = FloatField(
        default=300,
        validators=[validators.DataRequired(),
                    validators.NumberRange(min=0)])

    queue_name = TextField(validators=[validators.DataRequired()],
                           default='REPLACE ME')

    subprogram_name = TextField(validators=[validators.DataRequired()],
                                default='GW')

    program_id = SelectField(default='Partnership',
                             choices=[('2', 'Partnership'), ('3', 'Caltech')])

    def validate_validity_window_end(self, field):
        other = self.validity_window_start
        if field.validate(self) and other.validate(self):
            if field.data <= self.validity_window_start.data:
                raise validators.ValidationError(
                    'End time must be after start time')

    def validate_filters(self, field):
        available_filters = set(
            models.Telescope.query.get(self.telescope.data).filters)
        filters = set(re.split(r'[\s,]+', self.filters.data))

        unavailable_filters = filters - available_filters
        if unavailable_filters:
            raise validators.ValidationError(
                'Some filters are not available for this telescope: ' +
                ', '.join(unavailable_filters))
コード例 #4
0
 class ChildPageTypeForm(FlaskForm):
     parent_pk = HiddenField(validators=[InputRequired()])
     url = HiddenField(default=self.get_save_return_url(self.model))
     page_type = SelectField(
         validators=[InputRequired()],
         label=lazy_gettext("Select the type of the child page "),
         default="",
         choices=self._get_pchild_form_choices,
     )
コード例 #5
0
class Patient_mva(FlaskForm):
    medical = StringField('Medical Aid')
    name = StringField(u'Full Name', validators=[DataRequired()])
    case = StringField(u'Case Number', validators=[DataRequired()])
    po = IntegerField(u'PO', validators=[DataRequired()])
    tariff = SelectField(u'Tariff',
                         choices=[("namaf_pyhsio_2014", "Namaf Physio 2014"),
                                  ("namaf_physio_2019", "Namaf Physio 2019"),
                                  ("namaf_physio_2020", "Namaf Physio 2020")])
    date = StringField(u'Invoice Date', validators=[
        DataRequired()
    ])  # default=datetime.datetime.today().date())
    submit = SubmitField('Continue')
コード例 #6
0
class Patient_psemas(FlaskForm):
    medical = StringField('Medical Aid')
    name = StringField(u'Full Name', validators=[DataRequired()])
    main = StringField(u'Main Member', validators=[DataRequired()])
    number = IntegerField(u'Medical Aid No:', validators=[DataRequired()])
    dob = StringField(u'Date of Birth', validators=[DataRequired()])
    tariff = SelectField(u'Tariff',
                         choices=[("namaf_pyhsio_2014", "Namaf Physio 2014"),
                                  ("namaf_physio_2019", "Namaf Physio 2019"),
                                  ("namaf_physio_2020", "Namaf Physio 2020")])
    date = StringField(u'Invoice Date', validators=[
        DataRequired()
    ])  # default=datetime.datetime.today().date())
    submit = SubmitField('Continue')
コード例 #7
0
class PlanForm(ModelForm):
    class Meta:
        model = models.Plan
        exclude = ['plan_args']

    dateobs = DateTimeField()

    telescope = SelectField(default='ZTF')

    localization = SelectField()

    def _localization_query(self):
        return models.Localization.query.filter_by(dateobs=self.dateobs.data)

    validity_window_start = DateTimeField(
        format='%Y-%m-%d %H:%M:%S',
        default=lambda: datetime.datetime.utcnow(),
        validators=[validators.DataRequired()])

    validity_window_end = DateTimeField(
        format='%Y-%m-%d %H:%M:%S',
        default=lambda: datetime.datetime.utcnow() + datetime.timedelta(1),
        validators=[validators.DataRequired()])

    filters = TextField('filters', validators=[validators.DataRequired()])

    schedule = RadioField(choices=[('greedy', 'greedy'), ('sear', 'sear'),
                                   ('airmass_weighted', 'airmass_weighted'),
                                   ('greedy_slew', 'greedy_slew')],
                          default='greedy_slew')

    dither = BooleanField(default=False)

    references = BooleanField(default=False)

    primary = BooleanField(default=False)

    balance = BooleanField(default=False)

    completed = BooleanField(default=False)

    completed_window_start = DateTimeField(
        format='%Y-%m-%d %H:%M:%S',
        default=lambda: datetime.datetime.utcnow() - datetime.timedelta(1),
        validators=[validators.DataRequired()])

    completed_window_end = DateTimeField(
        format='%Y-%m-%d %H:%M:%S',
        default=lambda: datetime.datetime.utcnow(),
        validators=[validators.DataRequired()])

    planned = BooleanField(default=False)

    maxtiles = BooleanField(default=False)

    filterschedule = RadioField(choices=[('block', 'block'),
                                         ('integrated', 'integrated')],
                                default='block')

    schedule_strategy = RadioField(choices=[('tiling', 'tiling'),
                                            ('catalog', 'catalog')],
                                   default='tiling')

    exposure_time = FloatField(
        default=300,
        validators=[validators.DataRequired(),
                    validators.NumberRange(min=0)])

    max_nb_tiles = DecimalSliderField(
        [validators.NumberRange(min=0, max=1000)], default=1000)

    probability = DecimalSliderField([validators.NumberRange(min=0, max=100)],
                                     default=90)

    airmass_limit = DecimalSliderField(
        [validators.NumberRange(min=1.0, max=5.0)], default=2.5)

    mindiff = DecimalSliderField([validators.NumberRange(min=0, max=180)],
                                 default=30)

    plan_name = TextField(validators=[validators.DataRequired()],
                          default='REPLACE ME')

    previous = BooleanField(default=False)

    previous_plan = SelectField()

    raslice = BooleanField(default=False)

    ramin = DecimalSliderField([validators.NumberRange(min=0, max=24)],
                               default=0)

    ramax = DecimalSliderField([validators.NumberRange(min=0, max=24)],
                               default=0)

    def _previous_plan_query(self):
        return models.Plan.query.filter_by(dateobs=self.dateobs.data)

    def validate_validity_window_end(self, field):
        other = self.validity_window_start
        if field.validate(self) and other.validate(self):
            if field.data <= self.validity_window_start.data:
                raise validators.ValidationError(
                    'End time must be after start time')

    def validate_filters(self, field):
        available_filters = set(
            models.Telescope.query.get(self.telescope.data).filters)
        filters = set(re.split(r'[\s,]+', self.filters.data))

        unavailable_filters = filters - available_filters
        if unavailable_filters:
            raise validators.ValidationError(
                'Some filters are not available for this telescope: ' +
                ', '.join(unavailable_filters))

    def validate_plan_name(self, field):
        nplans = models.Plan.query.filter_by(
            dateobs=self.dateobs.data,
            telescope=self.telescope.data,
            plan_name=self.plan_name.data).count()
        if nplans > 0:
            raise validators.ValidationError('That plan name already exists.')

    def populate_obj(self, obj):
        super().populate_obj(obj)

        start_mjd = time.Time(self.validity_window_start.data).mjd
        end_mjd = time.Time(self.validity_window_end.data).mjd
        event_mjd = time.Time(self.dateobs.data).mjd
        timediff1 = start_mjd - event_mjd
        timediff2 = end_mjd - event_mjd
        t_obs = [timediff1, timediff2]
        completed_start_mjd = time.Time(self.completed_window_start.data).mjd
        completed_end_mjd = time.Time(self.completed_window_end.data).mjd
        c_obs = [completed_start_mjd, completed_end_mjd]
        filters = re.split(r'[\s,]+', self.filters.data)
        raslice = [float(self.ramin.data), float(self.ramax.data)]

        obj.plan_args = dict(localization_name=self.localization.data,
                             tobs=t_obs,
                             filt=filters,
                             exposuretimes=[self.exposure_time.data] *
                             len(filters),
                             probability=0.01 * float(self.probability.data),
                             airmass=float(self.airmass_limit.data),
                             mindiff=float(self.mindiff.data),
                             schedule_type=self.schedule.data,
                             doDither=self.dither.data,
                             doReferences=self.references.data,
                             doUsePrimary=self.primary.data,
                             doBalanceExposure=self.balance.data,
                             filterScheduleType=self.filterschedule.data,
                             schedule_strategy=self.schedule_strategy.data,
                             usePrevious=self.previous.data,
                             previous_plan=self.previous_plan.data,
                             doCompletedObservations=self.completed.data,
                             cobs=c_obs,
                             doPlannedObservations=self.planned.data,
                             doMaxTiles=self.maxtiles.data,
                             max_nb_tiles=int(self.max_nb_tiles.data),
                             doRASlice=self.raslice.data,
                             raslice=raslice)
コード例 #8
0
class DeleteForm(ModelForm):

    queue_name = SelectField()
コード例 #9
0
    class Treatment(FlaskForm):
        if ('namaf_physio' in tariff):
            treatments = SelectField(u'Treatments',coerce=int,
                    validators=[DataRequired()])
            date = TextField('Date', validators=[DataRequired()])
            description = TextField()
            units = DecimalField(u'Units')
            value = DecimalField(u'Value')
            post_value = DecimalField(u'Value')
            modifier = SelectField(u'Modifier', choices= 
                    [(0, 'None'),(6, '006 - Emergency treatment'),
                        (8, '008 - More than one procedure'), 
                        (9,'009 - Multpile conditions'),
                        (10, '010 - Treatment time overlap'),
                        (13, '013 - Travelling cost'),
                        (14,'014 - Rendered hospital')], default=0)
            date_invoice = TextField('Invoice date', validators=[DataRequired()])
            submit = SubmitField('Submit')
        else:
            treatments = TextField('Treatment')
            description = TextField('Description')
            units = DecimalField(u'Units')
            date = TextField('Date', validators=[DataRequired()])
            modifier = DecimalField(u'modifier')
            value = DecimalField(u'Value')
            post_value = DecimalField(u'Value')
            date_invoice =  TextField('Invoice date', validators=[DataRequired()])
            submit = SubmitField('Submit')

        def initialise_SelectOption(self,list_ordered_by_category = None, featured_ordered_by_category = None,  *args, **kwargs):
            super(Treatment, self).__init__(*args, **kwargs)
            if ('namaf_physio' in tariff):
                self.treatments.choices = featured_ordered_by_category + list_ordered_by_category

        def nestedObjects(self, filtered_result, featured_result):
            list_of_categories = []
            list_ordered_by_category = []
            featured_ordered_by_category = []
            for i in filtered_result:
                list_of_categories.append(i['category'])
            seen = {}
            dupes = []
            for x in list_of_categories:
                if x not in seen:
                    seen[x] = 1
            else:
                if seen[x] == 1:
                    dupes.append(x)
                seen[x] += 1
            for keys, values in seen.items():
                a = (keys, )
                b = []
                for x in filtered_result:
                    if x['category'] == keys:
                        b.append((x['item'],x['description']))
                c = a + (tuple(b,),)
                list_ordered_by_category.append(c)
            for i in featured_result:
                featured_ordered_by_category.append((i['item'],i['description']))
            featured_ordered_by_category  = [('Featured',) + (tuple(featured_ordered_by_category,),)]
            return list_ordered_by_category, featured_ordered_by_category

        def __init__(self, *args, **kwargs):
            if('namaf_physio' in tariff):
                featured = [501, 303, 314, 703, 702, 401, 405, 317, 503, 107, 901]
                filtered_result = getTreatments(tariff)
                featured_result = getTreatments(tariff, featured)
                list_ordered_by_category, featured_ordered_by_category = self.nestedObjects(filtered_result, featured_result)
                self.initialise_SelectOption(list_ordered_by_category = list_ordered_by_category, featured_ordered_by_category = featured_ordered_by_category)
            else:
                self.initialise_SelectOption()
コード例 #10
0
    class Treatment(FlaskForm):
        treatments = SelectField(u'Treatments', coerce=int)
        date = TextField('Date', validators=[DataRequired()])
        price = TextField(u'Value')
        modifier = SelectField(u'Modifier',
                               choices=[(0, 'None'), (14, 'Rendered hospital'),
                                        (13, 'Travelling cost')],
                               default=0)
        submit = SubmitField('Submit')

        def initialise_SelectOption(self,
                                    list_ordered_by_category=None,
                                    featured_ordered_by_category=None,
                                    *args,
                                    **kwargs):
            super(Treatment, self).__init__(*args, **kwargs)
            self.treatments.choices = [
                (0, "Select treatment")
            ] + featured_ordered_by_category + list_ordered_by_category

        def nestedObjects(something, filtered_result, featured_result):
            list_of_categories = []
            list_ordered_by_category = []
            featured_ordered_by_category = []
            for i in filtered_result:
                list_of_categories.append(i['category'])
            seen = {}
            dupes = []
            for x in list_of_categories:
                if x not in seen:
                    seen[x] = 1
            else:
                if seen[x] == 1:
                    dupes.append(x)
                seen[x] += 1
            for keys, values in seen.items():
                a = (keys, )
                b = []
                for x in filtered_result:
                    if x['category'] == keys:
                        b.append((x['item'], x['description']))
                c = a + (tuple(b, ), )
                list_ordered_by_category.append(c)
            for i in featured_result:
                featured_ordered_by_category.append(
                    (i['item'], i['description']))
            featured_ordered_by_category = [
                ('Featured', ) + (tuple(featured_ordered_by_category, ), )
            ]
            return list_ordered_by_category, featured_ordered_by_category

        def __init__(self, *args, **kwargs):
            if (tariff is not None):
                featured = [
                    501, 303, 314, 703, 702, 401, 405, 317, 503, 107, 901
                ]
                filtered_result = getTreatments(tariff)
                featured_result = getTreatments(tariff, featured)
                list_ordered_by_category, featured_ordered_by_category = self.nestedObjects(
                    filtered_result, featured_result)
                self.initialise_SelectOption(
                    list_ordered_by_category=list_ordered_by_category,
                    featured_ordered_by_category=featured_ordered_by_category)