示例#1
0
    def test_date(self):
        today = datetime.date(2013, 3, 1)

        date_type = DateType()
        self.assertEqual(date_type("2013-03-01"), today)

        self.assertEqual(date_type.to_primitive(today), "2013-03-01")
示例#2
0
def test_date():
    today = datetime.date(2013, 3, 1)

    date_type = DateType()
    assert date_type("2013-03-01") == today

    assert date_type.to_primitive(today) == "2013-03-01"
示例#3
0
    def test_date(self):
        today = datetime.date(2013, 3, 1)

        date_type = DateType()
        self.assertEqual(date_type("2013-03-01"), today)

        self.assertEqual(date_type.to_primitive(today), "2013-03-01")
示例#4
0
def test_date():
    today = datetime.date(2013, 3, 1)

    date_type = DateType()
    assert date_type("2013-03-01") == today

    assert date_type.to_primitive(today) == "2013-03-01"
示例#5
0
class FormerTenure(Tenure):
    start = DateType(default=None)
    end = DateType(default=None)

    @classmethod
    def _claim_polymorphic(cls, data):
        return data.get("tenure_type") == TenureType.FORMER
示例#6
0
class Transaction(TransactionEntity):
    date = DateType()
    cleared = StringType()
    accepted = BooleanType()
    dateEnteredFromSchedule = DateType()
    accountId = StringType()
    payeeId = StringType()
    subTransactions = ListType(ModelType(SubTransaction))
示例#7
0
class RecurrentEntryValidationModel(BaseValidationModel):
    frequency = StringType(choices=[
        "yearly", "half-yearly", "quarter-yearly", "bimonthly", "monthly",
        "weekly", "daily"
    ],
                           required=True)
    start = DateType(formats=("%Y-%m-%d", PERIOD_DATE_FORMAT))
    end = DateType(formats=("%Y-%m-%d", PERIOD_DATE_FORMAT))
class CityHallContractItem(BaseModel):
    contract_id = StringType(required=True)
    starts_at = DateType(formats=("%d/%m/%Y", "%d/%m/%y"))
    summary = StringType()
    contractor_document = StringType()
    contractor_name = StringType()
    value = StringType()
    ends_at = DateType(formats=("%d/%m/%Y", "%d/%m/%y"))
    files = ListType(StringType)
示例#9
0
def test_date():
    today = datetime.date(2013, 3, 1)

    date_type = DateType()
    assert date_type("2013-03-01") == today

    assert date_type.to_primitive(today) == "2013-03-01"

    assert date_type.to_native(today) is today

    with pytest.raises(ConversionError):
        date_type.to_native('foo')
class Claim(Model):
    """This model represents each claim submitted by a provider."""

    splt_clm_id = StringType()  # Split claim ID
    clm_rndrg_prvdr_npi_num = StringType()  # Unique ID of the provider
    clm_rndrg_prvdr_tax_num = StringType()  # Tax ID of the provider

    bene_sk = StringType()  # Unique ID of beneficiary
    clm_ptnt_birth_dt = DateType()  # Date of birth of beneficiary
    clm_bene_sex_cd = StringType(
    )  # Sex of beneficiary. 1 for male, 2 for female
    clm_from_dt = DateType()  # Claim from date
    clm_thru_dt = DateType()  # Claim through date

    dx_codes = ListType(StringType)  # List of diagnosis codes
    claim_lines = ListType(ModelType(
        claim_line.ClaimLine))  # The associated claim lines

    aggregated_procedure_codes = DictType(
        BooleanType)  # Map of procedure codes in all claim lines.

    def __init__(self, *args, **kwargs):
        """Initialize a Claim object, calculating and storing beneficiary age as float."""
        super(Claim, self).__init__(*args, **kwargs)
        # Store patient age in years at date of service.
        age_delta = relativedelta(self.clm_from_dt, self.clm_ptnt_birth_dt)
        self.bene_age = age_delta.years + age_delta.months / 12.0 + age_delta.days / 365.0

    def get_procedure_codes(self):
        """
        Return the map of procedure codes present in all claim lines under this claim.

        Check that codes exist. If this claim was not created by claim_reader (e.g. in a unit test)
        then aggregated_procedure_codes will be null so we need to populate it.
        """
        if not self.aggregated_procedure_codes:
            self.aggregated_procedure_codes = {
                line.clm_line_hcpcs_cd: True
                for line in self.claim_lines
            }

        return self.aggregated_procedure_codes

    def __str__(self):
        """Return a string representation of the claim."""
        return 'Claim-Split Claim ID: {splt_clm_id}, npi: {npi}, claim_lines: {claim_lines}'.format(
            splt_clm_id=self.splt_clm_id,
            npi=self.clm_rndrg_prvdr_npi_num,
            claim_lines=len(self.claim_lines or []))
