Skip to content

Filters Within Optional Field Declarations #35

@jp3477

Description

@jp3477

I have been able to create a JSON template for a SPARQL endpoint that works pretty well. However, I'm trying to now generate a structure that "conditionally" outputs one of three fields that all share the same root predicate but have different classes for the object. In the below example, the valueQuantity, valueCodeableConcept and valueString fields all originate from the predicate fhir:value.

I attempt to restrict them to different object classes in the $where clause with named variables. However, this does not produce the intended results if the fields are OPTIONAL. While the fields themselves are OPTIONAL, the class declarations in the $where clause seem to be absolute and will run independently of the fields in the translated SPARQL. Is there any way to fix these class declarations within the definition of the fields themselves using this package?

{
    "proto": {
        "id": "?observation$anchor",
        "identifier": {
            "id": "$fhir:identifier$asList$var:identifier",
            "value": "$fhir:value/fhir:v"
        },
        "status": "$fhir:status/fhir:v",
        "code": {
            "id": "$fhir:codeP$var:code$required",
            "coding": {
                "id": "$fhir:coding$asList",
                "system": "$fhir:system/fhir:v",
                "code": "$fhir:codeP/fhir:v",
                "display": "$fhir:display/fhir:v"
            }
        },
        "issued": "$fhir:issued/fhir:v",
        "valueQuantity": {
            "id": "$fhir:value$var:valueQuantity",
            "value": "$fhir:value/fhir:v",
            "code": "$fhir:codeP/fhir:v"
        },
        "valueCodeableConcept": {
            "id": "$fhir:value$var:valueCodeableConcept",
            "coding": {
                "id": "$fhir:coding$asList",
                "system": "$fhir:system/fhir:v",
                "code": "$fhir:codeP/fhir:v",
                "display": "$fhir:display/fhir:v"
            }
        },
        "valueString": "$fhir:value$var:valueString"
    },
    "$prefixes": {
        "fhir": "fhir/mcode.fhir.rdf.ttl/fhir.ttl#"
    },
    "$limit": 20,
    "$limitMode": "query",
    "$where": [
        "?observation a fhir:Observation",
        "?valueQuantity a fhir:Quantity",
        "?valueCodeableConcept a fhir:CodeableConcept",
        "?valueString a fhir:string"
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions