Search code examples
jsonhl7hl7-v2

How do i convert JSON to QPB_Q11 object using java


We have below json file. we need to convert it into QBP_Q11 java object using java. we are able to convert from hl7 message to QBP_Qll object but not able to do from json input.

Is there anyway to convert json to hl7?

{
"QBP_Q11": {
    "MSH": {
        "MSH.1": "|",
        "MSH.10": "f167c187-cefc-4102-a836-fe8679e31e0b",
        "MSH.11": {"PT.1": "P"},
        "MSH.12": {"VID.1": "2.5.1"},
        "MSH.18": "ASCII",
        "MSH.2": "^~\\&",
        "MSH.3": {"H    ": "COBAS6800/8800"},
        "MSH.5": {"HD.1": "LIS"},
        "MSH.7": {"TS.1": 20161130115359},
        "MSH.9": {
            "MSG.1": "QBP",
            "MSG.2": "Q11"
        }
    },
    "QPD": {
        "QPD.1": {
            "CE.1": "WOS",
            "CE.2": "Work·Order·Step",
            "CE.3": "IHE_LABTF"
        },
        "QPD.3  ": "$005D783C"
    },
    "xmlns": "urn:hl7-org:v2xml"
}
}

Solution

  • You have to either write your own converter or you have to use some existing tool kit. This has nothing to do with what message (QBP_Q11 or other) you are handling.

    You can simply deserialize the json and map the output to your HL7 instance. This is explained here.

    Tools like HAPI may be helpful.