Creates a new patient record in the system.
Object containing patient details:
Fields:
// Input:
const data = await patient.create({
idNumber: "123456789012",
idType: PatientIdTypeEnum.AADHAAR,
abhaAddress: "abha55578@example.com",
patientType: PatientTypeEnum.REGULAR,
firstName: "John",
lastName: "Doe",
birthDate: "1990-01-01",
gender: 'male',
mobileNumber: "+911234563291",
emailId: "john@example.com",
address: "123 Main St, Anytown, Anystate",
pincode: "560001",
state: StatesAndUnionTerritories.KARNATAKA,
resourceType: "Patient"
});
console.log(data);
// Expected Output:
{
message: 'Successfully created the Patient profile',
type: 'Patient',
resourceId: '791708f6-de6d-439e-bece-041e5d64e463',
validationErrors: [],
fhirProfileId: '',
resource: {
firstName: 'John',
lastName: 'Doe',
birthDate: '1990-01-01',
gender: 'male',
mobileNumber: '*********3291',
emailId: 'john@example.com',
address: '123 Main St, Anytown, Anystate, 12345',
pincode: '560001',
resourceType: 'Patient',
resourceId: '791708f6-de6d-439e-bece-041e5d64e463',
organizationId: 'ACHALA_HEALTH_01',
state: 'Andhra Pradesh',
idNumber: '1234567000',
idType: 'ABHA',
photo: '',
wantsToLinkWhatsapp: true,
abhaAddress: 'abha55578@example.com',
patientType: 'OLD',
lastUpdated: '2025-07-31T11:12:08.014760704Z'
}
}
Delete a patient
Patient's unique identifier
Checks whether a patient exists in the system using their Resource ID.
Unique identifier (Resource ID) of the patient to check - mandatory
A promise that resolves to:
true
if the patient existsRetrieves a paginated list of all patients.
Optional
pageSize: numberNumber of patients to fetch in a single page - optional (Only effective in the first request. Default is 10 if not provided)
Optional
nextPage: stringCursor to fetch the next set of patients - optional
(Use the value from the previous response's nextPage
for pagination)
// Input:
const patients = await patient.findAll(20);
const morePatients = await patient.findAll(undefined, patients.nextPage);
// Expected Output:
{
data: {
Entry: [
{
firstName: 'arya',
lastName: 'bunny',
// ... other fields
},
{
firstName: 'Neha',
lastName: 'Verma',
// ... other fields
}
// ... more entries
],
link: {
nextPage: 'X2NvdW50PTEwJl9zb3J0PS1fb'
},
total: 900
}
}
Retrieves a list of patients using a combination of optional filter criteria.
Filters to apply for fetching patients.
Fields:
Note:
fromDate
and toDate
should be valid ISO date strings and are used together to define a last-updated range.nextPage
token is used for pagination and is effective only on subsequent requests (not the first one).
Note: All filter parameters are only effective for the first request.
Subsequent requests using the nextPage parameter will return the records based on filters as specified in the initial request.Optional
nextPage: stringToken for retrieving the next page of results from the previous response.
// Input:
const filters = {
identifier: "joelpauljoel@sbx",
state : "Telangana",
fromDate": "2025-03-04T13:33:51.397512770Z",
toDate": "2025-03-05T13:33:51.397512770Z",
}
const response = await patient.findByFilters(filters);
console.log(response)
// 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
}
}
Fetches the details of a patient using Resource ID.
Unique identifier (Resource ID) of the patient to fetch - mandatory
// Input:
const patient = await patient.findById("123e4567-e89b-12d3-a456-426614174000");
console.log(patient);
// Expected Output:
{
type: 'Patient',
message: 'Patient Found !!!',
requestResource: {
firstName: 'Sreenivasa',
birthDate: '2025-07-23',
gender: 'male',
mobileNumber: '*********0000',
emailId: '',
address: 'DUMMY_ADDRESS',
pincode: '123456',
resourceType: 'Patient',
resourceId: '123e4567-e89b-12d3-a456-426614174000',
organizationId: 'ACHALA_HEALTH_01',
state: 'Telangana',
idNumber: 'BGSG-0000123456',
idType: 'UHID',
photo: '',
wantsToLinkWhatsapp: true,
abhaAddress: '',
patientType: 'NEW',
lastUpdated: '2025-07-23T09:51:13.201881128Z'
},
totalNumberOfRecords: 1
}
Updates existing patient data in the system.
Object containing fields to update:
Fields:
// Input:
await patient.update({
"resourceType": "Patient",
"resourceId": "791708f6-de6d-439e-bece-041e5d64e463",
"emailId": "VijayaLatha123@gmail.com",
"mobileNumber": "+919182853291"
});
// Expected Output:
{
message: 'Details Updated successfully',
type: 'Patient',
resource: {
firstName: 'Vijaya',
middleName: 'A',
lastName: 'Doe',
birthDate: '1980-01-01',
gender: 'male',
mobileNumber: '*********3291',
emailId: 'VijayaLatha123@gmail.com',
address: '123 Main St, Anytown, Anystate, 12345',
pincode: '12345',
resourceType: 'Patient',
resourceId: '791708f6-de6d-439e-bece-041e5d64e463',
organizationId: 'ACHALA_HEALTH_01',
state: 'Andhra Pradesh',
idNumber: '1234567000',
idType: 'ABHA',
photo: '',
wantsToLinkWhatsapp: true,
abhaAddress: 'abha55578@example.com',
patientType: 'OLD',
lastUpdated: '2025-07-31T11:16:36.550237457Z'
}
}
Service class for handling patient-related operations such as retrieving, creating, updating, and deleting patients.
The service provides methods for: