Files
Gainsight/Scripts/API_Tests/workatotest.py

95 lines
2.9 KiB
Python
Raw Normal View History

import tmp
# WEBHOOK_PAYLOAD = {
# "id": "dc9aafe3-eee7-4d50-a480-3bd9831b893a",
# "email": "it",
# "type": "person_properties",
# "attributes": {
# "properties": {
# "agency_name": "32",
# "agency_id": "323",
# "medicaid_id": "22222",
# "provider_id": "2123231234",
# "learner_role": "Agency Billing",
# "learner_state": "Ohio",
# "evv_radio_selection": "Alt EVV Aggregator",
# "cal_evv_id": "None",
# "successfully_completed_secondary_registration": True,
# }
# },
# }
webhook_payload = {
"payload": {
"array": [
{
"id": "e134030d-a2a9-4de2-b4d5-87081feee18a",
"email": "gwalden@sandata.com",
"type": "person_properties",
"attributes": {
"properties": {
"agency_name": "Test 2",
"agency_id": "Test 2",
"medicaid_id": "54321",
"provider_id": "0987654321",
2024-06-18 16:31:27 -04:00
"learner_role": "CG",
"learner_state": "TN",
"evv_radio_selection": "Agency EVV",
"successfully_completed_secondary_registration": True,
"cal_evv_id": None
}
}
}
]
},
"params": {}
}
# def main(input):
# payload = input["webhook_payload"]
# for item in input["webhook_payload"]:
# evv = item["attributes"]["properties"]["evv_radio_selection"]
# state = item["attributes"]["properties"]["learner_state"]
# group_result = [ref_state for ref_state in REF if state in ref_state]
# try:
# if len(group_result) > 1:
# for group in group_result:
# if evv in group:
# group_uuid = group[2]
# else:
# group_uuid = group_result[0][2]
# except ValueError:
# pass
# finally:
# return {"group_uuid": group_uuid}
2024-06-18 16:31:27 -04:00
#
# # The one used in production
# for item in webhook_payload['payload']['array']:
# evv = item['attributes']['properties']['evv_radio_selection']
# state = item['attributes']['properties']['learner_state']
# id_pair = f"{state} {evv}"
# group_result = [ref_state for ref_state in tmp.REF if state in ref_state]
# if len(group_result) > 1:
# for group in group_result:
# if id_pair in group[1]:
# group_uuid = group[2]
# print(group_uuid)
# else:
# group_uuid = group_result[0][2]
# print(group_uuid)
2024-06-18 16:31:27 -04:00
# The one for Caregivers
for item in webhook_payload['payload']['array']:
2024-06-18 16:31:27 -04:00
role = item['attributes']['properties']['learner_role']
state = item['attributes']['properties']['learner_state']
2024-06-18 16:31:27 -04:00
id_pair = f"{role} - {state}"
group_result = [ref_state for ref_state in tmp.CG if state in ref_state]
if group_result[0][1] == id_pair:
group_uuid = group_result[0][2]
2024-06-18 16:31:27 -04:00
# group_uuid = group_result[0][2]
# if __name__ == "__main__":
# # main()
# main2()