PROTO-TYPE-SOLUTIONS / easymed

Repository for Make-Easy HMIS. The all-in-one HMIS for Healthcare facilities.
7 stars 7 forks source link

add authentication to listener script #499

Closed mosesmbadi closed 3 months ago

mosesmbadi commented 3 months ago

Haven't figured what to call it but lis_list2.py will listen for incoming data from equipments, convert the data to json then send to lab results endpont. Task: Add authentication to the function that sends results to the endpoint

def send_to_lab_endpoints(data, format):
    endpoints = {
        'lab_test_results': 'http://127.0.0.1:8080/lab/lab-test-results/',
        'lab_test_results_panel': 'http://127.0.0.1:8080/lab/lab-test-results-panel/'
    }

    for endpoint in endpoints.values():
        response = requests.post(endpoint, json=data)
        if response.status_code == 200:
            print(f"Data sent successfully to {endpoint}")
        else:
            print(f"Failed to send data to {endpoint}. Status code: {response.status_code}")