<?xml version="1.0" encoding="utf-8"?>
<Entity 
Schema="APS" 
Name="RECIPE" 
Description="Рецепт" 
PrimaryKey="RecipeID" 
DNAttributes="{Number};{RecipeDate}" 
DisplayName="{0} - {1}">
  <Fields>
    <Attribute Name="RecipeID" Index="5090001" Type="guid" Description="Идентификатор" />
    <Attribute Name="PostCode" Index="5090003" Type="string" Description="Код врача" CharacterMaximumLength="20" Required="1" />
    <Attribute Name="Serial" Index="5090005" Type="string" Description="Серия" CharacterMaximumLength="32" Required="1" />
    <Attribute Name="Number" Index="5090006" Type="bigint" Description="Номер" Required="1" />
    <Attribute Name="Mkb" Index="5090007" Type="string" Description="Код МКБ" CharacterMaximumLength="16" Required="1" />
    <Attribute Name="Dose" Index="5090013" Type="string" Description="Дозировка" CharacterMaximumLength="255" />
    <Attribute Name="UnitsCount" Index="5090014" Type="float" DefaultFormat="{0:F3}" Description="Количество единиц" NumericPrecision="12" NumericScale="2" Required="1" />
    <Attribute Name="DocNumber" Index="5090015" Type="string" Description="Номер документа" CharacterMaximumLength="16" />
    <Attribute Name="DocSeries" Index="5090016" Type="string" Description="Серия документа" CharacterMaximumLength="16" />
    <Attribute Name="DocIssueDate" Type="date" Description="Дата выдачи документа" />
    <Attribute Name="DocIssueOrg" Type="string" Description="Организация выдавшая документ" />
    <Attribute Name="DocOrgNumber" Type="string" Description="Организация выдавшая документ(код подразделения)" />
    <Attribute Name="BarCode" Index="5090017" Type="string" Description="Штрих-код" CharacterMaximumLength="512" />
    <Attribute Name="PolicyNumber" Index="5090018" Type="string" Description="Номер полиса ОМС" />
    <Attribute Name="RecipeDate" Index="5090019" Type="date" Description="Дата выписки рецепта" Required="1" />
    <Attribute Name="AdressString" Index="5090020" Type="string" Description="Адрес" CharacterMaximumLength="4096" />
    <Attribute Name="LastName" Index="5090022" Type="string" Description="Фамилия" CharacterMaximumLength="40" Required="1" />
    <Attribute Name="FirstName" Index="5090023" Type="string" Description="Имя" CharacterMaximumLength="40" Required="1" />
    <Attribute Name="FatherName" Index="5090024" Type="string" Description="Отчество" CharacterMaximumLength="40" />
    <Attribute Name="Birthday" Index="5090025" Type="date" Description="Дата рождения" Required="1" />
    <Attribute Name="Phone" Index="5090026" Type="string" Description="Телефон" CharacterMaximumLength="128" />
    <Attribute Name="PolicySerial" Index="5090028" Type="string" Description="Серия полиса ОМС " CharacterMaximumLength="64" />
    <Attribute Name="VK" Index="5090044" Type="bool" Description="Наличие протокола ВК" Required="1" />
    <Attribute Name="IssueDate" Index="5090049" Type="date" Description="Дата отпуска ЛС" />
    <Attribute Name="DeleteDateTime" Index="5090051" Type="datetime" DefaultFormat="{0:dd.MM.yyyy HH:mm}" Description="Дата и время отбраковки" />
    <Attribute Name="DeleteReason" Index="5090052" Type="string" Description="Причина отбраковки" />
    <Attribute Name="RecipeVersion" Index="5090053" Type="string" Description="Версия рецепта" CharacterMaximumLength="8" Required="1" />
    <Attribute Name="Diagnosis" Index="5090055" Type="string" Description="Диагноз" />
    <Attribute Name="CheckIn" Index="5090057" Type="bool" Description="Проверен в регистре" Required="1" />
    <Attribute Name="DoctorCheckIn" Index="5090058" Type="bool" Description="Врач проверен в регистре" Required="1" />
    <Attribute Name="ApplicationDate" Index="5090060" Type="date" Description="Дата обращения" Required="1" />
    <Attribute Name="KladrCode" Index="5090061" Type="string" Description="Код КЛАДР" CharacterMaximumLength="17" />
    <Attribute Name="Branch" Type="string" Description="Код филиала" CharacterMaximumLength="25" />
    <Attribute Name="House" Index="5090062" Type="string" Description="Дом" CharacterMaximumLength="8" />
    <Attribute Name="Block" Index="5090063" Type="string" Description="Корпус" CharacterMaximumLength="4" />
    <Attribute Name="Flat" Index="5090064" Type="string" Description="Квартира" CharacterMaximumLength="4" />
    <Attribute Name="Category" Index="5090068" Type="int" Description="Код категории гражданина" />
    <Attribute Name="Doctor" Index="5090070" Type="string" Description="ФИО врача" />
    <Attribute Name="HCounter" Index="5090071" Type="int" Description="Счетчик записей истории" Required="1" />
    <Attribute Name="Signa" Index="5090073" Type="string" Description="Рекомендации по применению" CharacterMaximumLength="255" />
    <Attribute Name="DateOfChange" Index="5090074" Type="datetime" Description="Дата изменения статуса" />
    <Attribute Name="TotalAmount" Index="5090075" Type="float" DefaultFormat="{0:F3}" Description="Итоговое количество" NumericPrecision="12" NumericScale="2" />
    <Attribute Name="TotalSum" Index="5090076" Type="float" DefaultFormat="{0:F2}" Description="Итоговая сумма" NumericPrecision="12" NumericScale="2" />
    <Attribute Name="LastModifyDateTime" Index="5090077" Type="datetime" Description="Дата последнего изменения рецепта" />
    <Attribute Name="SNILS" Index="5090056" Type="string" Description="Снилс" CharacterMaximumLength="14" />
    <Parent Name="DocType" Index="5090032" Type="VCLib.ENUMS" Description="Тип документа" EnumType="DocType" />
    <Parent Name="CMnn" Index="5090034" Type="PHARM.C_MNN" Description="МНН" />
    <Parent Name="Post" Index="5090035" Type="APS.POST" Description="Должность" />
    <Parent Name="PaymentType" Index="5090036" Type="APS.PAYMENT_TYPE" Description="Источник финансирования" />
    <Parent Name="Sex" Index="5090037" Type="VCLib.ENUMS" Description="Пол" EnumType="Sex" Required="1" />
    <Parent Name="Benefits" Index="5090038" Type="APS.BENEFITS" Description="Льготы" Required="1" />
    <Parent Name="LpuMain" Index="5090045" Type="APS.LPU_MAIN" Description="Единый реестр медицинских организаций ОМС" CharacterMaximumLength="6" Required="1" />
    <Parent Name="Region" Index="5090046" Type="APS.REGION" Description="Регион" />
    <Parent Name="CTrn" Type="PHARM.C_TRN" Description="Торговое наименование препарата" />
    <Parent Name="Reference" Index="5090059" Type="APS.REFERENCE" Description="Справка о льготе" />
    <Parent Name="Street" Index="5090065" Type="APS.STREET" Description="Улица">
      <Parameter Name="Kladr" Description="Код кладр" Type="string">
        <lx:Path xmlns:lx="lexem">
          <lx:StepInt index="5090061" />
        </lx:Path>
      </Parameter>
    </Parent>
    <Parent Name="City" Index="5090066" Type="APS.CITY" Description="Город">
      <Parameter Name="Kladr" Description="Код кладр" Type="string">
        <lx:Path xmlns:lx="lexem">
          <lx:StepInt index="5090061" />
        </lx:Path>
      </Parameter>
    </Parent>
    <Parent Name="District" Index="5090067" Type="APS.DISTRICT" Description="Район">
      <Parameter Name="Kladr" Description="Код кладр" Type="string">
        <lx:Path xmlns:lx="lexem">
          <lx:StepInt index="5090061" />
        </lx:Path>
      </Parameter>
    </Parent>
    <Parent Name="Pharmacy" Index="5090069" Type="APS.PHARMACY" Description="Аптека" Required="1" />
    <Parent Name="LastModifyUser" Index="5090078" Type="APS.USERS" Description="Автор последней модификации" />
    <Parent Name="DloPatient" Index="5090079" Type="APS.DLO_PATIENT" Description="Пациент" CharacterMaximumLength="90" />
    <Child Name="RecipeElementss" Index="5090039" Type="APS.RECIPE_ELEMENTS" Description="Элементы рецепта" ChildAttribute="Recipe" />
    <Child Name="RecipeStatusHistorys" Index="5090072" Type="APS.RECIPE_STATUS_HISTORY" Description="История статусов рецепта" ChildAttribute="Recipe" />
    <Choice Name="Discount" Index="5090040" Description="Процент финансирования" Required="1">
      <Item Name="100%" Index="1" />
      <Item Name="50%" Index="2" />
    </Choice>
    <Choice Name="Status" Index="5090041" Description="Статус" Required="1">
      <Item Name="Загружен" Index="0" />
      <Item Name="Обработан" Index="1" />
      <Item Name="Отсрочен" Index="2" />
      <Item Name="Отбракован" Index="3" />
      <Item Name="Не обработан" Index="4" />
      <Item Name="Отложен" Index="5" />
    </Choice>
    <Choice Name="Period" Index="5090042" Description="Срок действия" Required="1">
      <Item Name="30 дней" Index="0" />
      <Item Name="14 дней" Index="1" />
      <Item Name="90 дней" Index="2" />
      <Item Name="5 дней" Index="3" />
      <Item Name="10 дней" Index="4" />
      <Item Name="15 дней" Index="5" />
    </Choice>
    <Link Name="RecipeInvoice" Index="5090043" Type="APS.RECIPE_INVOICE" Description="Накладная по рецепту" LinkAttribute="Recipe" />
    <Parent Name="MedicationForms" Type="PHARM.MEDICATION_FORMS" Description="Лекарственные формы" />
    <Child Name="RecipeSignatures" Type="APS.RECIPE_SIGNATURE" Description="Подписи рецепта" ChildAttribute="Recipe" />
    <Choice Name="SyncState" IsFlag="1" Description="Состояние синхронизации" Required="1">
      <Item Name="AKUZ" Index="1" />
      <Item Name="RDS" Index="2" />
      <Item Name="APS" Index="4" />
    </Choice>
    <Attribute Name="RecipeDateEnd" Type="date" Description="Дата окончания действия рецепта" />
    <Attribute Name="Cito" Type="bool" Description="Признак срочного отпуска препарата" Required="1" />
    <Attribute Name="Statim" Type="bool" Description="Признак немедленного отпуска препарата" Required="1" />
    <Attribute Name="Okato" Type="string" Description="ОКАТО субъекта РФ" CharacterMaximumLength="11" />
    <Attribute Name="Ogrn" Type="string" Description="ОГРН медицинской организации" CharacterMaximumLength="13" />
    <Attribute Name="DocLastName" Type="string" Description="Фамилия врача, выписавшего рецепт" CharacterMaximumLength="40" />
    <Attribute Name="DocFirstName" Type="string" Description="Имя врача, выписавшего рецепт" CharacterMaximumLength="40" />
    <Attribute Name="DocFatherName" Type="string" Description="Отчество врача, выписавшего рецепт" CharacterMaximumLength="40" />
    <Attribute Name="AcNumber" Type="string" Description="Номер амбулаторной карты пациента" CharacterMaximumLength="32" />
    <Attribute Name="Months" Type="int" Description="Количество полных месяцев" />
    <Attribute Name="Address" Type="string" Description="Адрес пациента" CharacterMaximumLength="1024" />
    <Attribute Name="Spec" Type="bool" Description="Отметка о специальном назначении ЛП" Required="1" />
    <Attribute Name="FiasAddress" Type="string" Description="Код ФИАС адреса" CharacterMaximumLength="36" />
    <Attribute Name="FiasHome" Type="string" Description="Код ФИАС дома" CharacterMaximumLength="36" />
    <Attribute Name="BirthSurname" Type="string" Description="Фамилия при рождении" CharacterMaximumLength="40" />
    <Attribute Name="DoctorSnils" Type="string" Description="Снилс врача" CharacterMaximumLength="14" />
    <Parent Name="EhrRus7pjsam6gjm" Type="EHR.EHR_RUS_7PJSAM6GJM" Description="Должности работников организаций медицинского и фармацевтического профиля(врач)" />
    <Parent Name="EhrRus9a9g09e8kl" Type="EHR.EHR_RUS_9A9G09E8KL" Description="Узлы СМНН. ЕСКЛП" />
    <Attribute Name="Enp" Type="string" Description="Единый номер полиса ОМС гражданина" CharacterMaximumLength="16" />
    <Parent Name="EhrRus6kiqts8t99" Type="EHR.EHR_RUS_6KIQTS8T99" Description="Потребительские единицы ЕСКЛП" />
    <Parent Name="EhrRusD4U765T5TH" Type="EHR.EHR_RUS_D4U765T5TH" Description="Пути введения лекарственных препаратов, в том числе для льготного обеспечения граждан лекарственными средствами" />
    <Child Name="EmdrMessages" Type="APS.EMDR_MESSAGE" Description="EMDR-сообщение" ChildAttribute="Recipe" />
    <Parent Name="EmdrMessage" Type="APS.EMDR_MESSAGE" Description="EMDR-сообщение" />
    <Attribute Name="SemdErrorCreating" Type="text" Description="Ошибка создания сэмд" />
    <Parent Name="SellingPharmacy" Type="APS.PHARMACY" Description="Аптека, выдавшая товар" />
    <Attribute Name="LSName" Type="string" Description="Наименование ЛС" CharacterMaximumLength="1000" />
    <Attribute Name="RequestCatalogId" Type="string" Description="Идентификатор элемента заявочного списка" CharacterMaximumLength="36" />
    <Attribute Name="PatientRegionalId" Type="guid" Description="Региональный ID пациента" />
    <Attribute Name="PharmacyTrn" Type="bool" Description="ТРН указано аптекой" Required="1" />
    <Attribute Name="ReferenceNumber" Type="string" Description="Номер справки" />
    <Attribute Name="ReferenceDateBegin" Type="date" Description="Справка действительна с" />
    <Attribute Name="ReferenceDateEnd" Type="date" Description="Справка действительна по" />
    <Parent Name="ProductOwner" Type="APS.LPU_MAIN" Description="Организация-владелец товара" CharacterMaximumLength="6" />
    <Attribute Name="TotalSellingSum" Type="float" DefaultFormat="{0:F2}" Description="Итоговая сумма продажи" NumericPrecision="12" NumericScale="2" />
  </Fields>
  <DbMapping>
    <Table name="T_RECIPE">
      <Map Name="RecipeID" Column="RecipeID" />
      <Map Name="PostCode" Column="PostCode" />
      <Map Name="Serial" Column="Serial" />
      <Map Name="Number" Column="Number" />
      <Map Name="Mkb" Column="Mkb" />
      <Map Name="Dose" Column="Dose" />
      <Map Name="UnitsCount" Column="UnitsCount" />
      <Map Name="DocNumber" Column="DocNumber" />
      <Map Name="DocSeries" Column="DocSeries" />
      <Map Name="DocIssueDate" Column="DocIssueDate" />
      <Map Name="DocIssueOrg" Column="DocIssueOrg" />
      <Map Name="DocOrgNumber" Column="DocOrgNumber" />
      <Map Name="BarCode" Column="BarCode" />
      <Map Name="PolicyNumber" Column="PolicyNumber" />
      <Map Name="RecipeDate" Column="RecipeDate" />
      <Map Name="AdressString" Column="AdressString" />
      <Map Name="LastName" Column="LastName" />
      <Map Name="FirstName" Column="FirstName" />
      <Map Name="FatherName" Column="FatherName" />
      <Map Name="Birthday" Column="Birthday" />
      <Map Name="Phone" Column="Phone" />
      <Map Name="PolicySerial" Column="PolicySerial" />
      <Map Name="VK" Column="VK" />
      <Map Name="IssueDate" Column="IssueDate" />
      <Map Name="DeleteDateTime" Column="DeleteDateTime" />
      <Map Name="DeleteReason" Column="DeleteReason" />
      <Map Name="RecipeVersion" Column="RecipeVersion" />
      <Map Name="Diagnosis" Column="Diagnosis" />
      <Map Name="CheckIn" Column="CheckIn" />
      <Map Name="DoctorCheckIn" Column="DoctorCheckIn" />
      <Map Name="ApplicationDate" Column="ApplicationDate" />
      <Map Name="KladrCode" Column="KladrCode" />
      <Map Name="Branch" Column="Branch" />
      <Map Name="House" Column="House" />
      <Map Name="Block" Column="Block" />
      <Map Name="Flat" Column="Flat" />
      <Map Name="Category" Column="Category" />
      <Map Name="HCounter" Column="HCounter" />
      <Map Name="Signa" Column="Signa" />
      <Map Name="LastModifyDateTime" Column="LastModifyDateTime" />
      <Map Name="SNILS" Column="SNILS" />
      <Map Name="DocType" Column="DocType" />
      <Map Name="CMnn" Column="CMnn" />
      <Map Name="Post" Column="Post" />
      <Map Name="PaymentType" Column="PaymentType" />
      <Map Name="Sex" Column="Sex" />
      <Map Name="Benefits" Column="Benefits" />
      <Map Name="LpuMain" Column="LpuMain" />
      <Map Name="Region" Column="Region" />
      <Map Name="CTrn" Column="CTrn" />
      <Map Name="Reference" Column="Reference" />
      <Map Name="Pharmacy" Column="Pharmacy" />
      <Map Name="LastModifyUser" Column="LastModifyUser" />
      <Map Name="Discount" Column="Discount" />
      <Map Name="Status" Column="Status" IsStored="0" />
      <Map Name="Period" Column="Period" />
      <Map Name="MedicationForms" Column="MedicationForms" />
      <Map Name="SyncState" Column="SyncState" />
      <Map Name="RecipeDateEnd" Column="RecipeDateEnd" />
      <Map Name="Cito" Column="Cito" />
      <Map Name="Statim" Column="Statim" />
      <Map Name="Okato" Column="Okato" />
      <Map Name="Ogrn" Column="Ogrn" />
      <Map Name="DocLastName" Column="DocLastName" />
      <Map Name="DocFirstName" Column="DocFirstName" />
      <Map Name="DocFatherName" Column="DocFatherName" />
      <Map Name="AcNumber" Column="AcNumber" />
      <Map Name="Months" Column="Months" />
      <Map Name="Address" Column="Address" />
      <Map Name="Spec" Column="Spec" />
      <Map Name="FiasAddress" Column="FiasAddress" />
      <Map Name="FiasHome" Column="FiasHome" />
      <Map Name="BirthSurname" Column="BirthSurname" />
      <Map Name="DoctorSnils" Column="DoctorSnils" />
      <Map Name="EhrRus7pjsam6gjm" Column="EhrRus7pjsam6gjm" />
      <Map Name="EhrRus9a9g09e8kl" Column="EhrRus9a9g09e8kl" />
      <Map Name="Enp" Column="Enp" />
      <Map Name="EhrRus6kiqts8t99" Column="EhrRus6kiqts8t99" />
      <Map Name="EhrRusD4U765T5TH" Column="EhrRusD4U765T5TH" />
      <Map Name="SemdErrorCreating" Column="SemdErrorCreating" />
      <Map Name="LSName" Function="dbo.fn_RecipeLSName" />
      <Map Name="RequestCatalogId" Column="RequestCatalogId" />
      <Map Name="PatientRegionalId" Column="PatientRegionalId" />
      <Map Name="PharmacyTrn" Column="PharmacyTrn" />
      <Map Name="ReferenceNumber" Column="ReferenceNumber" />
      <Map Name="ReferenceDateBegin" Column="ReferenceDateBegin" />
      <Map Name="ReferenceDateEnd" Column="ReferenceDateEnd" />
      <Map Name="ProductOwner" Column="ProductOwner" />
    </Table>
    <Lexem>
      <Map Name="Doctor">
        <lx:QueryValue entity="APS.DLO_ACCESSED_POSTS" top="1" xmlns:lx="lexem">
          <condition>
            <lx:Criteria type="And">
              <lx:Criterion type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepInt index="5210004" />
                </lx:Path>
                <lx:Path OwnerQueryLevel="1">
                  <lx:StepInt index="5090003" />
                </lx:Path>
              </lx:Criterion>
              <lx:Criterion type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepInt index="5210003" />
                  <lx:StepInt index="30000003" />
                </lx:Path>
                <lx:Path OwnerQueryLevel="1">
                  <lx:StepInt index="5090045" />
                  <lx:StepInt index="30000003" />
                </lx:Path>
              </lx:Criterion>
              <lx:Criteria type="Or">
                <lx:Criterion type="=">
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepInt index="5210017" />
                  </lx:Path>
                  <lx:ConstOperand isNull="1" />
                </lx:Criterion>
                <lx:Criterion type="&gt;">
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepInt index="5210017" />
                  </lx:Path>
                  <lx:Path OwnerQueryLevel="1">
                    <lx:StepInt index="5090019" />
                  </lx:Path>
                </lx:Criterion>
              </lx:Criteria>
              <lx:Criteria type="Or">
                <lx:Criterion type="=">
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepInt index="5210012" />
                  </lx:Path>
                  <lx:ConstOperand isNull="1" />
                </lx:Criterion>
                <lx:Criterion type="&gt;">
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepInt index="5210012" />
                  </lx:Path>
                  <lx:Path OwnerQueryLevel="1">
                    <lx:StepInt index="5090019" />
                  </lx:Path>
                </lx:Criterion>
              </lx:Criteria>
              <lx:Criteria type="Or">
                <lx:Criterion type="=">
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepInt index="5210011" />
                  </lx:Path>
                  <lx:ConstOperand isNull="1" />
                </lx:Criterion>
                <lx:Criterion type="&lt;=">
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepInt index="5210011" />
                  </lx:Path>
                  <lx:Path OwnerQueryLevel="1">
                    <lx:StepInt index="5090019" />
                  </lx:Path>
                </lx:Criterion>
              </lx:Criteria>
            </lx:Criteria>
          </condition>
          <value>
            <lx:MathOperator sign="+">
              <lx:MathOperator sign="+">
                <lx:MathOperator sign="+">
                  <lx:MathOperator sign="+">
                    <lx:Path OwnerQueryLevel="0">
                      <lx:StepInt index="5210005" />
                    </lx:Path>
                    <lx:ConstOperand type="String"><![CDATA[ ]]></lx:ConstOperand>
                  </lx:MathOperator>
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepInt index="5210006" />
                  </lx:Path>
                </lx:MathOperator>
                <lx:ConstOperand type="String"><![CDATA[ ]]></lx:ConstOperand>
              </lx:MathOperator>
              <lx:IsNull>
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepInt index="5210007" />
                </lx:Path>
                <lx:ConstOperand type="String"><![CDATA[]]></lx:ConstOperand>
              </lx:IsNull>
            </lx:MathOperator>
          </value>
        </lx:QueryValue>
      </Map>
      <Map Name="DateOfChange">
        <lx:QueryValue entity="APS.RECIPE_STATUS_HISTORY" top="1" xmlns:lx="lexem">
          <condition>
            <lx:Criterion type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepInt index="5400002" />
                <lx:StepInt index="5090001" />
              </lx:Path>
              <lx:Path OwnerQueryLevel="1">
                <lx:StepInt index="5090001" />
              </lx:Path>
            </lx:Criterion>
          </condition>
          <orderBy>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepInt index="5400003" />
            </lx:Path>
            <desc>True</desc>
          </orderBy>
          <value>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepInt index="5400003" />
            </lx:Path>
          </value>
        </lx:QueryValue>
      </Map>
      <Map Name="TotalAmount">
        <lx:ChildCount xmlns:lx="lexem">
          <condition>
            <lx:Criterion type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepInt index="19380005" />
                <lx:StepInt index="5090001" />
              </lx:Path>
              <lx:Path OwnerQueryLevel="1">
                <lx:StepInt index="5090001" />
              </lx:Path>
            </lx:Criterion>
          </condition>
          <lx:Path OwnerQueryLevel="0">
            <lx:StepInt index="5090039" />
          </lx:Path>
          <lx:Sum>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepInt index="19380002" />
            </lx:Path>
          </lx:Sum>
        </lx:ChildCount>
      </Map>
      <Map Name="TotalSum">
        <lx:ChildCount xmlns:lx="lexem">
          <condition>
            <lx:Criterion type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepInt index="19380005" />
                <lx:StepInt index="5090001" />
              </lx:Path>
              <lx:Path OwnerQueryLevel="1">
                <lx:StepInt index="5090001" />
              </lx:Path>
            </lx:Criterion>
          </condition>
          <lx:Path OwnerQueryLevel="0">
            <lx:StepInt index="5090039" />
          </lx:Path>
          <lx:Sum>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepInt index="19380006" />
            </lx:Path>
          </lx:Sum>
        </lx:ChildCount>
      </Map>
      <Map Name="Street">
        <lx:QueryValue xmlns:lx="lexem" entity="APS.STREET" top="1">
          <condition>
            <lx:Criterion type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepInt index="5150003" />
              </lx:Path>
              <lx:Argument>
                <lx:ConstOperand type="Int32">0</lx:ConstOperand>
              </lx:Argument>
            </lx:Criterion>
          </condition>
          <value>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepInt index="5150001" />
            </lx:Path>
          </value>
        </lx:QueryValue>
      </Map>
      <Map Name="City">
        <lx:QueryValue xmlns:lx="lexem" entity="APS.CITY" top="1">
          <condition>
            <lx:Criterion type="IN">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepInt index="5130001" />
              </lx:Path>
              <lx:LexemList>
                <lx:QueryValue entity="APS.STREET" top="1">
                  <condition>
                    <lx:Criterion type="=">
                      <lx:Path OwnerQueryLevel="0">
                        <lx:StepInt index="5150003" />
                      </lx:Path>
                      <lx:Argument>
                        <lx:ConstOperand type="Int32">0</lx:ConstOperand>
                      </lx:Argument>
                    </lx:Criterion>
                  </condition>
                  <value>
                    <lx:Path OwnerQueryLevel="0">
                      <lx:StepInt index="5150007" />
                      <lx:StepInt index="5130001" />
                    </lx:Path>
                  </value>
                </lx:QueryValue>
                <lx:QueryValue entity="APS.DISTRICT" top="1">
                  <condition>
                    <lx:Criterion type="=">
                      <lx:Path OwnerQueryLevel="0">
                        <lx:StepInt index="5140003" />
                      </lx:Path>
                      <lx:Argument>
                        <lx:ConstOperand type="Int32">0</lx:ConstOperand>
                      </lx:Argument>
                    </lx:Criterion>
                  </condition>
                  <value>
                    <lx:Path OwnerQueryLevel="0">
                      <lx:StepInt index="5140005" />
                      <lx:StepInt index="5130001" />
                    </lx:Path>
                  </value>
                </lx:QueryValue>
                <lx:QueryValue entity="APS.CITY" top="1">
                  <condition>
                    <lx:Criterion type="=">
                      <lx:Path OwnerQueryLevel="0">
                        <lx:StepInt index="5130003" />
                      </lx:Path>
                      <lx:Argument>
                        <lx:ConstOperand type="Int32">0</lx:ConstOperand>
                      </lx:Argument>
                    </lx:Criterion>
                  </condition>
                  <value>
                    <lx:Path OwnerQueryLevel="0">
                      <lx:StepInt index="5130001" />
                    </lx:Path>
                  </value>
                </lx:QueryValue>
              </lx:LexemList>
            </lx:Criterion>
          </condition>
          <value>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepInt index="5130001" />
            </lx:Path>
          </value>
        </lx:QueryValue>
      </Map>
      <Map Name="District">
        <lx:QueryValue xmlns:lx="lexem" entity="APS.DISTRICT" top="1">
          <condition>
            <lx:Criterion type="IN">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepInt index="5100001" />
              </lx:Path>
              <lx:LexemList>
                <lx:QueryValue entity="APS.STREET" top="1">
                  <condition>
                    <lx:Criterion type="=">
                      <lx:Path OwnerQueryLevel="0">
                        <lx:StepInt index="5150003" />
                      </lx:Path>
                      <lx:Argument>
                        <lx:ConstOperand type="Int32">0</lx:ConstOperand>
                      </lx:Argument>
                    </lx:Criterion>
                  </condition>
                  <value>
                    <lx:Path OwnerQueryLevel="0">
                      <lx:StepInt index="5150008" />
                      <lx:StepInt index="5100001" />
                    </lx:Path>
                  </value>
                </lx:QueryValue>
                <lx:QueryValue entity="APS.DISTRICT" top="1">
                  <condition>
                    <lx:Criterion type="=">
                      <lx:Path OwnerQueryLevel="0">
                        <lx:StepInt index="5140003" />
                      </lx:Path>
                      <lx:Argument>
                        <lx:ConstOperand type="Int32">0</lx:ConstOperand>
                      </lx:Argument>
                    </lx:Criterion>
                  </condition>
                  <value>
                    <lx:Path OwnerQueryLevel="0">
                      <lx:StepInt index="5100001" />
                    </lx:Path>
                  </value>
                </lx:QueryValue>
              </lx:LexemList>
            </lx:Criterion>
          </condition>
          <value>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepInt index="5100001" />
            </lx:Path>
          </value>
        </lx:QueryValue>
      </Map>
      <Map Name="EmdrMessage">
        <lx:QueryValue entity="APS.EMDR_MESSAGE" top="1" offset="0" xmlns:lx="lexem">
          <condition>
            <lx:Criterion type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="Recipe" />
              </lx:Path>
              <lx:Path OwnerQueryLevel="1">
                <lx:StepString name="RecipeID" />
              </lx:Path>
            </lx:Criterion>
          </condition>
          <orderBy>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="PostingDate" />
            </lx:Path>
            <desc>False</desc>
          </orderBy>
          <value>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="EmdrMessageId" />
            </lx:Path>
          </value>
        </lx:QueryValue>
      </Map>
      <Map Name="SellingPharmacy">
        <lx:QueryValue entity="APS.RECIPE_ELEMENTS" top="1" offset="0" xmlns:lx="lexem">
          <condition>
            <lx:Criterion type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="Recipe" />
                <lx:StepString name="RecipeID" />
              </lx:Path>
              <lx:Path OwnerQueryLevel="1">
                <lx:StepString name="RecipeID" />
              </lx:Path>
            </lx:Criterion>
          </condition>
          <value>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="Remains" />
              <lx:StepString name="Storage" />
              <lx:StepString name="IssuePlace" />
              <lx:StepAs as="APS.PHARMACY_ISSUE_PLACE" />
              <lx:StepString name="Pharmacy" />
              <lx:StepString name="Code" />
            </lx:Path>
          </value>
        </lx:QueryValue>
      </Map>
      <Map Name="TotalSellingSum">
        <lx:ChildCount xmlns:lx="lexem">
          <condition>
            <lx:Criterion type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="Recipe" />
                <lx:StepString name="RecipeID" />
              </lx:Path>
              <lx:Path OwnerQueryLevel="1">
                <lx:StepString name="RecipeID" />
              </lx:Path>
            </lx:Criterion>
          </condition>
          <lx:Path OwnerQueryLevel="0">
            <lx:StepString name="RecipeElementss" />
          </lx:Path>
          <lx:Sum>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="SellingSum" />
            </lx:Path>
          </lx:Sum>
        </lx:ChildCount>
      </Map>
    </Lexem>
  </DbMapping>
</Entity>