Пример #1
0
def _get_id(site: dict) -> str:
    name = _get_name(site)
    city = _get_city(site)

    id = location_id_from_name(f"{name}_{city}")

    return id
Пример #2
0
def _get_id(site: dict) -> str:
    addr = site.get("addressLine1")
    has_location = addr and addr != ""
    alt_id = (location_id_from_name(site["addressLine1"])
              if has_location else site.get("_id", "unknown"))

    return site.get("sourceSystemId", alt_id) or alt_id
Пример #3
0
def tableau_item_to_parsed_site(tableau_entry):
    """Put the tableau entry in something closer to the normalized format."""
    main_data = tableau_entry
    name = main_data["Name-value"]
    address = main_data["Address-value"]

    contact = {}
    if main_data["Web Site-alias"] != "%null%":
        contact["website"] = main_data["Web Site-alias"]
    if main_data["Phone-value"] != "%null%":
        contact["phone"] = main_data["Phone-value"]

    return {
        # Name isn't sufficient, multiple "Acme Pharmacy" etc.
        "id": location_id_from_name(name + address),
        "contact": contact,
        "name": name,
        "address": address,
    }
Пример #4
0
def tableau_item_to_parsed_site(tableau_entry):
    """Put the tableau entry in something closer to the normalized format."""
    main_data, extra_data = tableau_entry
    name, street, city_state = main_data["Site-value"].split("\n")
    city_state = city_state.strip()
    if city_state.endswith(" LA"):
        city = city_state[:-3]
    else:
        city = city_state
    state = "LA"
    address = {"street1": street, "city": city, "state": state}

    if name.startswith("** "):
        name = name[3:]
        minimum_age = 16
    else:
        minimum_age = 18

    id = location_id_from_name(name)

    contact = {}
    if main_data["Dimension-value"] == "Website":
        contact["website"] = main_data["Value-alias"]
    elif extra_data["Dimension-value"] == "Website":
        contact["website"] = extra_data["Value-alias"]

    if main_data["Phone-value"] != "%null%":
        contact["phone"] = main_data["Phone-value"]

    out = {}
    out["id"] = id
    if contact:
        out["contact"] = contact
    out["name"] = name
    out["address"] = address
    out["minimum_age"] = minimum_age
    return out
Пример #5
0
def _get_normalized_location(site: dict,
                             timestamp: str) -> schema.NormalizedLocation:
    id = location_id_from_name(site["name"])

    return schema.NormalizedLocation(
        id=f"ca_los_angeles_gov:{id}",
        name=site["name"],
        address=_get_address(site),
        location=_get_location(site),
        contact=_get_contacts(site),
        inventory=_get_inventory(site),
        parent_organization=_get_parent_organization(site),
        links=_get_links(site),
        notes=_get_notes(site),
        active=_get_active(site),
        source=schema.Source(
            source="ca_los_angeles_gov",
            id=id,
            fetched_from_uri=
            "http://publichealth.lacounty.gov/acd/ncorona2019/js/pod-data.js",
            fetched_at=timestamp,
            data=site,
        ),
    )
Пример #6
0
def _get_id(site: dict) -> str:
    if "ExtendedData" in site and "PIN" in site["ExtendedData"]:
        return location_id_from_name(site["ExtendedData"]["PIN"])

    return location_id_from_name(site["name"])
def _test(input_name, expected_output_id):
    assert location_id_from_name(input_name) == expected_output_id
Пример #8
0
def _get_parent(site: dict) -> Optional[schema.Organization]:
    if org := site["attributes"].get("agency"):
        return schema.Organization(id=location_id_from_name(org), name=org)