# FRIDAY SaaS 标准化字段临时映射

## 1. 患者一句话总结

患者主档需要宿主提供 `customer_basic_info`、`customer_contacts`、`customer_label`、`customer_description`。

## 1.1 患者宿主需提供表

| 表 | 用途 |
| --- | --- |
| `customer_basic_info` | 患者主档、品牌、获客来源 |
| `customer_contacts` | 患者默认手机号 |
| `customer_label` | 患者标签 |
| `customer_description` | 患者备注 |

## 1.2 PAC patients

| PAC 字段 | FRIDAY 候选 |
| --- | --- |
| `id` | PAC 生成 UUID |
| `host_id` | PAC `hosts.id` |
| `tenant_id` | 固定集团 slug |
| `source_unit` | 品牌 ID |
| `external_id` | `customer_basic_info.id` |
| `name` | `customer_basic_info.name` |
| `phone` | `customer_contacts.contacts_tel` where `contacts_type=1` and `is_default=1` |
| `gender` | `customer_basic_info.sex` |
| `birth_date` | `customer_basic_info.birthday` |
| `medical_record_number` | `customer_basic_info.file_number` |
| `preferences` |  |
| `active` |  |
| `created_at` | PAC 写入时间 |
| `updated_at` | PAC 写入时间 |

## 1.3 PAC patient_profiles

| PAC 字段 | FRIDAY 候选 |
| --- | --- |
| `patient_id` | PAC `patients.id` |
| `do_not_contact` |  |
| `do_not_contact_reason` |  |
| `do_not_contact_at` |  |
| `deceased` |  |
| `deceased_at` |  |
| `tags` | `customer_label.label_name[]` |
| `notes` | `customer_description.description` |
| `acquisition_channel` | `customer_basic_info.informed_first_name` |
| `acquisition_sub` | `customer_basic_info.informed_second_name` |
| `referral_count` | TODO |
| `referral_amount_cents` | TODO |
| `created_at` | PAC 写入时间 |
| `updated_at` | PAC 写入时间 |

## 2. 预约一句话总结

预约数据需要宿主提供 `appointment_base`、 `appointment_complaint`、`appointment_cancel`。

## 2.1 预约宿主需提供表

| 表                        | 用途        |
| ------------------------ | --------- |
| `appointment_base`       | 预约主记录     |
| `appointment_complaint`  | 预约主诉      |
| `appointment_cancel`     | 取消 / 改约原因 |

## 2.2 PAC appointment_record content

| PAC content 字段            | FRIDAY 候选                                                                         |
| ------------------------- | --------------------------------------------------------------------------------- |
| `appointment_external_id` | `appointment_base.id`                                                             |
| `scheduled_at`            | `appointment_base.appointment_date` + `appointment_base.appointment_start`        |
| `arrived_at`              | `appointment_base.in_time`                                                        |
| `doctor_id`               | `appointment_base.doctor_user_id`                                                 |
| `complaint_category`      | `appointment_complaint.complaint_category_name`                                   |
| `complaint_text`          | `appointment_complaint.complaint_name`                                            |
| `duration_minutes`        | `appointment_base.appointment_time_length`                                        |
| `cancellation_reason`     | `appointment_cancel.cancel_cause_name` / `appointment_cancel.cancel_cause_custom` |
| `staff_notes`             | `appointment_base.remark`                                                         |
| `status`                  | `appointment_base.appointment_status`                                             |

## 3. 接诊一句话总结

接诊数据需要宿主提供 `visit_info`。

## 3.1 接诊宿主需提供表

| 表               | 用途                        |
| --------------- | ------------------------- |
| `visit_info`    | 接诊主记录、预约关联、医生、就诊状态、就诊起止时间 |


## 3.2 PAC encounter_record content

| PAC content 字段          | FRIDAY 候选                |
| ----------------------- | ------------------------ |
| `encounter_external_id` | `visit_info.id`          |
| `doctor_id`             | `visit_info.doctor_id`   |
| `doctor_name`           | `visit_info.doctor_name` |
| `chief_complaint`       |                          |
| `notes`                 |                          |

