123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- import axiosInstance from '../interceptor';
- export interface AprConfig {
- AECDensity: number;
- AECField: string;
- AECFilm: number;
- Dose: number;
- ExposureMode: number;
- Focus: number;
- TOD: number;
- TubeLoad: number;
- kV: number;
- mA: number;
- mAs: number;
- ms: number;
- }
- interface AprSub {
- work_station_id: number;
- patient_size: string;
- config_object: {
- Common: AprConfig;
- };
- }
- interface APR {
- '@type': string;
- apr_id: string;
- apr_name: string;
- apr_description: string;
- patient_type: string;
- body_part_id: string;
- view_position: string;
- category: string;
- modality: string;
- sub: AprSub[];
- sort: number;
- is_enabled: boolean;
- product: string;
- is_pre_install: boolean;
- }
- // interface AprResponse {
- // code: string;
- // description: string;
- // solution: string;
- // data: APR;
- // }
- const getAprDetails = async (
- id: string,
- patientType: string,
- bodyPart: string,
- isEnabled: boolean,
- procedureId: string
- ): Promise<APR> => {
- const response = await axiosInstance.get(
- `/dr/api/v1/auth/protocol/view/${id}/apr`,
- {
- params: {
- patient_type: patientType,
- body_part: bodyPart,
- is_enabled: isEnabled,
- procedure_id: procedureId,
- },
- }
- );
- return response.data.data;
- };
- const getAprExposureParams = async (
- id: string,
- workStationId: number,
- patientSize: string
- ): Promise<AprConfig> => {
- const response = await axiosInstance.get(`auth/protocol/apr/${id}/tech`, {
- params: {
- work_station_id: workStationId,
- patient_size: patientSize,
- },
- });
- return response.data.data.ep;
- };
- const getAprByThickness = async (thickness: number): Promise<AprConfig> => {
- const response = await axiosInstance.get(
- `auth/protocol/thickness/${thickness}/apr`
- );
- return response.data.data;
- };
- export { getAprDetails, getAprExposureParams, getAprByThickness };
- interface DeviceActionMessage {
- deviceUri: string;
- reqName: string;
- reqParam: string;
- reqTransaction: string;
- reqClientID: string;
- }
- const pathOfGenerator = 'DIOS/DEVICE/Generator';
- const sendDeviceAction = async (reqName: string) => {
- const message: DeviceActionMessage = {
- deviceUri: pathOfGenerator,
- reqName,
- reqParam: `{"P0":"default"}`,
- reqTransaction: '',
- reqClientID: '',
- };
- try {
- await axiosInstance.post('/auth/device/action', message);
- } catch (error) {
- console.error(`[${reqName}] Failed to send device action:`, error);
- throw error;
- }
- };
- const incKv = async () => {
- await sendDeviceAction('IncParam_KV');
- };
- const decKv = async () => {
- await sendDeviceAction('DecParam_KV');
- };
- const incMas = async () => {
- await sendDeviceAction('IncParam_MAS');
- };
- const decMas = async () => {
- await sendDeviceAction('DecParam_MAS');
- };
- const incMa = async () => {
- await sendDeviceAction('IncParam_MA');
- };
- const decMa = async () => {
- await sendDeviceAction('DecParam_MA');
- };
- const incMs = async () => {
- await sendDeviceAction('IncParam_MS');
- };
- const decMs = async () => {
- await sendDeviceAction('DecParam_MS');
- };
- const incDensity = async () => {
- await sendDeviceAction('IncParam_Density');
- };
- const decDensity = async () => {
- await sendDeviceAction('DecParam_Density');
- };
- const incThickness = async () => {
- await sendDeviceAction('IncParam_Thickness');
- };
- const decThickness = async () => {
- await sendDeviceAction('DecParam_Thickness');
- };
- const SetAPR = async (reqParam: string) => {
- const message: DeviceActionMessage = {
- deviceUri: pathOfGenerator,
- reqName: 'SetAPR',
- reqParam,
- reqTransaction: '',
- reqClientID: '',
- };
- try {
- await axiosInstance.post('/auth/device/action', message);
- } catch (error) {
- console.error(`[SetAPR] Failed to send device action:`, error);
- throw error;
- }
- };
- export {
- incKv,
- decKv,
- incMas,
- decMas,
- incMa,
- decMa,
- incMs,
- decMs,
- incDensity,
- decDensity,
- incThickness,
- decThickness,
- SetAPR,
- };
|