class LegacyGazetteItem(BaseModel):
    title = StringType(required=True)
    published_on = StringType(required=False)
    # important info but not available in years like 2010
    date = DateType(required=False)
    details = StringType(required=True)
    files = ListType(StringType)
class CityHallPaymentsItem(BaseModel):
    published_at = DateType(formats=("%d/%m/%Y", "%d/%m/%y"))
    phase = StringType()
    company_or_person = StringType(required=True)
    value = StringType(required=True)
    number = StringType()
    document = StringType(required=True)
    date = DateType(formats=("%d/%m/%Y", "%d/%m/%y"))
    process_number = StringType()
    summary = StringType()
    group = StringType()
    action = StringType()
    function = StringType()
    subfunction = StringType()
    type_of_process = StringType()
    resource = StringType()
示例#13
0
class Flight(Model):
    FL_DATE = DateType()
    AIRLINE_ID = IntType()
    CARRIER = StringType()
    TAIL_NUM = StringType()
    FL_NUM = IntType()
    ORIGIN_AIRPORT_ID = IntType()
    ORIGIN_AIRPORT_SEQ_ID = IntType()
    ORIGIN_CITY_MARKET_ID = IntType()
    ORIGIN = StringType()
    ORIGIN_CITY_NAME = StringType()
    ORIGIN_STATE_ABR = StringType()
    ORIGIN_STATE_FIPS = IntType()
    ORIGIN_STATE_NM = StringType()
    ORIGIN_WAC = IntType()
    DEST_AIRPORT_ID = IntType()
    DEST_AIRPORT_SEQ_ID = IntType()
    DEST_CITY_MARKET_ID = IntType()
    DEST = StringType()
    DEST_CITY_NAME = StringType()
    DEST_STATE_ABR = StringType()
    DEST_STATE_FIPS = IntType()
    DEST_STATE_NM = StringType()
    DEST_WAC = IntType()
    DEP_DELAY = FloatType()
    TAXI_OUT = FloatType()
    WHEELS_OFF = FloatType()
    WHEELS_ON = FloatType()
    TAXI_IN = FloatType()
    ARR_DELAY = FloatType()
    AIR_TIME = FloatType()
    DISTANCE = FloatType()
示例#14
0
class GazetteItem(BaseModel):
    date = DateType()
    power = StringType(required=True)
    year_and_edition = StringType(required=True)
    events = ListType(DictType(StringType), required=True)
    file_urls = ListType(StringType, required=True)
    file_content = StringType()
示例#15
0
class ProjectContribDTO(Model):
    date = DateType(required=True)
    mapped = IntType(required=True)
    validated = IntType(required=True)
    cumulative_mapped = IntType(required=False)
    cumulative_validated = IntType(required=False)
    total_tasks = IntType(required=False)
示例#16
0
class TaskStats(Model):
    """ DTO for tasks stats for a single day """

    date = DateType(required=True)
    mapped = IntType(serialized_name="mapped")
    validated = IntType(serialized_name="validated")
    bad_imagery = IntType(serialized_name="badImagery")
示例#17
0
class Client(Model):
    _id = StringType(default=generate_uuid())
    name = StringType(required=True, min_length=1, max_length=80)
    cpf = StringType(required=True, min_length=11, max_length=11)
    birthdate = DateType(required=True)
    amount = DecimalType(required=True, validators=[is_between])
    terms = IntType(required=True, validators=[is_inside])
    income = DecimalType(required=True)
示例#18
0
class LegacyGazetteItem(BaseModel):
    title = StringType(required=True)
    published_on = StringType(required=False)
    # important info but not available in years like 2010
    date = DateType(required=False, formats=("%d/%m/%Y", "%d/%m/%y"))
    details = StringType(required=True)
    file_urls = ListType(URLType)
    file_content = StringType()
