<?xml version="1.0" encoding="utf-8"?>
<Entity 
Schema="PHARM" 
Name="BILL_OF_GOODS" 
Description="Номенклатура товаров" 
PrimaryKey="BillOfGoodsID" 
DNAttributes="{CDisplayName}" 
DisplayName="{0}">
  <Customs>
    <Custom Name="FilterUICondition"><![CDATA[<lx:Criterion type="=" xmlns:lx="lexem">
	<lx:Path OwnerQueryLevel="0">
		<lx:StepInt index="19160009" />
	</lx:Path>
	<lx:ConstOperand type="Boolean">True</lx:ConstOperand>
</lx:Criterion>]]></Custom>
  </Customs>
  <Fields>
    <Attribute Name="BillOfGoodsID" Index="19160001" Type="guid" Description="Идентификатор" />
    <Attribute Name="DoseView" Index="19160002" Type="string" Description="Концентрация активного вещества" />
    <Attribute Name="OtherID" Index="19160004" Type="int" Description="Идентификатор в других программах" />
    <Attribute Name="IsVital" Index="19160007" Type="bool" Description="Жизненно необходимое" Required="1" />
    <Attribute Name="Active" Index="19160009" Type="bool" Description="Активно" Required="1" />
    <Attribute Name="Rate" Index="19160013" Type="int" Description="Кратность" Required="1" />
    <Attribute Name="ExportCode" Index="19160014" Type="int" Description="Код экспорта" />
    <Attribute Name="PackQuantity" Index="19160018" Type="int" Description="Количество в упаковке(№)" Required="1" />
    <Attribute Name="FederalID" Index="19160028" Type="int" Description="Идентификатор в федеральном справочнике" />
    <Attribute Name="EAN" Index="19160029" Type="string" Description="Штрих код" CharacterMaximumLength="255" />
    <Attribute Name="ProductInfo" Index="19160030" Type="string" Description="Описание товара" CharacterMaximumLength="1000" />
    <Parent Name="MedicamentProducer" Index="19160010" Type="PHARM.MEDICAMENT_PRODUCER" Description="Производитель торгового наименования" Required="1" />
    <Parent Name="CTrn" Index="19160011" Type="PHARM.C_TRN" Description="Торговое наименование препарата" Required="1" />
    <Parent Name="MedicationForms" Index="19160012" Type="PHARM.MEDICATION_FORMS" Description="Лекарственные формы" />
    <Child Name="ProductForms" Index="19160005" Type="PHARM.PRODUCT_FORM" Description="Форма выпуска" ChildAttribute="BillOfGoods" Required="1" />
    <Child Name="Seriess" Index="19160006" Type="PHARM.SERIES" Description="Серия" ChildAttribute="BillOfGoods" />
    <Attribute Name="CDisplayName" Index="19160031" Type="string" Description="Отображаемое имя" CharacterMaximumLength="1000" />
    <Attribute Name="Dlo" Index="19160032" Type="bool" Description="Используется в ДЛО" Required="1" />
    <Child Name="BillOfGoodsLinkDoseViews" Type="PHARM.BILL_OF_GOODS_LINK_DOSE_VIEW" Description="Связь препарата с дозировками" ChildAttribute="BillOfGoods" />
    <Attribute Name="FedCode" Type="string" Description="Федеральный код" CharacterMaximumLength="50" />
    <Attribute Name="RegCode" Type="string" Description="Региональный код" CharacterMaximumLength="50" />
    <Attribute Name="Gtin" Type="string" Description="Gtin" CharacterMaximumLength="14" />
    <Parent Name="MedicamentsOfRoszdravnadzor" Type="PHARM.MEDICAMENTS_OF_ROSZDRAVNADZOR" Description="Медикаменты Росздравнадзора" />
    <Attribute Name="PackageComposition" Type="string" Description="Состав упаковки" />
    <Child Name="BillOfGoodsLinkPaymentTypes" Type="PHARM.BILL_OF_GOODS_LINK_PAYMENT_TYPE" Description="Связь препарата с источником финансирования" ChildAttribute="BillOfGoods" />
    <Parent Name="EhrRus2m69i03gtd" Type="EHR.EHR_RUS_2M69I03GTD" Description="Лекарственные препараты. Товарные позиции. ЕСКЛП с кодами КТРУ" />
    <Parent Name="EhrRus9a9g09e8kl" Type="EHR.EHR_RUS_9A9G09E8KL" Description="Узлы СМНН. ЕСКЛП" />
    <Parent Name="EhrRusClp14fvirj" Type="EHR.EHR_RUS_CLP14FVIRJ" Description="ФР14Н. Справочник торговых наименований" />
    <Parent Name="EhrRusH17F8UTS3N" Type="EHR.EHR_RUS_H17F8UTS3N" Description="ФР 14Н. Справочник дозировок лекарственного средства в лекарственном препарате" />
    <Parent Name="EhrRusDsg207" Type="EHR.EHR_RUS_DSG207" Description="ФР14Н. Справочник количества доз в упаковке лекарственных препаратов" />
    <Attribute Name="SellingName" Type="string" Description="Название товара в кассовом чеке" />
    <Attribute Name="RoundToWriteOff" Type="bool" Description="Округление до единиц списания" Required="1" />
  </Fields>
  <DbMapping>
    <Table name="T_BILL_OF_GOODS">
      <Map Name="BillOfGoodsID" Column="BillOfGoodsID" />
      <Map Name="DoseView" Column="DoseView" RefTable="S_DLO_DoseView" />
      <Map Name="OtherID" Column="OtherID" />
      <Map Name="IsVital" Column="IsVital" />
      <Map Name="Active" Column="Active" />
      <Map Name="Rate" Column="Rate" />
      <Map Name="ExportCode" Column="ExportCode" />
      <Map Name="PackQuantity" Column="PackQuantity" />
      <Map Name="FederalID" Column="FederalID" />
      <Map Name="EAN" Column="EAN" />
      <Map Name="ProductInfo" Column="ProductInfo" />
      <Map Name="MedicamentProducer" Column="MedicamentProducer" />
      <Map Name="CTrn" Column="CTrn" />
      <Map Name="MedicationForms" Column="MedicationForms" />
      <Map Name="Dlo" Column="Dlo" />
      <Map Name="FedCode" Column="FedCode" />
      <Map Name="RegCode" Column="RegCode" />
      <Map Name="Gtin" Column="Gtin" />
      <Map Name="MedicamentsOfRoszdravnadzor" Column="MedicamentsOfRoszdravnadzor" />
      <Map Name="EhrRus2m69i03gtd" Column="EhrRus2m69i03gtd" />
      <Map Name="EhrRus9a9g09e8kl" Column="EhrRus9a9g09e8kl" />
      <Map Name="EhrRusClp14fvirj" Column="EhrRusClp14fvirj" />
      <Map Name="EhrRusH17F8UTS3N" Column="EhrRusH17F8UTS3N" />
      <Map Name="EhrRusDsg207" Column="EhrRusDsg207" />
      <Map Name="RoundToWriteOff" Column="RoundToWriteOff" />
    </Table>
    <Lexem>
      <Map Name="CDisplayName">
        <lx:Case xmlns:lx="lexem">
          <When>
            <lx:Criterion type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="CTrn" />
              </lx:Path>
              <lx:BaseObjectOperand Entity="PHARM.C_TRN" isNull="1" />
            </lx:Criterion>
          </When>
          <Then>
            <lx:ConstOperand type="String"><![CDATA[]]></lx:ConstOperand>
          </Then>
          <When>
            <lx:Criterion type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="CTrn" />
                <lx:StepString name="ProductType" />
              </lx:Path>
              <lx:ChoiceOperand Entity="PHARM.C_TRN" AttributeName="ProductType" type="Int32" PrimaryKey="0" />
            </lx:Criterion>
          </When>
          <Then>
            <lx:MathOperator sign="+">
              <lx:MathOperator sign="+">
                <lx:MathOperator sign="+">
                  <lx:MathOperator sign="+">
                    <lx:MathOperator sign="+">
                      <lx:MathOperator sign="+">
                        <lx:IsNull>
                          <lx:Path OwnerQueryLevel="0">
                            <lx:StepString name="CTrn" />
                            <lx:StepString name="NameRus" />
                          </lx:Path>
                          <lx:ConstOperand type="String"><![CDATA[]]></lx:ConstOperand>
                        </lx:IsNull>
                        <lx:ConstOperand type="String"><![CDATA[ ]]></lx:ConstOperand>
                      </lx:MathOperator>
                      <lx:IsNull>
                        <lx:Path OwnerQueryLevel="0">
                          <lx:StepString name="MedicationForms" />
                          <lx:StepString name="Name" />
                        </lx:Path>
                        <lx:ConstOperand type="String"><![CDATA[]]></lx:ConstOperand>
                      </lx:IsNull>
                    </lx:MathOperator>
                    <lx:ConstOperand type="String"><![CDATA[ ]]></lx:ConstOperand>
                  </lx:MathOperator>
                  <lx:IsNull>
                    <lx:Path OwnerQueryLevel="0">
                      <lx:StepString name="DoseView" />
                    </lx:Path>
                    <lx:ConstOperand type="String"><![CDATA[]]></lx:ConstOperand>
                  </lx:IsNull>
                </lx:MathOperator>
                <lx:ConstOperand type="String"><![CDATA[, ]]></lx:ConstOperand>
              </lx:MathOperator>
              <lx:IsNull>
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="MedicamentProducer" />
                  <lx:StepString name="Name" />
                </lx:Path>
                <lx:ConstOperand type="String"><![CDATA[]]></lx:ConstOperand>
              </lx:IsNull>
            </lx:MathOperator>
          </Then>
          <Else>
            <lx:MathOperator sign="+">
              <lx:MathOperator sign="+">
                <lx:MathOperator sign="+">
                  <lx:MathOperator sign="+">
                    <lx:IsNull>
                      <lx:Path OwnerQueryLevel="0">
                        <lx:StepString name="CTrn" />
                        <lx:StepString name="NameRus" />
                      </lx:Path>
                      <lx:ConstOperand type="String"><![CDATA[]]></lx:ConstOperand>
                    </lx:IsNull>
                    <lx:ConstOperand type="String"><![CDATA[ ]]></lx:ConstOperand>
                  </lx:MathOperator>
                  <lx:IsNull>
                    <lx:Path OwnerQueryLevel="0">
                      <lx:StepString name="DoseView" />
                    </lx:Path>
                    <lx:ConstOperand type="String"><![CDATA[]]></lx:ConstOperand>
                  </lx:IsNull>
                </lx:MathOperator>
                <lx:ConstOperand type="String"><![CDATA[, ]]></lx:ConstOperand>
              </lx:MathOperator>
              <lx:IsNull>
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="MedicamentProducer" />
                  <lx:StepString name="Name" />
                </lx:Path>
                <lx:ConstOperand type="String"><![CDATA[]]></lx:ConstOperand>
              </lx:IsNull>
            </lx:MathOperator>
          </Else>
        </lx:Case>
      </Map>
      <Map Name="PackageComposition">
        <lx:ChildCount xmlns:lx="lexem">
          <condition />
          <lx:Path OwnerQueryLevel="0">
            <lx:StepString name="ProductForms" />
          </lx:Path>
          <lx:Joint>
            <lx:MathOperator sign="+">
              <lx:MathOperator sign="+">
                <lx:MathOperator sign="+">
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepString name="PackageType" />
                    <lx:StepString name="Name" />
                  </lx:Path>
                  <lx:ConstOperand type="String"><![CDATA[(]]></lx:ConstOperand>
                </lx:MathOperator>
                <lx:Cast type="String">
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepString name="Amount" />
                  </lx:Path>
                </lx:Cast>
              </lx:MathOperator>
              <lx:ConstOperand type="String"><![CDATA[)]]></lx:ConstOperand>
            </lx:MathOperator>
            <lx:ConstOperand type="String"><![CDATA[, ]]></lx:ConstOperand>
          </lx:Joint>
          <lx:Path OwnerQueryLevel="0">
            <lx:StepString name="OrdinalNumber" />
          </lx:Path>
          <lx:ConstOperand type="String"><![CDATA[asc]]></lx:ConstOperand>
        </lx:ChildCount>
      </Map>
      <Map Name="SellingName">
        <lx:MathOperator sign="+" xmlns:lx="lexem">
          <lx:MathOperator sign="+">
            <lx:MathOperator sign="+">
              <lx:MathOperator sign="+">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="CTrn" />
                  <lx:StepString name="NameRus" />
                </lx:Path>
                <lx:ConstOperand type="String"><![CDATA[ ]]></lx:ConstOperand>
              </lx:MathOperator>
              <lx:IsNull>
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="MedicationForms" />
                  <lx:StepString name="Name" />
                </lx:Path>
                <lx:ConstOperand type="String"><![CDATA[]]></lx:ConstOperand>
              </lx:IsNull>
            </lx:MathOperator>
            <lx:ConstOperand type="String"><![CDATA[ ]]></lx:ConstOperand>
          </lx:MathOperator>
          <lx:IsNull>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="DoseView" />
            </lx:Path>
            <lx:ConstOperand type="String"><![CDATA[]]></lx:ConstOperand>
          </lx:IsNull>
        </lx:MathOperator>
      </Map>
    </Lexem>
  </DbMapping>
  <CalculatingAttributes>
    <Attribute Name="PackageCoefficient" Index="19160015" Type="float" DefaultFormat="{0:0.#####}" Description="Коэффициент вида упаковки" RequiredAttributes="{ProductForms / OrdinalNumber}; {ProductForms / Amount}; {ProductForms /WriteOff}">
      <Parameter Name="Start" Description="Начальное значение" Type="guid" />
      <Parameter Name="End" Description="Конечное значение" Type="guid" />
      <Parameter Name="EhrRusMdr308" Description="Индентификатор МО(НСИ)" Type="int" />
    </Attribute>
    <Parent Name="cWriteOff" Index="19160003" Type="PHARM.PRODUCT_FORM" Description="Форма выпуска списание" RequiredAttributes="{ProductForms / WriteOff};{ProductForms / EhrRusMdr308}" PathAttributes="{ProductForms}">
      <Parameter Name="EhrRusMdr308" Description="Индентификатор МО(НСИ)" Type="int" />
    </Parent>
    <Parent Name="cUnitPrice" Index="19160008" Type="PHARM.PRODUCT_FORM" Description="Единица покупки" RequiredAttributes="{ProductForms / UnitPrice};{ProductForms / EhrRusMdr308}" PathAttributes="{ProductForms}">
      <Parameter Name="EhrRusMdr308" Description="Индентификатор МО(НСИ)" Type="int" />
    </Parent>
  </CalculatingAttributes>
</Entity>