NeoScan_Radiologist/app/modules/PatientCare/services/patientAPI.ts
2025-08-07 19:42:41 +05:30

168 lines
4.7 KiB
TypeScript

/*
* File: patientAPI.ts
* Description: API service for patient care operations using apisauce
* Design & Developed by Tech4Biz Solutions
* Copyright (c) Spurrin Innovations. All rights reserved.
*/
import { create } from 'apisauce';
import { API_CONFIG, buildHeaders } from '../../../shared/utils';
const api = create({
baseURL: API_CONFIG.BASE_URL
});
/**
* Patient API Service
*
* Purpose: Handle all patient-related API operations
*
* Features:
* - Get patient list with filtering
* - Get individual patient details
* - Update patient information
* - Get patient vital signs
* - Get patient medical history
*/
export const patientAPI = {
/**
* Get Patients
*
* Purpose: Fetch list of medical cases from server
*
* @param token - Authentication token
* @returns Promise with medical cases data
*/
getPatients: (token: string) => {
return api.get('/api/dicom/medpacks-sync/get-synced-medpacks-data', {}, buildHeaders({ token }));
},
/**
* Get Patient Details
*
* Purpose: Fetch detailed information for a specific patient
*
* @param patientId - Patient ID
* @param token - Authentication token
* @returns Promise with patient details
*/
getPatientDetails: (patientId: string, token: string) => {
return api.get(`/api/patients/${patientId}`, {}, buildHeaders({ token }));
},
/**
* Update Patient
*
* Purpose: Update patient information
*
* @param patientId - Patient ID
* @param patientData - Updated patient data
* @param token - Authentication token
* @returns Promise with updated patient data
*/
updatePatient: (patientId: string, patientData: any, token: string) => {
return api.put(`/api/patients/${patientId}`, patientData, buildHeaders({ token }));
},
/**
* Get Patient Vital Signs
*
* Purpose: Fetch latest vital signs for a patient
*
* @param patientId - Patient ID
* @param token - Authentication token
* @returns Promise with vital signs data
*/
getPatientVitals: (patientId: string, token: string) => {
return api.get(`/api/patients/${patientId}/vitals`, {}, buildHeaders({ token }));
},
/**
* Update Patient Vital Signs
*
* Purpose: Add new vital signs reading for a patient
*
* @param patientId - Patient ID
* @param vitalSigns - Vital signs data
* @param token - Authentication token
* @returns Promise with updated vital signs
*/
updatePatientVitals: (patientId: string, vitalSigns: any, token: string) => {
return api.post(`/api/patients/${patientId}/vitals`, vitalSigns, buildHeaders({ token }));
},
/**
* Get Patient Medical History
*
* Purpose: Fetch medical history for a patient
*
* @param patientId - Patient ID
* @param token - Authentication token
* @returns Promise with medical history data
*/
getPatientHistory: (patientId: string, token: string) => {
return api.get(`/api/patients/${patientId}/history`, {}, buildHeaders({ token }));
},
/**
* Get Patient Medications
*
* Purpose: Fetch current medications for a patient
*
* @param patientId - Patient ID
* @param token - Authentication token
* @returns Promise with medications data
*/
getPatientMedications: (patientId: string, token: string) => {
return api.get(`/api/patients/${patientId}/medications`, {}, buildHeaders({ token }));
},
/**
* Add Patient Medication
*
* Purpose: Add new medication for a patient
*
* @param patientId - Patient ID
* @param medication - Medication data
* @param token - Authentication token
* @returns Promise with updated medications
*/
addPatientMedication: (patientId: string, medication: any, token: string) => {
return api.post(`/api/patients/${patientId}/medications`, medication, buildHeaders({ token }));
},
/**
* Get Patient Allergies
*
* Purpose: Fetch allergies for a patient
*
* @param patientId - Patient ID
* @param token - Authentication token
* @returns Promise with allergies data
*/
getPatientAllergies: (patientId: string, token: string) => {
return api.get(`/api/patients/${patientId}/allergies`, {}, buildHeaders({ token }));
},
/**
* Search Patients
*
* Purpose: Search patients by various criteria
*
* @param query - Search query
* @param token - Authentication token
* @returns Promise with search results
*/
searchPatients: (query: string, token: string) => {
return api.get('/api/patients/search', { q: query }, buildHeaders({ token }));
},
};
// Legacy export for backward compatibility
export const caseAPI = patientAPI;
/*
* End of File: patientAPI.ts
* Design & Developed by Tech4Biz Solutions
* Copyright (c) Spurrin Innovations. All rights reserved.
*/