示例#19
0
class GazetteEventItem(BaseModel):
    date = DateType(formats=("%d/%m/%Y", "%d/%m/%y"))
    power = StringType(required=True)
    year_and_edition = StringType(required=True)
    event_title = StringType(required=True)
    event_secretariat = StringType(required=True)
    event_summary = StringType(required=True)
    file_urls = ListType(URLType)
    file_content = StringType()
示例#20
0
class PaymentSettlementSummary(BaseModel, metaclass=ORMMeta):
    """
    {
      "capture_submit_time": "2016-01-21T17:15:000Z",
      "captured_date": "2016-01-21"
    }
    """
    capture_submit_time: datetime = ArrowDTType()
    captured_date: date = DateType()
示例#21
0
class Account(DeletableEntity):
    accountName = StringType()
    accountType = StringType()
    hidden = BooleanType()
    onBudget = BooleanType()
    lastReconciledDate = DateType()
    lastReconciledBalance = FloatType()
    lastEnteredCheckNumber = FloatType()
    sortableIndex = IntType()
    note = StringType()
class DocumentData(Model):
    address_history: Optional[List[DatedAddress]] = ListType(
        ModelType(DatedAddress), default=None)
    expiry = DateType(default=None)
    external_ref = StringType(default=None)
    external_service = StringType(default=None)
    issued = DateType(default=None)
    issuer = StringType(default=None)
    issuing_country = StringType(default=None)
    mrz1 = StringType(default=None)
    mrz2 = StringType(default=None)
    mrz3 = StringType(default=None)
    number = StringType(default=None)
    personal_details: Optional[PersonalDetails] = ModelType(PersonalDetails,
                                                            default=None)
    result: Optional[DocumentResult] = ModelType(DocumentResult, default=None)

    class Options:
        export_level = NOT_NONE
示例#23
0
class ClaimLine(Model):
    """
    This model contains the claim-line specific information.

    Each claim will have multiple claim lines. Claim lines contain all of the encounter
    or procedure codes that took place in a visit.
    """

    clm_line_num = IntType()  # Claim line number
    clm_line_hcpcs_cd = StringType()  # HCPCS or C4 CPT code at the claim line level
    mdfr_cds = ListType(StringType)  # Come from 5 columns, some of which will be null
    clm_pos_code = StringType()  # Place of service
    clm_line_from_dt = DateType()  # Beginning date of service for the line item
    clm_line_thru_dt = DateType()  # Final date of service for the line item

    def __str__(self):
        """Return a string representation of the claim."""
        # TODO - Add more relevant info to __repr__.
        return 'ClaimLine - line_number: {clm_line_num}'.format(clm_line_num=self.clm_line_num)
示例#24
0
class Company(Model):
  name = StringType(required=True)
  full_name = StringType(required=True)
  domain = StringType(required=True)
  founded = DateType()
  headquarters = ModelType(Headquarters)
  long_description = StringType(required=True)
  short_description = StringType(required=True)
  technology_labels = ListType(StringType())
  industry_labels = ListType(StringType())
  num_employees = IntType()
示例#25
0
class Eventos(BaseModel):
    nome = StringType(max_length=100, required=True)
    data = DateType()
    local = StringType(max_length=100)
    endereco = StringType(max_length=100)
    site = StringType(max_length=100)

    class Meta:
        list_allowed_methods = [
            'get',
        ]
示例#26
0
class TCMBADocumentItem(Model):
    crawled_at = DateTimeType(required=True)
    category = StringType()
    filename = StringType(required=True)
    original_filename = StringType(required=True)
    filepath = StringType(required=True)
    inserted_by = StringType()
    inserted_at = DateType(formats=("%d/%m/%Y", "%d/%m/%y"))
    unit = StringType(required=True)
    month = StringType()
    year = StringType()
    period = StringType()
示例#27
0
class SignupInputs(Model):
    email = LowerCaseEmailType(required=True)
    password = StringType(min_length=6, max_length=12, required=True)
    full_name = StringType(required=True)
    phone_no = IntType(min_value=1000000000, max_value=9999999999,
                       required=True)
    college_id = IntType(min_value=0)
    referral_code_used = StringType(required=False)
    graduation_date = DateType(required=False)
    degree = StringType(required=False)
    branch = StringType(required=False)
    captcha_token = ReCaptchaValidator(required=True)
