dcarbone / php-fhir

Tools for consuming data from a FHIR server with PHP
Apache License 2.0
126 stars 40 forks source link

Validation of valueBoolean parameters has false negatives #136

Closed yunosh closed 1 month ago

yunosh commented 1 month ago

This unit test incorrectly fails with the validation error {"errors":{"parameter.0":{"valueBoolean":{"value":{"value":{"pattern":"Field \"value\" on type \"boolean-primitive\" value of \"1\" does not match pattern: /^true|false$/"}}}}}}

<?php

namespace App\Tests;

use DCarbone\PHPFHIRGenerated\R4\PHPFHIRResponseParser;
use PHPUnit\Framework\TestCase;

class BooleanValidationTest extends TestCase
{
    public function testBooleanValidation(): void
    {
        $fhir = <<<FHIR
<?xml version="1.0" encoding="utf-8"?>
<Parameters xmlns="http://hl7.org/fhir">
    <meta>
        <profile value="https://e-lb.de/fhir/StructureDefinition/KK_ELB_ParticipationStatusResponseParameters"/>
    </meta>
    <parameter>
        <name value="isParticipating"/>
        <valueBoolean value="true"/>
    </parameter>
</Parameters>
FHIR;

        $parser       = new PHPFHIRResponseParser();
        $fhirResponse = $parser->parseXml($fhir);
        $validationErrors = $fhirResponse->_getValidationErrors();
        self::assertEquals([], $validationErrors);
    }
}
dcarbone commented 1 month ago

@yunosh: I've released v3.1.0 with numerous fixes around validation, please let me know if you encounter any other issues!

yunosh commented 1 month ago

Works fine for me now, thanks!