-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Hi,
I've stumbled upon this library and I tried to use it for extracting values from FHIR proto structs, such as in the following sample:
package main
import (
"fmt"
"log"
dpb "github.com/google/fhir/go/proto/google/fhir/proto/r4/core/datatypes_go_proto"
r4pb "github.com/google/fhir/go/proto/google/fhir/proto/r4/core/resources/patient_go_proto"
"github.com/verily-src/fhirpath-go/fhirpath"
)
func main() {
// Create a FHIR Patient resource
patient := &r4pb.Patient{
Name: []*dpb.HumanName{
{
Given: []*dpb.String{
{Value: "John"},
},
Family: &dpb.String{Value: "Doe"},
},
},
}
// Compile the FHIRPath expression
expr := fhirpath.MustCompile("name.given")
// Pass the patient inside an interface slice
resources := []*r4pb.Patient{patient}
// Evaluate the FHIRPath expression
got, err := expr.Evaluate(resources, []fhirpath.EvaluateOption{}...) // <-- WON'T compile!
if err != nil {
log.Fatalf("Evaluation failed: %v", err)
}
// Print the result
fmt.Println("FHIRPath result:", got)
}
It might be because I have not used Golang in a while, but I can't seem to call Evaluate() because it accepts only a []fhir.Resource and fhir.Resource is internal to this package, so I can't access it. Since the[]T does not satisfy []I even when T implements I, I can't make this slice - the compiler won't accept a []r4pb.Patient as an argument to Evaluate(). Or is there something plainly obvious I'm overlooking?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels