PHPackages                             legit-health/dapi-sdk-php - 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/dapi-sdk-php

ActiveLibrary[API Development](/categories/api)

legit-health/dapi-sdk-php
=========================

SDK for integrate with the Dermatology API

12.0.0(1y ago)07821MITPHPPHP ^8.2

Since Jan 27Pushed 1y ago2 watchersCompare

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

READMEChangelogDependencies (10)Versions (19)Used By (1)

PHP SDK for integrate with the Dermatology API offered by Legit.Health
======================================================================

[](#php-sdk-for-integrate-with-the-dermatology-api-offered-by-legithealth)

Official SDK for integrate with the Dermatology API offered by Legit.Health 🩺🤖

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

[](#instructions)

If you want to start sending requests to Legit.Health's Dermatology API, you have to create an instance of the class `LegitHealth\Dapi\MediaAnalyzer`. It requires two arguments:

- The URL of the API. The preproduction enviroment uses the following value: `https://ai-pre.legit.health`.
- The API Key we have provided to you. Without it, you won't be able to send requests to the API.

The class `MediaAnalyzer` exposes two methods:

- `diagnosisSupport`, to send a diagnosis support request to the API, in case you need to analyze a set of images to obtain the probability of the detected pathologies.
- `severityAssessment`, to send a severity assessment up request to get the evolution information about a diagnosed image.

Diagnosis support requests
--------------------------

[](#diagnosis-support-requests)

The `diagnosisSupport` method of our `MediaAnalyzer` class receives one argument of the class `LegitHealth\Dapi\MediaAnalyzerArguments\DiagnosisSupportArguments`. The constructor of this class receives an object of the class `LegitHealth\Dapi\MediaAnalyzerArguments\DiagnosisSupportData`, in which you can specify the image itself and information about the patient or the body site:

```
$diagnosisSupportData = new DiagnosisSupportData(
    content: [base64_encode($image1), base64_encode($image2)],
    bodySiteCode: BodySiteCode::ArmLeft,
    operator: Operator::Patient,
    subject: new Subject(
        'subject identifier',
        Gender::Male,
        '1.75',
        '69.00',
        DateTimeImmutable::createFromFormat('Ymd', '19861020'),
        'practitioner identifier'
        new Company('company identifier', 'Company Name')
    )
);
```

Once you've created a `DiagnosisSupportData` object, you can send the request in this way:

```
$diagnosisSupportArguments = new DiagnosisSupportArguments('random id', $diagnosisSupportData)
$mediaAnalyzer = new MediaAnalyzer(
    $apiUrl,
    $apiKey
);
$response = $mediaAnalyzer->diagnosisSupport($diagnosisSupportArguments);
```

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

- `preliminaryFindings` is an object of the class `LegitHealth\Dapi\MediaAnalyzerResponse\PreliminaryFindingsValue` with the probability of the different suspicions that the algorithm has about the image.
- `metrics` contains the sensitivity and specificity values.
- `conclusions` is an array of `Conclusion` objects with the detected pathologies and its probability. The total probability is distributed among each of the pathologies detected.
- `observations` is an array of `Observation` objects with the conclusions of the algorithm for each image including its related metrics and preliminary findings.
- `iaSeconds` is the time spent by the algorithms analyzying the image.

Severity assessment requests
----------------------------

[](#severity-assessment-requests)

The `severityAssessment` method of our `MediaAnalyzer` class receives one argument of the class `LegitHealth\Dapi\MediaAnalyzerArguments\SeverityAssessmentArguments`. The constructor of this class receives an object of the class `LegitHealth\Dapi\MediaAnalyzerArguments\SeverityAssessmentData`, in which can specify the image itself and information about a well known condition.

### Example. Severity assessment request for psoriasis

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

Let's see how to send a severity assessment request for a patient diagnosed with psoriasis.

Firstly, we will create the different objects that represents the questionnaires used to track the evolution of psoriasis:

```
use LegitHealth\Dapi\MediaAnalyzerArguments\Questionnaires\ApasiLocalQuestionnaire;
use LegitHealth\Dapi\MediaAnalyzerArguments\Questionnaires\DlqiQuestionnaire;
use LegitHealth\Dapi\MediaAnalyzerArguments\Questionnaires\PasiLocalQuestionnaire;
use LegitHealth\Dapi\MediaAnalyzerArguments\Questionnaires\Pure4Questionnaire;
use LegitHealth\Dapi\MediaAnalyzerArguments\Questionnaires\Questionnaires;

// ...

$apasiLocal = new ApasiLocalQuestionnaire(3);
$pasiLocal = new PasiLocalQuestionnaire(3, 2, 1, 1);
$pure4 = new Pure4Questionnaire(0, 0, 0, 1);
$dlqi = new DlqiQuestionnaire(1, 1, 2, 0, 0, 0, 1, 2, 2, 0);
$questionnaires = new Questionnaires([$apasiLocal, $pasiLocal, $pure4, $dlqi]);
```

Then, we will create an object of the class `LegitHealth\Dapi\MediaAnalyzerArguments\SeverityAssessmentData`:

```
$data = new SeverityAssessmentData(
    content: base64_encode($image),
    pathologyCode: 'Psoriasis',
    bodySiteCode: BodySiteCode::ArmLeft,
    previousMedias: [
        new PreviousMedia(base64_encode($previousMediaImage), DateTimeImmutable::createFromFormat('Ymd', '20220106'))
    ],
    operator: Operator::Patient,
    subject: new Subject(
        'subject identifier',
        Gender::Male,
        '1.75',
        '69.00',
        DateTimeImmutable::createFromFormat('Ymd', '19861020'),
        'practitioner identifier'
        new Company('company identifier', 'Company Name')
    )
    scoringSystems: array_map(fn (Questionnaire $questionnaire) => $questionnaire->getName(), $questionnaires->questionnaires),
    // scoringSystems: ['APASI_LOCAL', 'PASI_LOCAL', 'PURE4', 'DLQI']
    questionnaires: $questionnaires
);
```

Unlike diagnostic support requests, severity assessment requests supports the following additional arguments:

- `previousMedias` is an array of objects of the class `PreviousMedia` with a list of previous images taken of the current pathology.
- `scoringSystems` is an array of strings with the name of the scoring systems to be evaluated. It supports the following values:

```
[ ASCORAD_LOCAL, APASI_LOCAL, AUAS_LOCAL, AIHS4_LOCAL, DLQI, SCOVID, ALEGI, PURE4, UCT, AUAS7, APULSI, SCORAD_LOCAL, PASI_LOCAL, UAS_LOCAL, IHS4_LOCAL]

```

- `questionnaires` is an object of the class `LegitHealth\Dapi\MediaAnalyzerArguments\Questionnaires\Questionnaires` with the values of the scoring systems to be evaluated.

Once you've created a `SeverityAssessmentData` object, you can send the request in this way:

```
$mediaAnalyzer = new MediaAnalyzer(
    $apiUrl,
    $apiKey
);
$severityAssessmentArguments = new SeverityAssessmentArguments('identifier of the request', $data);
$response = $mediaAnalyzer->severityAssessment($severityAssessmentArguments);
```

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

- `preliminaryFindings` is an object of the class `LegitHealth\Dapi\MediaAnalyzerResponse\PreliminaryFindingsValue` with the probability of the different suspicions that the algorithm has about the image.
- `modality` is the modality of the image detected.
- `mediaValidity` is an object that contains information about whether the image sent contains relevant dermatological information
- `metricsValue` contains the sensitivity and specificity values.
- `iaSeconds` is the time spent by the algorithms analyzying the image.

Besides, it contains two extra properties:

- `explainabilityMedia`, with the image containing the surface of the injury detected by our AI algorithms.
- `scoringSystemsValues`, an object of the class `LegitHealth\Dapi\MediaAnalyzerResponse\ScoringSystem\ScoringSystemValues.php` with the values calculated for each scoring system included in the array `scoringSystems` of the arguments.

#### The `ScoringSystemValues` object

[](#the-scoringsystemvalues-object)

The `ScoringSystemValues` contains all the information about a scoring system, for example, APASI\_LOCAL.

You can access to the value of one scoring system using the method `getScoringSystemValues`:

```
$apasiLocalScoringSystemValue = $response->getScoringSystemValues('APASI_LOCAL');
```

Once you have one object of the class `ScoringSystemValues`, you can access to the value of each facet using the method `getFacetCalculatedValue(string $facetCode)`.

By invoking the method `getFacets` you will get an array of facets. Each element in this list is an array with three keys:

- `facet`. The facet code.
- `value`. The calculated value for the facet. This value will be inside the allowed range for the facet.
- `intensity`. It represents the intensity of that facet in a scale from 0 to 100.

Finally, you can access to the score of the scoring system through its property `score`. It is an object with three properties:

- `category`, which represents the severity of the score.
- `calculatedScore`, for those scoring systems whose calculation depends on facets that are computed by our AI algorithm: APASI\_LOCAL, APULSI, ASCORAD\_LOCAL and AUAS\_LOCAL.
- `questionnaire`, for those scoring systems whose calculations not depends on facet computed by our AI algorithm, for example, DLQI.

Full example:

```
$apasiLocalScoringSystemValue = $response->getScoringSystemValues('APASI_LOCAL');

$apasiScore = $apasiLocalScoringSystemValue->getScore()->calculatedScore;
$apasiSeverityCategory = $apasiLocalScoringSystemValue->getScore()->category;

$apasiLocalScoringSystemValue = $response->getScoringSystemValues('APASI_LOCAL');
$desquamation = $apasiLocalScoringSystemValue->getFacetCalculatedValue('desquamation');
$desquamationValue = $desquamation->value; // A value between 0 and 4 as the PASI states
$desquamationIntensity = $desquamation->intensity; // A value between 0 and 100 reflecting the intensity of the desquamation
```

Detecting faces
---------------

[](#detecting-faces)

In some cases, you may want to enable the feature of the algorithm capable of detecting faces. In this case, **a metric called `pxToCm` is returned** allowing to get the ratio of conversion from pixels to centimeters. This feature works for both diagnosis support and severity assessment requests.

For example, if you are working with a `DiagnosisSupportData` object, you can send the request in this way:

```
// ...
use LegitHealth\Dapi\MediaAnalyzerArguments\OrderDetail;
// ...
$mediaAnalyzerArguments = new MediaAnalyzerArguments('random id', $data, new OrderDetail(true))
$mediaAnalyzer = new MediaAnalyzer(
    $apiUrl,
    $apiKey
);
$response = $mediaAnalyzer->diagnosisSupport($mediaAnalyzerArguments);
```

If the algorithm detects a face and can calculate the ratio from pixels to centimeters, the property `metrics` of the `explainabilityMedia` will get a value different of `null`

```
$response->explainabilityMedia->metrics->pxToCm;
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance47

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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

Every ~47 days

Recently: every ~98 days

Total

18

Last Release

396d ago

Major Versions

7.0.1 → 8.0.02024-03-18

8.0.0 → 9.0.02024-03-18

9.0.0 → 10.0.02024-12-13

10.0.0 → 11.0.02025-03-17

11.0.0 → 12.0.02025-04-15

PHP version history (2 changes)1.0.0PHP ^8.1

6.0.0PHP ^8.2

### 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 (44 commits)")

---

Tags

dermatological-analysesdermatologylegit-healthphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/legit-health-dapi-sdk-php/health.svg)

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

###  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)
