Hunflair / api_client.py
samaresh55's picture
Upload api_client.py
f41a399 verified
import json
import requests
api_url = "http://GLGBLN-SD911530.eu.novartis.net:8056/model"
input_json = {
"pdfName": "Sample-3-new.pdf",
"annotationType": "Highlighted",
"removedPages": "",
"data": {
"2": {
"4da46ce4-5299-44c7-9f4a-2aff980ff2c8": {
"onlypara": "On April 20, 2024, subject ID 1035, aged 45, received a dose of VAY736 as part of their ongoing clinical trial. The medication, administered intravenously at a dosage of 200 mg, aims to assess its efficacy in treating autoimmune disorders. Subject ID 1035 has been closely monitored for any adverse reactions or improvements in their condition following the administration of VAY736. The trial also includes regular follow-up appointments to track the subject's progress and ensure their safety throughout the study period.",
"id": "d4c692875c1418c41d62971e5330c8befca3b74680bc699b91979091606f5c47",
"paraId": "4da46ce4-5299-44c7-9f4a-2aff980ff2c8",
"pageNo": 2,
"para": "On April 20, 2024, subject ID 1035 received a dose of VAY736 as part of their ongoing clinical trial. The medication, administered intravenously at a dosage of 200 mg, aims to assess its efficacy in treating autoimmune disorders. Subject ID 1035 has been closely monitored for any adverse reactions or improvements in their condition following the administration of VAY736. The trial also includes regular follow-up appointments to track the subject's progress and ensure their safety throughout the study period.",
"entity": [
{
"entity": "",
"tag": "",
"position": []
}
],
"entities": {},
"isVerified": False,
"isTable": False
}
}
}
}
payload = json.dumps({"gps_datapath": "",
"jsonfolder": input_json,
"package": "4287",
"doc": "004e0402-eb96-3077-9dcc-8342a6c8ddc8",
"flow": "manual",
"compliance": "emea",
"tag_entities": {"Name": "NAME", "Age": "AGE", "Gender": "GENDER", "Subject_id": "SUBJID", "Patient_id": "SUBJID", "Date": "DATE", "Study_dates": "DATE", "Medical_history": "MH", "Height": "HEIGHT", "Weight": "WEIGHT", "Phone_number": "CONTACT", "Email": "CONTACT", "Address": "ADDRESS", "Country": "COUNTRY", "Ethnicity": "RACE","Non-participant": "NON_PARTICIPANT", "Non_participant": "NON_PARTICIPANT", "Smoking_habit": "SMOKING HABITS", "Drinking_habit": "DRINKING HABITS", "Study_day": "PRECLINICAL STUDY DAY", "Site_id": "Patient Related SiteID", "Circumstances": "CIRCUMSTANCES","Costs":"COSTS","Account_number":"ACCOUNT_NUMBER","Account_Number":"ACCOUNT_NUMBER","Swift_code":"SWIFT_CODE","Swift_Code":"SWIFT_CODE","Dosage":"DOSAGE","Dosages":"DOSAGES","Organization_names":"ORGANIZATION_NAMES","Drug_names":"DRUG_NAMES"},
"entity_mapping": {"Name": "NAME", "Age": "AGE", "Gender": "GENDER", "Subject_id": "SUBJID", "Patient_id": "SUBJID", "Date": "DATE", "Study_dates": "DATE", "Medical_history": "MH", "Height": "HEIGHT", "Weight": "WEIGHT", "Phone_number": "CONTACT", "Email": "CONTACT", "Address": "ADDRESS", "Country": "COUNTRY", "Ethnicity": "RACE","Non-participant": "NON_PARTICIPANT", "Non_participant": "NON_PARTICIPANT", "Smoking_habit": "SMOKING HABITS", "Drinking_habit": "DRINKING HABITS", "Study_day": "PRECLINICAL STUDY DAY", "Site_id": "Patient Related SiteID", "Circumstances": "CIRCUMSTANCES","Costs":"COSTS","Account_number":"ACCOUNT_NUMBER","Account_Number":"ACCOUNT_NUMBER","Swift_code":"SWIFT_CODE","Swift_Code":"SWIFT_CODE","Dosage":"DOSAGE","Dosages":"DOSAGES","Organization_names":"ORGANIZATION_NAMES","Drug_names":"DRUG_NAMES"},
"subject_ids": ['25291/3280']})
payload_1 = json.dumps({"gps_datapath": "",
"jsonfolder": "extracted_files/4287_004e0402-eb96-3077-9dcc-8342a6c8ddc8_extraction.json",
# "jsonfolder":"extracted_files/004e0402-eb96-3077-9dcc-8342a6c8ddc8_input_extracted_old_format.json",
"package": "4287",
"doc": "004e0402-eb96-3077-9dcc-8342a6c8ddc8",
"flow": "manual",
"compliance": "emea",
"tag_entities": {"Name": "NAME", "Age": "AGE", "Gender": "GENDER", "Subject_id": "SUBJID", "Patient_id": "SUBJID", "Date": "DATE", "Study_dates": "DATE", "Medical_history": "MH", "Height": "HEIGHT", "Weight": "WEIGHT", "Phone_number": "CONTACT", "Email": "CONTACT", "Address": "ADDRESS", "Country": "COUNTRY", "Ethnicity": "RACE","Non-participant": "NON_PARTICIPANT", "Non_participant": "NON_PARTICIPANT", "Smoking_habit": "SMOKING HABITS", "Drinking_habit": "DRINKING HABITS", "Study_day": "PRECLINICAL STUDY DAY", "Site_id": "Patient Related SiteID", "Circumstances": "CIRCUMSTANCES","Costs":"COSTS","Account_number":"ACCOUNT_NUMBER","Account_Number":"ACCOUNT_NUMBER","Swift_code":"SWIFT_CODE","Swift_Code":"SWIFT_CODE","Dosage":"DOSAGE","Dosages":"DOSAGES","Organization_names":"ORGANIZATION_NAMES","Drug_names":"DRUG_NAMES"},
"entity_mapping": {"Name": "NAME", "Age": "AGE", "Gender": "GENDER", "Subject_id": "SUBJID", "Patient_id": "SUBJID", "Date": "DATE", "Study_dates": "DATE", "Medical_history": "MH", "Height": "HEIGHT", "Weight": "WEIGHT", "Phone_number": "CONTACT", "Email": "CONTACT", "Address": "ADDRESS", "Country": "COUNTRY", "Ethnicity": "RACE","Non-participant": "NON_PARTICIPANT", "Non_participant": "NON_PARTICIPANT", "Smoking_habit": "SMOKING HABITS", "Drinking_habit": "DRINKING HABITS", "Study_day": "PRECLINICAL STUDY DAY", "Site_id": "Patient Related SiteID", "Circumstances": "CIRCUMSTANCES","Costs":"COSTS","Account_number":"ACCOUNT_NUMBER","Account_Number":"ACCOUNT_NUMBER","Swift_code":"SWIFT_CODE","Swift_Code":"SWIFT_CODE","Dosage":"DOSAGE","Dosages":"DOSAGES","Organization_names":"ORGANIZATION_NAMES","Drug_names":"DRUG_NAMES"},
"subject_ids": ['25291/3280']})
headers = {'Content-Type': 'application/json'}
response = requests.post(api_url, data=payload_1, headers=headers)
print(response)
if response.status_code == 200:
api_response = response.json()
print(api_response)
else:
print("Error in API:", response.status_code)