# ---------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
  name: fhir-source
  annotations:
    camel.apache.org/kamelet.support.level: "Stable"
    camel.apache.org/catalog.version: "4.10.2"
    camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOTUuMiAzMDAiPjxzdHlsZT48L3N0eWxlPjxnIGlkPSJMYXllcl8yIj48bGluZWFyR3JhZGllbnQgaWQ9IlNWR0lEXzFfIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjYyLjY0NCIgeTE9IjI2OC4yMDEiIHgyPSIzMC43MjEiIHkyPSI4Ny4xNTUiPjxzdG9wIG9mZnNldD0iLjE1NCIgc3RvcC1jb2xvcj0iI2ZmZTQwZSIvPjxzdG9wIG9mZnNldD0iLjkxIiBzdG9wLWNvbG9yPSIjZTEwZTE5Ii8+PC9saW5lYXJHcmFkaWVudD48cGF0aCBkPSJNNzkuNiA3OC41bC00NCAzOC41Uy04IDE1MS43IDEuMyAyMDUuOWMwIDAgMi45IDI5LjIgNDMuMyA2NS41IDAgMC0zMy00MS4xLTI2LjYtOTAuMlM3OS4zIDgzLjcgNzkuNiA3OC41eiIgZmlsbD0idXJsKCNTVkdJRF8xXykiLz48bGluZWFyR3JhZGllbnQgaWQ9IlNWR0l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bG9yPSIjZmZlNDAwIi8+PC9saW5lYXJHcmFkaWVudD48cGF0aCBkPSJNMTM3LjcgMi45czEzLjggMzguMi0yMS44IDkzLjEtODQgOTItNDguMSAxNzMuMmMwIDAtMzUuNC00NS41LTEzLjktOTcuNSAyNi43LTY0LjEgOTYuMi05Ny41IDgzLjgtMTY4Ljh6IiBmaWxsPSJ1cmwoI1NWR0lEXzZfKSIvPjwvZz48L3N2Zz4="
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/kamelet.group: "FHIR"
    camel.apache.org/kamelet.namespace: "API"
  labels:
    camel.apache.org/kamelet.type: "source"
spec:
  definition:
    title: "Fhir Source"
    description: |-
      Receive data from Fhir server.
    required:
      - serverUrl
      - username
      - password
    type: object
    properties:
      serverUrl:
        title: Server URL
        description: The Fhir server url
        type: string
      url:
        title: URL
        description: The Fhir resource type url
        type: string
        default: "/Patient"
      encoding:
        title: Encoding
        description: Encoding to use for all request. 
        type: string
        default: "JSON"
        enum: ["JSON", "XML"]
      fhirVersion:
        title: Fhir Version
        description: The FHIR Version to use.
        type: string
        default: "R4"
        enum: ["DSTU2", "DSTU2_HL7ORG", "DSTU2_1", "DSTU3", "R4", "R5"]
      username:
        title: Username
        description: The username to access the Fhir server
        type: string
        x-descriptors:
        - urn:camel:group:credentials
      password:
        title: Password
        description: The password to access the Fhir server
        type: string
        format: password
        x-descriptors:
        - urn:camel:group:credentials
      prettyPrint:
        title: Json Pretty Print
        description: Define if the Json must be pretty print or not
        type: boolean
        default: true
  types:
    out:
      mediaType: application/json
  dependencies:
    - "camel:fhir"
    - "camel:kamelet"
  template:
    from:
      uri: "fhir://search/searchByUrl"
      parameters:
        serverUrl: "{{serverUrl}}"
        url: "{{url}}"
        encoding: "{{encoding}}"
        fhirVersion: "{{fhirVersion}}"
        prettyPrint: "{{prettyPrint}}"
        username: "{{username}}"
        password: "{{password}}"
      steps:
      - marshal:
          fhirJson:
            fhirVersion: "{{fhirVersion}}"
            prettyPrint: "{{prettyPrint}}" 
      - to: "kamelet:sink"