2

Input:

{
  "heart_rate": {
    "value": 70,
    "unit": "beats/min"
  },
  "effective_time_frame": {
    "time_interval": {
      "start_date_time": "11/01/22 22:14:21"
    }
  },
  "descriptive-statistics": "minimum"
}

Jolt Spec:

[
  {
    "operation": "shift",
    "spec": {
      "effective_time_frame": {
        "time_interval": {
          "start_date_time": "effectiveDateTime"
        }
      },
      "heart_rate": {
        "value": "valueQuantity.value"
      }
    }
    }
,
  {
    "operation": "modify-default-beta",
    "spec": {
      "effectiveDateTime": "=concat(@(day),'-',@(month),'-2022')",
      "month": "=substring(@(effective_time_frame.time_interval.start_date_time),3,5)",
      "day": "=substring(@(effective_time_frame.time_interval.start_date_time),4,5)"
    }
  }
,
  {
    "operation": "default",
    "spec": {
      "valueQuantity": {
        "code": "/min",
        "system": "http://unitsofmeasure.org",
        "unit": "beats/minute"
      }
    }
  }
]


Output:

{
  "effectiveDateTime" : "11/01/22 22:14:21",
  "valueQuantity" : {
    "value" : 70,
    "unit" : "beats/minute",
    "code" : "/min",
    "system" : "http://unitsofmeasure.org"
  }
}

We have a date in the format (xxx/xx/xx/) and we want it in this format (xxxx-xx-xx) without the time. Maybe someone can help me. We need to change this as part of a project and unfortunately have no idea how Jolt transformation works.

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
mbGraz
  • 23
  • 3

1 Answers1

2

Yes, you can use concat function within modify transformation spec, but should bring from one level going up the tree as an example @(1,year), and use overwrite style instead of default for the transformation in order to overwrite the existing value of effectiveDateTime with the new one such as

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "effective_time_frame": {
        "time_interval": {
          "day": "=substring(@(1,start_date_time),0,2)",
          "month": "=substring(@(1,start_date_time),3,5)",
          "year": "=substring(@(1,start_date_time),6,8)",
          "start_date_time": "=concat('20',@(1,year),'-',@(1,month),'-',@(1,day))"
        }
      }
    }
  },
  {
    "operation": "shift",
    "spec": {
      "effective_time_frame": {
        "time_interval": {
          "start_date_time": "effectiveDateTime"
        }
      },
      "heart_rate": {
        "value": "valueQuantity.value"
      }
    }
  },
  {
    "operation": "default",
    "spec": {
      "valueQuantity": {
        "code": "/min",
        "system": "http://unitsofmeasure.org",
        "unit": "beats/minute"
      }
    }
  }
]

the demo on the site http://jolt-demo.appspot.com/ is

enter image description here

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55