<script lang="ts" setup>
/**
 * 病历公共词条-按字段拆分页（从路由 path 末段解析 field_code）
 * 例：/system/medical-record/entry-public/chief-complaint → chief_complaint
 */
import { computed } from 'vue';
import { useRoute } from 'vue-router';

import EntryListPage from '#/views/doctor/medical-record/components/EntryListPage.vue';
import { MEDICAL_RECORD_FIELD_OPTIONS } from '#/views/doctor/medical-record/config/constants';

defineOptions({ name: 'MedicalRecordEntryPublicField' });

const route = useRoute();

const fieldCode = computed(() => {
  const seg = (route.path.split('/').filter(Boolean).pop() || '').trim();
  return seg.replace(/-/g, '_');
});

const fieldLabel = computed(() => {
  const hit = MEDICAL_RECORD_FIELD_OPTIONS.find((o) => o.value === fieldCode.value);
  return hit?.label || fieldCode.value;
});

const pageTitle = computed(() => `公共词条·${fieldLabel.value}`);
</script>
<template>
  <EntryListPage
    :key="fieldCode"
    scope="public"
    :fixed-field-code="fieldCode"
    :page-title="pageTitle"
    :page-name="String(route.name || 'MedicalRecordEntryPublicField')"
  />
</template>
