EndpointsPatient Profiles

Patient Profiles

Function-calling namespace: patientProfiles

  • Base URL: https://api.aivida.in
  • Engine endpoint: POST /api
  • Auth: Stack token middleware enabled in optional mode.
  • Send token in header: x-stack-access-token: <access_token> (or Authorization: Bearer <access_token>).
  • In optional mode: no token is allowed; invalid token is rejected with 401.

create

Source: backend/endpoints/patient-profiles/create

Input Fields

FieldTypeRequiredConstraints
organizationIdstringNo-
stackUserIdstringNo-
primaryPatientIdstringNorequired when creating a relative
relationstringNooneof: SELF, FATHER, MOTHER, SPOUSE, SON, DAUGHTER, BROTHER, SISTER, GRANDFATHER, GRANDMOTHER, GUARDIAN, OTHER
firstNamestringYes-
lastNamestringNo-
titlestringNo-
phonestringNo-
emailstringNo-
dateOfBirthstringNo-
genderstringNo-
bloodGroupstringNo-
addressobjectNo-
emergencyContactobjectNo-
profileImageIdstringNo-
profileImageUrlstringNo-
isProfileCompletebooleanNo-
isPhoneVerifiedbooleanNo-
isEmailVerifiedbooleanNonullable
allergiesarray<string>No-
chronicConditionsarray<string>No-
currentMedicationsarray<string>No-
expoPushTokenstringNo-
createdAtintegerNounix-ms timestamp; nullable
updatedAtintegerNounix-ms timestamp; nullable

Relative Creation Notes

  • To create a relative, send the main patient profile ID in primaryPatientId and set relation to one of the supported relation values.
  • relation is trimmed and normalized to uppercase by the backend. If omitted, it defaults to SELF.
  • stackUserId is 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

FieldTypeRequiredConstraints
patientIdstringYes-

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

FieldTypeRequiredConstraints
idstringYes-
organizationIdstringNo-

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

FieldTypeRequiredConstraints
stackUserIdstringYes-

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

FieldTypeRequiredConstraints
patientIdstringYes-
organizationIdstringYes-
doctorUserIdstringYes-

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

FieldTypeRequiredConstraints
organizationIdstringNo-
patientIdstringYes-

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

FieldTypeRequiredConstraints
patientIdstringYes-

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

FieldTypeRequiredConstraints
itemsarray<object>No-
totalintegerNo-

Response Data Format Nested Structures

items[] item

FieldTypeRequiredConstraints
_idstringNo-
patientCodestringNo-
organizationIdstringNo-
stackUserIdstringNo-
importedByDoctorIdstringNo-
primaryPatientIdstringNo-
relationstringNo-
titlestringNo-
firstNamestringNo-
lastNamestringNo-
phonestringNo-
emailstringNo-
dateOfBirthstringNo-
genderstringNo-
bloodGroupstringNo-
addressobjectNo-
defaultAddressobjectNonullable
emergencyContactobjectNo-
profileImageIdstringNo-
profileImageUrlstringNo-
isProfileCompletebooleanNo-
isPhoneVerifiedbooleanNo-
isEmailVerifiedbooleanNonullable
allergiesarray<string>No-
chronicConditionsarray<string>No-
currentMedicationsarray<string>No-
expoPushTokenstringNo-
isDeletedbooleanNo-
deletedAtstringNonullable
createdAtintegerNounix-ms timestamp
updatedAtintegerNounix-ms timestamp

items[].defaultAddress

FieldTypeRequiredConstraints
_idstringNo-
userIdstringNo-
addressTypestringNo-
addressstringNo-
citystringNo-
statestringNo-
postcodestringNo-
countrystringNo-
latitudenumberNonullable
longitudenumberNonullable
isActivebooleanNo-
isDefaultbooleanNo-
isDeletedbooleanNo-
createdAtstringNo-
updatedAtstringNo-
deletedAtstringNonullable

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

FieldTypeRequiredConstraints
organizationIdstringYes-
doctorIdstringYes-
recordsarray<object>Yes-

Nested Field Structures

records item

FieldTypeRequiredConstraints
stackUserIdstringNo-
primaryPatientIdstringNorequired when importing a relative
relationstringNooneof: SELF, FATHER, MOTHER, SPOUSE, SON, DAUGHTER, BROTHER, SISTER, GRANDFATHER, GRANDMOTHER, GUARDIAN, OTHER
firstNamestringNo-
lastNamestringNo-
titlestringNo-
phonestringNo-
emailstringNo-
dateOfBirthstringNo-
genderstringNo-
bloodGroupstringNo-
addressObjectobjectNo-
addressstringNo-
citystringNo-
statestringNo-
countrystringNo-
pincodestringNo-
postcodestringNo-
emergencyContactobjectNo-
emergencyNamestringNo-
emergencyRelationstringNo-
emergencyPhonestringNo-
isPhoneVerifiedbooleanNo-
isEmailVerifiedbooleanNonullable
allergiesarray<string>No-
chronicConditionsarray<string>No-
currentMedicationsarray<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

FieldTypeRequiredConstraints
phonestringYes-

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

FieldTypeRequiredConstraints
searchstringNo-
sortBystringNo-
sortOrderstringNo-
pageintegerNo-
pageSizeintegerNo-

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

FieldTypeRequiredConstraints
organizationIdstringYes-
doctorIdstringNo-
querystringNo-
typestringNo-
valuesarray<string>No-
searchstringNo-
genderstringNo-
bloodGroupstringNo-
visitStatusstringNo-
pageintegerNo-
pageSizeintegerNo-

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

FieldTypeRequiredConstraints
organizationIdstringYes-
searchstringNo-
searchQuerystringNo-
filterstringNo-
pageintegerNo-
pageSizeintegerNo-

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

FieldTypeRequiredConstraints
patientIdstringYes-

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

FieldTypeRequiredConstraints
patientIdstringYes-
stackUserIdstringNonullable
primaryPatientIdstringNolinks this profile to the primary patient; nullable
relationstringNooneof: SELF, FATHER, MOTHER, SPOUSE, SON, DAUGHTER, BROTHER, SISTER, GRANDFATHER, GRANDMOTHER, GUARDIAN, OTHER; nullable
firstNamestringNonullable
lastNamestringNonullable
phonestringNonullable
emailstringNonullable
dateOfBirthstringNonullable
genderstringNonullable
bloodGroupstringNonullable
addressobjectNonullable
emergencyContactobjectNonullable
profileImageIdstringNonullable
profileImageUrlstringNonullable
isProfileCompletebooleanNonullable
isPhoneVerifiedbooleanNonullable
isEmailVerifiedbooleanNonullable
allergiesarray<string>Nonullable
chronicConditionsarray<string>Nonullable
currentMedicationsarray<string>Nonullable
expoPushTokenstringNonullable
createdAtintegerNounix-ms timestamp; nullable
updatedAtintegerNounix-ms timestamp; nullable

Relation Notes

  • Use primaryPatientId to link this profile to the primary patient profile.
  • Use relation to 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": {} }