Closed leonrenkema closed 4 years ago
That's an interesting approach. I will probably not update the old version of the generator going forward, its code base is too complex and difficult to maintain.
I can, however, add this to the new refactor branch. I'll keep this open just as a reminder.
You can see example output here: https://github.com/dcarbone/php-fhir-generated/tree/feature/refactor
This would be really useful to have. In our case we use an extension on the family
attribute of a HumanName to support Dutch family names with prefixes. Since family
is a scalar value, we receive _family
instead containing this extension: http://hl7.org/fhir/extension-humanname-own-prefix.html.
I tried the generator with the feature/refactor
code but it's understandably not stable. Furthermore the latest version of the code you linked above is empty.
Could you please give a rough indication (I understand it's not a guarantee!) of when you expect the refactor to be done? Is there a roadmap somewhere?
Isn't parsing the XML variant of the resource an option? That fixed it for me.
I understand, but I don't have full control of the message format since it concerns an existing implementation with a customer.
@leonrenkema & @LucidTaZ: Could you please try the latest output from v1.0 and see if it works for you?
Closing as this is now implemented.
Hi @dcarbone, it works now, thanks!
Code sample that shows the fix:
$parser = new PHPFHIRResponseParser();
$json = '{"resourceType":"Patient","name":[{"family":"Jansen","_family":{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/humanname-own-prefix","valueString":"van"}]},"given":["Jan"]}]}';
/** @var FHIRPatient $patientResource */
$patientResource = $parser->parse($json);
$name = $patientResource->getName()[0];
$givenName = $name->getGiven()[0];
$familyName = $name->getFamily();
$familyExtension = $familyName->getExtension()[0];
$this->assertEquals('Jan', $givenName->getValue());
$this->assertEquals('http://hl7.org/fhir/StructureDefinition/humanname-own-prefix', $familyExtension->getUrl()->getValue());
$this->assertEquals('van', $familyExtension->getValueString()->getValue());
$this->assertEquals('Jansen', $familyName->getValue());
@LucidTaZ: good to hear! let me know if you find any issues with the new version!
I found that there is a trick used in the JSON format to support extensions on a simple value. But the library appears not to support it. When I switch to the XML format there is no problem.
I get the following error when parsing an Organization
ErrorException : Could not find mapped property called "_name" on object "Organization".
For now there is no problem because we can switch to the XML format but maybe some nice feature to support.