## 4. EMR 一句话总结

EMR 数据需要宿主提供 `med_emr`、`med_emr_info`，通过 `visit_info` 回连接诊。

## 4.1 EMR 宿主需提供表

| 表 | 用途 |
| --- | --- |
| `med_emr` | 病历索引、患者、预约、医生、病历状态 |
| `med_emr_info` | 病历正文 |
| `visit_info` | 回连 PAC encounter |

## 4.2 PAC emr_record content

| PAC content 字段          | FRIDAY 候选                                                                   |
| ----------------------- | --------------------------------------------------------------------------- |
| `emr_external_id`       | `med_emr.emr_sub_id`                                                        |
| `encounter_external_id` | `visit_info.id` where `visit_info.registration_id = med_emr.appointment_id` |
| `doctor_id`             | `med_emr.user_id`                                                           |
| `doctor_name`           | `med_emr.user_name`                                                         |
| `illness_desc`          | `med_emr.illness_desc`                                                      |
| `pre_illness`           | `med_emr_info.pre_illness`                                                  |
| `past_history`          | `med_emr_info.past_hist`                                                    |
| `general_condition`     | `med_emr_info.gen_cond`                                                     |
| `exam_findings`         | `med_emr_info.examine` / `med_emr_info.auxi_exam`                           |
| `diagnosis_text`        | `med_emr_info.diag`                                                         |
| `treatment_plan`        | `med_emr_info.treat`                                                        |
| `disposal`              | `med_emr_info.dispose`                                                      |
| `doctor_advice`         | `med_emr_info.doc_order`                                                    |
| `quality_check`         | `med_emr_info.status`                                                       |

## 5. 诊断一句话总结

诊断数据需要宿主提供 `med_emr_info.diag[]`，可选补充 `std_diag`。

## 5.1 诊断宿主需提供表

| 表 | 用途 |
| --- | --- |
| `med_emr_info` | 病历正文 Mongo collection，`diag[]` 保存患者诊断 |
| `med_emr` | 病历索引、医生、患者、预约 |
| `visit_info` | 回连 PAC encounter |
| `std_diag` | 标准诊断词典 |

## 5.2 PAC diagnosis_record content

| PAC content 字段                 | FRIDAY 候选                                                                   |
| ------------------------------ | --------------------------------------------------------------------------- |
| `code`                         | `med_emr_info.diag[].link_code` / `std_diag.std_code`                       |
| `code_source`                  | `std_code`                                                                  |
| `name_zh`                      | `med_emr_info.diag[].value` / `std_diag.diag_name`                          |
| `tooth_position`               | `med_emr_info.diag[].tooth_position`                                        |
| `severity`                     |                                                                             |
| `onset_date`                   |                                                                             |
| `doctor_id`                    | `med_emr.user_id`                                                           |
| `doctor_name`                  | `med_emr.user_name`                                                         |
| `source_encounter_external_id` | `visit_info.id` where `visit_info.registration_id = med_emr.appointment_id` |

## 6. 治疗一句话总结

治疗数据需要宿主提供 `therapy_plan`、`visit_therapy_order`，可选补充 `med_emr_info.treat[]`、`med_emr_info.dispose[]`、`std_treat`。

## 6.1 治疗宿主需提供表

| 表 | 用途 |
| --- | --- |
| `therapy_plan` | 患者治疗计划、状态、医生、接诊关联 |
| `visit_therapy_order` | 治疗服务项、数量、单位、执行状态 |
| `visit_info` | 回连 PAC encounter |
| `med_emr_info` | 病历正文 Mongo collection，`treat[]` / `dispose[]` 保存病历治疗文本 |
| `std_treat` | 标准治疗词典 |

## 6.2 PAC treatment_record content

