๐Ÿ“˜ Hospitals Nepal System API

Authentication & Dashboard Notifications โ€” REST API Documentation

POST User Login

Authenticates a registered user and returns JWT token and Ktoken for authorized API access.

๐Ÿ”— Endpoint: https://mainapi.hospitalsnepal.com/api/Authorization/Auth/Login

๐Ÿ“ค Request Headers

HeaderValueRequired
Content-Typeapplication/jsonYes

๐Ÿ“ฆ Request Body Parameters

ParameterTypeRequiredDescription
CodestringYesOrganization / System code
UserNamestringYesUser's login username
PasswordstringYesUser's login password

๐Ÿ“ Request Example

{
  "Code": "PU",
  "UserName": "admin",
  "Password": "admin1234"
}

โœ… Success Response (200 OK)

{
  "data": {
    "userName": "admin",
    "jwtToken": "eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9...",
    "ktoken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }
}

๐Ÿ“‹ Response Fields

FieldTypeDescription
data.userNamestringAuthenticated username
data.jwtTokenstringJWT access token for API authorization
data.ktokenstringAdditional K-token for specific operations

GET Dashboard Notifications

Fetches real-time dashboard cards including financial summaries, inventory alerts, lab status, and other notification metrics.

๐Ÿ”— Endpoint: https://notificationhub.hospitalsnepal.com/api/khatanotification/StartNotifications

๐Ÿ“ค Request Headers

HeaderValueRequired
AuthorizationBearer {jwtToken}Yes

๐Ÿ“ Request Example

GET /api/khatanotification/StartNotifications
Host: notificationhub.hospitalsnepal.com
Authorization: Bearer eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9...

โœ… Success Response (200 OK)

{
  "message": "Request Completed",
  "data": "[{\"Category\":\"Total\",\"Title\":\"Total Notification\",\"Total\":\"14\",\"Menu\":\"\",\"URL\":\"\",\"Remarks\":\"\",\"Auth\":1},{\"Category\":\"Financial\",\"Title\":\"Total Sales\",\"Total\":\"0.00\",\"Menu\":\"My Sales Report\",\"URL\":\"\\/customreport\\/customreport\\/index?menuName=My Sales Report\",\"Remarks\":\"Total sales summary of session user\",\"Auth\":0}]"
}

๐Ÿ“‹ Response Fields (Top-level)

FieldTypeDescription
messagestringStatus of the request (e.g., "Request Completed")
datastring (JSON array)A JSON string containing an array of notification items

๐Ÿ“Œ Notification Item Fields (inside "data" array)

FieldTypeDescription
CategorystringGroup category: Total, Financial, Inventory, Lab
TitlestringDisplay title for the metric (e.g., "Total Sales", "Expired Items")
TotalstringValue or count (sometimes includes percentage like "136 [15%]")
MenustringAssociated menu name for navigation
URLstringRelative URL to detailed report or view
RemarksstringAdditional info or instructions for the user
Authinteger1 = Authorized, 0 = Not authorized (visibility flag)

๐Ÿ“Š Notification Categories Overview

CategoryExamples
TotalTotal Notification count
FinancialTotal Sales, Receivable, Payable, PDC Payable/Receivable
InventoryExpired Items, Reorder Level, Over Stock, No Sales Item, IRD Sync. Pending
LabSampled, Received, Reported, Verified (with percentages)
๐Ÿ’ก Note: The data field returns a stringified JSON array. You must parse it with JSON.parse() before using the array in your application.

โš ๏ธ Error Responses

Status CodeDescription
401 UnauthorizedMissing, expired, or invalid JWT token.
500 Internal Server ErrorServer-side failure.

๐Ÿ” Authentication Flow

  1. Call POST /api/Authorization/Auth/Login with valid Code, UserName, Password.
  2. Extract jwtToken from the JSON response.
  3. Use the token as a Bearer credential in the Authorization header for all protected endpoints.
  4. Request GET /api/KhataNotification/StartNotifications with the token to fetch dashboard data.
  5. Parse the data string and render notification cards.
๐Ÿ” The JWT token contains claims like UserId, Department, Permissions, Role and has an expiration timestamp. Refresh mechanism may be required after expiry.

๐Ÿ“Ž Additional Information

๐Ÿงฉ Full Dashboard Sample (Truncated)

[
  {"Category":"Inventory","Title":"Expired Items","Total":"38","Menu":"Stock Expiry Report","URL":"/customreport/customreport/index?menuname=Stock Expiry Report","Remarks":"Expired item list having stock.","Auth":1},
  {"Category":"Financial","Title":"Receivable","Total":"10","Menu":"Account Ledger Report","URL":"/customreport/customreport/index?menuname=Account Ledger Report","Remarks":"Receivable Account Ledger Report.","Auth":1},
  {"Category":"Lab","Title":"Sampled","Total":"136 [15%]","Menu":"Test Status Report","URL":"/customreport/customreport/index?menuname=Test Status Report","Remarks":"Total Sampled and pending test up to today.","Auth":1}
]

๐Ÿ”ง cURL Examples

Login Request:

curl -X POST https://mainapi.hospitalsnepal.com/api/Authorization/Auth/Login \
  -H "Content-Type: application/json" \
  -d '{"Code":"PU","UserName":"admin","Password":"admin1234"}'

Dashboard Request:

curl -X GET https://notificationhub.hospitalsnepal.com/api/KhataNotification/StartNotifications \
  -H "Authorization: Bearer YOUR_JWT_TOKEN_HERE"
โœ… This API documentation covers User Login and Dashboard Notifications endpoints. All timestamps, token expiration, and permission claims are embedded inside the JWT tokens. For any integration issues, verify the token validity and required permissions (Auth flag) from the response.