<?xml version="1.0" encoding="utf-8"?>
<Entity 
Schema="AKUZ" 
Name="MOVEMENT" 
Description="Движение" 
PrimaryKey="MovementID" 
DNAttributes="{MedCardNumber}" 
DisplayName="{0}">
  <Customs>
    <Custom Name="NotDisplayedInFilter" Value="MovementTimeDate" />
    <Custom Name="NotDisplayedColumns" Value="MovementTimeDate" />
    <Custom Name="NotTrackedAttributes" Value="MovementTimeDate" />
    <Custom Name="FilterUICondition"><![CDATA[<lx:Criterion type="=" xmlns:lx="lexem">
    <lx:Path OwnerQueryLevel="0">
        <lx:StepString name="Division" />
        <lx:StepString name="Branch" />
        <lx:StepString name="LpuMain" />
    </lx:Path>
    <lx:ParamHolder>
        <lx:StepString name="CURRENT_LPU_MAIN" />
    </lx:ParamHolder>
</lx:Criterion>]]></Custom>
  </Customs>
  <Fields>
    <Attribute Name="MedCardNumber" Index="10190005" Type="int" Description="Номер стат карты" CharacterMaximumLength="50" />
    <Attribute Name="Chamber" Index="10290008" Type="string" Description="Палата" CharacterMaximumLength="10" />
    <Attribute Name="PaymentDescription" Index="10290044" Type="string" Description="Особенности оплаты" />
    <Attribute Name="MovementID" Index="10610001" Type="guid" Description="Идентификатор" />
    <Attribute Name="MovementTime" Index="10610003" Type="datetime" DefaultFormat="{0:dd.MM.yyyy HH:mm}" Description="Дата фактического поступления в отделение" Required="1" />
    <Attribute Name="CreationDateTime" Index="10610006" Type="datetime" DefaultFormat="{0:dd.MM.yyyy HH:mm}" Description="Дата и время создания" />
    <Attribute Name="LastModifyDateTime" Index="10610007" Type="datetime" DefaultFormat="{0:dd.MM.yyyy HH:mm}" Description="Дата последней модификации" />
    <Attribute Name="MovementDate" Index="10610008" Type="date" DefaultFormat="{0:dd.MM.yyyy}" Description="Дата поступления" Required="1" />
    <Attribute Name="InteriorEatTable" Index="10610012" Type="string" Description="Актуальный стол питания" CharacterMaximumLength="5" />
    <Attribute Name="Diagnosis" Index="10610013" Type="string" Description="Диагноз" CharacterMaximumLength="4096" />
    <Attribute Name="Mkb" Index="10610014" Type="string" Description="Код МКБ" CharacterMaximumLength="8" />
    <Attribute Name="InteriorChamber" Index="10610048" Type="string" Description="Актуальная палата" CharacterMaximumLength="10" />
    <Attribute Name="ExpectedDateOfDischarge" Index="10610056" Type="date" Description="Предполагаемая дата выписки" />
    <Attribute Name="Bed" Index="10610057" Type="string" Description="Кровать" />
    <Attribute Name="MovementTimeDate" Index="10610060" Type="datetime" DefaultFormat="{0:dd.MM.yyyy}" Description="Дата фактического поступления в отделение" Required="1" />
    <Parent Name="EmergencyEvent" Index="10190032" Type="AKUZ.EMERGENCY_EVENT" Description="Случай госпитализации" Required="1" />
    <Parent Name="StructureBed" Index="10290006" Type="AKUZ.STRUCTURE_BED" Description="Профили коек" Required="1" />
    <Parent Name="PaymentType" Index="10290015" Type="VCLib.ENUMS" Description="Вид оплаты" EnumType="PaymentType" />
    <Parent Name="Division" Index="10610002" Type="AKUZ.DIVISION" Description="Отделение" Required="1" />
    <Parent Name="CreatorUser" Index="10610004" Type="AKUZ.USERS" Description="Автор записи" />
    <Parent Name="LastModifyUser" Index="10610005" Type="AKUZ.USERS" Description="Автор последней модификации" />
    <Parent Name="MovementType" Index="10610009" Type="VCLib.ENTITIES" Description="Тип записи" Save="0" />
    <Parent Name="CurrentDivision" Index="10610049" Type="AKUZ.DIVISION" Description="Текущее отделение" />
    <Parent Name="TableOfFeed" Index="10610058" Type="AKUZ.TABLE_OF_FEED" Description="Стол питания" />
    <Child Name="MovementsCards" Index="10190035" Type="AKUZ.MOVEMENTS_CARD" Description="Учет движения больных" ChildAttribute="MedicalcardRegistration" />
    <Child Name="HospitalRecords" Index="10190037" Type="AKUZ.HOSPITAL_RECORD" Description="Медицинские записи в стационаре" ChildAttribute="Movement" />
    <Child Name="PatientMovements" Index="10610010" Type="AKUZ.PATIENT_MOVEMENT" Description="Список перемещений" ChildAttribute="Movement" />
    <Child Name="LocationPatients" Index="10610011" Type="AKUZ.LOCATION_PATIENT" Description="Нахождения пациента" ChildAttribute="Patient" />
    <Child Name="MovementResults" Index="10610050" Type="AKUZ.MOVEMENT_RESULT" Description="Выписка отделения" ChildAttribute="MedicalcardRegistration" />
    <Child Name="HospitalSummaryEpicriss" Index="10610051" Type="AKUZ.HOSPITAL_SUMMARY_EPICRIS" Description="Эпикриз из случая стационарного лечения" ChildAttribute="Movement" />
    <Child Name="Accompanys" Index="10610052" Type="AKUZ.ACCOMPANY" Description="Сопровождающий" ChildAttribute="Movement" />
    <Child Name="MovementsDivisionCards" Index="10610054" Type="AKUZ.MOVEMENTS_DIVISION_CARD" Description="Движение в отделение" ChildAttribute="Movement" />
    <Child Name="AmbulanceRecords" Index="10610055" Type="AKUZ.AMBULANCE_CARD_RECORD" Description="Медицинская запись амбулаторной карты" ChildAttribute="Movement" />
    <Child Name="HistoryEatTables" Index="10610059" Type="AKUZ.HISTORY_EAT_TABLE" Description="История столов питания" ChildAttribute="Movement" />
    <Child Name="TransfusionRequests" Index="10610061" Type="AKUZ.TRANSFUSION_REQUEST" Description="Заявки на переливание" ChildAttribute="Movement" />
    <Link Name="PermissionMovenments" Index="10290043" Type="AKUZ.PERMISSION_MOVEMENT" Description="Данные для стола справок" LinkAttribute="Movement" />
    <Child Name="OperationsPlans" Index="10610063" Type="AKUZ.OPERATIONS_PLAN" Description="Запланированные операции" ChildAttribute="Movement" />
    <Child Name="PatientRegimens" Type="AKUZ.PATIENT_REGIMEN" Description="Режим пациента" ChildAttribute="Movement" />
    <Parent Name="PatientRegimen" Type="AKUZ.PATIENT_REGIMEN" Description="Режим пациента" />
    <Child Name="TemperatureListNews" Type="AKUZ.TEMPERATURE_LIST_NEW" Description="Новый температурный лист" ChildAttribute="Movement" />
    <Child Name="AnesthesiologicalCareCards" Type="AKUZ.ANESTHESIOLOGICAL_CARE_CARD" Description="Карта проведения анестезиологического пособия" ChildAttribute="Movement" />
    <Attribute Name="Barcode" Type="int" Description="Код для Штрих кода" />
    <Attribute Name="FullMedCardNum" Index="10610062" Type="string" Description="Полный номер стат карты" RequiredAttributes="{EmergencyEvent/AmbulanceCard/CardLpu/LpuSettings/LexemToNumber}" />
    <Child Name="MedicalExaminations" Type="AKUZ.MEDICAL_EXAMINATION" Description="Медицинский осмотр" ChildAttribute="Movement" />
    <Choice Name="PsychoObservationMode" Description="Режим наблюдения для психиатрических пациентов">
      <Item Name="I режим – ограничительный" Index="0" />
      <Item Name="II режим – дифференцированного наблюдения" Index="1" />
      <Item Name="III режим – лечебно-активирующий" Index="2" />
      <Item Name="IV режим – «открытых дверей»" Index="3" />
    </Choice>
    <Child Name="MovementsDivisionReanimationCards" Type="AKUZ.MOVEMENTS_DIVISION_REANIMATION_CARD" Description="Движение в реанимации" ChildAttribute="Movement" />
    <Child Name="MedicalCertificates" Type="AKUZ.MEDICAL_CERTIFICATE" Description="Лист нетрудоспособности" ChildAttribute="Movement" />
  </Fields>
  <DbMapping>
    <Table name="T_MOVEMENT">
      <Map Name="MedCardNumber" Column="MedCardNumber" />
      <Map Name="Chamber" Column="Chamber" />
      <Map Name="PaymentDescription" Column="PaymentDescription" />
      <Map Name="MovementID" Column="MovementID" />
      <Map Name="MovementTime" Column="MovementTime" />
      <Map Name="CreationDateTime" Column="CreationDateTime" />
      <Map Name="LastModifyDateTime" Column="LastModifyDateTime" />
      <Map Name="MovementDate" Column="MovementDate" />
      <Map Name="InteriorEatTable" Column="InteriorEatTable" />
      <Map Name="Diagnosis" Column="Diagnosis" />
      <Map Name="Mkb" Column="Mkb" />
      <Map Name="InteriorChamber" Column="InteriorChamber" />
      <Map Name="ExpectedDateOfDischarge" Column="ExpectedDateOfDischarge" />
      <Map Name="Bed" Column="Bed" />
      <Map Name="MovementTimeDate" Column="MovementTime" IsStored="0" />
      <Map Name="EmergencyEvent" Column="EmergencyEvent" />
      <Map Name="StructureBed" Column="StructureBed" />
      <Map Name="PaymentType" Column="PaymentType" />
      <Map Name="Division" Column="Division" />
      <Map Name="CreatorUser" Column="CreatorUser" />
      <Map Name="LastModifyUser" Column="LastModifyUser" />
      <Map Name="MovementType" Column="type_" IsStored="0" />
      <Map Name="TableOfFeed" Column="TableOfFeed" />
      <Map Name="Barcode" Column="Barcode" />
      <Map Name="FullMedCardNum" Column="FullMedCardNum" />
      <Map Name="PsychoObservationMode" Column="PsychoObservationMode" />
    </Table>
    <Lexem>
      <Map Name="CurrentDivision">
        <lx:Case xmlns:lx="lexem">
          <When>
            <lx:CriterionExists entity="AKUZ.MOVEMENTS_DIVISION_REANIMATION_CARD" top="-1" offset="0">
              <condition>
                <lx:Criteria type="And">
                  <lx:Criterion type="=">
                    <lx:Path OwnerQueryLevel="0">
                      <lx:StepString name="DateOut" />
                    </lx:Path>
                    <lx:ConstOperand isNull="1" />
                  </lx:Criterion>
                  <lx:Criterion type="=">
                    <lx:Path OwnerQueryLevel="0">
                      <lx:StepString name="Movement" />
                    </lx:Path>
                    <lx:Path OwnerQueryLevel="1">
                      <lx:StepString name="MovementID" />
                    </lx:Path>
                  </lx:Criterion>
                </lx:Criteria>
              </condition>
            </lx:CriterionExists>
          </When>
          <Then>
            <lx:QueryValue entity="AKUZ.MOVEMENTS_DIVISION_REANIMATION_CARD" top="1" offset="0">
              <condition>
                <lx:Criterion type="=">
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepString name="Movement" />
                  </lx:Path>
                  <lx:Path OwnerQueryLevel="1">
                    <lx:StepString name="MovementID" />
                  </lx:Path>
                </lx:Criterion>
              </condition>
              <orderBy>
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="DateIn" />
                </lx:Path>
                <desc>True</desc>
              </orderBy>
              <value>
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="Division" />
                  <lx:StepString name="DivisionID" />
                </lx:Path>
              </value>
            </lx:QueryValue>
          </Then>
          <Else>
            <lx:QueryValue entity="AKUZ.MOVEMENTS_DIVISION_CARD" top="1" offset="0">
              <condition>
                <lx:Criteria type="And">
                  <lx:Criterion type="=">
                    <lx:Path OwnerQueryLevel="0">
                      <lx:StepString name="Movement" />
                    </lx:Path>
                    <lx:Path OwnerQueryLevel="1">
                      <lx:StepString name="MovementID" />
                    </lx:Path>
                  </lx:Criterion>
                </lx:Criteria>
              </condition>
              <orderBy>
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="RealDateIn" />
                </lx:Path>
                <desc>True</desc>
              </orderBy>
              <value>
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="Division" />
                  <lx:StepString name="DivisionID" />
                </lx:Path>
              </value>
            </lx:QueryValue>
          </Else>
        </lx:Case>
      </Map>
      <Map Name="PatientRegimen">
        <lx:QueryValue entity="AKUZ.PATIENT_REGIMEN" top="1" offset="0" xmlns:lx="lexem">
          <condition>
            <lx:Criteria type="And">
              <lx:Criterion type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="Movement" />
                  <lx:StepString name="MovementID" />
                </lx:Path>
                <lx:Path OwnerQueryLevel="1">
                  <lx:StepString name="MovementID" />
                </lx:Path>
              </lx:Criterion>
            </lx:Criteria>
          </condition>
          <orderBy>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="DateIn" />
            </lx:Path>
            <desc>True</desc>
          </orderBy>
          <value>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="PatientRegimenID" />
            </lx:Path>
          </value>
        </lx:QueryValue>
      </Map>
    </Lexem>
  </DbMapping>
  <CalculatingAttributes>
    <Parent Name="FirstMovementsDivisionCard" Type="AKUZ.MOVEMENTS_DIVISION_CARD" Description="Первое отделение нахождения пациента" RequiredAttributes="{MovementsDivisionCards/RealDateIn}" PathAttributes="{MovementsDivisionCards}" />
    <Parent Name="LastMovementsDivisionCard" Type="AKUZ.MOVEMENTS_DIVISION_CARD" Description="Последнее отделение нахождения пациента" RequiredAttributes="{MovementsDivisionCards/RealDateIn}" PathAttributes="{MovementsDivisionCards}" />
    <Attribute Name="PatientAge" Index="10290045" Type="string" Description="Возраст пациента" RequiredAttributes="{EmergencyEvent/AmbulanceCard/Patient/Birthday};{MovementDate}" />
    <Parent Name="CurrentMovementCard" Index="10290046" Type="AKUZ.MOVEMENTS_CARD" Description="Текущее местонахождение" RequiredAttributes="{MovementsCards/MovementsDivision/MovementsLpu/PostingDate};{MovementsCards/MovementsDivision/Division};{MovementsCards/MovementType};{EmergencyEvent/CloseDate};{MovementsCards/StepsNumber}" PathAttributes="{MovementsCards}" />
    <Child Name="RequiredResult" Index="10290047" Type="AKUZ.MOVEMENTS_CARD" Description="Отчитывающиеся отделения" ChildAttribute="MedicalcardRegistration" RequiredAttributes="{MovementsCards}" />
    <Parent Name="HospitalisationActiveCall" Index="10610064" Type="AKUZ.HOSPITALISATION_ACTIVE_CALL" Description="Активный вызов стационара" RequiredAttributes="{EmergencyEvent/HospitalisationActiveCalls/Movement}" PathAttributes="{EmergencyEvent/HospitalisationActiveCalls}" />
    <Child Name="Monitorings" Type="AKUZ.MONITORING" Description="Мониторинг" RequiredAttributes="{TemperatureListNews/Temperature};{TemperatureListNews/DayPeriod};{TemperatureListNews/DiaPresure};{TemperatureListNews/SysPresure};{TemperatureListNews/RespiratoryRate};{HospitalRecords/PostingDate};{TemperatureListNews/Inspection};{EmergencyEvent/AmbulanceRecords/as AKUZ.DIAGNOSTICS_RESULTS/Research/Name};{EmergencyEvent/AmbulanceRecords/PostingDate};{EmergencyEvent/AmbulanceRecords/as AKUZ.ROUTE_TO_DIAGNOSTICS/TakingDate};{EmergencyEvent/AmbulanceRecords/as AKUZ.MEDICAL_EXAMINATION/ExaminationDate};{EmergencyEvent/AmbulanceRecords/as AKUZ.MEDICAL_EXAMINATION/ExaminationTime};{EmergencyEvent/AmbulanceRecords/as AKUZ.ROUTE_TO_DIAGNOSTICS/TicketDateTime};{EmergencyEvent/AmbulanceRecords/as AKUZ.ROUTE_TO_DOCTOR_INSPECTION/TicketDateTime};{EmergencyEvent/AmbulanceRecords/as AKUZ.ROUTE_TO_DIAGNOSTICS/Research/Name};{EmergencyEvent/AmbulanceRecords/as AKUZ.ROUTE_TO_DIAGNOSTICS/ResultExits};{EmergencyEvent/AmbulanceRecords/as AKUZ.ROUTE_TO_DOCTOR_INSPECTION/Speciality/Name};{EmergencyEvent/AmbulanceRecords/as AKUZ.MEDICAL_EXAMINATION/Post/Worker/FIO};{EmergencyEvent/AmbulanceRecords/as AKUZ.MEDICAL_EXAMINATION/Post/Worker/LastName_TP};{EmergencyEvent/AmbulanceRecords/as AKUZ.ROUTE_TO_DOCTOR_INSPECTION/ProcessingState};{EmergencyEvent/EventDate};{TemperatureListNews/Pulse};{EmergencyEvent/AmbulanceRecords/as AKUZ.ROUTE_TO_DIAGNOSTICS/Status};{EmergencyEvent/AmbulanceRecords/as AKUZ.ROUTE_TO_DIAGNOSTICS/Relationships};{EmergencyEvent/ListOfDestination/Destinations/Name};{EmergencyEvent/ListOfDestination/Destinations/Frequency};{EmergencyEvent/ListOfDestination/Destinations/Periodicity};{EmergencyEvent/ListOfDestination/Destinations/NumberMake};{EmergencyEvent/ListOfDestination/Destinations/ReceptionPeriod};{EmergencyEvent/ListOfDestination/Destinations/DaysOfWeek};{EmergencyEvent/ListOfDestination/Destinations/SchemeReception};{EmergencyEvent/ListOfDestination/Destinations/DataAdd};{EmergencyEvent/ListOfDestination/Destinations/DateCancel}" PathAttributes="{TemperatureListNews};{EmergencyEvent/AmbulanceRecords/as AKUZ.ROUTE_TO_DIAGNOSTICS};{EmergencyEvent/AmbulanceRecords/as AKUZ.ROUTE_TO_DOCTOR_INSPECTION};{EmergencyEvent/AmbulanceRecords/as AKUZ.MEDICAL_EXAMINATION};{EmergencyEvent/ListOfDestination/Destinations}" />
    <Child Name="ResponseWebs" Type="AKUZ.RESPONSE_WEB" Description="responseWeb" RequiredAttributes="{EmergencyEvent/AmbulanceRecords/as AKUZ.DIAGNOSTICS_RESULTS/Mkb};{EmergencyEvent/AmbulanceRecords/as AKUZ.DIAGNOSTICS_RESULTS/ResultDescription};{EmergencyEvent/AmbulanceRecords/as AKUZ.DIAGNOSTICS_RESULTS/Research/Name};{EmergencyEvent/EventDate};{EmergencyEvent/AmbulanceRecords/PostingDate};{EmergencyEvent/AmbulanceCard/Number};{EmergencyEvent/AmbulanceCard/Patient/FIO};{EmergencyEvent/AmbulanceRecords/as AKUZ.DIAGNOSTICS_RESULTS/Research/ResearchKind}" />
    <Attribute Name="FullBarcode" Type="string" Description="Штрих код" RequiredAttributes="{Barcode};{EmergencyEvent/AmbulanceCard/CardLpu/Code};{EmergencyEvent/EventDate}" />
  </CalculatingAttributes>
</Entity>