| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- import { decodeList } from '#/request/schema';
- // ---------------------------------------------------------------------------
- // 疾病类型 — DTO
- // ---------------------------------------------------------------------------
- export interface ICD10DTO {
- /** 主键 */
- id: string;
- /** 西医疾病名称 */
- name: string;
- /** 西医疾病编码 */
- code: string;
- /** 西医疾病副编码 */
- extCode: string;
- /** 版本 1:ICD10 2:临床版2.0 */
- vision: '1' | '2';
- /** 类型 1:标准 2:附加 */
- classify: '1' | '2';
- /** 备注 */
- remarks: string;
- }
- export interface DiseaseDTO {
- /** 主键 */
- id: string;
- /** 中医疾病名称 */
- name: string;
- /** 中医疾病编码 */
- code: string;
- /** 子疾病 */
- children?: DiseaseDTO[];
- /** 可选用词 */
- optionalWords?: string;
- /** 属性说明 */
- attributes?: { content: any; field: string; title: string }[];
- }
- export interface SymptomDTO {
- /** 主键 */
- id: string;
- /** 中医证型名称 */
- name: string;
- /** 中医证型编码 */
- code: string;
- /** 证候分析 */
- analysis: string;
- /** 备注 */
- remarks: string;
- }
- /** 推荐证型 / 治法 DTO,对应 `TreatmentDiagnoseVo` */
- export interface TreatmentDiagnoseDTO {
- disId?: string;
- disCode?: string;
- disName?: string;
- synId?: string;
- synCode?: string;
- synName?: string;
- therapyId?: string;
- therapyCode?: string;
- therapyName?: string;
- therapy?: string;
- classify?: string;
- preType?: string;
- }
- // ---------------------------------------------------------------------------
- // 疾病类型 — VO
- // ---------------------------------------------------------------------------
- export interface IllnessVO {
- /** 主键,-> `id` */
- id: string;
- /** 名称,-> `name` */
- name: string;
- /** 编码,-> `code` */
- code: string;
- }
- export interface ICD10VO extends IllnessVO {
- /** 类型,-> `classify` */
- type: '1' | '2';
- meta: {
- [K: string]: any;
- /** 副编码,-> `extCode` */
- extCode: string;
- /** 备注,-> `remarks` */
- remark: string;
- /** 版本,-> `vision` */
- versions: '1' | '2';
- };
- }
- export interface DiseaseVO extends IllnessVO {
- /** 子节点,-> `children` */
- children: DiseaseVO[];
- meta: {
- [K: string]: any;
- /** 属性说明,-> `attributes` */
- attributes?: { content: any; field: string; title: string }[];
- /** 可选用词,-> `optionalWords` */
- keywords: string[];
- };
- }
- export interface SymptomVO extends IllnessVO {
- meta: {
- [K: string]: any;
- /** 证候分析,-> `analysis` */
- analysis: string;
- /** 备注,-> `remarks` */
- remark: string;
- };
- }
- interface IllnessQueryVO {
- /** 搜索关键字,-> `keyWord` */
- keyword?: string;
- /** 关键字类型,-> `searchType` 1:拼音,2:五笔,3:中文 */
- keywordType?: string;
- /** 编码,-> `keyword` */
- name?: string;
- /** 编码,-> `code` */
- code?: string;
- /** 类型,-> `classify` 0:标准,1:扩充 */
- type?: '0' | '1';
- }
- export interface TreatDiagnoseQueryVO {
- keyword?: string;
- disId?: string;
- disCode?: string;
- disName?: string;
- synId?: string;
- synCode?: string;
- synName?: string;
- therapyId?: string;
- therapyCode?: string;
- therapyName?: string;
- therapy?: string;
- classify?: string;
- preType?: string;
- }
- // ---------------------------------------------------------------------------
- // 编解码
- // ---------------------------------------------------------------------------
- export const decodeICD10 = (dto: ICD10DTO): ICD10VO => ({
- id: dto.id,
- name: dto.name,
- code: dto.code,
- type: dto.classify,
- meta: {
- extCode: dto.extCode,
- remark: dto.remarks,
- versions: dto.vision,
- },
- });
- export const decodeDisease = (dto: DiseaseDTO): DiseaseVO => ({
- id: dto.id,
- name: dto.name,
- code: dto.code,
- children: decodeList(dto.children ?? [], decodeDisease),
- meta: {
- attributes: Array.isArray(dto.attributes) ? dto.attributes : [],
- keywords: Array.isArray(dto.optionalWords) ? dto.optionalWords : [],
- },
- });
- export const decodeSymptom = (dto: SymptomDTO): SymptomVO => ({
- id: dto.id,
- name: dto.name,
- code: dto.code,
- meta: {
- analysis: dto.analysis,
- remark: dto.remarks,
- },
- });
- export const decodeTreatSyn = (dto: TreatmentDiagnoseDTO): IllnessVO => ({
- id: dto.synId ?? '',
- name: dto.synName ?? '',
- code: dto.synCode ?? '',
- });
- export const decodeTreatTherapy = (dto: TreatmentDiagnoseDTO): IllnessVO => ({
- id: dto.therapyId ?? '',
- name: dto.therapy ?? dto.therapyName ?? '',
- code: dto.therapyCode ?? '',
- });
- export const encodeTreatSynQuery = (
- query: Partial<TreatDiagnoseQueryVO>,
- ): Partial<TreatmentDiagnoseDTO> => {
- const keyword = query.keyword?.trim();
- return {
- disId: query.disId,
- disCode: query.disCode,
- disName: query.disName,
- synId: query.synId,
- synCode: query.synCode,
- synName: keyword || query.synName,
- classify: query.classify,
- preType: query.preType,
- };
- };
- export const encodeTreatTherapyQuery = (
- query: Partial<TreatDiagnoseQueryVO>,
- ): Partial<TreatmentDiagnoseDTO> => {
- const keyword = query.keyword?.trim();
- return {
- disId: query.disId,
- disCode: query.disCode,
- disName: query.disName,
- synId: query.synId,
- synCode: query.synCode,
- synName: query.synName,
- therapyId: query.therapyId,
- therapyCode: query.therapyCode,
- therapy: keyword || query.therapy,
- therapyName: keyword || query.therapyName,
- classify: query.classify,
- preType: query.preType,
- };
- };
- export const encodeIllnessQuery = (
- query: Partial<IllnessQueryVO>,
- ): Record<string, any> => {
- const keyword = query.name || query.keyword;
- const keywordType =
- query.keywordType ??
- ((value: string) => {
- if (!value) return void 0;
- if (/[\u4E00-\u9FFF]/.test(value)) return '3';
- return '1';
- })(keyword ?? '');
- return {
- keyWord: query.keyword,
- keyword: query.name,
- searchType: keywordType,
- code: query.code,
- classify: query.type,
- };
- };
|