<?xml version="1.0" encoding="utf-8"?>
<Entity 
Schema="AKUZ" 
Name="TREATMENT_TEMPLATE_LINK_MEDICAMENT" 
Description="Связь шаблона лечения с препаратами" 
PrimaryKey="TreatmentTemplateLinkMedicamentID" 
DNAttributes="{DispName}" 
DisplayName="{0}">
  <Fields>
    <Attribute Name="TreatmentTemplateLinkMedicamentID" Type="guid" Description="Идентификатор" />
    <Parent Name="TreatmentDiseaseTemplate" Type="AKUZ.TREATMENT_DISEASE_TEMPLATE" Description="Шаблон лечения заболевания" Required="1" />
    <Parent Name="Atc" Type="EHR.EHR_RUS_M00002" Description="Анатомо-терапевтическо-химическая классификация" />
    <Parent Name="CMnn" Type="PHARM.C_MNN" Description="Международное непатентованное наименование (МНН)" />
    <Parent Name="CTrn" Type="PHARM.C_TRN" Description="Торговое наименование препарата" />
    <Attribute Name="DispName" Type="string" Description="Наименование" />
    <Child Name="ObjectLinkMedicalFactorss" Type="AKUZ.OBJECT_LINK_MEDICAL_FACTORS" Description="Связь объекта с медицинскими факторами" ChildAttribute="TreatmentTemplateLinkMedicament" />
    <Child Name="RestrictionsOfMedicationsForms" Type="AKUZ.RESTRICTIONS_OF_MEDICATIONS_FORM" Description="Ограничение по формам выпуска" ChildAttribute="TreatmentTemplateLinkMedicament" />
    <Child Name="RestrictionsOfReceptionMetods" Type="AKUZ.RESTRICTIONS_OF_RECEPTION_METOD" Description="Ограничения по методу приема" ChildAttribute="TreatmentTemplateLinkMedicament" />
    <Attribute Name="Comment" Type="string" Description="Комментарий" CharacterMaximumLength="4000" />
    <Child Name="TreatmentTemplateMedicamentLinkGroups" Type="AKUZ.TREATMENT_TEMPLATE_MEDICAMENT_LINK_GROUP" Description="Связь медикаментов и групп" />
    <Child Name="RestrictionsOfDosess" Type="AKUZ.RESTRICTIONS_OF_DOSES" Description="Ограничение по дозам" ChildAttribute="TreatmentTemplateLinkMedicament" />
  </Fields>
  <DbMapping>
    <Table name="T_TREATMENT_TEMPLATE_LINK_MEDICAMENT">
      <Map Name="TreatmentTemplateLinkMedicamentID" Column="TreatmentTemplateLinkMedicamentID" />
      <Map Name="TreatmentDiseaseTemplate" Column="TreatmentDiseaseTemplate" />
      <Map Name="Atc" Column="Atc" />
      <Map Name="CMnn" Column="CMnn" />
      <Map Name="CTrn" Column="CTrn" />
      <Map Name="Comment" Column="Comment" />
    </Table>
    <Lexem>
      <Map Name="DispName">
        <lx:Case xmlns:lx="lexem">
          <When>
            <lx:Criterion not="1" type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="CTrn" />
              </lx:Path>
              <lx:BaseObjectOperand Entity="PHARM.C_TRN" isNull="1" />
            </lx:Criterion>
          </When>
          <Then>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="CTrn" />
              <lx:StepString name="NameRus" />
            </lx:Path>
          </Then>
          <When>
            <lx:Criterion not="1" type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="CMnn" />
              </lx:Path>
              <lx:BaseObjectOperand Entity="PHARM.C_MNN" isNull="1" />
            </lx:Criterion>
          </When>
          <Then>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="CMnn" />
              <lx:StepString name="NameRus" />
            </lx:Path>
          </Then>
          <When>
            <lx:Criterion not="1" type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="Atc" />
              </lx:Path>
              <lx:BaseObjectOperand Entity="EHR.EHR_RUS_M00002" isNull="1" />
            </lx:Criterion>
          </When>
          <Then>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="Atc" />
              <lx:StepString name="NameEHR" />
            </lx:Path>
          </Then>
          <Else>
            <lx:ConstOperand isNull="1" />
          </Else>
        </lx:Case>
      </Map>
    </Lexem>
  </DbMapping>
</Entity>