﻿<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
  <entity name='llp_animals'>
    <attribute name='llp_name'/>
    <attribute name='llp_animalsid'/>
    <attribute name='llp_animaltype'/>
    <attribute name='llp_dob'/>
    <attribute name='llp_sex'/>
    <attribute name='llp_chipnr'/>
    <attribute name='llp_breedid'/>
    <attribute name='llp_insurancecode'/>
    <attribute name='llp_insurancelink'/>
    <attribute name='llp_policyid'/>
    <attribute name='llp_handoverdate'/>
    <attribute name='llp_policyexpiration'/>
    <attribute name='llp_activationdate'/>
    <order attribute='llp_name' descending='false'/>
    <filter type='and'>
      <condition attribute='llp_insurancecode' operator='eq' value='${code}'/>
    </filter>
    <link-entity name='llp_breed' from='llp_breedid' to='llp_breedid' link-type='inner' alias='breed'>
      <attribute name='llp_breedid'/>
      <attribute name='llp_name'/>
    </link-entity>
    <link-entity name='lead' from='leadid' to='llp_leadid' link-type='inner' alias='lead'>
      <attribute name='firstname'/>
      <attribute name='lastname'/>
      <attribute name='telephone1'/>
      <attribute name='emailaddress1'/>
      <attribute name='leadid'/>
    </link-entity>
  </entity>
</fetch>
