import request from "/@/utils/request";
import { IMapper, IHandCalculatorKtvAndUrrParams, IIistMapper, IInspectionItemsByChargeItem, IDeleteLisKtvReportParams } from "./type";
import { AxiosPromise } from "axios";



/**
 * 列出所有收费项目
 * @returns 
 */
export function apiGetChargeItems() {
    return request({
        url: "/lis/report/listFeeItems",
        method: "post"
    });
}

/**
 * 获取患者检验明细
 * @param params 
 * @returns 
 */
export function listReportsByPatientApi(params: object) {
    return request({
        url: '/lis/report/listReportsByPatient2',
        method: 'post',
        data: params
    })
}

/**
 * 删除检验报告
 * @param data 
 * @returns 
 */
export function apiDelLisByDate(data: string) {
	return request({
		url: "/lis/report/deleteLisReport",
		method: "post",
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data
	});
}

/**
 * 删除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
	});
}

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



/**
 * 根据收费项目获取系统内置检验项目
 * @param data 
 * @returns 
 */
export function apiGetInspectionItemsByChargeItem(feeItemName: string, clientCode: string) :AxiosPromise<IInspectionItemsByChargeItem> {
    return request({
        url: "/lis/report/listTestItemsByFeeItemName",
        method: "post",
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        data: "feeItemName=" + feeItemName + "&clientCode=" + clientCode
    });
}



/**
 * 根据客户编号查询对照列表
 * @param clientCode 
 * @returns 
 */
export function apiFindComparisonListByClientCode(clientCode: string) : AxiosPromise<IIistMapper[]> {
    return request({
        url: "/lis/test/item/mapper/listMapper",
        method: "post",
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        data: "clientCode=" + clientCode
    });
}


/**
 * 保存对照
 * @param data 
 * @returns 
 */
export function apiSavecompare(data: IMapper) {
    return request({
        url: "/lis/test/item/mapper/save",
        method: "post",
        headers: {
            "Content-Type": "application/json"
        },
        data
    });
}

/**
 * 查出所有lis里已有项目
 * @param clientCode 
 * @returns 
 */
export function apiGetListItemNames (clientCode: string): AxiosPromise<string[]> {
    return request({
        url: '/lis/report/listDistinctItemNames',
        method: 'post',
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        params: { clientCode }
    })
}


/**
 * 计算患者urr ktv
 * @param data 
 * @returns 
 */
export function handCalculatorKtvAndUrrApi(data: IHandCalculatorKtvAndUrrParams) {
    return request({
        url: '/lis/stat/handCalculatorKtvAndUrr',
        method: 'post',
        data
    })
}

/**
 * 删除KTV报告接口
 * @param params 
 * @returns 
 */
export function deleteLisKtvReportApi(params: { reportCode: string }) {
    return request({
        url: '/lis/report/deleteLisKtvReport',
        method: 'post',
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        params
    })
}

//获取列表
/**
 * 
 * @param params 
 * @returns 
 */
export function getAlertPatients(params: object) {
    return request({
        url: '/client/alert/info/queryAlertPatients',
        method: 'post',
        data: params
    })
}

//新增
/**
 * 
 * @param params 
 * @returns 
 */
export function addRemind(params: object) {
    return request({
        url: '/client/alert/info/add',
        method: 'post',
        data: params
    })
}

//批量新增
export function addRemindList(data: object) {
    return request({
        url: '/client/alert/info/addList',
        method: 'post',
        data
    })
}

/**
 * 修改api
 * @param data 
 * @returns 
 */
export function editRemindApi(data) {
  return request({
    url: '/client/alert/info/update',
    method: 'post',
    data
  })
}

/**
 * 删除api
 * @param id 
 * @returns 
 */
export function delRemindApi(id: number) {
    return request({
        url: '/client/alert/info/delete',
        method: 'post',
        params: { id }
    })
}

/**
 * 查询列表api
 * @param params 
 * @returns 
 */
export function getRemindApi(params) {
    return request({
        url: '/client/alert/info/list',
        method: 'post',
        params,
    })
}