def get_fhir_organisations(request, format, request_id):
    log_utils.log_layer_entry(constants.SERVICE, request_id )

    request_args = ImmutableMultiDict.copy(request.args)

    limit, page = get_pagination_parameters(request_args)

    ods_codes_dict, total_record_count, returned_record_count = model_entry.get_fhir_ods_codes(
        request_args, page, limit, request_id)

    list_of_org_dicts = []
    for ods_code in ods_codes_dict:
        org, address, role, contact, relationship, successor = model_entry.get_org_data(ods_code['odscode'], request_id,
                                                                                        is_fhir=True)
        org_dict = service_utils.build_org(org, address, role, contact, relationship, successor, is_fhir=True)
        list_of_org_dicts.append(org_dict)

    structured_bundle_dict = translation_entry.structure_fhir_organisations_bundle(list_of_org_dicts,
                                                                                   total_record_count, limit, page,
                                                                                   request, request_id)

    response_body = serialisation_entry.create_response_body(structured_bundle_dict, format, request_id, is_fhir=True)

    log_utils.log_layer_exit(constants.SERVICE, request_id)

    return response_body, returned_record_count, total_record_count
Beispiel #2
0
def create_fhir_error(format, code, display, request_id, description):

    response = create_fhir_error_dict(code, display, description)

    formatted_response_body = serialisation_entry.create_response_body(
        response, format, request_id, True)

    return formatted_response_body
Beispiel #3
0
def get_fhir_roles(request_id, format, request_url):
    log_utils.log_layer_entry(constants.SERVICE, request_id )

    organisation_roles_dict = model_entry.get_fhir_roles_codesystem(request_id)

    structred_organisation_roles_dict = translation_entry.structure_fhir_rolesystem(organisation_roles_dict, format,
                                                                                    request_url, request_id)

    response_body = serialisation_entry.create_response_body(structred_organisation_roles_dict, format, request_id, is_fhir=True)

    log_utils.log_layer_exit(constants.SERVICE, request_id)

    return response_body
def get_ord_organisations_summary(request, format, app_hostname, request_id):
    log_utils.log_layer_entry(constants.SERVICE, request_id)

    limit, offset = set_ord_offset_and_limit(request.args)

    orgs_summary_dict, total_record_count, returned_record_count = model_entry.get_ord_orgs_summary(
        request.args, limit, offset, request_id)

    structured_orgs_summary_dict = translation_entry.structure_ord_org_summary(
        orgs_summary_dict, app_hostname, request_id)

    response_body = serialisation_entry.create_response_body(
        structured_orgs_summary_dict, format, request_id, is_fhir=False)

    log_utils.log_layer_exit(constants.SERVICE, request_id)

    return response_body, returned_record_count, total_record_count
Beispiel #5
0
def get_single_organisation(ods_code, format, url_root, request_id, is_fhir):
    log_utils.log_layer_entry(constants.SERVICE, request_id)

    org, address, role, contact, relationship, successor = model_entry.get_org_data(
        ods_code, request_id, is_fhir)

    org_dict = service_utils.build_org(org, address, role, contact,
                                       relationship, successor, is_fhir)

    structured_org_dict = translation_entry.structure_org(
        org_dict, url_root, request_id, is_fhir)

    response_body = serialisation_entry.create_response_body(
        structured_org_dict, format, request_id, is_fhir)

    log_utils.log_layer_exit(constants.SERVICE, request_id)

    return response_body
Beispiel #6
0
def get_ord_organisations_changed_since(request_args, format, app_hostname,
                                        request_id):
    log_utils.log_layer_entry(constants.SERVICE, request_id)

    request_args = ImmutableMultiDict.copy(request_args)

    ods_codes = model_entry.get_ord_ods_codes_last_changed_since(
        request_args, request_id)

    total_record_count = len(ods_codes)

    structured_last_changed_since_summary = translation_entry.build_ord_last_changed_summary(
        ods_codes, format, app_hostname)

    response_body = serialisation_entry.create_response_body(
        structured_last_changed_since_summary,
        format,
        request_id,
        is_fhir=False)

    log_utils.log_layer_exit(constants.SERVICE, request_id)

    return response_body, total_record_count