<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.openhis.web.catalogmanage.mapper.CatalogMapper">
    <select id="get1315Page" resultType="com.openhis.ybcatalog.domain.CatalogZySyndrome">
        SELECT
            T1.tcm_syndrome_id
            ,T1.syndrome_class_code
            ,T1.syndrome_class_name
            ,T1.syndrome_property_code
            ,T1.syndrome_property
            ,T1.syndrome_type_code
            ,T1.syndrome_type_name
            ,T1.remark
            ,T1.active_flag
            ,T1.uni_record_id
            ,T1.craet_time
            ,T1.update_time
            ,T1.version
            ,T1.version_name
        FROM(
                SELECT
                    tcm_syndrome_id
                    ,syndrome_class_code
                    ,syndrome_class_name
                    ,syndrome_property_code
                    ,syndrome_property
                    ,syndrome_type_code
                    ,syndrome_type_name
                    ,remark
                    ,active_flag
                    ,uni_record_id
                    ,craet_time
                    ,update_time
                    ,version
                    ,version_name
                FROM yb_catalog_zy_syndrome
            ) AS T1
        ${ew.customSqlSegment}
    </select>
    <select id="get1314Page" resultType="com.openhis.ybcatalog.domain.CatalogZyDiseaseDiagnosis">
        SELECT
            id
            ,T1.category_code
            ,T1.category_name
            ,T1.specialty_system_category_code
            ,T1.specialty_system_category_name
            ,T1.disease_category_code
            ,T1.disease_category_name
            ,T1.remarks
            ,T1.valid_flag
            ,T1.unique_record_id
            ,T1.create_time
            ,T1.update_time
            ,T1.version_number
            ,T1.version_name
        FROM(
                SELECT
                    id
                    ,category_code
                    ,category_name
                    ,specialty_system_category_code
                    ,specialty_system_category_name
                    ,disease_category_code
                    ,disease_category_name
                    ,remarks
                    ,valid_flag
                    ,unique_record_id
                    ,create_time
                    ,update_time
                    ,version_number
                    ,version_name
                FROM yb_catalog_zy_syndrome
            ) AS T1
            ${ew.customSqlSegment}
    </select>
    <select id="get1308Page" resultType="com.openhis.ybcatalog.domain.CatalogSurgeryStandardDirectory">
        SELECT
            id
            ,T1.chapter
            ,T1.chapter_code_range
            ,T1.chapter_name
            ,T1.category_code
            ,T1.category_name
            ,T1.subcategory_code
            ,T1.subcategory_name
            ,T1.item_code
            ,T1.item_name
            ,T1.operation_code
            ,T1.operation_name
            ,T1.usage_flag
            ,T1.group_standard_operation_code
            ,T1.group_standard_operation_name
            ,T1.clinical_version_operation_code
            ,T1.clinical_version_operation_name
            ,T1.remarks
            ,T1.valid_flag
            ,T1.unique_record_id
            ,T1.create_time
            ,T1.update_time
            ,T1.version_number
            ,T1.version_name
        FROM(
                SELECT
                    id
                    ,chapter
                    ,chapter_code_range
                    ,chapter_name
                    ,category_code
                    ,category_name
                    ,subcategory_code
                    ,subcategory_name
                    ,item_code
                    ,item_name
                    ,operation_code
                    ,operation_name
                    ,usage_flag
                    ,group_standard_operation_code
                    ,group_standard_operation_name
                    ,clinical_version_operation_code
                    ,clinical_version_operation_name
                    ,remarks
                    ,valid_flag
                    ,unique_record_id
                    ,create_time
                    ,update_time
                    ,version_number
                    ,version_name
                FROM yb_catalog_surgery_standard_directory
            ) AS T1
            ${ew.customSqlSegment}
    </select>
    <select id="get1307Page" resultType="com.openhis.ybcatalog.domain.CatalogWesternDisease">
        SELECT
            disease_id
            ,T1.chapter
            ,T1.chapter_code_range
            ,T1.chapter_name
            ,T1.section_code_range
            ,T1.section_name
            ,T1.category_code
            ,T1.category_name
            ,T1.subcategory_code
            ,T1.subcategory_name
            ,T1.diagnosis_code
            ,T1.diagnosis_name
            ,T1.usage_flag
            ,T1.gb_diagnosis_code
            ,T1.gb_diagnosis_name
            ,T1.clinical_code
            ,T1.clinical_name
            ,T1.remarks
            ,T1.valid_flag
            ,T1.unique_record_id
            ,T1.create_time
            ,T1.update_time
            ,T1.version_number
            ,T1.version_name
        FROM(
                SELECT
                    disease_id
                     ,chapter
                     ,chapter_code_range
                     ,chapter_name
                     ,section_code_range
                     ,section_name
                     ,category_code
                     ,category_name
                     ,subcategory_code
                     ,subcategory_name
                     ,diagnosis_code
                     ,diagnosis_name
                     ,usage_flag
                     ,gb_diagnosis_code
                     ,gb_diagnosis_name
                     ,clinical_code
                     ,clinical_name
                     ,remarks
                     ,valid_flag
                     ,unique_record_id
                     ,create_time
                     ,update_time
                     ,version_number
                     ,version_name
                FROM yb_catalog_western_disease
            ) AS T1
            ${ew.customSqlSegment}
    </select>
    <select id="get1306Page" resultType="com.openhis.ybcatalog.domain.CatalogMedicalConsumables">
        SELECT
            T1.medical_catalog_code
            ,T1.consumable_name
            ,T1.device_unique_id
            ,T1.insurance_generic_code
            ,T1.insurance_generic_name
            ,T1.product_model
            ,T1.spec_code
            ,T1.specification
            ,T1.consumable_category
            ,T1.spec_model
            ,T1.material_code
            ,T1.material_type
            ,T1.package_spec
            ,T1.package_quantity
            ,T1.package_material
            ,T1.package_unit
            ,T1.conversion_ratio
            ,T1.min_usage_unit
            ,T1.production_area_type
            ,T1.production_area_name
            ,T1.product_standard
            ,T1.expiry_date
            ,T1.structure_composition
            ,T1.applicable_scope
            ,T1.usage_method
            ,T1.image_code
            ,T1.quality_standard
            ,T1.instructions
            ,T1.proof_materials
            ,T1.special_device_flag
            ,T1.special_device_name
            ,T1.kit_name
            ,T1.kit_flag
            ,T1.usage_restriction_flag
            ,T1.insurance_restriction
            ,T1.min_sale_unit
            ,T1.high_value_flag
            ,T1.medical_material_code
            ,T1.implant_flag
            ,T1.sterilization_flag
            ,T1.sterilization_name
            ,T1.implant_intervention_flag
            ,T1.implant_intervention_name
            ,T1.disposable_flag
            ,T1.disposable_flag_name
            ,T1.registrant_name
            ,T1.start_date
            ,T1.end_date
            ,T1.device_management_category
            ,T1.device_category_name
            ,T1.registration_no
            ,T1.registered_product_name
            ,T1.structure_details
            ,T1.other_content
            ,T1.approval_date
            ,T1.registrant_address
            ,T1.cert_effective_start
            ,T1.cert_effective_end
            ,T1.manufacturer_code
            ,T1.manufacturer_name
            ,T1.production_address
            ,T1.agent_company
            ,T1.agent_address
            ,T1.production_country
            ,T1.service_agency
            ,T1.cert_archive_path
            ,T1.product_images
            ,T1.valid_flag
            ,T1.unique_record_id
            ,T1.version_number
            ,T1.version_name
        FROM(
                SELECT
                    medical_catalog_code
                     ,T1.consumable_name
                     ,T1.device_unique_id
                     ,insurance_generic_code
                     ,insurance_generic_name
                     ,product_model
                     ,spec_code
                     ,specification
                     ,consumable_category
                     ,spec_model
                     ,material_code
                     ,material_type
                     ,package_spec
                     ,package_quantity
                     ,package_material
                     ,package_unit
                     ,conversion_ratio
                     ,min_usage_unit
                     ,production_area_type
                     ,production_area_name
                     ,product_standard
                     ,expiry_date
                     ,structure_composition
                     ,applicable_scope
                     ,usage_method
                     ,image_code
                     ,quality_standard
                     ,instructions
                     ,proof_materials
                     ,special_device_flag
                     ,special_device_name
                     ,kit_name
                     ,kit_flag
                     ,usage_restriction_flag
                     ,insurance_restriction
                     ,min_sale_unit
                     ,high_value_flag
                     ,medical_material_code
                     ,implant_flag
                     ,sterilization_flag
                     ,sterilization_name
                     ,implant_intervention_flag
                     ,implant_intervention_name
                     ,disposable_flag
                     ,disposable_flag_name
                     ,registrant_name
                     ,start_date
                     ,end_date
                     ,device_management_category
                     ,device_category_name
                     ,registration_no
                     ,registered_product_name
                     ,structure_details
                     ,other_content
                     ,approval_date
                     ,registrant_address
                     ,cert_effective_start
                     ,cert_effective_end
                     ,manufacturer_code
                     ,manufacturer_name
                     ,production_address
                     ,agent_company
                     ,agent_address
                     ,production_country
                     ,service_agency
                     ,cert_archive_path
                     ,product_images
                     ,valid_flag
                     ,unique_record_id
                     ,version_number
                     ,version_name
                FROM yb_catalog_medical_consumables
            ) AS T1
            ${ew.customSqlSegment}
    </select>
    <select id="get1305Page" resultType="com.openhis.ybcatalog.domain.CatalogMedicalService">
        SELECT
             T1.tenant_id
            ,T1.medical_catalog_code
            ,T1.billing_unit
            ,T1.billing_unit_name
            ,T1.medical_item_desc
            ,T1.exclusion_content
            ,T1.medical_item_connotation
            ,T1.valid_flag
            ,T1.remarks
            ,T1.service_category
            ,T1.medical_service_name
            ,T1.project_description
            ,T1.start_date
            ,T1.end_date
            ,T1.unique_record_id
            ,T1.version_number
            ,T1.version_name
            ,T1.issuance_flag
            ,T1.transfer_data_id
            ,T1.effective_time
            ,T1.expiry_time
        FROM(
                SELECT
                    #{tenantId} AS  tenant_id
                    ,medical_catalog_code
                    ,billing_unit
                    ,billing_unit_name
                    ,medical_item_desc
                    ,exclusion_content
                    ,medical_item_connotation
                    ,valid_flag
                    ,remarks
                    ,service_category
                    ,medical_service_name
                    ,project_description
                    ,start_date
                    ,end_date
                    ,unique_record_id
                    ,version_number
                    ,version_name
                    ,issuance_flag
                    ,transfer_data_id
                    ,effective_time
                    ,expiry_time
                     -- 添加窗口函数用于分组内排序
                    ,ROW_NUMBER() OVER (
                PARTITION BY medical_catalog_code
                ORDER BY version_number DESC
            ) AS row_num_max
                FROM yb_catalog_medical_service
            ) AS T1
            ${ew.customSqlSegment}
    </select>
    <select id="get1302Page" resultType="com.openhis.ybcatalog.domain.CatalogMedicalHerbInfo">
        SELECT
            T1.medical_catalog_code,
            T1.single_drug_name,
            T1.single_compound_flag,
            T1.quality_grade,
            T1.herbal_year,
            T1.medicinal_part,
            T1.safe_dosage,
            T1.conventional_usage,
            T1.properties_taste,
            T1.meridian_attribution,
            T1.species,
            T1.start_date,
            T1.end_date,
            T1.valid_flag,
            T1.unique_record_id,
            T1.create_time,
            T1.update_time,
            T1.version_number,
            T1.version_name,
            T1.herb_name,
            T1.indications,
            T1.processing_method,
            T1.efficacy_classification,
            T1.herb_source,
            T1.national_insurance_policy,
            T1.provincial_insurance_policy,
            T1.standard_name,
            T1.standard_page,
            T1.electronic_record,
            T1.issuance_flag,
            T1.transfer_data_id,
            T1.effective_time,
            T1.expiry_time
        FROM(
                SELECT
                    medical_catalog_code,
                    single_drug_name,
                    single_compound_flag,
                    quality_grade,
                    herbal_year,
                    medicinal_part,
                    safe_dosage,
                    conventional_usage,
                    properties_taste,
                    meridian_attribution,
                    species,
                    start_date,
                    end_date,
                    valid_flag,
                    unique_record_id,
                    create_time,
                    update_time,
                    version_number,
                    version_name,
                    herb_name,
                    indications,
                    processing_method,
                    efficacy_classification,
                    herb_source,
                    national_insurance_policy,
                    provincial_insurance_policy,
                    standard_name,
                    standard_page,
                    electronic_record,
                    issuance_flag,
                    transfer_data_id,
                    effective_time,
                    expiry_time
                FROM
                    yb_catalog_medical_herb_info
            ) AS T1
            ${ew.customSqlSegment}
    </select>
    <select id="get1301Page" resultType="com.openhis.ybcatalog.domain.CatalogDrugInfo">
        SELECT
             T1.tenant_id
            ,T1.medical_catalog_code
            ,T1.drug_trade_name
            ,T1.generic_name_id
            ,T1.drug_generic_name
            ,T1.chemical_name
            ,T1.alias
            ,T1.english_name
            ,T1.registered_name
            ,T1.drug_supervision_code
            ,T1.drug_form
            ,T1.drug_form_name
            ,T1.drug_category
            ,T1.drug_category_name
            ,T1.drug_specification
            ,T1.drug_spec_code
            ,T1.registered_form
            ,T1.registered_spec
            ,T1.registered_spec_code
            ,T1.dosage
            ,T1.frequency
            ,T1.acid_base
            ,T1.national_drug_code
            ,T1.usage
            ,T1.tcm_flag
            ,T1.production_area_type
            ,T1.production_area_name
            ,T1.pricing_unit_type
            ,T1.otc_flag
            ,T1.otc_flag_name
            ,T1.packaging_material
            ,T1.packaging_material_name
            ,T1.packaging_spec
            ,T1.packaging_quantity
            ,T1.function_indication
            ,T1.administration_route
            ,T1.instructions
            ,T1.start_date
            ,T1.end_date
            ,T1.min_use_unit
            ,T1.min_sale_unit
            ,T1.min_measurement_unit
            ,T1.min_package_quantity
            ,T1.min_package_unit
            ,T1.min_preparation_unit
            ,T1.min_package_unit_name
            ,T1.min_preparation_unit_name
            ,T1.conversion_ratio
            ,T1.shelf_life
            ,T1.min_pricing_unit
            ,T1.wubi_code
            ,T1.pinyin_code
            ,T1.repackager
            ,T1.manufacturer_code
            ,T1.manufacturer_name
            ,T1.special_price_limit_flag
            ,T1.special_drug_flag
            ,T1.use_restriction
            ,T1.use_restriction_flag
            ,T1.registration_cert_no
            ,T1.reg_cert_start_date
            ,T1.reg_cert_end_date
            ,T1.approval_no
            ,T1.approval_start_date
            ,T1.approval_end_date
            ,T1.market_status
            ,T1.market_status_name
            ,T1.reg_document_archive
            ,T1.supp_application_archive
            ,T1.national_insurance_notes
            ,T1.essential_drug_flag_name
            ,T1.essential_drug_flag
            ,T1.vat_adjustment_flag
            ,T1.vat_adjustment_name
            ,T1.listed_drug_flag
            ,T1.negotiation_drug_flag
            ,T1.negotiation_drug_name
            ,T1.nhc_drug_code
            ,T1.remarks
            ,T1.valid_flag
            ,T1.unique_record_id
            ,T1.created_at
            ,T1.updated_at
            ,T1.version
            ,T1.version_name
            ,T1.pediatric_use
            ,T1.company_name
            ,T1.generic_evaluation_flag
            ,T1.distribution_company
            ,T1.distribution_contact
            ,T1.distribution_auth_archive
            ,T1.insurance_form
            ,T1.insurance_class
            ,T1.marketing_authorization_holder
            ,T1.release_flag
            ,T1.transmission_data_id
            ,T1.valid_from
            ,T1.valid_to
        FROM(
                SELECT
                     #{tenantId} AS tenant_id
                     ,medical_catalog_code
                     ,drug_trade_name
                     ,generic_name_id
                     ,drug_generic_name
                     ,chemical_name
                     ,alias
                     ,english_name
                     ,registered_name
                     ,drug_supervision_code
                     ,drug_form
                     ,drug_form_name
                     ,drug_category
                     ,drug_category_name
                     ,drug_specification
                     ,drug_spec_code
                     ,registered_form
                     ,registered_spec
                     ,registered_spec_code
                     ,dosage
                     ,frequency
                     ,acid_base
                     ,national_drug_code
                     ,usage
                     ,tcm_flag
                     ,production_area_type
                     ,production_area_name
                     ,pricing_unit_type
                     ,otc_flag
                     ,otc_flag_name
                     ,packaging_material
                     ,packaging_material_name
                     ,packaging_spec
                     ,packaging_quantity
                     ,function_indication
                     ,administration_route
                     ,instructions
                     ,start_date
                     ,end_date
                     ,min_use_unit
                     ,min_sale_unit
                     ,min_measurement_unit
                     ,min_package_quantity
                     ,min_package_unit
                     ,min_preparation_unit
                     ,min_package_unit_name
                     ,min_preparation_unit_name
                     ,conversion_ratio
                     ,shelf_life
                     ,min_pricing_unit
                     ,wubi_code
                     ,pinyin_code
                     ,repackager
                     ,manufacturer_code
                     ,manufacturer_name
                     ,special_price_limit_flag
                     ,special_drug_flag
                     ,use_restriction
                     ,use_restriction_flag
                     ,registration_cert_no
                     ,reg_cert_start_date
                     ,reg_cert_end_date
                     ,approval_no
                     ,approval_start_date
                     ,approval_end_date
                     ,market_status
                     ,market_status_name
                     ,reg_document_archive
                     ,supp_application_archive
                     ,national_insurance_notes
                     ,essential_drug_flag_name
                     ,essential_drug_flag
                     ,vat_adjustment_flag
                     ,vat_adjustment_name
                     ,listed_drug_flag
                     ,negotiation_drug_flag
                     ,negotiation_drug_name
                     ,nhc_drug_code
                     ,remarks
                     ,valid_flag
                     ,unique_record_id
                     ,created_at
                     ,updated_at
                     ,version
                     ,version_name
                     ,pediatric_use
                     ,company_name
                     ,generic_evaluation_flag
                     ,distribution_company
                     ,distribution_contact
                     ,distribution_auth_archive
                     ,insurance_form
                     ,insurance_class
                     ,marketing_authorization_holder
                     ,release_flag
                     ,transmission_data_id
                     ,valid_from
                     ,valid_to
                     -- 添加窗口函数用于分组内排序
                     ,ROW_NUMBER() OVER (
                    PARTITION BY medical_catalog_code
                    ORDER BY version DESC
                    ) AS row_num_max
                FROM yb_catalog_drug_info
            ) AS T1
            ${ew.customSqlSegment}
    </select>
</mapper>