PHPackages                             legit-health/medical-device-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. legit-health/medical-device-sdk

ActiveLibrary[API Development](/categories/api)

legit-health/medical-device-sdk
===============================

SDK for integrate with the Medical Device API

1.0.0(10mo ago)0473↓33.3%1MITPHPPHP ^8.4

Since Jul 7Pushed 10mo agoCompare

[ Source](https://github.com/Legit-Health/medical-device-sdk-php)[ Packagist](https://packagist.org/packages/legit-health/medical-device-sdk)[ RSS](/packages/legit-health-medical-device-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (11)Versions (2)Used By (1)

PHP SDK for Integrating with Legit.Health's Medical Device API
==============================================================

[](#php-sdk-for-integrating-with-legithealths-medical-device-api)

Official SDK for integrating with Legit.Health's Medical Device API 🩺🤖

Before You Start
----------------

[](#before-you-start)

Ensure that you have a registered username and password for our API before making any requests.

Instructions
------------

[](#instructions)

To start sending requests to Legit.Health's Dermatology API, create an instance of the `LegitHealth\MedicalDevice\MedicalDeviceClient` class. There are several ways to instantiate this object, but the simplest is by using the `createWithBaseUri` method. This static method accepts a single argument: the API's base URL, which varies depending on the environment you're working in. For development purposes, use `https://medical-device-pre.legit.health`.

The `MedicalDeviceClient` class provides three main methods:

- `login`: Requires your username and password, returning an access token that must be included in subsequent requests.
- `diagnosisSupport`: Sends a diagnosis support request to the API. Use this method to analyze a set of images to determine the probability of detected pathologies, or to retrieve metrics such as malignancy or the need for referral.
- `severityAssessment`: Sends a severity assessment request to evaluate the severity of a known condition. For example, you can use this method to assess the severity of a psoriasis lesion and calculate the corresponding `APASI` score

Login Request
-------------

[](#login-request)

Before invoking the diagnosis support or severity assessment methods, you need to obtain an access token. This is done by calling the `login` method of the `MedicalDeviceClient` class. This method expects a username and a password and returns an `AccessToken` object. This object contains the access token and its expiration time in minutes.

```
$medicalDeviceClient = MedicalDeviceClient::createWithBaseUri('url');
$accessToken = $medicalDeviceClient->login('username', 'password');
$bearerToken = new BearerToken($accessToken->value);
```

Diagnosis Support Request
-------------------------

[](#diagnosis-support-request)

The `diagnosisSupport` method of the `MedicalDeviceClient` class accepts three arguments:

- An object of the `DiagnosisSupportArguments` class, containing the images to analyze. **Important**: The maximum allowed length for the `medias` argument is 3.
- A bearer token obtained by invoking the `login` method.
- An object containing request options such as `timeout`.

```
$fileToUpload1 = $this->currentDir . '/tests/resources/psoriasis_01.png';
$image1 = file_get_contents($fileToUpload1);
$fileToUpload2 = $this->currentDir . '/tests/resources/psoriasis_02.png';
$image2 = file_get_contents($fileToUpload2);
$fileToUpload3 = $this->currentDir . '/tests/resources/psoriasis_03.png';
$image3 = file_get_contents($fileToUpload3);
$diagnosisSupportArguments = new DiagnosisSupportArguments(
    // three images at most
    medias: [
        base64_encode($image1),
        base64_encode($image2),
        base64_encode($image3)
    ]
);
```

Once you've created a `DiagnosisSupportArguments` object, you can send the request as follows:

```
$medicalDeviceClient = MedicalDeviceClient::createWithBaseUri('https://...');
$response = $medicalDeviceClient->diagnosisSupport(
    $diagnosisSupportArguments,
    $bearerToken
);
```

The response object, which is an instance of `DiagnosisSupportResponse`, contains several properties with the information returned by the API about the analyzed images:

- `clinicalIndicators`: an object of the `ClinicalIndicators` class with the probabilities of different suspicions, such as `hasCondition` or `malignancy`.
- `performanceIndicators`: contains the sensitivity, specificity, and entropy values.
- `conclusions`: an array of `Conclusion` objects with the detected pathologies and their probabilities. The total probability is distributed among the detected pathologies.
- `imagingStudySeries`: an array of `ImagingStudySeriesInstance` objects with information related to each image, such as conclusions, performance indicators, and clinical indicators. It also contains a `media` object that includes the modality of the image and whether it passed our Dermatology Image Quality Assessment (DIQA).
- `analysisDuration`: the time spent by the AI model analyzing the image.
- `effectiveDateTime`: the date and time of the report.

Severity Assessment Requests
----------------------------

[](#severity-assessment-requests)

The `severityAssessment` method of the `MedicalDeviceClient` class accepts three arguments:

- An object of the `SeverityAssessmentArguments` class, containing the image whose severity is to be assessed along with the related questionnaires.
- A bearer token obtained by invoking the `login` method.
- An object containing request options such as `timeout`.

### Example: Severity Assessment Request for Psoriasis

[](#example-severity-assessment-request-for-psoriasis)

Here’s how to send a severity assessment request for a patient diagnosed with psoriasis.

First, create the objects representing the questionnaires used to track the evolution of psoriasis:

```
use LegitHealth\MedicalDevice\Arguments\Params\ApasiLocalQuestionnaire;
use LegitHealth\Dapi\MediaAnalyzerArguments\Questionnaires\Questionnaires;

// ...

$apasiLocal = new ApasiLocalQuestionnaire(3);
$questionnaires = new Questionnaires([$apasiLocal]);
```

Then, create an object of the `SeverityAssessmentArguments` class:

```
$fileToUpload = $this->currentDir . '/tests/resources/psoriasis_02.png';
$image = file_get_contents($fileToUpload);
$apasiLocal = new ApasiLocalQuestionnaire(3);
$questionnaires = new Questionnaires([$apasiLocal]);
$severityAssessmentArguments = new SeverityAssessmentArguments(
    base64_encode($image),
    scoringSystems: array_map(
        fn (Questionnaire $questionnaire) => $questionnaire->getName(),
        $questionnaires->questionnaires
    ),
    questionnaires: $questionnaires,
    knownCondition: new KnownCondition('Psoriasis'),
    bodySiteCode: ParamsBodySiteCode::ArmLeft
);
```

Unlike diagnosis support requests, severity assessment requests support the following additional arguments:

- `scoringSystems`: an array of strings with the names of the scoring systems to be calculated. It supports all codes returned by the `Questionnaire` classes within the `LegitHealth\MedicalDevice\Arguments\Params` namespace.
- `questionnaires`: an object of the `Questionnaires` class with the answers required for practitioner or patient input. For psoriasis, the `surface` value is needed when creating an `ApasiLocalQuestionnaire` object.

Once the `SeverityAssessmentArguments` object is created, send the request as follows:

```
$medicalDeviceClient = MedicalDeviceClient::createWithBaseUri('https://...');
$response = $medicalDeviceClient->severityAssessment(
    $severityAssessmentArguments,
    $bearerToken
);
```

The response object contains several properties with information returned by the API about the analyzed image:

- `media`: contains the image modality and its validity, including whether it passed the Dermatology Image Quality Assessment (DIQA).
- `patientEvolution`: an array of `PatientEvolutionInstance` objects containing the score for each calculated scoring system along with its corresponding items.
- `analysisDuration`: the time spent by the AI model analyzing the image.

#### The `PatientEvolutionInstance` Class

[](#the-patientevolutioninstance-class)

The `PatientEvolutionInstance` contains all the information about a scoring system, for example, `APASI_LOCAL`.

You can access the value of a scoring system using the `getPatientEvolutionInstance` method:

```
$apasiLocalScoringSystemValue = $response->getPatientEvolutionInstance(ScoringSystemCode::ApasiLocal);
```

This object contains the following properties:

- `scoringSystemCode`
- `score`: the calculated score for the scoring system.
- `items`: an array of `EvolutionItem` objects representing each item used to calculate the scoring system.
- `attachments`: an array of images that contain an overlay with detections made by the AI model.
- `detections`: an array of `Detection` objects representing each box identifying a lesion detected in the image.

Once you have a `PatientEvolutionInstance` object, you can access the value of each item using the `getEvolutionItem(string $itemCode)` method. Each item contains its code and the calculated value. For example, the `APASI_LOCAL` scoring system includes 4 items: desquamation, erythema, induration, and surface.

Full example:

```
$apasiLocalScoringSystemValue = $response->getPatientEvolutionInstance(ScoringSystemCode::ApasiLocal);
// score
$apasiLocalScoringSystemValue->score->value
// score interpretation
$apasiLocalScoringSystemValue->score->interpretation
// accessing desquamation item
$apasiLocalScoringSystemValue->getEvolutionItem('desquamation');
$apasiLocalScoringSystemValue->getEvolutionItem('desquamation')->value;
// raw values output by the AI model
$apasiLocalScoringSystemValue->getEvolutionItem('desquamation')->additionalData;
```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance54

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

309d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a6e1759fc94c42d7d8806df9af12c822764a2a03cab098d3c3acddeb61881623?d=identicon)[Legit.Health](/maintainers/Legit.Health)

---

Top Contributors

[![ger86](https://avatars.githubusercontent.com/u/1313445?v=4)](https://github.com/ger86 "ger86 (29 commits)")[![gerardo-legit-health](https://avatars.githubusercontent.com/u/143383543?v=4)](https://github.com/gerardo-legit-health "gerardo-legit-health (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/legit-health-medical-device-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/legit-health-medical-device-sdk/health.svg)](https://phpackages.com/packages/legit-health-medical-device-sdk)
```

###  Alternatives

[temporal/sdk

Temporal SDK

4002.2M18](/packages/temporal-sdk)[storyblok/php-content-api-client

PHP Client for Storyblok Content API

11136.8k4](/packages/storyblok-php-content-api-client)[storyblok/php-management-api-client

Storyblok PHP Client for Management API

1224.4k1](/packages/storyblok-php-management-api-client)[smnandre/pagespeed-api

PageSpeed Insight PHP Api Client 🚀 Analyse web pages for performances metrics, core web vitals...

1511.5k](/packages/smnandre-pagespeed-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