示例#28
0
class UserContribution(Model):
    """ User contribution for a project """

    username = StringType()
    mapping_level = StringType(serialized_name="mappingLevel")
    picture_url = StringType(serialized_name="pictureUrl")
    mapped = IntType()
    validated = IntType()
    total = IntType()
    mapped_tasks = ListType(IntType, serialized_name="mappedTasks")
    validated_tasks = ListType(IntType, serialized_name="validatedTasks")
    name = StringType()
    date_registered = DateType(serialized_name="dateRegistered")
示例#29
0
class CourtOrderESAJModel(Model):
    number = StringType(required=True)
    decision = StringType(required=True)
    decision_date = DateType(required=True)
    status = StringType()
    source_numbers = StringType()
    reporter = StringType()
    category = StringType()
    subject = StringType()
    petitioner = StringType()
    petitioner_attorneys = StringType()
    requested = StringType()
    requested_attorneys = StringType()
    appeals = StringType()
示例#30
0
class PostItem(Model):
    visit_ts = DateTimeType(required=True)
    date = DateType(required=True)

    link = URLType(required=True)
    parent_link = URLType(required=True)
    campus = StringType(required=True)
    sections = StringType(required=True)

    title = StringType(required=True)
    description = StringType()
    text = StringType(required=True)

    tags = ListType(StringType)
    people = ListType(StringType)
    branches = ListType(StringType)
示例#31
0
def test_date():
    today = datetime.date(2013, 3, 1)

    date_type = DateType()
    assert date_type("2013-03-01") == today

    assert date_type.to_primitive(today) == "2013-03-01"

    assert date_type.to_native(today) is today

    with pytest.raises(ConversionError):
        date_type.to_native('foo')
示例#32
0
文件: validate.py 项目: 5l1v3r1/slim
def field_class_to_schematics_field(field: peewee.Field) -> BaseType:
    if isinstance(field, peewee.ForeignKeyField):
        field = field.rel_field

    kwargs = {}

    # 检查是否 require
    if not ((field.default is not None) or field.null or field.sequence
            or isinstance(field, peewee.AutoField)):
        kwargs['required'] = True

    if field.help_text:
        kwargs['metadata'] = {'description': field.help_text}

    if isinstance(field, peewee.IntegerField):
        return IntType(**kwargs)
    elif isinstance(field, peewee.FloatField):
        return FloatType(**kwargs)
    elif isinstance(field,
                    (PG_JSONField, PG_BinaryJSONField, SQLITE_JSONField)):
        # 注意 SQLITE_JSONField 是一个 _StringField 所以要提前
        return JSONType(**kwargs)
        # HStore 貌似才应该对应 dict,json可以对应任意类型
        # return JSONDictType(StringType, **kwargs)
    elif isinstance(field, peewee.DateTimeField):
        return DateTimeType(**kwargs)
    elif isinstance(field, peewee.DateField):
        return DateType(**kwargs)
    elif isinstance(field, peewee._StringField):
        return StringType(**kwargs)
    elif isinstance(field, peewee.BooleanField):
        return BooleanType(**kwargs)
    elif isinstance(field, peewee.BlobField):
        return BlobType(**kwargs)
    elif isinstance(field, PG_ArrayField):
        field: PG_ArrayField
        return JSONListType(
            field_class_to_schematics_field(field._ArrayField__field),
            **kwargs)
示例#33
0
class CompanyMetadata(Model):
    name = StringType(default=None)
    number = StringType(default=None)
    lei = StringType(default=None)
    isin = StringType(default=None)
    lei = StringType(default=None)

    company_type = StringType(default=None)
    # structured_company_type = ModelType(StructuredCompanyType)
    industry_classifications = ListType(ModelType(IndustryClassification),
                                        default=None)

    # tax_ids = ListType(ModelType(TaxId), default=list, required=True)

    country_of_incorporation = StringType(default=None)
    incorporation_date = DateType(default=None)

    contact_information = ModelType(ContactDetails, default=None)
    addresses = ListType(ModelType(CompanyAddress), default=None)

    is_active = BooleanType(default=None)
    is_active_details = StringType(default=None)
    trade_description = StringType(default=None)
    description = StringType(default=None)