import request from '/@/utils/request';
import type { PrinterSjcsParams, ListRecentSummaryListParams, ListRecordsByPatItem, AdvanceDeliveryParams, AdvanceDelivery } from './types'
import { AxiosPromise } from 'axios';
import type { 
	IGetRecordsInTodayParams, 
	IRecordsInToday, 
	IListReadyRowsParams, 
	IListReadyRows, 
	IListStatInfoParams, 
	IListStatInfo,
	IPrepareWorkParams,
	IPrepareWork,
	IPrepareWorkMedicineParams,
	IPrepareWorkMedicine,
	IPrepareWorkMedicineStatParams,
	IPrepareWorkMedicineStat,
	IFixedDrugStatisticsParams,
	IFixedDrugStatistics,
	IStatisticBothItemDrugsParams,
	IStatisticBothItemDrugsItem,
	IListRecordsByToolUsageDetailsParams,
	IListRecordsByToolUsageDetailsReponse,
} from './types/index.type';


export function Add(params: string) {
	return request({
		url: '/patient/hemo/med/record/add',
		method: 'post',
		data: params,
	});
}
export function update(params: string) {
	return request({
		url: '/patient/hemo/med/record/update',
		method: 'post',
		data: params,
	});
}
export function deleteId(params: string) {
	return request({
		url: '/patient/hemo/med/record/delete',
		method: 'post',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data: params,
	});
}
export function list(params: object) {
    return request({
		url: '/patient/hemo/med/record/list',
		method: 'post',
		headers: {
		'Content-Type': 'application/x-www-form-urlencoded'
		},
		params
    })
}
export function syncClothesWeight(params: object) {
    return request({
		url: '/patient/hemo/med/record/syncClothesWeight',
		method: 'post',
		headers: {
		'Content-Type': 'application/x-www-form-urlencoded'
		},
		params
    })
}

/**
 * 获取透析单列表
 * @param params 
 * @returns 
 */
export function getRecordsInToday(params: IGetRecordsInTodayParams): AxiosPromise<IRecordsInToday[]> {
    return request({
		url: '/patient/hemo/med/record/getRecordsInToday2',
		method: 'post',
		data:params
    })
}

/**
 * 获取透析单详情
 * @param params 
 * @returns 
 */
export function getRecordsDetail(params: string) {
    return request({
		url: '/patient/hemo/med/record/detail2',
		method: 'post',
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data: params,
    })
}

/**
 * 获取透析耗材准备Api
 * @param params 
 * @returns 
 */
export function listReadyRows(params: IListReadyRowsParams) :AxiosPromise<IListReadyRows[]> {
    return request({
		url: '/patient/hemo/med/record/listReadyRows',
		method: 'post',
		data:params
    })
}

/**
 * 获取透析耗材统计Api
 * @param params 
 * @returns 
 */
export function listStatInfo(params: IListStatInfoParams) :AxiosPromise<IListStatInfo[]> {
    return request({
		url: '/patient/hemo/med/record/listStatInfo',
		method: 'post',
		data:params
    })
}

/**
 * 获取上机参数Api
 * @param params 
 * @returns 
 */
export function prepareWork(params: IPrepareWorkParams) :AxiosPromise<IPrepareWork[]> {
    return request({
		url: '/patient/hemo/med/record/prepareWork',
		method: 'post',
		data:params
    })
}

/**
 * 获取药品准备Api
 * @param params 
 * @returns 
 */
export function prepareWorkMedicine(params: IPrepareWorkMedicineParams) :AxiosPromise<IPrepareWorkMedicine[]> {
    return request({
		url: '/patient/hemo/med/record/prepareWorkMedicine',
		method: 'post',
		data:params
    })
}

/**
 * 获取药品统计Api
 * @param params 
 * @returns 
 */
export function prepareWorkMedicineStat(params: IPrepareWorkMedicineStatParams) :AxiosPromise<IPrepareWorkMedicineStat[]> {
    return request({
		url: '/patient/hemo/med/record/prepareWorkMedicineStat',
		method: 'post',
		data:params
    })
}
export function batchPrint(params: object) {
    return request({
		url: '/patient/hemo/med/record/batchPrint',
		method: 'post',
		data:params
    })
}
export function batchPrint2(params: object) {
    return request({
		url: '/patient/hemo/med/record/batchPrint2',
		method: 'post',
		data:params
    })
}
export  async function batchPrintAwait(params: object) {
    return request({
		url: '/patient/hemo/med/record/batchPrint2',
		method: 'post',
		data:params
    })
}
export function doCheck(params: string) {
    return request({
		url: '/patient/hemo/med/record/doCheck2',
		method: 'post',
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data: params,
    })
}
export function doArchive(params: string) {
    return request({
		url: '/patient/hemo/med/record/doArchive',
		method: 'post',
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data: params,
    })
}
export function listMonitorDatas1(params: object) {
    return request({
		url: '/patient/hemo/med/record/listMonitorDatas1',
		method: 'post',
		data:params
    })
}

export function listMonitorDatas2(params: object) {
    return request({
		url: '/patient/hemo/med/record/listMonitorDatas2',
		method: 'post',
		data:params
    })
}
export function listRecordCountByPat(params: object) {
    return request({
		url: '/patient/hemo/med/record/listRecordCountByPat',
		method: 'post',
		data:params
    })
}

