1

I am able to retrieve the results for a drug from the openFDA via PHP; however the results are just strings of text without any indicators for formatting such as html tags or splitting them up into different objects. Is there a version of the data that can be more easily formatted? I feel the data is pointless if it isn't human readable.

EDITED above for clarification.

How I am retrieving the data:

$xml_path = 'https://api.fda.gov/drug/label.json?api_key='.$api.'&search=set_id:'.$setid;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$xml_path);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);

$setid_array = json_decode($data, true);

// Empty string
$results = '';

// Ensure there is a setid array
if (!empty($setid_array)) {

    // Results 
    $sections = $setid_array['results'][0];

    // Cycle through each
    foreach ($sections as $key => $section) {

        // Get the content
        $content = $section[0];
        echo $content;
    }
}

What I get for "Indications & Usage" on Rosuvastatin for example:

1 INDICATIONS AND USAGE Pediatric use information for patients 7 to 17 years of age is approved for AstraZeneca’s CRESTOR (rosuvastatin calcium) tablets. However, due to AstraZeneca’s marketing exclusivity rights, this drug product is not labeled with that pediatric information. Rosuvastatin tablets are an HMG Co-A reductase inhibitor indicated for: • adult patients with hypertriglyceridemia as an adjunct to diet ( 1.3 ) • adult patients with primary dysbetalipoproteinemia (Type III hyperlipoproteinemia) as an adjunct to diet ( 1.4 ) • adult patients with homozygous familial hypercholesterolemia (HoFH) to reduce LDL-C, total-C, and ApoB ( 1.5 ) Limitations of use (1.8): Rosuvastatin tablets have not been studied in Fredrickson Type I and V dyslipidemias. 1.3 Hypertriglyceridemia Rosuvastatin tablets are indicated as adjunctive therapy to diet for the treatment of adult patients with hypertriglyceridemia. 1.4 Primary Dysbetalipoproteinemia (Type III Hyperlipoproteinemia) Rosuvastatin tablets are indicated as an adjunct to diet for the treatment of adult patients with primary dysbetalipoproteinemia (Type III Hyperlipoproteinemia). 1.5 Adult Patients with Homozygous Familial Hypercholesterolemia Rosuvastatin tablets are indicated as adjunctive therapy to other lipid-lowering treatments (e.g., LDL apheresis) or alone if such treatments are unavailable to reduce LDL-C, Total-C, and ApoB in adult patients with homozygous familial hypercholesterolemia. 1.8 Limitations of Use Rosuvastatin tablets have not been studied in Fredrickson Type I and V dyslipidemias.
1
  • I feel the data is pointless if it isn't human readable. Speaking very broadly, APIs normally return data in machine-readable format. Commented Jul 26, 2022 at 14:25

1 Answer 1

0

The openFDA APIs are meant to return json data which contains text strings, some of which can be long. Once the json is parsed, which you appear to be doing in your PHP code, these text strings are then available for whatever formatting you want to do. Since you are already programming in PHP, why not manipulate each retrieved string as necessary? Anyway, openFDA is behaving properly.

1
  • I understand that JSON data is meant to contain text strings, but plenty of APIs either contain HTML tags in these strings that you can then use to format them, or are broken up into separate objects that you can at least split up and format. Here each item is just one long run-on sentence even if they are meant to be broken up into lists, etc. And I can't just format a string when there is no consistency the information.
    – Aristocles
    Commented Jul 31, 2022 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.