@@ -2743,6 +2743,22 @@ public Expression applyTargetMap(Expression source, String targetMap) {
2743
2743
String functionArgument = targetMap .substring (invocationStart + 1 , targetMap .lastIndexOf (')' ));
2744
2744
Expression argumentSource =
2745
2745
functionArgument .equals ("%value" ) ? source : applyTargetMap (source , functionArgument );
2746
+
2747
+ // NOTE: This is needed to work around the mapping for ToInterval
2748
+ // FHIRHelpers defines multiple overloads of ToInterval, but the type mapping
2749
+ // does not have the type of the source data type.
2750
+ // All the mappings for ToInterval use FHIR.Period, so this is safe to assume
2751
+ // In addition, no other FHIRHelpers functions use overloads (except ToString and ToDateTime,
2752
+ // but those mappings expand the value element directly, rather than invoking the FHIRHelpers function)
2753
+ TypeSpecifier argumentSignature = null ;
2754
+ if (this .options .getSignatureLevel () != SignatureLevel .None ) {
2755
+ if (qualifiedFunctionName .equals ("FHIRHelpers.ToInterval" )) {
2756
+ NamedTypeSpecifier namedTypeSpecifier =
2757
+ new NamedTypeSpecifier ().withName (dataTypeToQName (resolveTypeName ("FHIR" , "Period" )));
2758
+ argumentSignature = namedTypeSpecifier ;
2759
+ }
2760
+ }
2761
+
2746
2762
if (argumentSource .getResultType () instanceof ListType ) {
2747
2763
Query query = of .createQuery ()
2748
2764
.withSource (of .createAliasedQuerySource ()
@@ -2752,6 +2768,11 @@ public Expression applyTargetMap(Expression source, String targetMap) {
2752
2768
.withLibraryName (libraryName )
2753
2769
.withName (functionName )
2754
2770
.withOperand (of .createAliasRef ().withName ("$this" ));
2771
+
2772
+ if (argumentSignature != null ) {
2773
+ fr .getSignature ().add (argumentSignature );
2774
+ }
2775
+
2755
2776
// This doesn't quite work because the US.Core types aren't subtypes of FHIR types.
2756
2777
// resolveCall(libraryName, functionName, new FunctionRefInvocation(fr), false, false);
2757
2778
query .setReturn (of .createReturnClause ().withDistinct (false ).withExpression (fr ));
@@ -2763,6 +2784,11 @@ public Expression applyTargetMap(Expression source, String targetMap) {
2763
2784
.withName (functionName )
2764
2785
.withOperand (argumentSource );
2765
2786
fr .setResultType (source .getResultType ());
2787
+
2788
+ if (argumentSignature != null ) {
2789
+ fr .getSignature ().add (argumentSignature );
2790
+ }
2791
+
2766
2792
return fr ;
2767
2793
// This doesn't quite work because the US.Core types aren't subtypes of FHIR types,
2768
2794
// or they are defined as System types and not FHIR types
0 commit comments