export function updatePureWeight(params: object) {
    return request({
		url: '/patient/hemo/med/record/updatePureWeight',
		method: 'post',
		data:params
    })
}
export function listRecordsByPat(params: object): AxiosPromise<{ list: ListRecordsByPatItem[]; total: number; [key: string]: any;}> {
    return request({
		url: '/patient/hemo/med/record/listRecordsByPat',
		method: 'post',
		data:params
    })
}
export function printPrePaper(params: string) {
    return request({
		url: '/patient/hemo/med/record/printPrePaper',
		method: 'post',
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data: params,
    })
}
export function getSummary(params: object) {
    return request({
		url: '/patient/hemo/med/record/getSummary',
		method: 'post',
		headers: {
		'Content-Type': 'application/x-www-form-urlencoded'
		},
		params,
    })
}
export function getAlertSet(params: object) {
    return request({
		url: '/monitor/data/alert/getAlertSet',
		method: 'post',
		headers: {
		'Content-Type': 'application/x-www-form-urlencoded'
		},
		params,
    })
}
export function saveAlertSet(params: object) {
    return request({
		url: '/monitor/data/alert/saveAlertSet',
		method: 'post',
		data:params
    })
}
export function listWithCalendar(params: object) {
    return request({
        url: '/patient/hemo/med/record/listWithCalendar',
        method: 'post',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        params
    })
}
export function doUpdatePureState(params: object) {
    return request({
		url: '/patient/hemo/med/record/doUpdatePureState',
		method: 'post',
		headers: {
		'Content-Type': 'application/x-www-form-urlencoded'
		},
		params,
    })
}
export function listRecordsHistory(params: object) {
    return request({
		url: '/patient/hemo/med/record/listRecordsHistory',
		method: 'post',
		data:params
    })
}



/**
 * 获取病区数据
 * @param data 
 * @returns 
 */
export function apiGetDeviceGroups(params: object) {
	return request({
		url: "/device/group/info/list",
		method: "post",
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		params,
	});
}


/**
 * 获取固定药品统计数据
 * @param data 
 * @returns 
 */
export function apiFixedDrugStatistics(data: IFixedDrugStatisticsParams) :AxiosPromise<IFixedDrugStatistics[]> {
	return request({
		url: "/patient/hemo/med/record/listHemoMedMedicineStat2",
		method: "post",
		headers: {
			"Content-Type": "application/json"
		},
		data
	});
}
export function sendQueueNotification(params: object) {
    return request({
		url: '/patient/hemo/med/record/sendQueueNotification',
		method: 'post',
		params
    })
}


/**
 * 获取上级参数a4值打印的图片
 * @param data 
 * @returns 
 */
export function printerSjcsByA4Api(data: PrinterSjcsParams): AxiosPromise<string[]> {
	return request({
		url: '/patient/hemo/med/record/printUpParameters',
		method: 'post',
		data
	})
}

/**
 * 获取上级参数标签打印的图片
 * @param data 
 * @returns 
 */
export function printerSjcsByLabelApi(data: PrinterSjcsParams):  AxiosPromise<string[]> {
	return request({
		url: '/patient/hemo/med/record/printUpParametersBarcode',
		method: 'post',
		data
	})
}

/**
 * 手动his签到就诊
 * @param recordCode 
 * @returns 
 */
export function hisManualVisitApi(recordCode: string): AxiosPromise<void> {
	return request({
		url: '/patient/hemo/med/record/doHisVisit',
		method: 'post',
		headers: {
			"Content-Type": "application/x-www-form-urlencoded"
		},
		params: { recordCode }
	})
}

/**
 * 列出最近的透析单列表数量, 默认为3
 * @param params 
 * @returns 
 */
export function listRecentSummaryListApi(params: ListRecentSummaryListParams) {
	return request({
		url: '/patient/hemo/med/record/listRecentSummaryList',
		method: 'post',
		headers: {
			"Content-Type": "application/x-www-form-urlencoded"
		},
		params
	})
}

/**
 * 打印透析器标签
 * @param data 
 * @returns 
 */
export function printHemoMedReadyToolsApi(data: { clientCode: string; list: any[]; deviceName:string}) {
	return request({
		url: '/patient/hemo/med/record/printHemoMedReadyTools',
		method: 'post',
		data
	})
}
/**
 * 选择打印机返回
 * @param data 
 * @returns 
 */
export function getAvailableDevicesByDeviceType(params) {
	return request({
		url: '/comm/service/device/info/getAvailableDevicesByDeviceType',
		method: 'post',
		headers: {
			"Content-Type": "application/x-www-form-urlencoded"
		},
		params
	})
}



/**
 * 查询提前下机的患者
 * @param data 
 * @returns 
 */
export function advanceDeliveryApi(data: AdvanceDeliveryParams) :AxiosPromise<{ list: AdvanceDelivery[]; total: number; [key: string]: any }> {
	return request({
		url: '/patient/hemo/med/record/advanceDelivery',
		method: 'post',
		data
	})
}


export function batchPrintRecordsByPatientCodeCount(params: object) {
	return request({
		url: '/patient/hemo/med/record/batchPrintRecordsByPatientCodeCount',
		method: 'post',
		params
	})
}

/**
 * 获取每日透析耗用明细表Api
 * @param params 
 * @returns 
 */
export function statisticBothItemDrugsApi(params: IStatisticBothItemDrugsParams) :AxiosPromise<IStatisticBothItemDrugsItem[]> {
	return request({
		url: '/patient/hemo/med/record/statisticBothItemDrugs',
		method: 'post',
		headers: {
			"Content-Type": "application/x-www-form-urlencoded"
		},
		params
	})
}

/**
 * 查看耗材详情接口API
 * @param params 
 * @returns 
 */
export function listRecordsByToolUsageDetailsApi(params: IListRecordsByToolUsageDetailsParams) :AxiosPromise<IListRecordsByToolUsageDetailsReponse> {
	return request({
		url: '/patient/hemo/med/record/listRecordsByToolUsageDetails',
		method: 'post',
		data: params,
	})
}