| PAC content 字段 | FRIDAY 候选 |
| --- | --- |
| `category` | `visit_therapy_order.cure_info_name` / `visit_therapy_order.service_project_name` / `med_emr_info.treat[].value` |
| `subtype` | `visit_therapy_order.spec_name` / `visit_therapy_order.subject_class_name` |
| `tooth_position` | `med_emr_info.treat[].tooth_position` / `med_emr_info.dispose[].tooth_position` |
| `status` | `therapy_plan.plan_status` / `visit_therapy_order.status` |
| `started_at` | `therapy_plan.created_gmt_at` |
| `completed_at` | `therapy_plan.updated_gmt_at` when `therapy_plan.plan_status=3` |
| `doctor_id` | `therapy_plan.doctor_id` / `visit_therapy_order.doctor_id` |
| `doctor_name` | `therapy_plan.doctor_name` |
| `quantity` | `visit_therapy_order.number` |
| `unit_name` | `visit_therapy_order.unit_name` |
| `treat_stages` |  |
| `source_encounter_external_id` | `therapy_plan.visit_id` |
| `related_diagnosis_subject_id` |  |
| `review_window_days` |  |

## 7. 影像和影像分析一句话总结

影像数据需要宿主提供 `med_check`、`med_emr_check`；影像分析 FRIDAY 代码未见独立表，PAC 落 `agent_invocations.output` / `agent_invocations.output_text`。

## 7.1 影像宿主需提供表

| 表 | 用途 |
| --- | --- |
| `med_check` | 影像/检查文件主记录 |
| `med_emr_check` | 病历与影像关联 |
| `med_emr` | 回连预约、医生、患者 |
| `visit_info` | 回连 PAC encounter |
| `std_check_class` | 影像/检查分类词典 |

## 7.2 PAC image_record content

| PAC content 字段 | FRIDAY 候选 |
| --- | --- |
| `image_external_id` | `med_check.id` |
| `encounter_external_id` | `visit_info.id` where `visit_info.registration_id = med_emr.appointment_id` |
| `modality` | `med_check.file_type` / `med_check.class_code` / `std_check_class.class_name` |
| `tooth_positions` |  |
| `finding` | `med_check.file_desc` |
| `captured_at` | `med_check.shooting_time` |
| `doctor_id` | `med_check.user_id` / `med_emr.user_id` |
| `doctor_name` | `med_check.user_name` / `med_emr.user_name` |

## 8. 收款一句话总结

收款数据需要宿主提供 `patient_settlement`，通过 `patient_settlement_spec` 补项目/折扣，通过 `settlement_modes` 补支付渠道/卡券。

## 8.1 收款宿主需提供表

| 表 | 用途 |
| --- | --- |
| `patient_settlement` | 结算单主表 |
| `patient_settlement_spec` | 结算单收费项目明细 |
| `settlement_modes` | 结算支付方式/卡券/储值 |
| `visit_info` | 通过 `patient_settlement.registration_id` 回连 PAC encounter |

## 8.2 PAC payment_record content

| PAC content 字段 | FRIDAY 候选 |
| --- | --- |
| `payment_external_id` | `patient_settlement.uuid` |
| `amount_cents` | `patient_settlement.net_receipts_this` / sum(`settlement_modes.money`) |
| `channel` | `settlement_modes.modes_name` / `settlement_modes.modes` |
| `insurance_name` | `patient_settlement.insurance_name` |
| `card_type_name` |  |
| `card_name` | `settlement_modes.card_name` / `patient_settlement.welfare_cards` / `patient_settlement_spec.used_welfare_name` |
| `discount_cents` | `patient_settlement.hospital_receipts` + `patient_settlement.custom_company_receipts` + `patient_settlement.special_welfare_receipts` |
| `settlement_project` | `patient_settlement_spec.service_project_name` / `patient_settlement_spec.cure_name` / `patient_settlement_spec.classify_name` |
| `doctor_id` | `patient_settlement.doctor_id` / `patient_settlement_spec.doctor_id` |
| `encounter_external_id` | `visit_info.id` where `visit_info.registration_id = patient_settlement.registration_id` |
| `related_order_external_id` | `patient_settlement.visit_therapy_id` / `patient_settlement_spec.order_pricing_id` |

## 9. 退款一句话总结

退款数据需要宿主提供 `patient_settlement` 退款行，`ref_settlement_id` 关联原结算单；退款原因可从 `patient_problem_list` 补。

