hive的复杂json数组对象中包含的数组对象扁平化解析

一、原始json格式如下

{
    "primaryScheme": {
        "groupCode": "TJ-hba1cG7L8-ageG60-bmiG28",
        "regimenType": "drug",
        "regimens": [
            {
                "drugTypes": [
                    {
                        "drugs": [
                            {
                                "dose": "0.5g或1g,单日最大累积剂量2g",
                                "drugGenericCode": "XA10BAE021",
                                "drugGenericName": "二甲双胍",
                                "frequency": "每天两次或每天三次,推荐餐后",
                                "remark": "由于老年患者可能出现肾功能减退,应定期检查肾功能并根据肾功能调整二甲双胍的剂量",
                                "usage": "口服"
                            }
                        ],
                        "notes": [
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "二甲双胍"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "60>=eGFR>30",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "二甲双胍"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "30>=eGFR",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "二甲双胍"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "谷草谷丙>=100",
                                "type": "肝功能禁忌"
                            }
                        ],
                        "typeCode": "XA10BA",
                        "typeName": "双胍类"
                    }
                ],
                "priority": 1,
                "reason": "",
                "regimenCode": "TJ-hba1cG7L8-ageG60-bmiG28-reg1",
                "regimenName": "【优选】二甲双胍"
            },
            {
                "drugTypes": [
                    {
                        "drugs": [
                            {
                                "dose": "50mg-100mg,单次最大剂量200mg",
                                "drugGenericCode": "XA10BFA025",
                                "drugGenericName": "阿卡波糖",
                                "frequency": "每天三次,餐中",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "0.2mg,单次最大剂量0.3mg",
                                "drugGenericCode": "XA10BFF058",
                                "drugGenericName": "伏格列波糖",
                                "frequency": "每天三次,餐中",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "25mg起始,单次最大剂量100mg",
                                "drugGenericCode": "XA10BFM097",
                                "drugGenericName": "米格列醇",
                                "frequency": "每天三次,餐中",
                                "remark": "",
                                "usage": "口服"
                            }
                        ],
                        "notes": [
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "伏格列波糖",
                                    "米格列醇",
                                    "阿卡波糖"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "30>=eGFR",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "伏格列波糖",
                                    "阿卡波糖"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "谷草谷丙>=100",
                                "type": "肝功能禁忌"
                            }
                        ],
                        "typeCode": "XA10BF",
                        "typeName": "α⁃糖苷酶抑制剂"
                    }
                ],
                "priority": 2,
                "reason": "",
                "regimenCode": "TJ-hba1cG7L8-ageG60-bmiG28-reg2",
                "regimenName": "【可用】α-糖苷酶抑制剂"
            },
            {
                "drugTypes": [
                    {
                        "drugs": [
                            {
                                "dose": "0.6mg一周后无明显胃肠道反应后可加至1.2mg,单日最大剂量1.8mg",
                                "drugGenericCode": "XA10BJL326",
                                "drugGenericName": "利拉鲁肽",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "0.25mg或0.5mg起始,每周最大推荐剂量为1mg",
                                "drugGenericCode": "XA10BJS279",
                                "drugGenericName": "司美格鲁肽",
                                "frequency": "每周一次",
                                "remark": "",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "0.75 mg起始,每周最大推荐剂量为 1.5 mg",
                                "drugGenericCode": "XA10BJD332",
                                "drugGenericName": "度拉糖肽",
                                "frequency": "每周一次",
                                "remark": "",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "5 μg起始,单次最大剂量10mg",
                                "drugGenericCode": "XA10BJA085",
                                "drugGenericName": "艾塞那肽",
                                "frequency": "每天二次,早餐、晚餐前 60 分钟内",
                                "remark": "对患有胰腺炎的患者,禁用本品。不推荐本品用于终末期肾病或严重肾功能 不全(肌酐清除率<30 ml/min)的患者",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "10μg应用14天,后调整为20μg维持",
                                "drugGenericCode": "XA10BJL366",
                                "drugGenericName": "利司那肽",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "0.1mg,每周最大推荐剂量为0.2mg",
                                "drugGenericCode": "XA10BJJ237",
                                "drugGenericName": "洛塞那肽",
                                "frequency": "每周一次",
                                "remark": "",
                                "usage": "皮下注射"
                            }
                        ],
                        "notes": [
                            {
                                "decrements": [
                                    "洛塞那肽"
                                ],
                                "disables": [
                                    
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "60>=eGFR>30",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "度拉糖肽",
                                    "司美格鲁肽",
                                    "利拉鲁肽",
                                    "艾塞那肽",
                                    "利司那肽",
                                    "洛塞那肽"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "30>=eGFR",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "利拉鲁肽",
                                    "司美格鲁肽"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "谷草谷丙>=100",
                                "type": "肝功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    
                                ],
                                "recommends": [
                                    "度拉糖肽",
                                    "司美格鲁肽",
                                    "利拉鲁肽",
                                    "艾塞那肽",
                                    "利司那肽",
                                    "洛塞那肽"
                                ],
                                "target": "冠心病/心衰",
                                "type": "心血管功能禁忌"
                            }
                        ],
                        "typeCode": "XA10BJ",
                        "typeName": "GLP-1RA"
                    },
                    {
                        "drugs": [
                            {
                                "dose": "10mg起始,单日最大剂量25mg",
                                "drugGenericCode": "XA10BKE079",
                                "drugGenericName": "恩格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "100mg起始,单日最大剂量300mg",
                                "drugGenericCode": "XA10BKK130",
                                "drugGenericName": "卡格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "5mg",
                                "drugGenericCode": "XA10BKA338",
                                "drugGenericName": "艾托格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "5mg起始,单日最大剂量10mg",
                                "drugGenericCode": "XA10BKD256",
                                "drugGenericName": "达格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            }
                        ],
                        "notes": [
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "卡格列净",
                                    "恩格列净",
                                    "艾托格列净"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "60>=eGFR>30",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "卡格列净",
                                    "达格列净",
                                    "恩格列净",
                                    "艾托格列净"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "30>=eGFR",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "卡格列净",
                                    "达格列净",
                                    "恩格列净",
                                    "艾托格列净"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "谷草谷丙>=100",
                                "type": "肝功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    
                                ],
                                "recommends": [
                                    "卡格列净",
                                    "达格列净",
                                    "恩格列净",
                                    "艾托格列净"
                                ],
                                "target": "冠心病/心衰",
                                "type": "心血管功能禁忌"
                            }
                        ],
                        "typeCode": "XA10BK",
                        "typeName": "SGLT-2抑制剂"
                    },
                    {
                        "drugs": [
                            {
                                "dose": "50mg",
                                "drugGenericCode": "XA10BHW104",
                                "drugGenericName": "维格列汀",
                                "frequency": "每天两次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "100mg",
                                "drugGenericCode": "XA10BHX202",
                                "drugGenericName": "西格列汀",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "5mg",
                                "drugGenericCode": "XA10BHL343",
                                "drugGenericName": "利格列汀",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "5mg",
                                "drugGenericCode": "XA10BHS231",
                                "drugGenericName": "沙格列汀",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "25mg",
                                "drugGenericCode": "XA10BHA283",
                                "drugGenericName": "阿格列汀",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            }
                        ],
                        "notes": [
                            {
                                "decrements": [
                                    "维格列汀",
                                    "西格列汀",
                                    "阿格列汀",
                                    "沙格列汀"
                                ],
                                "disables": [
                                    
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "60>=eGFR>30",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    "维格列汀"
                                ],
                                "disables": [
                                    "沙格列汀",
                                    "西格列汀",
                                    "阿格列汀"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "30>=eGFR",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "维格列汀"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "谷草谷丙>=100",
                                "type": "肝功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    
                                ],
                                "recommends": [
                                    "维格列汀",
                                    "西格列汀",
                                    "沙格列汀",
                                    "阿格列汀",
                                    "利格列汀"
                                ],
                                "target": "冠心病/心衰",
                                "type": "心血管功能禁忌"
                            }
                        ],
                        "typeCode": "XA10BH",
                        "typeName": "DPP⁃4抑制剂"
                    }
                ],
                "priority": 3,
                "reason": "",
                "regimenCode": "TJ-hba1cG7L8-ageG60-bmiG28-reg3",
                "regimenName": "【可用】GLP-1RA或SGLT-2抑制剂或DPP-4抑制剂"
            }
        ]
    },
    "specialistScheme": {
        "groupCode": "HS-hba1cG7L8-ageG60-bmiG28",
        "regimenType": "drug",
        "regimens": [
            {
                "drugTypes": [
                    {
                        "drugs": [
                            {
                                "dose": "0.6mg一周后无明显胃肠道反应后可加至1.2mg,单日最大剂量1.8mg",
                                "drugGenericCode": "XA10BJL326",
                                "drugGenericName": "利拉鲁肽",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "0.25mg或0.5mg起始,每周最大推荐剂量为1mg",
                                "drugGenericCode": "XA10BJS279",
                                "drugGenericName": "司美格鲁肽",
                                "frequency": "每周一次",
                                "remark": "",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "0.75 mg起始,每周最大推荐剂量为 1.5 mg",
                                "drugGenericCode": "XA10BJD332",
                                "drugGenericName": "度拉糖肽",
                                "frequency": "每周一次",
                                "remark": "",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "5 μg起始,单次最大剂量10mg",
                                "drugGenericCode": "XA10BJA085",
                                "drugGenericName": "艾塞那肽",
                                "frequency": "每天二次,早餐、晚餐前 60 分钟内",
                                "remark": "对患有胰腺炎的患者,禁用本品。不推荐本品用于终末期肾病或严重肾功能 不全(肌酐清除率<30 ml/min)的患者",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "10μg应用14天,后调整为20μg维持",
                                "drugGenericCode": "XA10BJL366",
                                "drugGenericName": "利司那肽",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "0.1mg,每周最大推荐剂量为0.2mg",
                                "drugGenericCode": "XA10BJJ237",
                                "drugGenericName": "洛塞那肽",
                                "frequency": "每周一次",
                                "remark": "",
                                "usage": "皮下注射"
                            }
                        ],
                        "notes": [
                            {
                                "decrements": [
                                    "洛塞那肽"
                                ],
                                "disables": [
                                    
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "60>=eGFR>30",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "利拉鲁肽",
                                    "利司那肽",
                                    "艾塞那肽",
                                    "度拉糖肽",
                                    "司美格鲁肽",
                                    "洛塞那肽"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "30>=eGFR",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "司美格鲁肽",
                                    "利拉鲁肽"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "谷草谷丙>=100",
                                "type": "肝功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    
                                ],
                                "recommends": [
                                    "利拉鲁肽",
                                    "利司那肽",
                                    "艾塞那肽",
                                    "度拉糖肽",
                                    "司美格鲁肽",
                                    "洛塞那肽"
                                ],
                                "target": "冠心病/心衰",
                                "type": "心血管功能禁忌"
                            }
                        ],
                        "typeCode": "XA10BJ",
                        "typeName": "GLP-1RA"
                    },
                    {
                        "drugs": [
                            {
                                "dose": "10mg起始,单日最大剂量25mg",
                                "drugGenericCode": "XA10BKE079",
                                "drugGenericName": "恩格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "100mg起始,单日最大剂量300mg",
                                "drugGenericCode": "XA10BKK130",
                                "drugGenericName": "卡格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "5mg",
                                "drugGenericCode": "XA10BKA338",
                                "drugGenericName": "艾托格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "5mg起始,单日最大剂量10mg",
                                "drugGenericCode": "XA10BKD256",
                                "drugGenericName": "达格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            }
                        ],
                        "notes": [
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "卡格列净",
                                    "艾托格列净",
                                    "恩格列净"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "60>=eGFR>30",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "卡格列净",
                                    "达格列净",
                                    "艾托格列净",
                                    "恩格列净"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "30>=eGFR",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "卡格列净",
                                    "达格列净",
                                    "艾托格列净",
                                    "恩格列净"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "谷草谷丙>=100",
                                "type": "肝功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    
                                ],
                                "recommends": [
                                    "卡格列净",
                                    "达格列净",
                                    "艾托格列净",
                                    "恩格列净"
                                ],
                                "target": "冠心病/心衰",
                                "type": "心血管功能禁忌"
                            }
                        ],
                        "typeCode": "XA10BK",
                        "typeName": "SGLT-2抑制剂"
                    }
                ],
                "priority": 1,
                "reason": "",
                "regimenCode": "HS-hba1cG7L8-ageG60-bmiG28-reg1",
                "regimenName": "【优选】GLP-1RA(或加用SGLT-2抑制剂)"
            },
            {
                "drugTypes": [
                    {
                        "drugs": [
                            {
                                "dose": "10mg起始,单日最大剂量25mg",
                                "drugGenericCode": "XA10BKE079",
                                "drugGenericName": "恩格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "100mg起始,单日最大剂量300mg",
                                "drugGenericCode": "XA10BKK130",
                                "drugGenericName": "卡格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "5mg",
                                "drugGenericCode": "XA10BKA338",
                                "drugGenericName": "艾托格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "5mg起始,单日最大剂量10mg",
                                "drugGenericCode": "XA10BKD256",
                                "drugGenericName": "达格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            }
                        ],
                        "notes": [
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "卡格列净",
                                    "艾托格列净",
                                    "恩格列净"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "60>=eGFR>30",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "卡格列净",
                                    "达格列净",
                                    "艾托格列净",
                                    "恩格列净"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "30>=eGFR",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "卡格列净",
                                    "达格列净",
                                    "艾托格列净",
                                    "恩格列净"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "谷草谷丙>=100",
                                "type": "肝功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    
                                ],
                                "recommends": [
                                    "卡格列净",
                                    "达格列净",
                                    "艾托格列净",
                                    "恩格列净"
                                ],
                                "target": "冠心病/心衰",
                                "type": "心血管功能禁忌"
                            }
                        ],
                        "typeCode": "XA10BK",
                        "typeName": "SGLT-2抑制剂"
                    }
                ],
                "priority": 2,
                "reason": "",
                "regimenCode": "HS-hba1cG7L8-ageG60-bmiG28-reg2",
                "regimenName": "【优选】SGLT-2抑制剂"
            },
            {
                "drugTypes": [
                    {
                        "drugs": [
                            {
                                "dose": "0.5g或1g,单日最大累积剂量2g",
                                "drugGenericCode": "XA10BAE021",
                                "drugGenericName": "二甲双胍",
                                "frequency": "每天两次或每天三次,推荐餐后",
                                "remark": "由于老年患者可能出现肾功能减退,应定期检查肾功能并根据肾功能调整二甲双胍的剂量",
                                "usage": "口服"
                            }
                        ],
                        "notes": [
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "二甲双胍"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "60>=eGFR>30",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "二甲双胍"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "30>=eGFR",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "二甲双胍"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "谷草谷丙>=100",
                                "type": "肝功能禁忌"
                            }
                        ],
                        "typeCode": "XA10BA",
                        "typeName": "双胍类"
                    },
                    {
                        "drugs": [
                            {
                                "dose": "50mg",
                                "drugGenericCode": "XA10BHW104",
                                "drugGenericName": "维格列汀",
                                "frequency": "每天两次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "100mg",
                                "drugGenericCode": "XA10BHX202",
                                "drugGenericName": "西格列汀",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "5mg",
                                "drugGenericCode": "XA10BHL343",
                                "drugGenericName": "利格列汀",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "5mg",
                                "drugGenericCode": "XA10BHS231",
                                "drugGenericName": "沙格列汀",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "25mg",
                                "drugGenericCode": "XA10BHA283",
                                "drugGenericName": "阿格列汀",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            }
                        ],
                        "notes": [
                            {
                                "decrements": [
                                    "沙格列汀",
                                    "维格列汀",
                                    "阿格列汀",
                                    "西格列汀"
                                ],
                                "disables": [
                                    
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "60>=eGFR>30",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    "维格列汀"
                                ],
                                "disables": [
                                    "沙格列汀",
                                    "阿格列汀",
                                    "西格列汀"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "30>=eGFR",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "维格列汀"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "谷草谷丙>=100",
                                "type": "肝功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    
                                ],
                                "recommends": [
                                    "维格列汀",
                                    "西格列汀",
                                    "利格列汀",
                                    "阿格列汀",
                                    "沙格列汀"
                                ],
                                "target": "冠心病/心衰",
                                "type": "心血管功能禁忌"
                            }
                        ],
                        "typeCode": "XA10BH",
                        "typeName": "DPP⁃4抑制剂"
                    },
                    {
                        "drugs": [
                            {
                                "dose": "10mg起始,单日最大剂量25mg",
                                "drugGenericCode": "XA10BKE079",
                                "drugGenericName": "恩格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "100mg起始,单日最大剂量300mg",
                                "drugGenericCode": "XA10BKK130",
                                "drugGenericName": "卡格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "5mg",
                                "drugGenericCode": "XA10BKA338",
                                "drugGenericName": "艾托格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "5mg起始,单日最大剂量10mg",
                                "drugGenericCode": "XA10BKD256",
                                "drugGenericName": "达格列净",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            }
                        ],
                        "notes": [
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "卡格列净",
                                    "艾托格列净",
                                    "恩格列净"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "60>=eGFR>30",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "卡格列净",
                                    "达格列净",
                                    "艾托格列净",
                                    "恩格列净"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "30>=eGFR",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "卡格列净",
                                    "达格列净",
                                    "艾托格列净",
                                    "恩格列净"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "谷草谷丙>=100",
                                "type": "肝功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    
                                ],
                                "recommends": [
                                    "卡格列净",
                                    "达格列净",
                                    "艾托格列净",
                                    "恩格列净"
                                ],
                                "target": "冠心病/心衰",
                                "type": "心血管功能禁忌"
                            }
                        ],
                        "typeCode": "XA10BK",
                        "typeName": "SGLT-2抑制剂"
                    },
                    {
                        "drugs": [
                            {
                                "dose": "0.6mg一周后无明显胃肠道反应后可加至1.2mg,单日最大剂量1.8mg",
                                "drugGenericCode": "XA10BJL326",
                                "drugGenericName": "利拉鲁肽",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "0.25mg或0.5mg起始,每周最大推荐剂量为1mg",
                                "drugGenericCode": "XA10BJS279",
                                "drugGenericName": "司美格鲁肽",
                                "frequency": "每周一次",
                                "remark": "",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "0.75 mg起始,每周最大推荐剂量为 1.5 mg",
                                "drugGenericCode": "XA10BJD332",
                                "drugGenericName": "度拉糖肽",
                                "frequency": "每周一次",
                                "remark": "",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "5 μg起始,单次最大剂量10mg",
                                "drugGenericCode": "XA10BJA085",
                                "drugGenericName": "艾塞那肽",
                                "frequency": "每天二次,早餐、晚餐前 60 分钟内",
                                "remark": "对患有胰腺炎的患者,禁用本品。不推荐本品用于终末期肾病或严重肾功能 不全(肌酐清除率<30 ml/min)的患者",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "10μg应用14天,后调整为20μg维持",
                                "drugGenericCode": "XA10BJL366",
                                "drugGenericName": "利司那肽",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "0.1mg,每周最大推荐剂量为0.2mg",
                                "drugGenericCode": "XA10BJJ237",
                                "drugGenericName": "洛塞那肽",
                                "frequency": "每周一次",
                                "remark": "",
                                "usage": "皮下注射"
                            }
                        ],
                        "notes": [
                            {
                                "decrements": [
                                    "洛塞那肽"
                                ],
                                "disables": [
                                    
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "60>=eGFR>30",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "利拉鲁肽",
                                    "利司那肽",
                                    "艾塞那肽",
                                    "度拉糖肽",
                                    "司美格鲁肽",
                                    "洛塞那肽"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "30>=eGFR",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "司美格鲁肽",
                                    "利拉鲁肽"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "谷草谷丙>=100",
                                "type": "肝功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    
                                ],
                                "recommends": [
                                    "利拉鲁肽",
                                    "利司那肽",
                                    "艾塞那肽",
                                    "度拉糖肽",
                                    "司美格鲁肽",
                                    "洛塞那肽"
                                ],
                                "target": "冠心病/心衰",
                                "type": "心血管功能禁忌"
                            }
                        ],
                        "typeCode": "XA10BJ",
                        "typeName": "GLP-1RA"
                    }
                ],
                "priority": 3,
                "reason": "",
                "regimenCode": "HS-hba1cG7L8-ageG60-bmiG28-reg3",
                "regimenName": "【优选】二甲双胍(或加用DPP-4抑制剂或SGLT-2抑制剂或GLP-1RA)"
            },
            {
                "drugTypes": [
                    {
                        "drugs": [
                            {
                                "dose": "4mg,单日最大剂量8mg",
                                "drugGenericCode": "XA10BGL261",
                                "drugGenericName": "罗格列酮",
                                "frequency": "每天一次",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "15mg-30mg,单日最大剂量45mg",
                                "drugGenericCode": "XA10BGB091",
                                "drugGenericName": "吡格列酮",
                                "frequency": "每天一次",
                                "remark": "老年患者应谨慎给药,密切观察服用期间是否发生不良反应",
                                "usage": "口服"
                            }
                        ],
                        "notes": [
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "吡格列酮"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "60>=eGFR>30",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "吡格列酮",
                                    "罗格列酮"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "30>=eGFR",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "吡格列酮",
                                    "罗格列酮"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "谷草谷丙>=100",
                                "type": "肝功能禁忌"
                            }
                        ],
                        "typeCode": "XA10BG",
                        "typeName": "噻唑烷二酮类"
                    },
                    {
                        "drugs": [
                            {
                                "dose": "50mg-100mg,单次最大剂量200mg",
                                "drugGenericCode": "XA10BFA025",
                                "drugGenericName": "阿卡波糖",
                                "frequency": "每天三次,餐中",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "0.2mg,单次最大剂量0.3mg",
                                "drugGenericCode": "XA10BFF058",
                                "drugGenericName": "伏格列波糖",
                                "frequency": "每天三次,餐中",
                                "remark": "",
                                "usage": "口服"
                            },
                            {
                                "dose": "25mg起始,单次最大剂量100mg",
                                "drugGenericCode": "XA10BFM097",
                                "drugGenericName": "米格列醇",
                                "frequency": "每天三次,餐中",
                                "remark": "",
                                "usage": "口服"
                            }
                        ],
                        "notes": [
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "伏格列波糖",
                                    "米格列醇",
                                    "阿卡波糖"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "30>=eGFR",
                                "type": "肾功能禁忌"
                            },
                            {
                                "decrements": [
                                    
                                ],
                                "disables": [
                                    "伏格列波糖",
                                    "阿卡波糖"
                                ],
                                "recommends": [
                                    
                                ],
                                "target": "谷草谷丙>=100",
                                "type": "肝功能禁忌"
                            }
                        ],
                        "typeCode": "XA10BF",
                        "typeName": "α⁃糖苷酶抑制剂"
                    },
                    {
                        "drugs": [
                            {
                                "dose": "0.1-0.2U/kg/d起始,根据空腹血糖调整用量",
                                "drugGenericCode": "XA10AEC074",
                                "drugGenericName": "甘精胰岛素",
                                "frequency": "每天一次,睡前",
                                "remark": "",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "0.1-0.2U/kg/d起始,根据空腹血糖调整用量",
                                "drugGenericCode": "XA10AED087",
                                "drugGenericName": "地特胰岛素",
                                "frequency": "每天一次,睡前",
                                "remark": "",
                                "usage": "皮下注射"
                            },
                            {
                                "dose": "0.1-0.2U/kg/d起始,根据空腹血糖调整用量",
                                "drugGenericCode": "XA10AED318",
                                "drugGenericName": "德谷胰岛素",
                                "frequency": "每天一次,睡前",
                                "remark": "",
                                "usage": "皮下注射"
                            }
                        ],
                        "notes": [
                            
                        ],
                        "typeCode": "XA10AE",
                        "typeName": "基础胰岛素"
                    }
                ],
                "priority": 4,
                "reason": "",
                "regimenCode": "HS-hba1cG7L8-ageG60-bmiG28-reg4",
                "regimenName": "【可用】噻唑烷二酮类、α-糖苷酶抑制剂(优选方案基础上加用)"
            }
        ]
    }
}

