<?xml version="1.0" encoding="utf-8"?>
<Entity 
Schema="AKUZ" 
Name="MEDICAL_EPISODE" 
Description="Медицинсий эпизод" 
PrimaryKey="MedicalEpisodeID">
  <Fields>
    <Attribute Name="MedicalEpisodeID" Type="guid" Description="Идентификатор" />
    <Attribute Name="TNMS" Type="string" Description="Онкологический диагноз" />
    <Parent Name="RecordType" Type="VCLib.ENTITIES" Description="Тип записи" Save="0" />
    <Attribute Name="SetDTClinicalDiagnosis" Type="datetime" Description="Дата и время установки клинического диагноза" />
    <Parent Name="OutcomeRecord" Type="AKUZ.OUTCOME_OF_INSPECTION" Description="Исход случая обращения" />
    <Parent Name="AmbulanceEvent" Type="AKUZ.AMBULANCE_EVENT" Description="Амбулаторный случай обращения" />
    <Parent Name="PaymentType" Type="VCLib.ENUMS" Description="Вид оплаты" EnumType="PaymentType" />
    <Child Name="DivisionSignificantEventss" Type="AKUZ.DIVISION_SIGNIFICANT_EVENTS" Description="Значимые события в отделении" ChildAttribute="MedicalEpisode" />
    <Child Name="NurseMedicalExaminations" Type="AKUZ.NURSE_MEDICAL_EXAMINATION" Description="Осмотр медицинской сестрой" ChildAttribute="MedicalEpisode" />
    <Attribute Name="Mkb" Type="string" Description="Код МКБ" Required="1" />
    <Attribute Name="Diagnosis" Type="string" Description="Расшифровка диагноза" CharacterMaximumLength="4096" Required="1" />
    <Attribute Name="Descr" Type="string" Description="Дополнительное описание диагноза" />
    <Child Name="AssociatedAndComplicationDiseases" Type="AKUZ.ASSOCIATED_AND_COMPLICATION_DISEASE" Description="Сопутствующие диагнозы и осложнения в случаe обращения" ChildAttribute="MedicalEpisode" />
    <Child Name="PostTreats" Type="AKUZ.POST_TREAT" Description="Лечащий врач" ChildAttribute="MedicalEpisode" />
    <Parent Name="Post" Type="AKUZ.POST" Description="Должность" />
  </Fields>
  <DbMapping>
    <Table name="T_MEDICAL_EPISODE">
      <Map Name="MedicalEpisodeID" Column="MedicalEpisodeID" />
      <Map Name="TNMS" Column="TNMS" />
      <Map Name="RecordType" Column="type_" IsStored="0" />
      <Map Name="SetDTClinicalDiagnosis" Column="SetDTClinicalDiagnosis" />
      <Map Name="OutcomeRecord" Column="OutcomeRecord" />
      <Map Name="AmbulanceEvent" Column="AmbulanceEvent" />
      <Map Name="PaymentType" Column="PaymentType" />
      <Map Name="Mkb" Column="Mkb" />
      <Map Name="Diagnosis" Column="Diagnosis" />
      <Map Name="Descr" Column="Descr" />
    </Table>
    <Lexem>
      <Map Name="Post" PathAttributes="{PostTreats/Post}">
        <lx:ChildCount xmlns:lx="lexem">
          <condition>
            <lx:Criterion type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="EndCareDate" />
              </lx:Path>
              <lx:ConstOperand isNull="1" />
            </lx:Criterion>
          </condition>
          <lx:Path OwnerQueryLevel="0">
            <lx:StepString name="PostTreats" />
          </lx:Path>
          <lx:First>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="Post" />
            </lx:Path>
          </lx:First>
        </lx:ChildCount>
      </Map>
    </Lexem>
  </DbMapping>
</Entity>