PHP code example of legit-health / dapi-sdk-php

1. Go to this page and download the library: Download legit-health/dapi-sdk-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

legit-health / dapi-sdk-php example snippets


$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')
    )
);

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

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]);

$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
);

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

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

$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

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

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