import request from '/@/utils/request';
import { AxiosPromise } from 'axios';
import type { IopDataParams } from './types';
import type { ICommonListParams } from '/@/api/common.type';
import type { IMedMonitorList, IMedMonitor, IIotHistories } from './types/patient_hemo_med_monitor_data.type';

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

/**
 * 获取监测记录列表
 * @param params 
 * @returns 
 */
export function list(params: ICommonListParams): AxiosPromise<IMedMonitorList> {
    return request({
		url: '/patient/hemo/med/monitor/data/list',
		method: 'post',
		headers: {
		'Content-Type': 'application/x-www-form-urlencoded'
		},
		params
    })
}

/**
 * 确认监测记录
 * @param params 
 * @returns 
 */
export function confirm(params: { recordCode: string }) {
    return request({
		url: '/patient/hemo/med/monitor/data/confirm',
		method: 'post',
		headers: {
		'Content-Type': 'application/x-www-form-urlencoded'
		},
		params
    })
}

/**
 * 获取监测记录默认内容
 * @param params 
 * @returns 
 */
export function prepareAdd(params: string): AxiosPromise<IMedMonitor> {
    return request({
		url: '/patient/hemo/med/monitor/data/prepareAdd',
		method: 'post',
		headers: {
		'Content-Type': 'application/x-www-form-urlencoded'
		},
		data: params,
    })
}

/**
 * 获取监测记录想去
 * @param params 
 * @returns 
 */
export function detail2(params: string): AxiosPromise<IMedMonitor> {
	return request({
		url: '/patient/hemo/med/monitor/data/detail2',
		method: 'post',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data: params,
	});
}
export function getLinkedIOTStatus(params: string) {
    return request({
		url: '/device/info/getLinkedIOTStatus',
		method: 'post',
		headers: {
		'Content-Type': 'application/x-www-form-urlencoded'
		},
		data: params,
    })
}


/**
 * 获取iot联机数据
 * @param params 
 * @returns 
 */
export function iopDataApi(params: IopDataParams): AxiosPromise<IIotHistories[]> {
	return request({
		url: '/device/info/outputDeviceIOTHistories',
		method: 'post',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		params
	})
}
