import { BaseService, ClientConfig } from "../base"; import { PractitionerDTO, UpdatePractitionerDTO, CreateUpdatePractitionerResponse, GetPractitionerResponse, PractitionerFiltersDTO } from "./practitioner.dto"; import { HprService } from "./hpr"; /** * Provides services for managing Practitioner resources within the EHR system. * * This class is the main entry point for all practitioner-related operations. * * The service provides methods for: * - Retrieving all practitioners with pagination * - Fetching a practitioner by their unique ID * - Checking if a practitioner exists * - Creating a new practitioner * - Updating an existing practitioner * - Searching for practitioners using various filters * - Deleting a practitioner */ export declare class PractitionerService extends BaseService { private readonly logger; private hprService; constructor(config: ClientConfig); /** * Retrieves a paginated list of all practitioners. * * @param {number} [pageSize] - Number of practitioners to fetch in a single page - optional * (Only effective in the first request. Default is 10 if not provided) * * @param {string} [nextPage] - Cursor to fetch the next set of practitioners - optional * (Use the value from the previous response's `nextPage` for pagination) * * @returns {Promise} A promise that resolves to the practitioner's details returns: * - type: Type of the response (e.g., "success", "error") * - message: Description or status of the response * - requestResource: The actual data (practitioners list) * - totalNumberOfRecords: Total number of practitioners available * - nextPageLink: Cursor to the next page of results, if any * @throws {Error} Throws an error if the request fails or response is invalid. * * @example * // Input * const practitioners = await practitioner.findAll(20); * const morePractitioners = await practitioner.findAll(undefined, practitioners.nextPage); * * * // Expected Output * { * data: { * Entry: [ * { * firstName: 'arya', * lastName: 'bunny', * // ... other fields * }, * { * firstName: 'Neha', * lastName: 'Verma', * // ... other fields * } * // ... more entries * ], * link: { * nextPage: 'X2NvdW50PTEwJl9zb3J0PS1fb' * }, * total: 900 * } * } */ findAll(pageSize?: number, nextPage?: string): Promise; /** * Fetches the details of a practitioner using their unique identifier. * * @param {string} id - Unique identifier (Resource ID) of the practitioner to fetch - mandatory * * @returns {Promise} A promise that resolves to the practitioner's details: * - type: Type of the response (e.g., "success", "error") * - message: Description or status of the response * - requestResource: Practitioner data of the requested resource ID * - totalNumberOfRecords: Total number of practitioners found * - nextPageLink: Cursor to the next page of results, if available * * @throws {ValidationError} If the `id` is null, undefined, or empty. * @throws {Error} If the API request fails. * * @example * // Input: * const practitioner = await practitioner.findById("767113fd-aaaf-492f-8226-347f804757b6"); * console.log(practitioner); * * // Expected Output: * { * type: 'Practitioner', * message: 'Practitioner Found !!!', * requestResource: { * firstName: 'Nandamuri', * lastName: 'Taraka Rama Rao', * birthDate: '1980-12-25', * registrationId: '1234567890', * resourceId: '767113fd-aaaf-492f-8226-347f804757b6', * gender: 'male', * photo: 'data:application/pdf;base64,base64EncodedPhotoString', * address: '123 Main Street, Cityville', * pincode: '560001', * state: 'Karnataka', * mobileNumber: '*********3225', * emailId: 'tarak.Nandamuri@example.com', * organizationId: 'ACHALA_HEALTH_01', * resourceType: 'Practitioner', * hprId: '', * department: 'cardiology', * designation: 'Junior Consultant', * wantsToLinkWhatsapp: true, * status: 'Active', * joiningDate: '2023-05-15', * staffType: 'Doctor' * }, * totalNumberOfRecords: 1 * } */ findById(id: string): Promise; /** * Checks whether a practitioner exists in the system using their unique identifier. * * @param {string} id - Unique identifier (Resource ID) of the practitioner to check - mandatory * * @returns {Promise} A promise that resolves to: * - `true` if the practitioner exists * * @throws {ValidationError} If the `id` is null, undefined, or an empty string. * @throws {Error} If the API request fails or an unexpected error occurs. * * @example * // Input: * const doesExist = await practitioner.exists("123e4567-e89b-12d3-a456-426614174000"); * console.log(doesExist); * * * // Expected Output: * true */ exists(id: string): Promise; /** * Create a new Practitioner. * * This function registers a new practitioner by validating and sending their information to the backend. * * @param {PractitionerDTO} practitioner - Practitioner data containing the following fields: * - registrationId - Registration ID of the practitioner - mandatory * - department - Department the practitioner belongs to (enum: Departments) - mandatory * - designation - Designation of the practitioner (e.g., Doctor, Nurse) - mandatory * - status - Current employment status of the practitioner - mandatory * - joiningDate - Date when the practitioner joined - mandatory * - staffType - Type of staff (e.g., Permanent, Contract) - mandatory * - firstName - First name of the practitioner (3–20 characters, alphabets only) - mandatory * - middleName - Middle name of the practitioner - optional * - lastName - Last name of the practitioner (3–20 characters, alphabets only) - mandatory * - birthDate - Birth date of the practitioner (in ISO format) - mandatory * - gender - Gender of the practitioner (enum: Gender) - mandatory * - mobileNumber - Mobile number (must be valid, no masked numbers allowed) - mandatory * - emailId - Email address of the practitioner - mandatory * - address - Residential address of the practitioner (5–50 characters) - mandatory * - pincode - Area pincode (6 digits) - mandatory * - state - State or Union Territory (enum: StatesAndUnionTerritories) - mandatory * - wantsToLinkWhatsapp - Whether the practitioner wants to link WhatsApp - optional * - photo - Profile photo of the practitioner (base64 string or URL) - optional * - resourceType - Type of resource (enum: ResourceType) - mandatory * - resourceId - Unique identifier for the resource - optional * * @returns {Promise} A promise resolving to the created practitioner response object: * - message: Status message * - type: Resource type (e.g., "Practitioner") * - resourceId: Unique identifier of the created resource * - validationErrors: Array of any validation errors (empty if none) * - fhirProfileId: Associated FHIR profile ID (empty if not applicable) * - resource: Practitioner profile object * * @throws {ValidationError} If the practitioner data is missing or invalid. * @throws {Error} If the request to create a practitioner fails. * * @example * // Input: * const createPractitioner = { * registrationId: "1234567458", * department: "urology", * designation: "surgeon", * status: "Active", * joiningDate: "2023-05-15", * staffType: "Full-Time", * firstName: "Baipalli", * middleName: "A", * lastName: "Rama Rao", * birthDate: "1980-12-25", * gender: "male", * mobileNumber: "+919182856790", * emailId: "ramarao.baipalli@example.com", * address: "123 Main Street, Cityville", * pincode: "560001", * state: "Karnataka", * wantsToLinkWhatsapp: true, * photo: "base64EncodedPhotoString", * resourceType: "Practitioner" * }; * * const result = await practitioner.create(createPractitioner); * console.log(result); * * // Expected Output: * { * message: "Successfully created the Practitioner profile", * type: "Practitioner", * resourceId: "43a0f739-0c54-4b9f-ab4b-08afbed0bf3c", * validationErrors: [], * fhirProfileId: "", * resource: { * firstName: "Baipalli", * lastName: "Rama Rao", * birthDate: "1980-12-25", * registrationId: "1234567458", * resourceId: "43a0f739-0c54-4b9f-ab4b-08afbed0bf3c", * gender: "male", * photo: "data:application/pdf;base64,base64EncodedPhotoString", * address: "123 Main Street, Cityville", * pincode: "560001", * state: "Karnataka", * mobileNumber: "*********6790", * emailId: "ramarao.baipalli@example.com", * organizationId: "ACHALA_HEALTH_01", * resourceType: "Practitioner", * hprId: "", * department: "urology", * designation: "surgeon", * wantsToLinkWhatsapp: true, * status: "Active", * joiningDate: "2023-05-15", * staffType: "Doctor" * } * } */ create(practitioner: PractitionerDTO): Promise; /** * Update Practitioner data. * * This method validates and updates the practitioner’s details. * * @param {UpdatePractitionerDTO} updatePractitionerData - The updated practitioner information, including: * - registrationId: Unique registration ID of the practitioner - mandatory * - department: Department the practitioner belongs to (enum: Departments) - mandatory * - designation: Role/designation of the practitioner - mandatory * - status: Current employment status (e.g., Active, Inactive) - mandatory * - joiningDate: Joining date of the practitioner (ISO format) - mandatory * - staffType: Type of staff (e.g., Contract, Permanent) - mandatory * - firstName: First name (3–20 characters, alphabets only) - mandatory * - middleName: Middle name - optional * - lastName: Last name (3–20 characters, alphabets only) - mandatory * - birthDate: Date of birth (ISO format) - mandatory * - gender: Gender of the practitioner (enum: Gender) - mandatory * - mobileNumber: Valid mobile number (must not contain masked values like '*') - mandatory * - emailId: Valid email address - mandatory * - address: Home address (5–50 characters) - mandatory * - pincode: Area pincode (exactly 6 digits) - mandatory * - state: State or union territory (enum: StatesAndUnionTerritories) - mandatory * - wantsToLinkWhatsapp: Indicates if WhatsApp linking is desired - optional * - photo: Base64 image string or file URL - optional * - resourceType: Type of resource (enum: ResourceType) - mandatory * - resourceId: Optional resource ID used for reference or linking - optional * * @returns {Promise} A promise resolving to the updated practitioner data and a success message. * * @throws {ValidationError} If the provided practitioner data is null or fails validation. * @throws {Error} For unexpected failures such as network or backend issues. * * @example * // Input: * const updatedData: UpdatePractitionerDTO = { * registrationId: "PR12345", * department: "Cardiology", * designation: "Senior Surgeon", * status: "Active", * joiningDate: "2022-07-01", * staffType: "Permanent", * firstName: "Arjun", * lastName: "Rao", * birthDate: "1985-12-20", * gender: "male", * mobileNumber: "+911234567890", * emailId: "arjun.rao@hospital.com", * address: "123 Hospital Road", * pincode: "500001", * state: "Telanagana", * resourceType: "practitioner" * }; * * const result = await practitioner.update(updatedData); * console.log(result); * * * // Expected Output: * { * message: 'Details Updated successfully', * type: 'Patient', * resource: { * firstName: 'Vijaya', * middleName: 'A', * lastName: 'Doe', * .....Other Details * } * } */ update(updatePractitionerData: UpdatePractitionerDTO): Promise; /** * Fetches a list of practitioners based on provided filters. * * This function allows filtering practitioners using various parameters such as name, location, contact information, and date ranges. * Pagination is supported through the `nextPage` parameter. * * @param {PractitionerFiltersDTO} filters - Filters to apply while fetching practitioners: * - firstName - First name of the practitioner - optional * - lastName - Last name of the practitioner - optional * - state - State where the practitioner is located - optional * - pageSize - Number of records to fetch in one page - optional * - pincode - Area pincode of the practitioner - optional * - email - Email address of the practitioner - optional * - identifier - Unique identifier (e.g., ABHA ID, ABHA Address) - optional * - gender - Gender of the practitioner - optional * - phone - Mobile number of the practitioner - optional * - fromDate - Start date to filter based on last updated date - optional * - toDate - End date to filter based on last updated date - optional * * @param {string} [nextPage] - URL or token to fetch the next page of results. Used for pagination - optional * * @returns {Promise} A promise resolving to the list of practitioners and metadata. * * @throws {Error} Throws an error if validation fails or request encounters an issue. * * @note: * - All filter parameters are effective only for the first request. * - On subsequent paginated requests, the filters applied in the initial request will persist. * * @example * // Input: * const result = await practitioner.findByFilters({ * firstName: "John", * state: "Telangana", * fromDate: "2024-01-01", * toDate: "2024-12-31" * }); * console.log(result); * * * // Expected Output: * { * data: { * Entry: [ * { * firstName: 'Joel', * middleName: 'Paul', * lastName: 'Jeripothula', * abhaAddress: 'joelpauljoel@sbx', * state: 'Telangana' * // ... other fields * }, * { * firstName: 'Neha', * lastName: 'Verma', * abhaAddress: 'joelpauljoel@sbx', * state: 'Telangana' * // ... other fields * } * // ... more entries * ], * total: 2 * } * } */ findByFilters(filters: PractitionerFiltersDTO, nextPage?: string): Promise; transformFilterKeys(filters: Record): Promise>; get hpr(): HprService; /** * Delete a practitioner * @param id - Practitioner's unique identifier */ delete(id: string): Promise; }