<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
    <entity name = 'llp_insurancepolicy'>
        <attribute name='llp_insurancepolicyid' />
        <attribute name='llp_name' />
        <attribute name='llp_productid' />
        <attribute name='llp_policynumber' />
        <attribute name='llp_dateactivated' />
        <attribute name='llp_customerid' />
        <attribute name='llp_daterenew' />
        <attribute name='llp_providerid' />
        <attribute name='llp_qualifyingdate' />
        <attribute name='llp_policystatus_public' />
        <attribute name='llp_policynote_public' />
        <attribute name='statecode' />
        <attribute name='statuscode' />
        <attribute name='createdon' />
        <order attribute='llp_customerid' descending='false' />
        <filter type='and'>
            <condition attribute='llp_policynumber' operator='eq' value='${policyNr}' />
            <condition attribute='statuscode' operator='eq' value='1' />
        </filter>
        <link-entity name='llp_insuredobjectanimal' from='llp_insurancepolicyid' to='llp_insurancepolicyid' visible='false' link-type='outer' alias='animal'>
            <attribute name='llp_name' />
            <attribute name='llp_animalkind' />
            <attribute name='llp_dateofbirth' />
            <attribute name='llp_origin' />
            <attribute name='llp_chipnumber' />
            <attribute name='llp_sex' />
            <link-entity name='llp_breed' from='llp_breedid' to='llp_breedid' link-type='outer' alias='breed'>
                <attribute name='llp_name' />
            </link-entity>
        </link-entity>
        <link-entity name='contact' from='contactid' to='llp_customerid' visible='false' link-type='outer' alias='contact'>
            <attribute name='firstname' />
            <attribute name='lastname' />
            <attribute name='emailaddress1' />
            <attribute name='telephone1' />
            <attribute name='address1_line1' />
            <attribute name='address1_city' />
            <attribute name='address1_postalcode' />
            <attribute name='llp_customerid' />
        </link-entity>
        <link-entity name='product' from='productid' to='llp_productid' visible='false' link-type='outer' alias='product'>
            <attribute name='name' />
        </link-entity>
        <link-entity name='account' from='accountid' to='llp_providerid' visible='false' link-type='outer' alias='provider'>
            <attribute name='name' />
        </link-entity>
    </entity>
</fetch>