# `HL7v2.Type.XAD`
[🔗](https://github.com/Balneario-de-Cofrentes/hl7v2/blob/v3.10.1/lib/hl7v2/type/xad.ex#L1)

Extended Address (XAD) -- HL7v2 composite data type.

14 components:
1. Street Address (SAD) -- sub-components delimited by `&`
2. Other Designation (ST)
3. City (ST)
4. State or Province (ST)
5. Zip or Postal Code (ST)
6. Country (ID) -- Table 0399, ISO 3166-1
7. Address Type (ID) -- Table 0190: H=Home, B=Business, M=Mailing, etc.
8. Other Geographic Designation (ST)
9. County/Parish Code (IS) -- Table 0289
10. Census Tract (IS) -- Table 0288
11. Address Representation Code (ID) -- Table 0465
12. Address Validity Range (DR) -- deprecated, sub-components delimited by `&`
13. Effective Date (TS) -- sub-components delimited by `&`
14. Expiration Date (TS) -- sub-components delimited by `&`

# `t`

```elixir
@type t() :: %HL7v2.Type.XAD{
  address_representation_code: binary() | nil,
  address_type: binary() | nil,
  address_validity_range: HL7v2.Type.DR.t() | nil,
  census_tract: binary() | nil,
  city: binary() | nil,
  country: binary() | nil,
  county_code: binary() | nil,
  effective_date: HL7v2.Type.TS.t() | nil,
  expiration_date: HL7v2.Type.TS.t() | nil,
  other_designation: binary() | nil,
  other_geographic: binary() | nil,
  state: binary() | nil,
  street_address: HL7v2.Type.SAD.t() | nil,
  zip: binary() | nil
}
```

# `encode`

```elixir
@spec encode(t() | nil) :: list()
```

Encodes an XAD to a list of component strings.

## Examples

    iex> HL7v2.Type.XAD.encode(%HL7v2.Type.XAD{
    ...>   street_address: %HL7v2.Type.SAD{street_or_mailing_address: "123 Main St"},
    ...>   city: "Springfield",
    ...>   state: "IL",
    ...>   zip: "62704"
    ...> })
    ["123 Main St", "", "Springfield", "IL", "62704"]

    iex> HL7v2.Type.XAD.encode(nil)
    []

# `parse`

```elixir
@spec parse(list()) :: t()
```

Parses an XAD from a list of components.

## Examples

    iex> HL7v2.Type.XAD.parse(["123 Main St&Main St&123", "", "Springfield", "IL", "62704", "USA", "H"])
    %HL7v2.Type.XAD{
      street_address: %HL7v2.Type.SAD{street_or_mailing_address: "123 Main St", street_name: "Main St", dwelling_number: "123"},
      city: "Springfield",
      state: "IL",
      zip: "62704",
      country: "USA",
      address_type: "H"
    }

    iex> HL7v2.Type.XAD.parse([])
    %HL7v2.Type.XAD{}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
