Patient Profiles
Function-calling namespace: patientProfiles
- Base URL:
https://api.aivida.in - Engine endpoint:
POST /api - Auth: Stack token middleware enabled in
optionalmode. - Send token in header:
x-stack-access-token: <access_token>(orAuthorization: Bearer <access_token>). - In
optionalmode: no token is allowed; invalid token is rejected with401.
create
Source: backend/endpoints/patient-profiles/create
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
organizationId | string | No | - |
stackUserId | string | No | - |
primaryPatientId | string | No | required when creating a relative |
relation | string | No | oneof: SELF, FATHER, MOTHER, SPOUSE, SON, DAUGHTER, BROTHER, SISTER, GRANDFATHER, GRANDMOTHER, GUARDIAN, OTHER |
firstName | string | Yes | - |
lastName | string | No | - |
title | string | No | - |
phone | string | No | - |
email | string | No | - |
dateOfBirth | string | No | - |
gender | string | No | - |
bloodGroup | string | No | - |
address | object | No | - |
emergencyContact | object | No | - |
profileImageId | string | No | - |
profileImageUrl | string | No | - |
isProfileComplete | boolean | No | - |
isPhoneVerified | boolean | No | - |
isEmailVerified | boolean | No | nullable |
allergies | array<string> | No | - |
chronicConditions | array<string> | No | - |
currentMedications | array<string> | No | - |
expoPushToken | string | No | - |
createdAt | integer | No | unix-ms timestamp; nullable |
updatedAt | integer | No | unix-ms timestamp; nullable |
Relative Creation Notes
- To create a relative, send the main patient profile ID in
primaryPatientIdand setrelationto one of the supported relation values. relationis trimmed and normalized to uppercase by the backend. If omitted, it defaults toSELF.stackUserIdis optional for relatives and can be omitted when the relative does not have a Stack user account.
Supported relation values:
SELF, FATHER, MOTHER, SPOUSE, SON, DAUGHTER, BROTHER, SISTER, GRANDFATHER, GRANDMOTHER, GUARDIAN, OTHER
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "patientProfiles",
"apiName": "create",
"data": {
"organizationId": "org_123",
"primaryPatientId": "patient_123",
"relation": "FATHER",
"firstName": "Rajesh",
"lastName": "Kumar",
"title": "Mr",
"phone": "+911234567890",
"email": "rajesh.kumar@example.com",
"dateOfBirth": "1975-04-18",
"gender": "male",
"bloodGroup": "O+",
"address": {
"street": "221B Baker Street",
"city": "Bengaluru",
"state": "Karnataka",
"postalCode": "560001",
"country": "India"
},
"emergencyContact": {
"name": "Anita Kumar",
"relationship": "SPOUSE",
"phone": "+919876543210"
},
"isProfileComplete": true,
"isPhoneVerified": false,
"isEmailVerified": false,
"allergies": [],
"chronicConditions": [],
"currentMedications": []
}
}'Example Response
{ "status": "ok", "data": {} }delete
Source: backend/endpoints/patient-profiles/delete
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
patientId | string | Yes | - |
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "patientProfiles",
"apiName": "delete",
"data": {
"patientId": "patient_123"
}
}'Example Response
{ "status": "ok", "data": {} }getById
Source: backend/endpoints/patient-profiles/get-by-id
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
id | string | Yes | - |
organizationId | string | No | - |
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "patientProfiles",
"apiName": "getById",
"data": {
"id": "id_123"
}
}'Example Response
{ "status": "ok", "data": {} }getByStackUserId
Source: backend/endpoints/patient-profiles/get-by-stack-user-id
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
stackUserId | string | Yes | - |
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "patientProfiles",
"apiName": "getByStackUserId",
"data": {
"stackUserId": "stackuser_123"
}
}'Example Response
{ "status": "ok", "data": {} }getDoctorPatientDetail
Source: backend/endpoints/patient-profiles/get-doctor-patient-detail
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
patientId | string | Yes | - |
organizationId | string | Yes | - |
doctorUserId | string | Yes | - |
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "patientProfiles",
"apiName": "getDoctorPatientDetail",
"data": {
"patientId": "patient_123",
"organizationId": "org_123",
"doctorUserId": "doctoruser_123"
}
}'Example Response
{ "status": "ok", "data": {} }getMine
Source: backend/endpoints/patient-profiles/get-mine
Input schema type: unknown
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "patientProfiles",
"apiName": "getMine",
"data": {}
}'Example Response
{ "status": "ok", "data": {} }getOrderStats
Source: backend/endpoints/patient-profiles/get-order-stats
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
organizationId | string | No | - |
patientId | string | Yes | - |
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "patientProfiles",
"apiName": "getOrderStats",
"data": {
"patientId": "patient_123"
}
}'Example Response
{ "status": "ok", "data": {} }getRelativesByPatientId
Source: backend/endpoints/patient-profiles/get-relatives-by-patient-id
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
patientId | string | Yes | - |
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "patientProfiles",
"apiName": "getRelativesByPatientId",
"data": {
"patientId": "patient_123"
}
}'Response Data Format
| Field | Type | Required | Constraints |
|---|---|---|---|
items | array<object> | No | - |
total | integer | No | - |
Response Data Format Nested Structures
items[] item
| Field | Type | Required | Constraints |
|---|---|---|---|
_id | string | No | - |
patientCode | string | No | - |
organizationId | string | No | - |
stackUserId | string | No | - |
importedByDoctorId | string | No | - |
primaryPatientId | string | No | - |
relation | string | No | - |
title | string | No | - |
firstName | string | No | - |
lastName | string | No | - |
phone | string | No | - |
email | string | No | - |
dateOfBirth | string | No | - |
gender | string | No | - |
bloodGroup | string | No | - |
address | object | No | - |
defaultAddress | object | No | nullable |
emergencyContact | object | No | - |
profileImageId | string | No | - |
profileImageUrl | string | No | - |
isProfileComplete | boolean | No | - |
isPhoneVerified | boolean | No | - |
isEmailVerified | boolean | No | nullable |
allergies | array<string> | No | - |
chronicConditions | array<string> | No | - |
currentMedications | array<string> | No | - |
expoPushToken | string | No | - |
isDeleted | boolean | No | - |
deletedAt | string | No | nullable |
createdAt | integer | No | unix-ms timestamp |
updatedAt | integer | No | unix-ms timestamp |
items[].defaultAddress
| Field | Type | Required | Constraints |
|---|---|---|---|
_id | string | No | - |
userId | string | No | - |
addressType | string | No | - |
address | string | No | - |
city | string | No | - |
state | string | No | - |
postcode | string | No | - |
country | string | No | - |
latitude | number | No | nullable |
longitude | number | No | nullable |
isActive | boolean | No | - |
isDefault | boolean | No | - |
isDeleted | boolean | No | - |
createdAt | string | No | - |
updatedAt | string | No | - |
deletedAt | string | No | nullable |
Response Data Format Example
{
"items": [
{
"_id": "__123",
"patientCode": "value",
"organizationId": "org_123",
"stackUserId": "stackuser_123",
"importedByDoctorId": "importedbydoctor_123",
"primaryPatientId": "primarypatient_123",
"relation": "value",
"title": "value",
"firstName": "value",
"lastName": "value",
"phone": "+911234567890",
"email": "user@example.com",
"dateOfBirth": "2026-03-12",
"gender": "value",
"bloodGroup": "value",
"address": "221B Baker Street",
"defaultAddress": "221B Baker Street",
"emergencyContact": {},
"profileImageId": "profileimage_123",
"profileImageUrl": "value",
"isProfileComplete": true,
"isPhoneVerified": "+911234567890",
"isEmailVerified": "user@example.com",
"allergies": [
"value"
],
"chronicConditions": [
"value"
],
"currentMedications": [
"value"
],
"expoPushToken": "value",
"isDeleted": false,
"deletedAt": "value",
"createdAt": 1710201600000,
"updatedAt": 1710201600000
}
],
"total": 1
}Example Response
{
"status": "ok",
"data": {
"items": [
{
"_id": "__123",
"patientCode": "value",
"organizationId": "org_123",
"stackUserId": "stackuser_123",
"importedByDoctorId": "importedbydoctor_123",
"primaryPatientId": "primarypatient_123",
"relation": "value",
"title": "value",
"firstName": "value",
"lastName": "value",
"phone": "+911234567890",
"email": "user@example.com",
"dateOfBirth": "2026-03-12",
"gender": "value",
"bloodGroup": "value",
"address": "221B Baker Street",
"defaultAddress": "221B Baker Street",
"emergencyContact": {},
"profileImageId": "profileimage_123",
"profileImageUrl": "value",
"isProfileComplete": true,
"isPhoneVerified": "+911234567890",
"isEmailVerified": "user@example.com",
"allergies": [
"value"
],
"chronicConditions": [
"value"
],
"currentMedications": [
"value"
],
"expoPushToken": "value",
"isDeleted": false,
"deletedAt": "value",
"createdAt": 1710201600000,
"updatedAt": 1710201600000
}
],
"total": 1
}
}importRecords
Source: backend/endpoints/patient-profiles/import-records
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
organizationId | string | Yes | - |
doctorId | string | Yes | - |
records | array<object> | Yes | - |
Nested Field Structures
records item
| Field | Type | Required | Constraints |
|---|---|---|---|
stackUserId | string | No | - |
primaryPatientId | string | No | required when importing a relative |
relation | string | No | oneof: SELF, FATHER, MOTHER, SPOUSE, SON, DAUGHTER, BROTHER, SISTER, GRANDFATHER, GRANDMOTHER, GUARDIAN, OTHER |
firstName | string | No | - |
lastName | string | No | - |
title | string | No | - |
phone | string | No | - |
email | string | No | - |
dateOfBirth | string | No | - |
gender | string | No | - |
bloodGroup | string | No | - |
addressObject | object | No | - |
address | string | No | - |
city | string | No | - |
state | string | No | - |
country | string | No | - |
pincode | string | No | - |
postcode | string | No | - |
emergencyContact | object | No | - |
emergencyName | string | No | - |
emergencyRelation | string | No | - |
emergencyPhone | string | No | - |
isPhoneVerified | boolean | No | - |
isEmailVerified | boolean | No | nullable |
allergies | array<string> | No | - |
chronicConditions | array<string> | No | - |
currentMedications | array<string> | No | - |
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "patientProfiles",
"apiName": "importRecords",
"data": {
"organizationId": "org_123",
"doctorId": "doctor_123",
"records": [
{
"stackUserId": "stackuser_123",
"primaryPatientId": "patient_123",
"relation": "FATHER",
"firstName": "value",
"lastName": "value",
"title": "value",
"phone": "+911234567890",
"email": "user@example.com",
"dateOfBirth": "2026-03-12",
"gender": "value",
"bloodGroup": "value",
"addressObject": "221B Baker Street",
"address": "221B Baker Street",
"city": "Bengaluru",
"state": "Karnataka",
"country": "India",
"pincode": "value",
"postcode": "560001",
"emergencyContact": {},
"emergencyName": "value",
"emergencyRelation": "value",
"emergencyPhone": "+911234567890",
"isPhoneVerified": "+911234567890",
"isEmailVerified": "user@example.com",
"allergies": [
"value"
],
"chronicConditions": [
"value"
],
"currentMedications": [
"value"
]
}
]
}
}'Example Response
{ "status": "ok", "data": {} }isPhoneRegistered
Source: backend/endpoints/patient-profiles/is-phone-registered
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
phone | string | Yes | - |
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "patientProfiles",
"apiName": "isPhoneRegistered",
"data": {
"phone": "+911234567890"
}
}'Example Response
{ "status": "ok", "data": {} }listAll
Source: backend/endpoints/patient-profiles/list-all
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
search | string | No | - |
sortBy | string | No | - |
sortOrder | string | No | - |
page | integer | No | - |
pageSize | integer | No | - |
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "patientProfiles",
"apiName": "listAll",
"data": {
"search": "value",
"sortBy": "value",
"sortOrder": "value",
"page": 1,
"pageSize": 1
}
}'Example Response
{ "status": "ok", "data": {} }listByAppointmentsOrganization
Source: backend/endpoints/patient-profiles/list-by-appointments-organization
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
organizationId | string | Yes | - |
doctorId | string | No | - |
query | string | No | - |
type | string | No | - |
values | array<string> | No | - |
search | string | No | - |
gender | string | No | - |
bloodGroup | string | No | - |
visitStatus | string | No | - |
page | integer | No | - |
pageSize | integer | No | - |
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "patientProfiles",
"apiName": "listByAppointmentsOrganization",
"data": {
"organizationId": "org_123"
}
}'Example Response
{ "status": "ok", "data": {} }listByOrganization
Source: backend/endpoints/patient-profiles/list-by-organization
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
organizationId | string | Yes | - |
search | string | No | - |
searchQuery | string | No | - |
filter | string | No | - |
page | integer | No | - |
pageSize | integer | No | - |
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "patientProfiles",
"apiName": "listByOrganization",
"data": {
"organizationId": "org_123"
}
}'Example Response
{ "status": "ok", "data": {} }softDelete
Source: backend/endpoints/patient-profiles/soft-delete
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
patientId | string | Yes | - |
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "patientProfiles",
"apiName": "softDelete",
"data": {
"patientId": "patient_123"
}
}'Example Response
{ "status": "ok", "data": {} }update
Source: backend/endpoints/patient-profiles/update
Input Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
patientId | string | Yes | - |
stackUserId | string | No | nullable |
primaryPatientId | string | No | links this profile to the primary patient; nullable |
relation | string | No | oneof: SELF, FATHER, MOTHER, SPOUSE, SON, DAUGHTER, BROTHER, SISTER, GRANDFATHER, GRANDMOTHER, GUARDIAN, OTHER; nullable |
firstName | string | No | nullable |
lastName | string | No | nullable |
phone | string | No | nullable |
email | string | No | nullable |
dateOfBirth | string | No | nullable |
gender | string | No | nullable |
bloodGroup | string | No | nullable |
address | object | No | nullable |
emergencyContact | object | No | nullable |
profileImageId | string | No | nullable |
profileImageUrl | string | No | nullable |
isProfileComplete | boolean | No | nullable |
isPhoneVerified | boolean | No | nullable |
isEmailVerified | boolean | No | nullable |
allergies | array<string> | No | nullable |
chronicConditions | array<string> | No | nullable |
currentMedications | array<string> | No | nullable |
expoPushToken | string | No | nullable |
createdAt | integer | No | unix-ms timestamp; nullable |
updatedAt | integer | No | unix-ms timestamp; nullable |
Relation Notes
- Use
primaryPatientIdto link this profile to the primary patient profile. - Use
relationto describe how this profile is related to the primary patient.
Supported relation values:
SELF, FATHER, MOTHER, SPOUSE, SON, DAUGHTER, BROTHER, SISTER, GRANDFATHER, GRANDMOTHER, GUARDIAN, OTHER
Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "patientProfiles",
"apiName": "update",
"data": {
"patientId": "patient_123"
}
}'Example Response
{ "status": "ok", "data": {} }