二、使用lateral VIEW posexplode ( split ( space( drugTypes_num -1), ‘’ ) ) t AS drugTypes_pos, val 炸裂解析


select 
t5.*,
get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[',drugTypes_pos,'].drugs[',drugs_pos,'].drugGenericCode')) as drug_generic_code, 
get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[',drugTypes_pos,'].drugs[',drugs_pos,'].drug_generic_name')) as drug_generic_name ,
get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[',drugTypes_pos,'].drugs[',drugs_pos,'].dose')) as dose ,
get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[',drugTypes_pos,'].drugs[',drugs_pos,'].usage')) as usage ,   
get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[',drugTypes_pos,'].drugs[',drugs_pos,'].frequency')) as frequency, 
get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[',drugTypes_pos,'].drugs[',drugs_pos,'].remark')) as remark   
from (
     select 
     t4.*,
     drugs_pos
     from (
          select 
          t3.*,
          size(split(regexp_replace(t3.drug_generic_codes,'\\[|\\]',''),',')) as drugs_num
          from (
               select 
               t2.*,
               get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[',drugTypes_pos,'].typeCode')) as durg_type_code,
               get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[',drugTypes_pos,'].typeName')) as durg_type_name,
               get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[',drugTypes_pos,'].drugs[*].drugGenericCode')) as drug_generic_codes, 
               get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[',drugTypes_pos,'].drugs[*].drug_generic_name')) as drug_generic_names ,
               get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[',drugTypes_pos,'].drugs[*].dose')) as doses ,
               get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[',drugTypes_pos,'].drugs[*].usage')) as usages ,   
               get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[',drugTypes_pos,'].drugs[*].frequency')) as frequencys, 
               get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[',drugTypes_pos,'].drugs[*].remark')) as remarks          
               from (
                    select 
                    t1.*,
                    drugTypes_pos
                    from (
                        select 
                        t0.*,
                        size(split(regexp_replace(t0.typeCodes,'\\[|\\]',''),',')) as drugTypes_num
                        from (
                            select 
                            t.*,
                            oper_result_primaryScheme_groupCode as group_code,
                            get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].regimenCode')) as regimenCode,
                            get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].regimenName')) as regimenName,
                            get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].reason')) as reason,
                            get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].priority')) as priority,
                            get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[*].typeCode')) as typeCodes,
                            get_json_object(oper_result, concat('$.specialistScheme.regimens[',regimens_pos,'].drugTypes[*].typeName')) as typeNames,
                            2 as origin_type
                            from (
                                 select 
                                 n.*,
                                 regimens_pos
                                 from wedw_dw.ai_base_recommended_plan_detail_df_tmp1 n 
                                 lateral VIEW  posexplode ( split ( space( specialistScheme_regimens_num -1), '' ) ) t  AS regimens_pos, val 
                            ) t 
                        ) t0 
                    ) t1 lateral VIEW  posexplode ( split ( space( drugTypes_num -1), '' ) ) t  AS drugTypes_pos, val 
               ) t2 
          ) t3 
     ) t4 lateral VIEW  posexplode ( split ( space( drugs_num -1), '' ) ) t  AS drugs_pos, val
) t5 

你可能感兴趣的:(大数据之Hive,hive,json,hadoop)