HL7v2 to JSON

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf HL7v2 to JSON

  • Creator
    Topic
  • #55799
    Ryan Curtin
    Participant

      I have a project that takes in HL7v2 ADT/SIU data and translates it to JSON.

      I want to know If there is any way to iteratively build a JSON object based on the number of HL7 segments i.e. build a JSON object for each IN1 repeated segment (IN1|1|, IN1|2|, IN1|3|) = Obj1.1, Obj1.2, Obj1.3

      Iterating over the group only populates the JSON object with the last instance of IN1 (IN1|3|) = Obj1; it does not build additional objects for each segment.

      Additionally; is there a way to suppress or hide a JSON object if the requisite HL7 data that populates the object is blank/NULL? (including removing brackets from the OB “{}”)

    Viewing 2 reply threads
    • Author
      Replies
      • #86538
        Jim Kosloskey
        Participant

          I am guessing the issue is the JSON definition does not define those objects as a repeating instance but rather discreet fields.

          In that case, then (unless you can alter the JSON definition) I think you will need some Tcl to modify the field name of the destination on the fly so that with each iteration of the IB you add one to the ITERATE Counter and use that value to modify the Address Path of the OB field.

          I do not know whether or how you can get rid of the ’empty’ JSON fields unless there is an option to change the Cloverleaf definition of the JSON message and alter thos fields to be optional (that might end up not producing them).

          You could always write a post Xlate Tcl proc to remove them from the message as long as you understand all of the rules necessary to restructure the message that way.

          email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

        • #86539
          Ryan Curtin
          Participant

            What would need to be added and/or how to the JSON definition to allow it to be repeatable? I imported a JSON doc into Cloverleaf, just not sure how or where to make the change to allow it to repeat.

          • #86540
            Jim Kosloskey
            Participant

              I don’t know much about JSON. I think there is a JSON Configurator which should allow you to open the structure and change it.

              I think there is an array structure I believe. I am not sure how to or if mix and match is possible.

              Read the Cloverleaf Doc regarding JSON and visit http://www.json.org as well as search the internet for more information on potential JSON structures.

              You might also contact whoever gave you the structure, explain what you would like, and see if they will send you a new accommodating structure.

              Even if you figure out on your own how to alter the structure such that it is repeating to the Xlate, the final structure as you send it to the receiving system will likely be different than what they are expecting so you will need to coordinate the altered structure with them I would think.

              email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

          Viewing 2 reply threads
          • The forum ‘Cloverleaf’ is closed to new topics and replies.