Registers a new Organization.
This function registers a new organization using the provided organization data.
The organization data required for registration.
A promise that resolves to a string containing a message indicating whether the organization was successfully created or if an error occurred.
// Input:
const response = await organization.create({
basicInformation: {
address: "123 Main Street, Hyderabad",
state: "Telangana",
pincode: "500001",
contactNumber: "+919876543210"
},
// ... other organization fields
});
console.log(message);
// Expected Output:
"Facility added successfully. Your facility ID is IN6778"
Delete an organization
organization's unique identifier
Checks if an organization exists for the given identifier and ID type.
Type of identifier used to check the organization (e.g., accountId, facilityId, id) - mandatory
Accepted values: OrganizationIdType.ACCOUNT_ID | OrganizationIdType.FACILITY_ID | OrganizationIdType.ID
Unique identifier value of the organization corresponding to the given idType
- mandatory
true
if the organization existsRetrieves a paginated list of all organizations.
Optional
nextPage: stringToken to fetch the next set of organizations (optional).
Use the value from the previous response's nextPageLink
for pagination.
A promise that resolves to an object containing:
message
- Status or information message about the response (mandatory)data
- List of organization objects or related information (mandatory)nextPageLink
- Token to retrieve the next page of organizations (mandatory)totalNumberOfRecords
- Total number of organizations available (optional)Throws an error if:
// Input:
const organizations = await organization.findAll();
// Fetch next page using pagination token
const moreOrgs = await organization.findAll(organizations.nextPageLink);
// Expected output:
{
data: [
{ id: "ORG001", organizationName: "City Hospital", ... },
{ id: "ORG002", organizationName: "Community Clinic", ... }
],
nextPageLink: "someOpaqueTokenForPage2",
message: "Successfully fetched organizations",
totalNumberOfRecords: 200
}
Retrieves an organization by its identifier and ID type.
Type of identifier used to fetch the organization (e.g., "accountId", "facilityId", "id") - mandatory
Accepted values: OrganizationIdType.ACCOUNT_ID | OrganizationIdType.FACILITY_ID | OrganizationIdType.ID
Unique identifier value for the organization based on the provided idType
- mandatory
A promise that resolves to:
message
: Status or informational message about the response (mandatory)data
: Organization data associated with the given identifier (mandatory)nextPageLink
: Pagination token if additional data exists (optional)totalNumberOfRecords
: Total count of matching records (optional)// Input:
const response = await organization.findById("accountId", "12345");
console.log(response)
// Expected Output:
{
message: "Organization Found !!!",
data: {
id: "someInternalId",
organizationId: "HFR-XYZ-123",
organizationName: "Sunshine Hospital",
basicInformation: {
address: "123 Main Street, Hyderabad",
state: "Telangana",
pincode: "500001",
contactNumber: "+919876543210"
},
// ... other organization fields
},
totalNumberOfRecords: 1
}
Extracts districts for a specific state from a pre-fetched list of states. This is a client-side filtering operation and does not make an API call.
The LGD code of the state for which to get districts (e.g., "27" for Maharashtra). Must be a valid, non-null string.
A promise that resolves to an array of DistrictDTO
objects for the given state.
If the state code is not found, returns an empty array.
// Input:
// First, fetch all states
const allStates = await organization.getStates();
// Then, extract districts for a specific state
const districts = await organization.getDistrictsByState("27", allStates);
console.log("Districts in Maharashtra:", districts);
// Expected Output:
[
{ "code": "519", "name": "Mumbai" },
{ "code": "520", "name": "Pune" },
...
]
Fetches the latitude and longitude for a given location using the Google Maps Geocoding API.
The location (address, city, etc.) to geocode. Must be a valid non-empty string.
A promise that resolves to a LocationDTO
containing geolocation data such as latitude and longitude.
// Input:
const result = await organization.getLatitudeAndLongitude("Bengaluru, India");
console.log(result.results[0].geometry.location); // { lat: ..., lng: ... }
// Expected Output:
{
"results": [
{
"geometry": {
"location": {
"lat": 37.4224764,
"lng": -122.0842499
}
},
...
}
],
"status": "OK"
}
Fetches a list of code-value pairs for a specific master data type (e.g., all "ownership" types).
The master data type to fetch (e.g., "ownership").
A promise that resolves to an object containing:
// Input:
const result = await organization.getMasterData("ownership");
console.log("Ownership Types:");
result.data.forEach(item => {
console.log(`- Code: ${item.code}, Value: ${item.value}`);
});
// Expected Output:
{
"type": "ownership",
"data": [
{ "code": "PVT", "value": "Private" },
{ "code": "GOV", "value": "Government" }
]
}
Fetches a list of all available master data categories from the demographic service. These types can then be used to fetch specific master data lists.
A promise that resolves with an object containing:
// Input:
const masterTypes = await organization.getMasterTypes();
console.log("Available Master Data Types:");
masterTypes.masterTypes.forEach(type => {
console.log(`- ${type.type}: ${type.desc}`);
});
// Expected Output:
{
"masterTypes": [
{ "type": "ownership", "desc": "Facility Ownership" },
{ "type": "speciality", "desc": "Medical Specialities" }
// ...
]
}
Fetches organization sub-type data based on the provided request.
This function validates the input organizationSubType
data before making a request to retrieve
organization sub-type information. If validation fails or if an error occurs during the API call, an error is thrown.
An object containing the data needed to fetch organization sub-types.
The parent organization type code (e.g., "HOSP").
A promise that resolves to an object containing the type and an array of organization sub-type entries.
// Input:
const result = await organization.getOrganizationSubType({ code: "HOSP" });
console.log("Hospital Subtypes:");
result.data.forEach(item => console.log("- " + item.value));
// Expected Output:
{
type: "facilitySubType",
data: [
{ code: "GEN", value: "General Hospital" },
{ code: "SUP", value: "Super Speciality Hospital" }
]
}
Fetches organization type data based on the provided request.
This function validates the input organizationType
data before making a request to retrieve organization type information.
If the validation fails or if an error occurs during the API call, an error is thrown.
The data required to fetch the organization type information.
A promise that resolves to an object containing the organization type data, or an error message if the request fails.
// Input:
const result = await orgganization.getOrganizationType("PVT");
console.log("Organization Types for Private Ownership:");
result.data.forEach(item => console.log("- " + item.value));
// Expected Output:
{
"type": "facilityType",
"data": [
{ "code": "HOSP", "value": "Hospital" },
{ "code": "CLIN", "value": "Clinic" }
]
}
Fetches a list of ownership subtypes based on a parent ownership type code.
For example, if the parent type is "Government", the subtypes might include "State Government" or "Central Government".
A promise that resolves to an object containing the ownership subtype list.
// Input:
const result = await organization.getOwnershipSubType("GOV");
console.log("Government Ownership Subtypes:");
result.data.forEach(item => console.log("- " + item.value));
// Expected Output:
{
type: "ownershipSubType",
data: [
{ code: "SG", value: "State Government" },
{ code: "CG", value: "Central Government" }
]
}
Fetches a list of medical specialities available for a given system of medicine.
For example, for "Allopathy", it may return specialities like "General Medicine", "Pediatrics", etc.
The code representing the system of medicine (e.g., "AYUSH", "ALLO").
A promise that resolves to an object containing the list of specialities.
// Input:
const specialities = await organization.getSpecialitiesForMedicine("AYUSH");
console.log("AYUSH Specialities:");
specialities.data.forEach(item => console.log("- " + item.value));
// Expected Output:
{
type: "speciality",
data: [
{ code: "AYUR", value: "Ayurveda" },
{ code: "YOGA", value: "Yoga & Naturopathy" }
]
}
Fetches a complete list of all states and their associated districts from the LGD (Local Government Directory) API.
A promise that resolves to an array of StateDTO
objects.
Each StateDTO
includes:
// Input:
const states = await organizationService.getLgdStates();
console.log("Total states found:", states.length);
states.forEach(state => {
console.log("- " + state.name);
});
// Expected Output:
[
{ "code": "27", "name": "MAHARASHTRA", "districts": [ ... ] },
{ "code": "29", "name": "KARNATAKA", "districts": [ ... ] },
...
]
Fetches a list of sub-districts (talukas/tehsils) that belong to a specific district, identified by its LGD code.
The LGD code of the district. Must not be null.
A promise that resolves to a list of sub-districts, each represented as a DistrictDTO
object with its own code and name.
Searches for Organizations based on provided filters and pagination info.
Validates the input search data and sends a request to the /search-organization
endpoint.
Filters and pagination info used for searching organizations.
Fields of SearchOrganizationDTO
include:
organizationName
.organizationId
.// Input:
const response = await organization.search({
ownershipCode: "GOVT",
stateLGDCode: "28",
pincode: "500032",
facilityName: "Primary Health Center",
page: 1,
resultsPerPage: 10
});
// Expected Output:
{
"data": [
{
"organizationName": "Andheri West Clinic",
// other fields...
}
],
"total": 1,
"page": 1
}
Updates an existing Organization's Spoc details.
Object containing updated organization information - mandatory
Fields of UpdateOrganizationDTO
include:
Provides specialized services for managing Organization resources.
This class handles all operations related to organizations, including:
Unlike other resource services, this class has custom methods tailored specifically for organization management and does not implement the generic
ResourceService
interface.