FirelyTeam / firely-cql-sdk

BSD 3-Clause "New" or "Revised" License
30 stars 17 forks source link

Improve TypeConverter infrastructure so differences in the model can be supported #493

Open ewoutkramer opened 2 months ago

ewoutkramer commented 2 months ago

Currently, the Firely POCO's use a string for Extension.url, where a FhirString is expected. There is no way the TypeConverter can currently "hide" this fact for the ExpressionBuilder, so we had to make a patch in the Expression builder specifically for the Firely model. This is of course not optimal, so we should find a way for the model to handle this.

One way is for GetProperty to return a Linq.Expression instead of a PropertyInfo, as this gives the underlying converter way more freedom to insert masking code so the Builder does not have to know about intricacies of the underlying model. We tried this in the past but failed, but it might be worth a second try.

For now, this patch is done to the TypeFor() method. This method normally takes the CQL model types expected from the resultTypeSpecifier, but if a Property expression does not have a resultTypespecifier (which it does in the case of most Extension.url accesses), it relies on the underlying model. Which returns the "incorrect" type of string, (where the CQL model would have had FHIR.String). The TypeFor() method now corrects for this.

ewoutkramer commented 2 months ago

When we found a solution for this, we should also make sure we return object for choice properties, not DataType.