<?xml version="1.0" encoding="utf-8"?>
<Entity 
Schema="AKUZ" 
Name="AMBULANCE_CARD" 
Description="Амбулаторная карта" 
PrimaryKey="AmbulanceCardID" 
DNAttributes="{Number};{Patient/cFIO};{Patient/Birthday}" 
DisplayName="№{0} {1} {2}">
  <Customs>
    <Custom Name="NotDisplayedInFilter" Value="SchetZaps;IntID;CurrentDispanserisationInit;HospitalizationReferrals;CurrentPregnantDispanserisation;fnState" />
    <Custom Name="NotDisplayedColumns" Value="SchetZaps;IntID;CurrentDispanserisationInit;HospitalizationReferrals;CurrentPregnantDispanserisation;fnState" />
    <Custom Name="NotTrackedAttributes" Value="SchetZaps;IntID;HospitalizationReferrals;CurrentPregnantDispanserisation;fnState" />
    <Custom Name="FilterUICondition"><![CDATA[<lx:Criterion type="=" xmlns:lx="lexem">
    <lx:Path OwnerQueryLevel="0">
        <lx:StepString name="CardLpu" />
    </lx:Path>
    <lx:ParamHolder>
        <lx:StepString name="CURRENT_LPU_MAIN" />
    </lx:ParamHolder>
</lx:Criterion>]]></Custom>
    <Custom Name="UniteObjectsKey" Value="format(&quot;{0}|{1}&quot;, {Patient/PatientID}, {CardLpu/LpuID})" />
    <Custom Name="UniteObjectsKeyHumanView" Value="format(&quot;Пациент: {0}, МО: {1}&quot;, {Patient/DisplayName}, {CardLpu/DisplayName})" />
  </Customs>
  <Fields>
    <Attribute Name="AmbulanceCardID" Index="5220001" Type="guid" Description="Идентификатор" />
    <Attribute Name="Number" Index="5220003" Type="string" Description="Номер карты" CharacterMaximumLength="32" Required="1" />
    <Attribute Name="CreationDateTime" Index="5220006" Type="datetime" DefaultFormat="{0:dd.MM.yyyy HH:mm}" Description="Дата и время регистрации" />
    <Attribute Name="LocalNumber" Index="5220014" Type="string" Description="Номер по картотеке" />
    <Attribute Name="IntID" Index="5220031" Type="int" Description="Идентификатор интеграции" />
    <Parent Name="Patient" Index="5220002" Type="AKUZ.PATIENT" Description="Пациент" Required="1" />
    <Parent Name="CardLpu" Index="5220004" Type="AKUZ.LPU_MAIN" Description="МО, выдавшая карту" Required="1" />
    <Parent Name="CreatorUser" Index="5220007" Type="AKUZ.USERS" Description="Регистратор" />
    <Parent Name="State" Index="5220011" Type="AKUZ.STATE" Description="Участок" />
    <Child Name="AmbulanceEvents" Index="5220005" Type="AKUZ.AMBULANCE_EVENT" Description="Случаи обращения" ChildAttribute="AmbulanceCard" />
    <Child Name="AmbulanceRecords" Index="5220010" Type="AKUZ.AMBULANCE_CARD_RECORD" Description="Медицинские записи амбулаторной карты" ChildAttribute="AmbulanceCard" />
    <Child Name="AllergicAnamnesiss" Index="5220015" Type="AKUZ.ALLERGIC_ANAMNESIS" Description="Аллергологический анамнез" ChildAttribute="AmbulanceCard" />
    <Child Name="VaccinationCancels" Index="5220016" Type="AKUZ.VACCINATION_CANCEL" Description="Мед.отводы от вакцинации" ChildAttribute="AmbulanceCard" />
    <Child Name="VaccinationAccepts" Index="5220017" Type="AKUZ.VACCINATION_ACCEPT" Description="Выполненные вакцинации" ChildAttribute="AmbulanceCard" />
    <Child Name="OutcomeOfInspections" Index="5220020" Type="AKUZ.OUTCOME_OF_INSPECTION" Description="Исходы осмотров врачей" ChildAttribute="AmbulanceCard" />
    <Child Name="CardNotes" Index="5220021" Type="AKUZ.CARD_NOTE" Description="Справки" ChildAttribute="AmbulanceCard" />
    <Child Name="DiscountCards" Index="5220022" Type="AKUZ.DISCOUNT_CARD" Description="Дисконтная карта" ChildAttribute="AmbulanceCard" />
    <Child Name="MovementResults" Index="5220023" Type="AKUZ.MOVEMENT_RESULT" Description="Выписка отделения" ChildAttribute="AmbulanceCard" />
    <Child Name="DeathInfoHistorys" Index="5220025" Type="AKUZ.DEATH_INFO_HISTORY" Description="История данных о смерти" ChildAttribute="AmbulanceCard" />
    <Child Name="SchetZaps" Index="5220026" Type="AKUZ.SCHET_ZAP" Description="Записи счета" ChildAttribute="AmbulanceCard" />
    <Child Name="SchedluedVaccinations" Index="5220029" Type="AKUZ.SCHEDULED_VACCINATION" Description="Запланированные вакцинации" ChildAttribute="AmbulanceCard" />
    <Child Name="WaitingLists" Index="5220032" Type="AKUZ.WAITING_LIST" Description="Лист ожидания" ChildAttribute="AmbulanceCard" />
    <Link Name="SkipDublicateControlReason" Index="5220009" Type="AKUZ.SKIP_DUBLICATE_CONTROL_REASON" Description="Причина обхода контроля дубликатов карт" LinkAttribute="AmbulanceCard" />
    <Link Name="DeathInfo" Index="5220024" Type="AKUZ.DEATH_INFO" Description="Данные о смерти" LinkAttribute="AmbulanceCard" />
    <Link Name="DeathCertificate" Index="5220028" Type="AKUZ.MEDICAL_DEATH_CERTIFICATE" Description="Медицинское свидетельство о смерти" LinkAttribute="AmbulanceCard" />
    <Child Name="DispanserisationInits" Index="5220035" Type="AKUZ.DISPANSERISATION_INIT" Description="Записи диспансерного наблюдения" ChildAttribute="AmbulanceCard" />
    <Child Name="RdsDispPatients" Index="5220034" Type="AKUZ.RDS_DISP_PATIENT" Description="Данные диспансеризации пациента для РДС" ChildAttribute="AmbulanceCard" />
    <Child Name="VaccinationImmunitys" Type="AKUZ.VACCINATION_IMMUNITY" Description="Напряженность иммунитета" ChildAttribute="AmbulanceCard" />
    <Child Name="HospitalizationReferrals" Type="AKUZ.HOSPITALIZATION_REFERRAL" Description="Направление на госпитализацию" ChildAttribute="AmbulanceCard" RequiredAttributes="{AmbulanceEvents/AmbulanceRecords/as AKUZ.HOSPITALIZATION_REFERRAL/All}" />
    <Child Name="MentalDispanserisationInits" Type="AKUZ.MENTAL_DISPANSERISATION_INIT" Description="Записи диспансерного наблюдения психиатрического профиля" ChildAttribute="AmbulanceCard" />
    <Link Name="SportsControlCard" Type="AKUZ.SPORTS_CONTROL_CARD" Description="Врачебно-контрольная карта спортсмена" LinkAttribute="AmbulanceCard" />
    <Child Name="NotificationAboutHospitals" Type="AKUZ.NOTIFICATION_ABOUT_HOSPITAL" Description="Уведомление в стационар о предстоящей госпитализации пациента" ChildAttribute="AmbulanceCard" />
    <Child Name="CdaDocuments" Type="AKUZ.CDA_DOCUMENT" Description="Документы в формате CDA" ChildAttribute="AmbulanceCard" />
    <Child Name="SportsExaminationPatients" Type="AKUZ.SPORTS_EXAMINATION_PATIENT" Description="Пациент направленный на медосмотр спортивной организацией" ChildAttribute="AmbulanceCard" />
    <Child Name="MonitoringPrograms" Type="AKUZ.PATIENT_MONITORING_PROGRAM" Description="Программы мониторинга" ChildAttribute="AmbulanceCard" />
    <Child Name="ImportantOccasionss" Type="AKUZ.IMPORTANT_OCCASIONS" Description="События на участке" ChildAttribute="AmbulanceCard" />
    <Child Name="AkbarsTcPatients" Type="AKUZ.AKBARS_TC_PATIENT" Description="Пациент телеконсультации АкБарс " ChildAttribute="AmbulanceCard" />
    <Child Name="AnamnesVitas" Type="AKUZ.ANAMNES_VITA" Description="Анамнез жизни" ChildAttribute="AmbulanceCard" />
    <Child Name="MedicalEpisodes" Type="AKUZ.MEDICAL_EPISODE" Description="Медицинский эпизод" ChildAttribute="AmbulanceCard" />
    <Parent Name="fnState" Type="AKUZ.STATE" Description="Участок (устаревшее поле)">
      <Parameter Name="Profile" Description="Профиль участка" Type="int" />
    </Parent>
    <Child Name="MilkDirections" Type="AKUZ.MILK_DIRECTION" Description="Направление на получение молочного питания" ChildAttribute="AmbulanceCard" />
    <Child Name="HschetZaps" Type="AKUZ.HSCHET_ZAP" Description="Запись счета" ChildAttribute="AmbulanceCard" />
    <Child Name="RecipeGenerals" Type="AKUZ.RECIPE_GENERAL" Description="Льготный рецепт" ChildAttribute="AmbulanceCard" />
    <Child Name="VimisMedicalCards" Type="AKUZ.VIMIS_MEDICAL_CARD" Description="Информация о медицинской карте пациента" ChildAttribute="AmbulanceCard" />
  </Fields>
  <DbMapping>
    <Table name="T_AMBULANCE_CARD">
      <Map Name="AmbulanceCardID" Column="AmbulanceCardID" />
      <Map Name="Number" Column="Number" />
      <Map Name="CreationDateTime" Column="CreationDateTime" />
      <Map Name="LocalNumber" Column="LocalNumber" />
      <Map Name="IntID" Column="IntID" />
      <Map Name="Patient" Column="Patient" />
      <Map Name="CardLpu" Column="CardLpu" />
      <Map Name="CreatorUser" Column="CreatorUser" />
      <Map Name="State" Column="State" />
      <Map Name="fnState" Function="dbo.fn_GetState" />
    </Table>
    <Filter>
      <Map Name="AmbulanceRecords">
        <lx:Not xmlns:lx="lexem">
          <lx:Criterion type="IS">
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="ObjectProperties" />
              <lx:StepString name="ObjectTypeID" />
            </lx:Path>
            <lx:ConstOperand type="String"><![CDATA[AKUZ.AMBULANCE_RECORD]]></lx:ConstOperand>
          </lx:Criterion>
        </lx:Not>
      </Map>
    </Filter>
  </DbMapping>
  <CalculatingAttributes>
    <Attribute Name="ActualDstatus" Index="5220019" Type="string" Description="Состояние Д учета" RequiredAttributes="{OutcomeOfInspections/CheckUpStatus};{OutcomeOfInspections/MKBCode};{OutcomeOfInspections/PostingDate}" />
    <Child Name="DiagnosisHistory" Index="5220012" Type="AKUZ.DIAGNOSIS_HISTORY" Description="Лист заключительных диагнозов" ChildAttribute="AmbulanceCard" PathAttributes="{AmbulanceRecords}" />
    <Child Name="AllScheduledVaccinations" Index="5220030" Type="AKUZ.SCHEDULED_VACCINATION" Description="Запланированные вакцинации со всех карт" ChildAttribute="AmbulanceCard" RequiredAttributes="{Patient/AmbulanceCards/SchedluedVaccinations/ScheduledDate};{Patient/AmbulanceCards/SchedluedVaccinations/VaccineLibrary/Name}" />
    <Child Name="CalcPaidContractList" Index="5220033" Type="AKUZ.PHYSICAL_CONTRACT" Description="Список договоров на оказание платных услуг" RequiredAttributes="{AmbulanceEvents/PhysicalContracts/CostContract};{AmbulanceEvents/PhysicalContracts/WhoIsPayer};{AmbulanceEvents/PhysicalContracts/CostCategory};{AmbulanceEvents/PhysicalContracts/Contract/ContractDate};{AmbulanceEvents/PhysicalContracts/Contract/Number}" PathAttributes="{AmbulanceEvents/PhysicalContracts}" />
    <Parent Name="CheckUpStatus" Index="5220036" Type="VCLib.ENUMS" Description="Признак ДН по диагнозу" EnumType="CheckUpStatus" RequiredAttributes="{DispanserisationInits/CurrentMkb};{DispanserisationInits/DispanserisationEnd}">
      <Parameter Name="Mkb" Description="Код МКБ" Type="string" />
    </Parent>
    <Parent Name="CurrentDispanserisationInit" Index="5220037" Type="AKUZ.DISPANSERISATION_INIT" Description="Текущая запись диспансерного наблюдения" RequiredAttributes="{DispanserisationInits/CurrentMkb};{DispanserisationInits/DispanserisationEnd}">
      <Parameter Name="Mkb" Description="Код МКБ" Type="string" />
    </Parent>
    <Parent Name="CurrentPregnantDispanserisation" Type="AKUZ.PREGNANT_DISPANSERISATION" Description="Текущее диспансерное наблюдение за беременной" RequiredAttributes="{Patient/Sex/EnumID}" />
  </CalculatingAttributes>
</Entity>