import request from '/@/utils/request';
import type { ListTestResultsParams, SaveTestResultData, ListTestSamplesReponseItem, IListResultsByPatCodeParams, IListResultsByPatCode } from './type';
import { AxiosPromise } from 'axios';

export function reportList(params) {
	return request({
		url: '/lis/report/list',
		method: 'post',
        data: params,
	})
}
export function listResults(params:string) {
	return request({
		url: '/lis/report/listResults',
		method: 'post',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data: params,
	})
}
export function listReportsByPatient(params) {
	return request({
		url: '/lis/report/listReportsByPatient',
		method: 'post',
        data: params,
	})
}
export function listReportsByPatientDay(params) {
	return request({
		url: '/lis/report/listReportsByPatientDay',
		method: 'post',
        data: params,
	})
}
export function listReportResultsByPatientDayFeeItem(params) {
	return request({
		url: '/lis/report/listReportResultsByPatientDayFeeItem',
		method: 'post',
        data: params,
	})
}
export function listFeeItems() {
	return request({
		url: '/lis/report/listFeeItems',
		method: 'post',
	})
}
export function listTestItemsByFeeItemName(params) {
	return request({
		url: '/lis/report/listTestItemsByFeeItemName',
		method: 'post',
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data: params,
	})
}
export function saveLisResult(params) {
	return request({
		url: '/lis/report/saveLisResult',
		method: 'post',
		data: params,
	})
}



/**
 * 修改LIS结果
 * @param data 
 * @returns 
 */
export function apiUpdateLis(params: { code: string; result: string; sampleDate: string; }) {
	return request({
		url: "/lis/report/updateLisResult",
		method: "post",
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		params
	});
}


/**
 * 删除lis结果
 * @param code 
 * @returns 
 */
export function apiDelLis(data: string) {
	return request({
		url: "/lis/report/deleteLisResult",
		method: "post",
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data
	});
}



/**
 * 根据患者获取标本列表
 * @param patientCode 患者编号
 * @returns 
 */
export function listTestSamplesApi(patientCode: string): AxiosPromise<ListTestSamplesReponseItem[]> {
	return request({
		url: '/patient/lis/report/listTestSamples',
		method: 'post',
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		params: { patientCode }
	})
}


/**
 * 根据患者+标本编号查询出所有检查项目
 * @param params 
 * @returns 
 */
export function listTestResultsApi(params: ListTestResultsParams) {
	return request({
		url: '/patient/lis/report/listTestResults',
		method: 'post',
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		params
	})
}


/**
 * 保存手动填写的检查项目
 * @param data 
 * @returns 
 */
export function saveTestResultApi(data: SaveTestResultData) {
	return request({
		url: '/patient/lis/report/saveTestResult',
		method: 'post',
		data
	})
}


/**
 * 删除检查项目
 * @param id 
 * @returns 
 */
export function delTestResultApi(id: number) {
	return request({
		url: '/patient/lis/report/delete',
		method: 'post',
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		params: { id }
	})
}


/**
 * 根据患者编号和日期范围获取检验结果列表
 * @param params 
 * @returns 
 */
export function listResultsByPatCodeApi(params: IListResultsByPatCodeParams) :AxiosPromise<IListResultsByPatCode[]> {
	return request({
		url: '/lis/report/listResultsByPatCode',
		method: 'post',
		params
	})
}