## 9.1 退款宿主需提供表

| 表 | 用途 |
| --- | --- |
| `patient_settlement` | 退款结算单主记录 |
| `patient_settlement_spec` | 退款收费项目明细 |
| `settlement_modes` | 退款支付方式/卡券/储值回滚 |
| `patient_problem_list` | 退款申请、原因、协议 |
| `refund_audit` | 退费审核信息 |
| `refund_audit_auditing_reason` | 退费审核失败原因 |

## 9.2 PAC refund_record content

| PAC content 字段 | FRIDAY 候选 |
| --- | --- |
| `refund_external_id` | `patient_settlement.uuid` |
| `amount_cents` | abs(`patient_settlement.net_receipts_this`) / abs(sum(`settlement_modes.money`)) |
| `reason` | `patient_problem_list.reason` / `patient_problem_list.refuse_reason` / `refund_audit_auditing_reason.auditing_reason` |
| `related_payment_external_id` | `patient_settlement.ref_settlement_id` |

## 10. 充值/储值/福利卡一句话总结

充值/储值数据需要宿主提供 `transaction_records`，账户信息用 `patient_pre_deposit`，支付方式用 `pay_method`，福利卡权益用 `old_welfare` / `welfare_activity` / `welfare_activity_detail`。

## 10.1 充值/储值/福利卡宿主需提供表

| 表 | 用途 |
| --- | --- |
| `transaction_records` | 预存款/储值交易流水 |
| `patient_pre_deposit` | 患者预存款账户 |
| `pay_method` | 充值支付方式 |
| `pay_records` | 预存款消费/退费关联 |
| `old_welfare` | 结算单绑定福利卡/储值卡 |
| `welfare_activity` | 福利活动 |
| `welfare_activity_detail` | 福利活动规则明细 |

## 10.2 PAC recharge_record content

| PAC content 字段 | FRIDAY 候选 |
| --- | --- |
| `recharge_external_id` | `transaction_records.id` |
| `amount_cents` | `transaction_records.principal_amount` + `transaction_records.donation_amount` |
| `card_type` | `transaction_records.pre_deposit_activity_name` / `old_welfare.card_type_name` / `old_welfare.card_name` |

## 11. 投诉一句话总结

投诉数据需要宿主提供 `complain_patient_handling`，跟进记录可补 `complain_follow_records`，处理人/权限可补 `complain_user_relationship`。

## 11.1 投诉宿主需提供表

| 表 | 用途 |
| --- | --- |
| `complain_patient_handling` | 投诉主表 |
| `complain_follow_records` | 投诉跟进记录 |
| `complain_user_relationship` | 投诉单处理人/人员关系 |
| `complain_type_info` | 投诉分类/渠道/对象枚举 |

## 11.2 PAC complaint_record content

| PAC content 字段 | FRIDAY 候选 |
| --- | --- |
| `complaint_external_id` | `complain_patient_handling.id` / `complain_patient_handling.complain_number` |
| `host_status` | `complain_patient_handling.complain_type` |
| `category` | `complain_patient_handling.complain_classification` / `complain_patient_handling.complain_concerned` |
| `content` | `complain_patient_handling.complain_content` |
| `related_treatment_subject_id` | `complain_patient_handling.settlement_number` / `complain_patient_handling.complain_treatment` |
| `resolved_at` | `complain_follow_records.follow_date` where `follow_type=4` |

## 12. 咨询一句话总结

咨询数据需要宿主提供 `customer_consult`，治疗方案补 `customer_treatment_schedule`，预约咨询师/会诊时间补 `appointment_consultation`。

## 12.1 咨询宿主需提供表

| 表 | 用途 |
| --- | --- |
| `customer_consult` | 客户咨询主体 |
| `customer_treatment_schedule` | 咨询治疗方案/预算 |
| `appointment_consultation` | 预约咨询师/会诊时间 |
| `appointment_base` | 回连预约与到诊 |

## 12.2 PAC consultation_record content

