<?xml version="1.0" encoding="utf-8"?>
<Entity 
Schema="AKUZ" 
Name="BASE_DRUG_REQUEST_ITEM" 
Description="Базовый элемент заявочного списка" 
PrimaryKey="BaseDrugRequestItemID" 
DNAttributes="{Preparation};{MedicationForms/Name};{BaseDoseView}" 
DisplayName="{0}-{1}, {2}">
  <Fields>
    <Attribute Name="BeginDate" Index="14010002" Type="datetime" DefaultFormat="{0:dd.MM.yyyy}" Description="Дата ввода" Required="1" />
    <Attribute Name="Price" Index="14010004" Type="float" Description="Цена" Required="1" />
    <Attribute Name="RequestCode" Index="14010016" Type="int" Description="Код в заявочном списке" Required="1" />
    <Attribute Name="AppListBeginDate" Index="14010017" Type="date" Description="Дата начала действия заявочного списка" Required="1" />
    <Attribute Name="AppListEndDate" Index="14010018" Type="date" Description="Дата окончания действия заявочного списка" Required="1" />
    <Attribute Name="Preparation" Index="14010019" Type="string" Description="Препарат" CharacterMaximumLength="1024" />
    <Attribute Name="BaseDrugRequestItemID" Index="14010020" Type="guid" Description="Идентификатор" />
    <Attribute Name="BaseDoseView" Index="14010021" Type="string" Description="ед.изм" CharacterMaximumLength="1024" />
    <Parent Name="MedicationForms" Index="14010014" Type="PHARM.MEDICATION_FORMS" Description="Лекарственные формы" Required="1" />
    <Attribute Name="PersRequest" Type="bool" Description="Персонифицированная заявка" Required="1" />
  </Fields>
  <DbMapping>
    <Table name="T_BASE_DRUG_REQUEST_ITEM">
      <Map Name="BeginDate" Column="BeginDate" />
      <Map Name="Price" Column="Price" />
      <Map Name="RequestCode" Column="RequestCode" />
      <Map Name="AppListBeginDate" Column="AppListBeginDate" />
      <Map Name="AppListEndDate" Column="AppListEndDate" />
      <Map Name="BaseDrugRequestItemID" Column="BaseDrugRequestItemID" />
      <Map Name="MedicationForms" Column="MedicationForms" />
      <Map Name="PersRequest" Column="PersRequest" />
    </Table>
    <Lexem>
      <Map Name="Preparation">
        <lx:Case xmlns:lx="lexem">
          <When>
            <lx:Criterion type="IS">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="ObjectProperties" />
                <lx:StepString name="ObjectTypeID" />
              </lx:Path>
              <lx:ConstOperand type="String"><![CDATA[AKUZ.DRUG_REQUEST_LIST]]></lx:ConstOperand>
            </lx:Criterion>
          </When>
          <Then>
            <lx:Format>
              <lx:ConstOperand type="String"><![CDATA[{0} {1}, {2} {3} №{4}]]></lx:ConstOperand>
              <lx:Case>
                <When>
                  <lx:Criteria type="And">
                    <lx:Criterion type="IS">
                      <lx:Path OwnerQueryLevel="0">
                        <lx:StepString name="ObjectProperties" />
                        <lx:StepString name="ObjectTypeID" />
                      </lx:Path>
                      <lx:ConstOperand type="String"><![CDATA[AKUZ.DRUG_REQUEST_LIST]]></lx:ConstOperand>
                    </lx:Criterion>
                    <lx:Criterion type="=">
                      <lx:Path OwnerQueryLevel="0">
                        <lx:StepAs as="AKUZ.DRUG_REQUEST_LIST" />
                        <lx:StepString name="Mnn" />
                        <lx:StepString name="Code" />
                      </lx:Path>
                      <lx:ConstOperand type="Int32">1</lx:ConstOperand>
                    </lx:Criterion>
                  </lx:Criteria>
                </When>
                <Then>
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepAs as="AKUZ.DRUG_REQUEST_LIST" />
                    <lx:StepString name="Trn" />
                    <lx:StepString name="Name" />
                  </lx:Path>
                </Then>
                <Else>
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepAs as="AKUZ.DRUG_REQUEST_LIST" />
                    <lx:StepString name="Mnn" />
                    <lx:StepString name="Name" />
                  </lx:Path>
                </Else>
              </lx:Case>
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="MedicationForms" />
                <lx:StepString name="Name" />
              </lx:Path>
              <lx:Path OwnerQueryLevel="0">
                <lx:StepAs as="AKUZ.DRUG_REQUEST_LIST" />
                <lx:StepInt index="7090008" />
              </lx:Path>
              <lx:Path OwnerQueryLevel="0">
                <lx:StepAs as="AKUZ.DRUG_REQUEST_LIST" />
                <lx:StepInt index="7090023" />
                <lx:StepInt index="6290002" />
              </lx:Path>
              <lx:Path OwnerQueryLevel="0">
                <lx:StepAs as="AKUZ.DRUG_REQUEST_LIST" />
                <lx:StepInt index="7090024" />
              </lx:Path>
            </lx:Format>
          </Then>
          <Else>
            <lx:Format>
              <lx:ConstOperand type="String"><![CDATA[{0} {1} {2}]]></lx:ConstOperand>
              <lx:Case>
                <When>
                  <lx:Criterion type="&lt;&gt;">
                    <lx:Path OwnerQueryLevel="0">
                      <lx:StepAs as="AKUZ.REQUEST_CATALOG" />
                      <lx:StepString name="CTrn" />
                    </lx:Path>
                    <lx:Null />
                  </lx:Criterion>
                </When>
                <Then>
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepAs as="AKUZ.REQUEST_CATALOG" />
                    <lx:StepString name="CTrn" />
                    <lx:StepString name="NameRus" />
                  </lx:Path>
                </Then>
                <Else>
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepAs as="AKUZ.REQUEST_CATALOG" />
                    <lx:StepString name="CMnn" />
                    <lx:StepString name="NameRus" />
                  </lx:Path>
                </Else>
              </lx:Case>
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="MedicationForms" />
                <lx:StepString name="Name" />
              </lx:Path>
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="BaseDoseView" />
              </lx:Path>
            </lx:Format>
          </Else>
        </lx:Case>
      </Map>
      <Map Name="BaseDoseView">
        <lx:Case xmlns:lx="lexem">
          <When>
            <lx:Criterion type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="ObjectProperties" />
                <lx:StepString name="ObjectTypeID" />
              </lx:Path>
              <lx:ConstOperand type="Int32">1233</lx:ConstOperand>
            </lx:Criterion>
          </When>
          <Then>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepAs as="AKUZ.REQUEST_CATALOG" />
              <lx:StepString name="DoseView" />
            </lx:Path>
          </Then>
          <When>
            <lx:Criterion type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="ObjectProperties" />
                <lx:StepString name="ObjectTypeID" />
              </lx:Path>
              <lx:ConstOperand type="Int32">709</lx:ConstOperand>
            </lx:Criterion>
          </When>
          <Then>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepAs as="AKUZ.DRUG_REQUEST_LIST" />
              <lx:StepString name="DoseView" />
              <lx:StepString name="Name" />
            </lx:Path>
          </Then>
          <Else>
            <lx:ConstOperand isNull="1" />
          </Else>
        </lx:Case>
      </Map>
      <Map Name="TRN">
        <lx:Case xmlns:lx="lexem">
          <When>
            <lx:Criteria type="And">
              <lx:Criterion type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="ObjectProperties" />
                  <lx:StepString name="ObjectTypeID" />
                </lx:Path>
                <lx:ConstOperand type="Int32">1233</lx:ConstOperand>
              </lx:Criterion>
            </lx:Criteria>
          </When>
          <Then>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepAs as="AKUZ.REQUEST_CATALOG" />
              <lx:StepString name="CTrn" />
              <lx:StepString name="NameRus" />
            </lx:Path>
          </Then>
          <Else>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepAs as="AKUZ.DRUG_REQUEST_LIST" />
              <lx:StepString name="Trn" />
              <lx:StepString name="Name" />
            </lx:Path>
          </Else>
        </lx:Case>
      </Map>
    </Lexem>
  </DbMapping>
  <CalculatingAttributes>
    <Attribute Name="TRN" Index="14010022" Type="string" Description="ТРН" CharacterMaximumLength="1024" />
  </CalculatingAttributes>
</Entity>