<?xml version="1.0" encoding="utf-8"?>
<Entity 
Schema="AKUZ" 
Name="MEDICAL_RECORD" 
Description="Медицинская запись" 
PrimaryKey="MedicalRecordID" 
DNAttributes="{RecordType/EntDesc}" 
DisplayName="{0}">
  <Customs>
    <Custom Name="NotDisplayedInFilter" Value="RecordTime;RecordDate" />
    <Custom Name="NotDisplayedColumns" Value="RecordTime;RecordDate" />
    <Custom Name="NotTrackedAttributes" Value="RecordTime;RecordDate" />
  </Customs>
  <Fields>
    <Attribute Name="MedicalRecordID" Index="5460001" Type="guid" Description="Идентификатор" />
    <Attribute Name="RecordTime" Index="5460005" Type="datetime" DefaultFormat="{0:HH:mm}" Description="Время записи" />
    <Parent Name="Post" Index="5460002" Type="AKUZ.POST" Description="Должность" Required="1" />
    <Parent Name="Users" Index="5460007" Type="AKUZ.USERS" Description="Пользователь системы" />
    <Parent Name="RecordType" Index="5460008" Type="VCLib.ENTITIES" Description="Тип записи" Save="0" />
    <Child Name="Relationships" Index="5460009" Type="AKUZ.MEDICAL_RECORD_RELATIONSHIP" Description="Связанные записи" ChildAttribute="MedicalRecord" />
    <Child Name="ServiceRelationShips" Index="11100022" Type="AKUZ.SERVICE_RELATION_SHIPS" Description="Связь между медицинской записью и услугой" ChildAttribute="MedicalRecord" />
    <Link Name="RecordSign" Type="AKUZ.RECORD_SIGN" Description="Подпись записи" LinkAttribute="MedicalRecord" />
    <Parent Name="MOMain" Type="AKUZ.LPU_MAIN" Description="Медицинская организация" Required="1" />
    <Parent Name="MedicalEpisode" Type="AKUZ.MEDICAL_EPISODE" Description="Медицинский эпизод" />
    <Attribute Name="PostingDate" Index="6710004" Type="datetime" DefaultFormat="{0:dd.MM.yyyy}" Description="Дата события" Required="1" />
    <Parent Name="AmbulanceCard" Index="6710001" Type="AKUZ.AMBULANCE_CARD" Description="Амбулаторная карта" />
    <Parent Name="AmbulanceEvent" Index="5490001" Type="AKUZ.AMBULANCE_EVENT" Description="Случай обращения" />
    <Parent Name="Movement" Index="5490002" Type="AKUZ.MOVEMENT" Description="Движение" />
    <Parent Name="PatientBase" Type="AKUZ.PATIENT" Description="Идентификатор принадлежности медицинской записи пациенту" />
    <Attribute Name="RecordDate" Type="datetime" DefaultFormat="{0:dd.MM.yyyy}" Description="Дата записи" />
  </Fields>
  <DbMapping>
    <Table name="T_MEDICAL_RECORD">
      <Map Name="MedicalRecordID" Column="MedicalRecordID" />
      <Map Name="RecordTime" Column="RecordTime" />
      <Map Name="Post" Column="Post" />
      <Map Name="Users" Column="Users" />
      <Map Name="RecordType" Column="type_" IsStored="0" />
      <Map Name="MOMain" Column="MOMain" />
      <Map Name="PostingDate" Column="PostingDate" />
      <Map Name="AmbulanceCard" Column="AmbulanceCard" />
      <Map Name="AmbulanceEvent" Column="AmbulanceEvent" />
      <Map Name="Movement" Column="Movement" />
      <Map Name="PatientBase" Column="PatientBase" />
    </Table>
    <Spread>
      <Map Name="MedicalEpisode" />
    </Spread>
    <Lexem>
      <Map Name="RecordDate">
        <lx:Cast type="DateTime" xmlns:lx="lexem">
          <lx:Path OwnerQueryLevel="0">
            <lx:StepString name="RecordTime" />
          </lx:Path>
          <lx:ConstOperand type="String"><![CDATA[yyyyMMdd]]></lx:ConstOperand>
        </lx:Cast>
      </Map>
    </Lexem>
  </DbMapping>
  <CalculatingAttributes>
    <Attribute Name="MkbOsn" Index="11100017" Type="string" Description="Код МКБ основного заболевания" RequiredAttributes="{as AKUZ.HOSPITAL_RECORD/MKBCode};{as AKUZ.OUTCOME_OF_INSPECTION/MKBCode};{as AKUZ.MEDICAL_CERTIFICATE/MKBCode}" />
    <Attribute Name="DiagOsn" Index="11100021" Type="string" Description="Расшифровка основного диагноза" RequiredAttributes="{as AKUZ.HOSPITAL_RECORD/Diagnosis};{as AKUZ.OUTCOME_OF_INSPECTION/Diagnosis};{as AKUZ.MEDICAL_CERTIFICATE/Diagnosis}" />
    <Attribute Name="Type" Index="5460010" Type="int" Description="Тип" />
  </CalculatingAttributes>
</Entity>