﻿<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
  <entity name='llp_insurancepolicy'>
    <attribute name='llp_name'/>
    <attribute name='llp_parentpolicyid' />
    <attribute name='llp_paymethod' />
    <attribute name='llp_payperiod' />
    <attribute name='llp_policynumber' />
    <attribute name='llp_policytype' />
    <attribute name='llp_productid' />
    <attribute name='llp_providerid' />
    <attribute name='llp_referralcode' />
    <attribute name='llp_insurancepolicyid'/>
    <attribute name='statuscode'/>
    <order attribute='llp_name' descending='false'/>
    <filter type='and'>
      <condition attribute='llp_activationcode' operator='eq' value='${code}'/>
      <condition attribute='statecode' operator='eq' value='0'/>
    </filter>
    <link-entity name='llp_insuredobjectanimal' from='llp_insurancepolicyid' to='llp_insurancepolicyid' link-type='inner' alias='animal'>
      <attribute name='llp_name'/>
      <attribute name='llp_insuredobjectanimalid' />
      <attribute name='llp_animalid' />
      <attribute name='llp_animalkind' />
      <attribute name='llp_dateofbirth' />
      <attribute name='llp_chipnumber' />
      <attribute name='llp_origin' />
      <attribute name='llp_sex' />
      <link-entity name='llp_breed' from='llp_breedid' to='llp_breedid' link-type='inner' alias='breed'>
        <attribute name='llp_name'/>
        <attribute name='llp_breedid'/>
      </link-entity>
    </link-entity>
    <link-entity name='contact' from='contactid' to='llp_customerid' link-type='inner' alias='customer'>
      <attribute name='firstname'/>
      <attribute name='lastname'/>
      <attribute name='telephone1'/>
      <attribute name='emailaddress1'/>
      <attribute name='address1_city'/>
      <attribute name='address1_line1'/>
      <attribute name='address1_line2'/>
      <attribute name='address1_line3'/>
      <attribute name='address1_postalcode'/>
      <attribute name='llp_personalid'/>
      <attribute name='birthdate'/>
      <attribute name='contactid'/>
    </link-entity>
    <link-entity name='product' from='productid' to='llp_productid' link-type='outer' alias='product'>
      <attribute name='llp_publicname'/>
      <attribute name='name'/>
      <attribute name='productnumber'/>
    </link-entity>
  </entity>
</fetch>
