|
| 1 | +"""Normalized Location Schema |
| 2 | +
|
| 3 | +Spec defined here: |
| 4 | +https://github.com/CAVaccineInventory/vaccine-feed-ingest/wiki/Normalized-Location-Schema |
| 5 | +""" |
| 6 | + |
| 7 | +from typing import List, Optional |
| 8 | + |
| 9 | +from .common import BaseModel |
| 10 | + |
| 11 | + |
| 12 | +class Address(BaseModel): |
| 13 | + """ |
| 14 | + { |
| 15 | + "street1": str, |
| 16 | + "street2": str, |
| 17 | + "city": str, |
| 18 | + "state": str as state initial e.g. CA, |
| 19 | + "zip": str, |
| 20 | + }, |
| 21 | + """ |
| 22 | + |
| 23 | + street1: str |
| 24 | + street2: Optional[str] |
| 25 | + city: str |
| 26 | + state: str |
| 27 | + zip: str |
| 28 | + |
| 29 | + |
| 30 | +class LatLng(BaseModel): |
| 31 | + """ |
| 32 | + { |
| 33 | + "latitude": float, |
| 34 | + "longitude": float, |
| 35 | + }, |
| 36 | + """ |
| 37 | + |
| 38 | + latitude: float |
| 39 | + longitude: float |
| 40 | + |
| 41 | + |
| 42 | +class Contact(BaseModel): |
| 43 | + """ |
| 44 | + { |
| 45 | + "contact_type": str as contact type enum e.g. booking, |
| 46 | + "phone": str as (###) ###-###, |
| 47 | + "website": str, |
| 48 | + "email": str, |
| 49 | + "other": str, |
| 50 | + } |
| 51 | + """ |
| 52 | + |
| 53 | + contact_type: Optional[str] |
| 54 | + phone: Optional[str] |
| 55 | + website: Optional[str] |
| 56 | + email: Optional[str] |
| 57 | + other: Optional[str] |
| 58 | + |
| 59 | + |
| 60 | +class OpenDate(BaseModel): |
| 61 | + """ |
| 62 | + { |
| 63 | + "opens": str as iso8601 date, |
| 64 | + "closes": str as iso8601 date, |
| 65 | + } |
| 66 | + """ |
| 67 | + |
| 68 | + opens: Optional[str] |
| 69 | + closes: Optional[str] |
| 70 | + |
| 71 | + |
| 72 | +class OpenHour(BaseModel): |
| 73 | + """ |
| 74 | + { |
| 75 | + "day": str as day of week enum e.g. monday, |
| 76 | + "opens": str as hh:mm, |
| 77 | + "closes": str as hh:mm, |
| 78 | + } |
| 79 | + """ |
| 80 | + |
| 81 | + day: str |
| 82 | + open: str |
| 83 | + closes: str |
| 84 | + |
| 85 | + |
| 86 | +class Availability(BaseModel): |
| 87 | + """ |
| 88 | + { |
| 89 | + "drop_in": bool, |
| 90 | + "appointments": bool, |
| 91 | + }, |
| 92 | + """ |
| 93 | + |
| 94 | + drop_in: Optional[bool] |
| 95 | + appointments: Optional[bool] |
| 96 | + |
| 97 | + |
| 98 | +class Vaccine(BaseModel): |
| 99 | + """ |
| 100 | + { |
| 101 | + "vaccine": str as vaccine type enum, |
| 102 | + "supply_level": str as supply level enum e.g. more_than_48hrs |
| 103 | + } |
| 104 | + """ |
| 105 | + |
| 106 | + vaccine: str |
| 107 | + supply_level: Optional[str] |
| 108 | + |
| 109 | + |
| 110 | +class Access(BaseModel): |
| 111 | + """ |
| 112 | + { |
| 113 | + "walk": bool, |
| 114 | + "drive": bool, |
| 115 | + "wheelchair": str, |
| 116 | + } |
| 117 | + """ |
| 118 | + |
| 119 | + walk: Optional[bool] |
| 120 | + drive: Optional[bool] |
| 121 | + wheelchair: Optional[str] |
| 122 | + |
| 123 | + |
| 124 | +class Organization(BaseModel): |
| 125 | + """ |
| 126 | + { |
| 127 | + "id": str as parent organization enum e.g. rite_aid, |
| 128 | + "name": str, |
| 129 | + } |
| 130 | + """ |
| 131 | + |
| 132 | + id: Optional[str] |
| 133 | + name: Optional[str] |
| 134 | + |
| 135 | + |
| 136 | +class Link(BaseModel): |
| 137 | + """ |
| 138 | + { |
| 139 | + "authority": str as authority enum e.g. rite_aid or google_places, |
| 140 | + "id": str as id used by authority to reference this location e.g. 4096, |
| 141 | + "uri": str as uri used by authority to reference this location, |
| 142 | + } |
| 143 | + """ |
| 144 | + |
| 145 | + authority: Optional[str] |
| 146 | + id: Optional[str] |
| 147 | + uri: Optional[str] |
| 148 | + |
| 149 | + |
| 150 | +class Source(BaseModel): |
| 151 | + """ |
| 152 | + { |
| 153 | + "source": str as source type enum e.g. vaccinespotter, |
| 154 | + "id": str as source defined id e.g. 7382088, |
| 155 | + "fetched_from_uri": str as uri where data was fetched from, |
| 156 | + "fetched_at": str as iso8601 datetime (when scraper ran), |
| 157 | + "published_at": str as iso8601 datetime (when source claims it updated), |
| 158 | + "data": {...parsed source data in source schema...}, |
| 159 | + } |
| 160 | + """ |
| 161 | + |
| 162 | + source: str |
| 163 | + id: str |
| 164 | + fetched_from_uri: Optional[str] |
| 165 | + fetched_at: Optional[str] |
| 166 | + published_at: Optional[str] |
| 167 | + data: dict |
| 168 | + |
| 169 | + |
| 170 | +class NormalizedLocation(BaseModel): |
| 171 | + id: str |
| 172 | + name: Optional[str] |
| 173 | + address: Optional[Address] |
| 174 | + location: Optional[LatLng] |
| 175 | + contact: Optional[List[Contact]] |
| 176 | + languages: Optional[List[str]] # [str as ISO 639-1 code] |
| 177 | + opening_dates: Optional[List[OpenDate]] |
| 178 | + opening_hours: Optional[List[OpenHour]] |
| 179 | + availability: Optional[Availability] |
| 180 | + inventory: Optional[List[Vaccine]] |
| 181 | + access: Optional[Access] |
| 182 | + parent_organization: Optional[Organization] |
| 183 | + links: Optional[List[Link]] |
| 184 | + notes: Optional[List[str]] |
| 185 | + active: Optional[bool] |
| 186 | + source: Source |
0 commit comments