| PAC content 字段 | FRIDAY 候选 |
| --- | --- |
| `consultation_external_id` | `customer_consult.id` |
| `consult_date` | `customer_consult.created_gmt_at` / `appointment_consultation.consultation_date` |
| `source_channel` | `customer_consult.data_sources` |
| `intents` | `customer_consult.potential_treatment` / `customer_treatment_schedule.schedule_content` |
| `intent_categories` | `customer_consult.potential_treatment` / `customer_treatment_schedule.schedule_content` |
| `is_first_visit` |  |
| `task_director` | `customer_consult.task_director` / `appointment_consultation.consultation_resource_name` |
| `doctor_id` | `customer_consult.task_director_id` / `appointment_consultation.consultation_resource_id` |
| `appointment_external_id` | `appointment_consultation.appointment_id` / `customer_consult.task_id` |
| `intent` | `customer_consult.potential_treatment` |
| `content` | `customer_consult.treatment_plan` / `customer_consult.other_conditions` / `customer_consult.unsettled_reason_description` |

## 13. 回访一句话总结

回访数据需要宿主提供 `customer_task` + `customer_return_visit`，计划型诊后回访可补 `return_visit_plan`、`return_visit_plan_patient`、`return_visit_plan_record`。

## 13.1 回访宿主需提供表

| 表 | 用途 |
| --- | --- |
| `customer_task` | 回访任务主体/任务日期 |
| `customer_return_visit` | 回访内容/类型/结果 |
| `return_visit_plan` | 计划型诊后回访方案 |
| `return_visit_plan_patient` | 计划型回访患者 |
| `return_visit_plan_record` | 计划型回访执行记录 |

## 13.2 PAC patient_return_visit

| PAC 字段 | FRIDAY 候选 |
| --- | --- |
| `externalId` | `customer_return_visit.id` |
| `patientExternalId` | `customer_return_visit.customer_id` / `customer_task.customer_id` |
| `clinicId` | `customer_return_visit.organization_id` / `customer_task.organization_id` |
| `taskDate` | `customer_task.task_date` |
| `type` | `customer_return_visit.return_visit_type` |
| `status` | `customer_return_visit.return_visit_status` |
| `taskStatus` | `customer_task.task_status` |
| `treatmentItems` | `customer_return_visit.treatment_items` + `customer_return_visit.treatment_items_two` |
| `followContent` | `customer_return_visit.follow_content` |
| `result` | `customer_return_visit.return_visit_result` / `customer_task.remark` |

## 14. 主体关注表汇总

| 主体        | 需要关注的表                                                                                                              |
| --------- | ------------------------------------------------------------------------------------------------------------------- |
| 患者        | `customer_basic_info`、`customer_contacts`、`customer_label`、`customer_description`                                   |
| 预约        | `appointment_base`、`appointment_complaint`、`appointment_cancel`                                                     |
| 接诊        | `visit_info`                                                                                                        |
| EMR       | `med_emr`、`med_emr_info`、`visit_info`                                                                               |
| 诊断        | `med_emr_info`、`med_emr`、`visit_info`、`std_diag`                                                                    |
| 治疗        | `therapy_plan`、`visit_therapy_order`、`visit_info`、`med_emr_info`、`std_treat`                                        |
| 影像/影像分析   | `med_check`、`med_emr_check`、`med_emr`、`visit_info`、`std_check_class`                                                |
| 收款        | `patient_settlement`、`patient_settlement_spec`、`settlement_modes`、`visit_info`                                      |
| 退款        | `patient_settlement`、`patient_settlement_spec`、`settlement_modes`、`patient_problem_list`                            |
| 充值/储值/福利卡 | `transaction_records`、`patient_pre_deposit`、`pay_method`、`old_welfare`、`welfare_activity`、`welfare_activity_detail` |
| 投诉        | `complain_patient_handling`、`complain_follow_records`、`complain_user_relationship`                                  |
| 咨询        | `customer_consult`、`customer_treatment_schedule`、`appointment_consultation`、`appointment_base`                      |
| 回访        | `customer_task`、`customer_return_visit`、`return_visit_plan`、`return_visit_plan_patient`、`return_visit_plan_record`  |
