Organization¶
organization_dto ¶
MasterType ¶
Bases: BaseModel
Represents a master type with a type and description.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
The type identifier. |
desc |
str
|
The description of the type. |
MasterTypeResponse ¶
Bases: BaseModel
Represents a response containing a list of master types.
Attributes:
| Name | Type | Description |
|---|---|---|
master_types |
list[MasterType]
|
List of master types. |
MasterData ¶
Bases: BaseModel
Represents a single master data entry with a code and value.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
The code for the master data. |
value |
str
|
The value for the master data. |
MasterDataResponse ¶
Bases: BaseModel
Represents a response containing a list of master data entries.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
The type of master data. |
data |
list[MasterData]
|
List of master data entries. |
LGDDistrictsResponse ¶
Bases: BaseModel
Represents a district with its code and name.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
The district code. |
name |
str
|
The district name. |
LGDDistrictsListResponse ¶
LGDStatesResponse ¶
Bases: LGDDistrictsResponse
Represents a state with its code, name, and a list of districts. Inherits code and name from LGDDistrictsResponse.
Attributes:
| Name | Type | Description |
|---|---|---|
districts |
list[LGDDistrictsResponse]
|
List of districts in the state. |
LGDStatesListResponse ¶
LocationResponse ¶
Bases: BaseModel
Represents location response.
GetOrganizationsResponse ¶
Bases: BaseModel
Represents the response for retrieving organization data.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
Optional[str]
|
A message describing the response. |
data |
Optional[Any]
|
The actual data returned in the response. |
next_page_link |
Optional[str]
|
A link to the next page of results. |
total_number_of_records |
Optional[int]
|
The total number of records available. |
BasicInformation ¶
Bases: BaseModel
Represents the basic information of an organization.
Attributes:
| Name | Type | Description |
|---|---|---|
organization_name |
str
|
The name of the organization. |
region |
str
|
The region where the organization is located. |
address_line1 |
str
|
The first line of the organization's address. |
address_line2 |
str
|
The second line of the organization's address. |
district |
str
|
The district of the organization. |
sub_district |
str
|
The sub-district of the organization. |
city |
str
|
The city where the organization is located. |
state |
str
|
The state or union territory. |
country |
Country
|
The country of the organization. |
pincode |
PincodeType
|
The pincode of the organization's location. |
lat_longs |
list[str]
|
The latitude and longitude coordinates of the organization. |
ContactInformation ¶
Bases: BaseModel
Represents the contact details of an organization.
Attributes:
| Name | Type | Description |
|---|---|---|
mobile_number |
MobileNumberType
|
The mobile number of the organization. |
email |
EmailStr
|
The email address of the organization. |
landline |
str
|
The landline number of the organization. |
stdcode |
str
|
The STD code associated with the landline. |
website_link |
str
|
The official website link of the organization. |
UploadDocuments ¶
Bases: BaseModel
Represents the document upload details for an organization.
Attributes:
| Name | Type | Description |
|---|---|---|
board_photo |
dict[str, str]
|
Must contain 'value' and 'name' keys. |
building_photo |
dict[str, str]
|
Must contain 'value' and 'name' keys. |
AddAddressProof ¶
Bases: BaseModel
Represents an address proof document with type and attachment details.
Attributes:
| Name | Type | Description |
|---|---|---|
address_proof_type |
str
|
The type of address proof. |
address_proof_attachment |
dict[str, str]
|
The attachment details, must contain 'value' and 'name' keys. |
OrganizationTimings ¶
Bases: BaseModel
Represents organization timings with multiple shifts.
Attributes:
| Name | Type | Description |
|---|---|---|
timings |
str
|
The timings description. |
shifts |
list[dict[str, Optional[Any]]]
|
List of shift dictionaries, each with 'start' and 'end' keys. |
OrganizationDetails ¶
Bases: BaseModel
Represents the details of an organization, including ownership type, subtype, and status.
Attributes:
| Name | Type | Description |
|---|---|---|
ownership_type |
str
|
The ownership type. |
ownership_sub_type |
str
|
The ownership sub-type. |
status |
str
|
The status of the organization. |
SystemOfMedicine ¶
Bases: BaseModel
Represents a system of medicine, including specialities, organization type, and service type.
Attributes:
| Name | Type | Description |
|---|---|---|
specialities |
list[dict[str, Any]]
|
List of specialities, each with 'systemofMedicineCode' and 'specialities' keys. |
organization_type |
str
|
The organization type. |
organization_sub_type |
str
|
The organization sub-type. |
service_type |
str
|
The service type. |
ImagingCenterServiceType ¶
Bases: BaseModel
Represents an imaging center service type with a service name and count.
Attributes:
| Name | Type | Description |
|---|---|---|
service |
str
|
The name of the imaging service. |
count |
int
|
The count of the service. |
OrganizationInventory ¶
Bases: BaseModel
Represents the inventory details of a healthcare organization, including available ventilators, beds, and various organization attributes.
Attributes:
| Name | Type | Description |
|---|---|---|
total_number_of_ventilators |
int
|
Total number of ventilators. |
total_number_of_beds |
int
|
Total number of beds. |
has_dialysis_center |
str
|
Whether the organization has a dialysis center. |
has_pharmacy |
str
|
Whether the organization has a pharmacy. |
has_blood_bank |
str
|
Whether the organization has a blood bank. |
has_cath_lab |
str
|
Whether the organization has a cath lab. |
has_diagnostic_lab |
str
|
Whether the organization has a diagnostic lab. |
has_imaging_center |
str
|
Whether the organization has an imaging center. |
services_by_imaging_center |
list[ImagingCenterServiceType]
|
List of imaging center services. |
nhrrid |
str
|
NHRR ID. |
nin |
str
|
NIN. |
abpmjayid |
str
|
ABPMJAY ID. |
rohini_id |
str
|
ROHINI ID. |
echs_id |
str
|
ECHS ID. |
cghs_id |
str
|
CGHS ID. |
cea_registration |
str
|
CEA registration. |
state_insurance_scheme_id |
str
|
State insurance scheme ID. |
AddOrganizationDTO ¶
Bases: BaseModel
Represents the data transfer object for adding a new healthcare organization.
This includes organization-related information such as basic details, contact information, documents, address proof, timings, details, system of medicine, inventory, and account identifiers.
Attributes:
| Name | Type | Description |
|---|---|---|
basic_information |
BasicInformation
|
Basic information about the organization. |
contact_information |
ContactInformation
|
Contact details. |
upload_documents |
UploadDocuments
|
Uploaded documents. |
add_address_proof |
list[AddAddressProof]
|
List of address proof documents. |
organization_timings |
list[OrganizationTimings]
|
Organization timings. |
organization_details |
OrganizationDetails
|
Organization details. |
system_of_medicine |
SystemOfMedicine
|
System of medicine information. |
organization_inventory |
OrganizationInventory
|
Inventory details. |
account_id |
str
|
Account ID. |
organization_id |
Optional[str]
|
Organization ID. |
id |
Optional[str]
|
Internal ID. |
UpdateOrganizationDTO ¶
Bases: BaseModel
Represents the data transfer object for updating organization details.
This includes fields related to the organization's Single Point of Contact (SPOC), along with optional consent manager details.
Attributes:
| Name | Type | Description |
|---|---|---|
spoc_name |
str
|
Name of the SPOC. |
id |
str
|
Organization ID. |
spoc_id |
str
|
SPOC ID. |
consent_manager_name |
Optional[str]
|
Consent manager name. |
consent_manager_id |
Optional[str]
|
Consent manager ID. |
SearchOrganizationDTO ¶
Bases: BaseModel
Represents the data transfer object for searching facilities.
Attributes:
| Name | Type | Description |
|---|---|---|
ownership_code |
Optional[str]
|
The ownership code of the organization. |
state_lgd_code |
Optional[str]
|
The LGD code of the state. |
district_lgd_code |
Optional[str]
|
The LGD code of the district. |
sub_district_lgd_code |
Optional[str]
|
The LGD code of the sub-district. |
pincode |
Optional[str]
|
The pincode of the organization's location. |
organization_name |
Optional[str]
|
The name of the organization. |
organization_id |
Optional[str]
|
The ID of the organization. |
page |
int
|
The page number for pagination. |
results_per_page |
int
|
The number of results per page for pagination. |
Organization ¶
Bases: BaseModel
Represents an organization.
Attributes:
| Name | Type | Description |
|---|---|---|
organization_id |
str
|
The ID of the organization. |
organization_name |
str
|
The name of the organization. |
organization_status |
str
|
The status of the organization. |
ownership |
str
|
The ownership of the organization. |
ownership_code |
str
|
The ownership code of the organization. |
system_of_medicine_code |
str
|
The system of medicine code of the organization. |
system_of_medicine |
str
|
The system of medicine of the organization. |
organization_type_code |
str
|
The organization type code of the organization. |
organization_type |
str
|
The organization type of the organization. |
state_name |
str
|
The name of the state. |
state_lgd_code |
str
|
The LGD code of the state. |
district_name |
str
|
The name of the district. |
district_lgd_code |
str
|
The LGD code of the district. |
sub_district_name |
str
|
The name of the sub-district. |
sub_district_lgd_code |
str
|
The LGD code of the sub-district. |
village_city_town_name |
Optional[str]
|
The name of the village, city, or town. |
village_city_town_lgd_code |
str
|
The LGD code of the village, city, or town. |
address |
str
|
The address of the organization. |
pincode |
str
|
The pincode of the organization. |
latitude |
str
|
The latitude of the organization's location. |
longitude |
str
|
The longitude of the organization's location. |
SearchOrganizationResponse ¶
Bases: BaseModel
Represents the response for searching facilities.
Attributes:
| Name | Type | Description |
|---|---|---|
organizations |
list[Organization]
|
A list of organizations. |
message |
str
|
A message describing the response. |
total_organizations |
int
|
The total number of organizations. |
number_of_pages |
int
|
The number of pages. |
OrganizationTypeRequest ¶
Bases: BaseModel
Represents the request body for fetching organization types.
Attributes:
| Name | Type | Description |
|---|---|---|
ownership_code |
str
|
The ownership code. Required. |
system_of_medicine_code |
Optional[str]
|
The system of medicine code. Optional. |
OwnershipSubTypeRequest ¶
Bases: BaseModel
Represents the request body for fetching ownership subtypes.
Attributes:
| Name | Type | Description |
|---|---|---|
ownership_code |
str
|
The ownership code. Required. |
owner_subtype_code |
Optional[str]
|
The owner subtype code. Optional. |
SpecialitiesRequest ¶
Bases: BaseModel
Represents the request body for fetching specialities.
Attributes:
| Name | Type | Description |
|---|---|---|
system_of_medicine_code |
str
|
The system of medicine code. Required. |
OrganizationSubTypeRequest ¶
Bases: BaseModel
Represents the request body for fetching organization subtypes.
Attributes:
| Name | Type | Description |
|---|---|---|
organization_type_code |
str
|
The organization type code. Required. |
Organization ¶
Organization(config: ClientConfig)
Bases: BaseService
SDK-friendly service for managing organization-related operations.
This service provides a comprehensive interface for interacting with the CareStack organization API. It supports operations such as creating, updating, deleting, and searching organizations, as well as fetching master data types and LGD administrative data.
It internally validates all input data using Pydantic DTOs, manages request formatting, and gracefully handles errors with comprehensive logging.
Key Features
- Asynchronous operations for non-blocking I/O.
- Strongly typed request and response models using Pydantic.
- Error handling with custom exceptions for API failures.
- Support for complex search queries and pagination.
- Utility methods to fetch master data types and LGD administrative data.
Methods:
| Name | Description |
|---|---|
create |
Registers a new organization. |
find_all |
Retrieves all organizations with optional pagination. |
find_by_id |
Fetches an organization by a specific ID type and value. |
exists |
Checks if an organization exists by ID type and value. |
update |
Updates an existing organization's information. |
delete |
Deletes an organization by its unique ID. |
search |
Searches for organizations based on complex criteria. |
get_master_types |
Retrieves master types of organizations. |
get_master_data |
Fetches master data for a specific type (e.g., ownership, organization type). |
get_lgd_states |
Retrieves all states with their districts. |
get_lgd_sub_districts |
Retrieves sub-districts for a given district code. |
get_organization_type |
Retrieves organization types based on ownership and optional system of medicine. |
get_owner_subtypes |
Retrieves ownership subtypes for a given ownership code. |
get_specialities |
Retrieves specialities associated with a system of medicine. |
get_organization_subtypes |
Retrieves organization subtypes for a given organization type code. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ClientConfig
|
Configuration object with API connection and authentication details. |
required |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
If any API request fails or validation errors occur. |
Example Usage
config = ClientConfig(api_key="your_api_key",hprid_auth="your_auth_token")
organization_service = Organization(config)
# Register a new organization
new_org_data = {
"basicInformation": {
"facilityName": "City Hospital",
"region": "East Zone",
"addressLine1": "123 Main Street",
"addressLine2": "Near City Mall",
"district": "District One",
"subDistrict": "Subdistrict A",
"city": "Metropolis",
"state": "State X",
"country": "IN",
"pincode": "123456",
"latLongs": ["28.6139,77.2090"]
},
...
}
message = await organization_service.create(new_org_data)
print(message) # e.g., "Organization registered successfully."
create
async
¶
create(organization: dict[str, Any]) -> str
Registers a new organization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
organization
|
AddOrganizationDTO
|
Data for the new organization, validated via AddOrganizationDTO. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Response message indicating success or error description. |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
On validation or API request failure. |
Example
message = await organization_service.create(new_org_data)
print(message) # "Organization registered successfully."
Response:¶
Sample Output:
"Organization registered successfully."
find_all
async
¶
find_all(next_page: Optional[str] = None) -> GetOrganizationsResponse
Retrieves all organizations with optional pagination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
next_page
|
Optional[str]
|
Token for fetching next page of results. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
GetOrganizationsResponse |
GetOrganizationsResponse
|
Includes organization list, pagination tokens, and total count. |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
On API communication failures. |
Example
response = await organization_service.find_all()
print(response.data)
if response.next_page:
print("More results available at:", response.next_page)
Response:¶
Sample Output:
{
"data": [
{
"organizationId": "org123",
"organizationName": "City Hospital",
"district": "District One",
"pincode": "110001",
"state": "State X",
"country": "IN"
},
{
"organizationId": "org456",
"organizationName": "Another Hospital",
"district": "District Two",
"pincode": "110002",
"state": "State Y",
"country": "IN"
}
],
"nextPage": "token_for_next_page",
"total": 5
}
find_by_id
async
¶
find_by_id(search_param: OrganizationsIdType, search_term: str) -> GetOrganizationsResponse
Retrieves an organization by a specific ID type and its corresponding value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search_param
|
OrganizationsId
|
Enum specifying ID type (e.g., ACCOUNT_ID, ORGANIZATION_ID). |
required |
search_term
|
str
|
The unique identifier value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
GetOrganizationsResponse |
GetOrganizationsResponse
|
Detailed organization information. |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
On invalid IDs or request errors. |
Example
org = await organization_service.find_by_id(OrganizationsId.ORGANIZATION_ID, "org123")
print(org.data)
Response:¶
Sample Output:
{
"data": {
"organizationId": "org123",
"organizationName": "City Hospital",
"district": "District One",
"pincode": "110001",
"state": "State X",
"country": "IN"
}
}
exists
async
¶
exists(search_param: OrganizationsIdType, search_term: str) -> bool
Checks whether an organization exists given a specific ID and its value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search_param
|
OrganizationsIdType
|
The ID type (e.g., ACCOUNT_ID, ORGANIZATION_ID). |
required |
search_term
|
str
|
The unique ID value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the organization exists; otherwise False. |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
On API failures. |
Example
exists = await organization_service.exists(OrganizationsId.ORGANIZATION_ID, "org123")
print(exists)
Response:¶
Sample Output:
True or False depending on existence of organization with ID `search_term`.
update
async
¶
update(update_organization_data: UpdateOrganizationDTO) -> str
Updates an existing organization's information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update_organization_data
|
UpdateOrganizationDTO
|
Data including organization update fields. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Response message from the update operation. |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
On validation or API request failure. |
Example
update_info = UpdateOrganizationDTO(
id="org123",
spocName="Dr. Smith",
spocId="spoc001",
consentManagerName="Manager Name",
consentManagerId="cm001"
)
message = await organization_service.update(update_info)
print(message) # "Organization updated successfully."
Response:¶
Sample Output:
"Organization updated successfully."
delete
async
¶
delete(organization_id: str) -> str
Deletes an organization by its unique ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
organization_id
|
str
|
The unique ID of the organization to delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Response message indicating success or failure. |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
On invalid IDs or unsuccessful deletion. |
Example
message = await organization_service.delete("org123")
print(message) # "Organization deleted successfully."
Response:¶
Sample Output:
"Organization deleted successfully."
### Raises:
EhrApiError: If the organization ID is invalid or deletion fails.
search
async
¶
search(search_organization_data: SearchOrganizationDTO) -> SearchOrganizationResponse
Searches for organizations based on complex criteria.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search_organization_data
|
SearchOrganizationDTO
|
DTO containing search parameters, including location, type, etc. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SearchOrganizationResponse |
SearchOrganizationResponse
|
Contains matching organizations and pagination info. |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
On validation failure or API request errors. |
Example
criteria = SearchOrganizationDTO(
organizationName="City Hospital",
districtLGDCode="DL01",
pincode="110001",
page=1,
resultsPerPage=20
)
response = await organization_service.search(criteria)
print(f"Found {response.total} organizations matching criteria.")
for org in response.organizations:
print(org.organization_name, org.district)
Response:¶
Sample Output:
{ "total": 5,
"page": 1,
"resultsPerPage": 20,
"organizations": [
{
"organizationId": "org123",
"organizationName": "City Hospital",
"district": "District One",
"pincode": "110001",
"state": "State X",
"country": "IN"
},
{
"organizationId": "org456",
"organizationName": "Another Hospital",
"district": "District Two",
"pincode": "110002",
"state": "State Y",
"country": "IN"
}
]
}
get_master_types
async
¶
get_master_types() -> MasterTypeResponse
Retrieves master types of organizations from the utility API.
Returns:
| Name | Type | Description |
|---|---|---|
MasterTypeResponse |
MasterTypeResponse
|
List of master types with descriptions. |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
On API request failure. |
Example
master_types = await organization_service.get_master_types()
for mt in master_types.master_types:
print(mt.type, mt.desc)
Response:¶
Sample Output:
{
"master_types": [
{"type": "ownershipType", "desc": "Ownership Type"},
{"type": "organizationType", "desc": "Organization Type"},
{"type": "specialities", "desc": "Specialities"}
]
}
get_master_data
async
¶
get_master_data(data_type: str) -> MasterDataResponse
Retrieves master data of a given type from the utility API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_type
|
str
|
The type of master data to fetch, e.g., "ownershipType", "organizationType", etc. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MasterDataResponse |
MasterDataResponse
|
List of key-value master data pairs. |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
On invalid data type or API failure. |
Example
ownership_types = await organization_service.get_master_data("ownershipType")
for item in ownership_types.data:
print(item.code, item.value)
Response:¶
Sample Output:
{
"data": [
{"code": "GOV", "value": "Government"},
{"code": "PRV", "value": "Private"}
],
"type": "ownershipType"
}
get_lgd_states
async
¶
get_lgd_states() -> LGDStatesListResponse
Retrieves all states with their districts from the LGD (Local Government Directory) API.
Returns:
| Name | Type | Description |
|---|---|---|
LGDStatesListResponse |
LGDStatesListResponse
|
List of states, each containing a list of districts. |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
On API communication failure or invalid response. |
Example
states = await organization_service.get_lgd_states()
for state in states.root:
print(state.code, state.name)
for district in state.districts:
print(" -", district.code, district.name)
Response:¶
Sample Output:
{
{"code": "DL", "name": "Delhi", "districts": [
{"code": "DL01", "name": "District One"},
{"code": "DL02", "name": "District Two"}
]},
get_lgd_sub_districts
async
¶
get_lgd_sub_districts(district_code: str) -> LGDDistrictsListResponse
Retrieves sub-districts for a given district code from the LGD API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
district_code
|
str
|
The code identifying the district. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
LGDDistrictsListResponse |
LGDDistrictsListResponse
|
List of sub-districts. |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
On invalid district code or API failures. |
Example
subdistricts = await organization_service.get_lgd_districts("DL01")
for sd in subdistricts.root:
print(sd.code, sd.name)
Response:¶
Sample Output:
{
"root": [
{"code": "DL01", "name": "Subdistrict A"},
{"code": "DL02", "name": "Subdistrict B"}
]
}
get_organization_type
async
¶
get_organization_type(request_body: OrganizationTypeRequest) -> MasterDataResponse
Retrieves organization types based on given ownership and optional system of medicine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_body
|
OrganizationTypeRequest
|
DTO specifying ownership code and optional systemOfMedicineCode. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MasterDataResponse |
MasterDataResponse
|
List of organization types. |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
On validation or API failure. |
Example
request = OrganizationTypeRequest(ownershipCode="GOV", systemOfMedicineCode="AYUSH")
types = await organization_service.get_organization_type(request)
for t in types.data:
print(t.code, t.value)
Response:¶
Sample Output:
{
"data": [
{"code": "HOSP", "value": "Hospital"},
{"code": "CLINIC", "value": "Clinic"},
{"code": "LAB", "value": "Laboratory"}
],
"type": "organizationType"
}
get_owner_subtypes
async
¶
get_owner_subtypes(request_body: OwnershipSubTypeRequest) -> MasterDataResponse
Retrieves ownership subtypes for a given ownership code and optional subtype code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_body
|
OwnershipSubTypeRequest
|
DTO specifying ownership code and optional owner subtype code. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MasterDataResponse |
MasterDataResponse
|
List of ownership subtypes. |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
On validation or API failure. |
Example
request = OwnershipSubTypeRequest(ownershipCode="PRV")
subtypes = await organization_service.get_owner_subtypes(request)
for s in subtypes.data:
print(s.code, s.value)
Response:¶
Sample Output:
{
"data": [
{"code": "PRV", "value": "Private"},
{"code": "GOV", "value": "Government"}
],
"type": "ownershipSubType"
}
get_specialities
async
¶
get_specialities(request_body: SpecialitiesRequest) -> MasterDataResponse
Retrieves specialities associated with a given system of medicine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_body
|
SpecialitiesRequest
|
DTO specifying systemOfMedicineCode. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MasterDataResponse |
MasterDataResponse
|
List of specialities. |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
On request failure or invalid input. |
Example
request = SpecialitiesRequest(systemOfMedicineCode="ALL")
specialities = await organization_service.get_specialities(request)
for sp in specialities.data:
print(sp.code, sp.value)
Response:¶
Sample Output:
{
"data": [
{"code": "ALL", "value": "All"},
{"code": "CARD", "value": "Cardiology"},
{"code": "NEURO", "value": "Neurology"}
],
"type": "specialities"
}
get_organization_subtypes
async
¶
get_organization_subtypes(request_body: OrganizationSubTypeRequest) -> MasterDataResponse
Retrieves organization subtypes for a given organization type code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_body
|
OrganizationSubTypeRequest
|
DTO specifying organization type code. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MasterDataResponse |
MasterDataResponse
|
List of organization subtypes. |
Raises:
| Type | Description |
|---|---|
EhrApiError
|
On validation or API failure. |
Example
request = OrganizationSubTypeRequest(facilityType="HOSP")
subtypes = await organization_service.get_organization_subtypes(request)
for st in subtypes.data:
print(st.code, st.value)
Response:¶
Sample Output:
{
"data": [
{"code": "HOSP", "value": "Hospital"},
{"code": "CLINIC", "value": "Clinic"}
],
"type": "organizationSubType",
}
get_location
async
¶
get_location(address: str) -> LocationResponse
Retrieves location information for a given address.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
address
|
str
|
The address for which to retrieve location information. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
LocationResponse |
LocationResponse
|
|
Example
location = await organization_service.get_location("123 Main St, City")
print(location.lat, location.lng)
Response:¶
Sample Output:
{
"lat": "28.6139",
"lng": "77.2090"
}