2017 © Pedro Peláez
 

library medlineplus

MedlinePlus Web Service Guzzle Client

image

tutor/medlineplus

MedlinePlus Web Service Guzzle Client

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 1 Versions
  • 100 % Grown

The README.md

MedlinePlus Web Service Guzzle Client

Provides an implementation of the Guzzle library to query MedlinePlus Web Service., (*1)

MedlinePlus offers a search-based Web service that provides access to MedlinePlus health topic data in XML format. Using the Web service, software developers can build applications that utilize MedlinePlus health topic information. The service accepts keyword searches as requests and returns relevant health topics (English or Spanish) in ranked order. Keyword searches may be limited to specific fields. The service also returns health topic summaries, search result snippets, external links, and other associated data., (*2)

  • https://medlineplus.gov/webservices.html

Usage

To use the MedlinePlus API Client simply instantiate the client., (*3)

<?php

require dirname(__FILE__).'/../vendor/autoload.php';

use Tutor\MedlinePlus\MedlinePlusClient;
$client = MedlinePlusClient::factory();

// if you want to see what is happening, add debug => true to the factory call
$client = MedlinePlusClient::factory(['debug' => true]);

Invoke Commands using the __call method (auto-complete phpDocs are included), (*4)

<?php

$client = MedlinePlusClient::factory();
$response = $client->query([
  'term' => '"diabetes medicines" OR "diabetes drugs"',
]);

Or Use the getCommand method (in this case you need to work with the $response['data'] array:, (*5)

<?php

$client = MedlinePlusClient::factory();

//Retrieve the Command from Guzzle
$command = $client->getCommand('Query', [
  'term' => '"diabetes medicines" OR "diabetes drugs"',
]);
$command->prepare();

$response = $command->execute();

$data = $response['data'];

Examples

You can execute the examples in the examples directory., (*6)

You can look at the services.json for details on what methods are available and what parameters are available to call them., (*7)

https://wsearch.nlm.nih.gov/ws/query?db=healthTopics&term=asthma, (*8)

<?php

$client = MedlinePlusClient::factory();
$response = $client->query([
  'term' => 'asthma',
]);

https://wsearch.nlm.nih.gov/ws/query?db=healthTopics&term=%22diabetes+medicines%22+OR+%22diabetes+drugs%22, (*9)

<?php

$client = MedlinePlusClient::factory();
$response = $client->query([
  'term' => '"diabetes medicines" OR "diabetes drugs"',
]);

https://wsearch.nlm.nih.gov/ws/query?db=healthTopicsSpanish&term=asma, (*10)

<?php

$client = MedlinePlusClient::factory();
$response = $client->query([
  'db' => 'healthTopicsSpanish',
  'term' => 'asma',
]);

Field Searching

The text for term can include limiters to restrict the search to a specific health topic field. The syntax is :. Fields that can be searched in this way are:, (*11)

  • title
  • alt-title
  • mesh (only available for English-language searches)
  • full-summary
  • group

https://wsearch.nlm.nih.gov/ws/query?db=healthTopics&term=title:asthma, (*12)

<?php

$client = MedlinePlusClient::factory();
$response = $client->query([
  'term' => 'title:asthma',
]);

Subsequent Requests

https://wsearch.nlm.nih.gov/ws/query?file=viv_0Uu9LP&server=qvlbsrch04&retstart=20, (*13)

<?php

$client = MedlinePlusClient::factory();
$response = $client->query([
  'file' => 'viv_0Uu9LP',
  'server' => 'qvlbsrch04',
  'retstart' => 20,
]);

Optional Parameters

https://wsearch.nlm.nih.gov/ws/query?db=healthTopics&term=diabetes&retmax=50, (*14)

<?php

$client = MedlinePlusClient::factory();
$response = $client->query([
  'term' => 'diabetes',
  'retmax' => 50,
]);

https://wsearch.nlm.nih.gov/ws/query?db=healthTopics&term=asthma&rettype=all, (*15)

<?php

$client = MedlinePlusClient::factory();
$response = $client->query([
  'term' => 'asthma',
  'rettype' => 'all',
]);

TODO

  • [ ] Add some more examples
  • [ ] Add tests
  • [ ] Add some Response models

Contributions welcome

Found a bug, open an issue, preferably with the debug output and what you did. Bugfix? Open a Pull Request and I'll look into it., (*16)

License

The use MedlinePlus\MedlinePlusClient API client is available under an MIT License., (*17)

The Versions

07/12 2017

dev-master

9999999-dev http://github.com/jorgetutor/medlineplus

MedlinePlus Web Service Guzzle Client

  Sources   Download

MIT

The Requires

 

api guzzle tutor medlineplus