0

im in learning process to learn jolt, but quite hard to master as there is array and the output must be the exactly the same as example below.

how to create a jolt spec form , the json input is like this :

[
  {
    "encounter_date": "1616509603296",
    "id_no": "671223025051",
    "patient_id": "MAEPS-PID-2100003716",
    "patient_mrn": "MAEPS-MRN-2100003815",
    "first_name": "MOHD RAZALI "
  },
  {
    "encounter_date": "1621324591194",
    "id_no": "950224145647",
    "patient_id": "MAEPS-PID-2100030302",
    "patient_mrn": "MAEPS-MRN-2100030401",
    "first_name": "MUHAMMAD FADDIL BIN YASIN"
  }
]

expected output is like this :

{
  "forms": [
    {
      "visit": {
        "patientId": "MAEPS-PID-2100003716",
        "Patientmrn": "MAEPS-MRN-2100003815",
        "encounterDate": "2021-03-23 22:26:43.296"
      },
      "person": {
        "firstname": "MOHD RAZALI ",
        "identifications": [
          {
            "idNo": "671223025051"
          }
        ]
      }
    },
    {
      "visit": {
        "patientId": "MAEPS-PID-2100030302",
        "Patientmrn": "MAEPS-MRN-2100030401",
        "encounterDate": "2021-05-18 15:56:31.194"
      },
      "person": {
        "firstname": "MUHAMMAD FADDIL BIN YASIN",
        "identifications": [
          {
            "idNo": "950224145647"
          }
        ]
      }
    }
  ]
}

i'm new to jolt and require guidance

1 Answer 1

2

This can be done with just a single shift operation as below.

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "patient_id": "forms[&1].visit.patientId",
        "patient_mrn": "forms[&1].visit.Patientmrn",
        "encounter_date": "forms[&1].visit.encounterDate",
        "first_name": "forms[&1].person.firstname",
        "id_no": "forms[&1].person.identifications[0].idNo"
      }
    }
  }
]
Sign up to request clarification or add additional context in comments.

2 Comments

thank u so much , i now only have the issue regarding date .. but other than that ur solution is great, thank you so much
@YaminAzlan perhaps this might help you for the date formatting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.