<?xml version="1.0" encoding="utf-8"?>
<Entity 
Schema="AKUZ" 
Name="OUTCOME_OF_INSPECTION" 
Description="Исход осмотра врача" 
DNAttributes="{MKBCode}" 
DisplayName="{0}" 
Inherits="AKUZ.AMBULANCE_CARD_RECORD">
  <Fields>
    <Attribute Name="MKBCode" Index="5990001" Type="string" Description="Заключительный диагноз" CharacterMaximumLength="8" Required="1" />
    <Attribute Name="Diagnosis" Index="5990002" Type="string" Description="Заключительный диагноз(описание)" CharacterMaximumLength="4096" />
    <Attribute Name="Decision" Index="5990005" Type="text" Description="Заключение/Рекомендации" />
    <Attribute Name="DirectionMKB" Index="5990006" Type="string" Description="Направительный диагноз" CharacterMaximumLength="8" />
    <Attribute Name="ActiveFindDiagnosis" Index="6670004" Type="bool" Description="Признак активного выявления диагноза" Required="1" />
    <Attribute Name="ExternalCause" Index="6670018" Type="string" Description="Внешняя причина" CharacterMaximumLength="8" />
    <Parent Name="SicknessMode" Index="5990003" Type="VCLib.ENUMS" Description="Характер заболевания" EnumType="SicknessMode" />
    <Parent Name="CheckUpStatus" Index="6670007" Type="VCLib.ENUMS" Description="Признак ДН по диагнозу" EnumType="CheckUpStatus" />
    <Parent Name="Trauma" Index="6670013" Type="AKUZ.TRAUMA" Description="Травма" />
    <Parent Name="CheckUpGroup" Index="6670014" Type="VCLib.ENUMS" Description="Группа Д-наблюдения" EnumType="CheckUpGroup" />
    <Child Name="AccompanyingDiseasess" Index="5990007" Type="AKUZ.ACCOMPANYING_DISEASES" Description="Сопутствующие заболевания" ChildAttribute="OutcomeOfInspection" />
    <Child Name="ListQualitys" Index="5990008" Type="AKUZ.LIST_QUALITY" Description="Анкета оценки качества лечения" ChildAttribute="OutcomeOfInspection" />
    <Child Name="PrescriptionOfOutcomes" Index="6670020" Type="AKUZ.PRESCRIPTION_OF_OUTCOME" Description="Направление" ChildAttribute="OutcomeOfInspection" />
    <Choice Name="SicknessStage" Index="5990004" Description="Стадия заболевания">
      <Item Name="ранняя" Index="1" />
      <Item Name="поздняя" Index="2" />
      <Item Name="0" Index="10" />
      <Item Name="1" Index="11" />
      <Item Name="2" Index="12" />
      <Item Name="3" Index="13" />
      <Item Name="4" Index="14" />
      <Item Name="5" Index="15" />
      <Item Name="6" Index="16" />
    </Choice>
    <Choice Name="TraumaT" Index="6670019" Description="Тип травмы">
      <Item Name="Производственная" Index="1" />
      <Item Name="Непроизводственная" Index="2" />
    </Choice>
    <Link Name="OnkTreatmentCase" Index="6670021" Type="AKUZ.ONK_TREATMENT_CASE" Description="Сведения о случае лечения онкологического заболевания" LinkAttribute="OutcomeOfInspection" />
    <Child Name="Councils" Type="AKUZ.COUNCIL" Description="Консилиум" ChildAttribute="OutcomeOfInspection" />
    <Parent Name="Mes" Type="AKUZ.MES" Description="МЭС" />
    <Attribute Name="Extract" Type="text" Description="Выписка при закрытии случая" />
    <Parent Name="EhrRus5hi70r6mcm" Type="EHR.EHR_RUS_5GHJ6NA301" Description="Морфологические коды" />
    <Attribute Name="DN_DATE_1" Type="datetime" Description="Дата постановки пациента с ОЗ на диспансерное наблюдение" />
    <Link Name="MovementResultLekPrepLink" Type="AKUZ.MOVEMENT_RESULT_LEK_PREP_LINK" Description="Связка между выпиской из отделения и сведениями о введенном лекарственном препарате" LinkAttribute="OutcomeOfInspection" />
    <Parent Name="DiagnosisRecord" Type="AKUZ.DIAGNOSIS_HISTORY" Description="Запись в лист заключительных диагнозов пациента" />
    <Parent Name="MedicalExaminationData" Type="AKUZ.MEDICAL_EPISODE" Description="Данные о случае обращения в поликлинике" />
    <Attribute Name="HtmlDecision" Type="binary" Description="Заключение/Рекомендации HTML" ContentType="text/zip" />
    <Child Name="MedicalEpisodes" Type="AKUZ.MEDICAL_EPISODE" Description="Медицинсий эпизод" ChildAttribute="OutcomeRecord" />
  </Fields>
  <DbMapping>
    <Table name="T_OUTCOME_OF_INSPECTION">
      <Map Name="MKBCode" Column="MKBCode" />
      <Map Name="Diagnosis" Column="Diagnosis" />
      <Map Name="Decision" Column="Decision" />
      <Map Name="DirectionMKB" Column="DirectionMKB" />
      <Map Name="ActiveFindDiagnosis" Column="ActiveFindDiagnosis" />
      <Map Name="ExternalCause" Column="ExternalCause" />
      <Map Name="SicknessMode" Column="SicknessMode" />
      <Map Name="CheckUpStatus" Column="CheckUpStatus" />
      <Map Name="Trauma" Column="Trauma" />
      <Map Name="CheckUpGroup" Column="CheckUpGroup" />
      <Map Name="SicknessStage" Column="SicknessStage" />
      <Map Name="TraumaT" Column="TraumaT" />
      <Map Name="Mes" Column="Mes" />
      <Map Name="Extract" Column="Extract" />
      <Map Name="EhrRus5hi70r6mcm" Column="EhrRus5hi70r6mcm" />
      <Map Name="DN_DATE_1" Column="DN_DATE_1" />
      <Map Name="DiagnosisRecord" Column="DiagnosisRecord" />
      <Map Name="HtmlDecision" Column="HtmlDecision" />
    </Table>
    <Lexem>
      <Map Name="MedicalExaminationData" PathAttributes="{MedicalEpisodes}">
        <lx:Case xmlns:lx="lexem">
          <When>
            <lx:Criteria type="And">
              <lx:Criterion not="1" type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="AmbulanceEvent" />
                  <lx:StepString name="ObjectProperties" />
                  <lx:StepString name="ObjectType" />
                  <lx:StepString name="EntName" />
                </lx:Path>
                <lx:ConstOperand type="String"><![CDATA[EMERGENCY_EVENT]]></lx:ConstOperand>
              </lx:Criterion>
              <lx:Criterion type="&gt;">
                <lx:ChildCount>
                  <condition />
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepString name="MedicalEpisodes" />
                  </lx:Path>
                  <lx:Count />
                </lx:ChildCount>
                <lx:ConstOperand type="Int32">0</lx:ConstOperand>
              </lx:Criterion>
            </lx:Criteria>
          </When>
          <Then>
            <lx:ChildCount>
              <condition />
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="MedicalEpisodes" />
              </lx:Path>
              <lx:First>
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepCurrent />
                </lx:Path>
              </lx:First>
            </lx:ChildCount>
          </Then>
          <Else>
            <lx:ConstOperand isNull="1" />
          </Else>
        </lx:Case>
      </Map>
    </Lexem>
  </DbMapping>
  <CalculatingAttributes>
    <Attribute Name="CompDiagnosis" Index="6670012" Type="string" Description="Осложнение диагноза" CharacterMaximumLength="4096" RequiredAttributes="{AccompanyingDiseasess/TypeDisease};{AccompanyingDiseasess/Diagnosis}" />
    <Attribute Name="MkbComp" Index="6670017" Type="string" Description="Код мкб осложнения диагноза" CharacterMaximumLength="8" RequiredAttributes="{AccompanyingDiseasess/TypeDisease};{AccompanyingDiseasess/MKBCode}" />
    <Attribute Name="CheckUp" Index="6670016" Type="bool" Description="Состояние Д-учета" RequiredAttributes="{MKBCode};{AmbulanceCard/OutcomeOfInspections/MKBCode};{AmbulanceCard/OutcomeOfInspections/PostingDate};{AmbulanceCard/OutcomeOfInspections/as AKUZ.OUTCOM_OF_INSPECTION/CheckUpStatus/Code}">
      <Parameter Name="ActualDate" Description="Дата актуальности" Type="date" />
    </Attribute>
    <Child Name="AmbulanceSurgicalOperations" Type="AKUZ.AMBULANCE_SURGICAL_OPERATION" Description="Амбулаторное хирургическое вмешательство или манипуляция" RequiredAttributes="{AmbulanceEvent/DoctorVisits/DoctorVisitServices/MedicalService/Code};{AmbulanceEvent/DoctorInspections/OutcomeRecord};{AmbulanceEvent/DoctorInspections/DoctorVisitServices/MedicalService/Code};{AmbulanceEvent/DoctorInspections/DoctorInspectionRes/DoctorVisitServices/MedicalService/Code};{AmbulanceEvent/DoctorVisits/OutcomeRecord}" />
    <Parent Name="DiapanserizationInit" Type="AKUZ.DISPANSERISATION_INIT" Description="Диспансеризация" RequiredAttributes="{Relationships/MedicalRecordLink};{Relationships/RelationshipType};{Relationships/MedicalRecordLink/DisplayName};{Relationships/MedicalRecordLink/as AKUZ.AMBULANCE_CARD_RECORD/AmbulanceEvent}" PathAttributes="{Relationships/MedicalRecordLink/As AKUZ.DISPANSERISATION_INIT}" />
    <Attribute Name="HasOnkDiagnosis" Type="bool" Description="Имеет онкологический диагноз" RequiredAttributes="{AccompanyingDiseasess/MKBCode};{MKBCode}" />
  </CalculatingAttributes>
</Entity>