package com.yihu.wlyy.service.app.record;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.XMLUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.apache.poi.util.StringUtil;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by zhenglingfeng on 2016/10/17.
 * 测试(弃用)
 */
@Service
public class OutpatientService extends BaseService {

    @Autowired
    SystemDictService systemDictService;

    @Autowired
    private ObjectMapper objectMapper;

    /**
     * 获取门诊记录详情 0101
     * @param strSSID       健康卡号
     * @param strEvent      事件ID
     * @param strCatalog    档案类型
     * @param strSerial     该类别顺序号，默认填1
     * @return
     * @throws Exception
     */
    public Map getOutpatientInfo(String strSSID, String strEvent, String strCatalog, String strSerial) throws Exception {
//        String url = SystemConf.getInstance().getSystemProperties().getProperty("sign_check_upload");
//        url = url + "/third/smjk/HealthData";
//
//        List<NameValuePair> params = new ArrayList<>();
//        params.add(new BasicNameValuePair("strSSID", strSSID));
//        params.add(new BasicNameValuePair("strEvent", strEvent));
//        params.add(new BasicNameValuePair("strCatalog", strCatalog));
//        params.add(new BasicNameValuePair("strSerial", strSerial));
//
//        String response = HttpClientUtil.post(url, params, "UTF-8");
//        if (!StringUtils.isEmpty(response)){
//            JSONObject jsonObject = new JSONObject(response);
//            int status = jsonObject.getInt("status");
//            if (status == 200){
//                String data = jsonObject.getString("data");
//                if (!StringUtils.isEmpty(data)){
//                    JSONObject jsonData = new JSONObject(data);
//                    result = jsonData.getJSONArray("EhrList");
//                }
//            }
//        }

        //TODO  示例数据，未转成前端需要
        String xml = "<ClinicalDocument><version date=\"2009-12-01\" code=\"2.0.0.0\">根据卫生部标准第一次修订</version><ehr codeSystem=\"STD_EHR\" code=\"0101\">门诊基本诊疗信息</ehr><title>门诊基本诊疗信息</title><org codeSystem=\"STD_HEALTH_ORG\" code=\"350211A1049\"/><id eventno=\"\" extension=\"\"/><effectiveTime/><recordTarget><patient><id extension=\"B55553768744\"/><name>江良福</name><sex codeSystem=\"GB/T2261.1-2003\" code=\"1\">男性</sex><birthDate>1993-08-05 00:00:00.0</birthDate><marriage codeSystem=\"GB/T 2261.2-2003\" code=\"null\">null</marriage></patient></recordTarget><component><section><code displayName=\"门诊基本诊疗信息\" codeSystem=\"\" code=\"common\"/><entry><onsetTime/><treatTime/><diagnosisDate/><reg><value/><type codeSystem=\"STD_REG_TYPE\" code=\"51\">急诊</type></reg><sec><value>null</value><type codeSystem=\"STD_SEC_TYPE\" code=\"3\">自费医疗</type></sec><dept codeSystem=\"GB/T 17538-1998\" code=\"31600\"/><doctor><id extension=\"83178\"/><name/><title codeSystem=\"GB/T 8561-1988\" code=\"null\">null</title></doctor><symptom/><diagnosis><item><icd codeSystem=\"ICD-10\" code=\"T11.900\">上肢损伤</icd><result codeSystem=\"CV5501.11\" code=\"\"/><prop codeSystem=\"STD_DIAGNOSIS_PROP\" code=\"\"/></item></diagnosis></entry></section></component></ClinicalDocument>";
        String xmlJson = XMLUtil.xml2json(xml);
        Map result = objectMapper.readValue(xmlJson, Map.class);
        return result;
    }

    /**
     * 获取门诊费用明细 0102
     * @return
     * @throws Exception
     */
    public  Map getOutpatientCost() throws Exception {
        //TODO  示例数据，未转成前端需要
        String xml = "<ClinicalDocument><version date=\"2011-06-01\" code=\"2.0.0.1\">根据卫生部标准第2次修订</version><ehr codeSystem=\"STD_EHR\" code=\"0102\">门诊费用明细</ehr><title>门诊费用明细</title><org codeSystem=\"STD_HEALTH_ORG\" code=\"350211A1049\"/><id eventno=\"\" extension=\"\"/><effectiveTime/><recordTarget><patient><id extension=\"DA2222433\"/><name>夏永平</name></patient></recordTarget><component><section><code displayName=\"门诊费用明细\" codeSystem=\"\" code=\"common\"/><entry><group><type codeSystem=\"CV5600.01\" code=\"01\">西药</type><payway codeSystem=\"CV5600.02\" code=\"null\">null</payway><fee>19.4</fee><item><time>2016-07-02 09:07:03.0</time><value code=\"10101090206475810101\">青霉素钠</value><custome code=\"1337205\">注射用青霉素钠</custome><spec>80万u</spec><unit>支</unit><price>0.27</price><quantity>24</quantity><total>6.48</total><notes>null</notes></item><item><time>2016-07-02 09:07:03.0</time><value code=\"11802002015084916501\">氯化钠</value><custome code=\"73734\">0.9%氯化钠溶液(袋装)</custome><spec>100ml</spec><unit>瓶</unit><price>3.23</price><quantity>4</quantity><total>12.92</total><notes>null</notes></item></group><group><type codeSystem=\"CV5600.01\" code=\"05\">治疗</type><payway codeSystem=\"CV5600.02\" code=\"null\">null</payway><fee>40</fee><item><time>2016-07-02 08:54:33.0</time><value code=\"011020000300\">急诊诊查费</value><custome code=\"011020000305\">急诊诊察费</custome><spec>null</spec><unit>人次</unit><price>20</price><quantity>1</quantity><total>20</total><notes>null</notes></item><item><time>2016-07-02 09:11:25.0</time><value code=\"012040000600\">静脉输液</value><custome code=\"012040000600\">静脉输液</custome><spec>null</spec><unit>组</unit><price>5</price><quantity>4</quantity><total>20</total><notes>null</notes></item></group><group><type codeSystem=\"CV5600.01\" code=\"99\">其他</type><payway codeSystem=\"CV5600.02\" code=\"null\">null</payway><fee>25.12</fee><item><time>2016-07-02 09:11:25.0</time><value code=\"950029000000\">一次性输液器</value><custome code=\"950029000002\">一次性输液器</custome><spec>null</spec><unit>套</unit><price>0.76</price><quantity>4</quantity><total>3.04</total><notes>null</notes></item><item><time>2016-07-02 09:11:25.0</time><value code=\"950030000000\">注射器</value><custome code=\"950030000005\">一次性注射器(20ml)</custome><spec>null</spec><unit>支</unit><price>0.52</price><quantity>4</quantity><total>2.08</total><notes>null</notes></item><item><time>2016-07-02 09:11:25.0</time><value code=\"011090000530\">急诊观察床位费？四人及以上间</value><custome code=\"011090000501\">急诊观察床位费{躺椅}</custome><spec>null</spec><unit>次</unit><price>5</price><quantity>4</quantity><total>20</total><notes>null</notes></item></group></entry></section></component></ClinicalDocument>";
        String xmlJson = XMLUtil.xml2json(xml);
        Map result = objectMapper.readValue(xmlJson, Map.class);
        return result;
    }

    /**
     * 获取门诊检验明细 0121
     * @return
     * @throws Exception
     */
    public Map getOutpatientLabReport() throws Exception {
        //TODO  示例数据，未转成前端需要
        String xml = "<ClinicalDocument><version date=\"2009-12-01\" code=\"2.0.0.0\">根据卫生部标准第一次修订</version><ehr codeSystem=\"STD_EHR\" code=\"0121\">门诊检验报告</ehr><title>粪便Rt报告单</title><org codeSystem=\"STD_HEALTH_ORG\" code=\"350211A1049\"/><id eventno=\"2912831001\" extension=\"20160711G0270348\"/><effectiveTime value=\"2016-07-11 11:19:46.0\"/><recordTarget><patient><id extension=\"\"/><name>张亦尘</name><sex codeSystem=\"GB/T 2261.1-2003\" code=\"1\">男</sex></patient></recordTarget><author><time>null</time><id extension=\"null\"/><name>null</name></author><authenticator><time>2016-07-11 11:19:46.0</time><id extension=\"陈亚平\"/><name>陈亚平</name></authenticator><participant><time>2016-07-10 16:55:00.0</time><id extension=\"null\"/><name>曾珑/85253</name><dept>儿科门诊</dept></participant><inFulfillmentOf><order><id>null</id><priority codeSystem=\"HL7 27\" code=\"2\">常规</priority></order></inFulfillmentOf><component><section><code displayName=\"null\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"体液报告单\"/><entry><id>0348</id><performer><assignedEntity>null</assignedEntity><name>吴江南</name><time>2016-07-11 11:18:07.0</time></performer><classCode>粪便</classCode><specimenDeterminer codeSystem=\"HL7 0163\" code=\"null\">null</specimenDeterminer><risk codeSystem=\"HL7 0489\" code=\"null\">null</risk><quantity codeSystem=\"HL7 0491\" code=\"null\">null</quantity><rejectReason codeSystem=\"HL7 0490\" code=\"null\">null</rejectReason><playingDevice><name>null</name></playingDevice><observation><code displayName=\"null\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"体液报告单\"/><type codeSystem=\"STD_OBSERVATION_TYPE\" code=\"\"/><value/><unit/><referenceRange><observationRange><notes/><low><value/><unit/></low><high><value/><unit/></high></observationRange></referenceRange><effectiveTime>2016-07-11 11:19:44.0</effectiveTime><interpretationCode codeSystem=\"2.16.840.1.113883.5.83\" code=\"\"/></observation><observation><code displayName=\"红细胞\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"5742\"/><type codeSystem=\"STD_OBSERVATION_TYPE\" code=\"CD\">文本型</type><value>未检出</value><unit>个/HP</unit><referenceRange><observationRange><notes>null</notes><low><value>null</value><unit>个/HP</unit></low><high><value>null</value><unit>个/HP</unit></high></observationRange></referenceRange><effectiveTime>2016-07-11 11:19:44.0</effectiveTime><interpretationCode codeSystem=\"2.16.840.1.113883.5.83\" code=\"N\">正常</interpretationCode></observation><observation><code displayName=\"蛲虫卵\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"5762\"/><type codeSystem=\"STD_OBSERVATION_TYPE\" code=\"CD\">文本型</type><value>未检出</value><unit>null</unit><referenceRange><observationRange><notes>null</notes><low><value>null</value><unit>null</unit></low><high><value>null</value><unit>null</unit></high></observationRange></referenceRange><effectiveTime>2016-07-11 11:19:44.0</effectiveTime><interpretationCode codeSystem=\"2.16.840.1.113883.5.83\" code=\"N\">正常</interpretationCode></observation><observation><code displayName=\"颜色\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"5731\"/><type codeSystem=\"STD_OBSERVATION_TYPE\" code=\"CD\">文本型</type><value>黄色</value><unit>null</unit><referenceRange><observationRange><notes>null</notes><low><value>null</value><unit>null</unit></low><high><value>null</value><unit>null</unit></high></observationRange></referenceRange><effectiveTime>2016-07-11 11:19:44.0</effectiveTime><interpretationCode codeSystem=\"2.16.840.1.113883.5.83\" code=\"N\">正常</interpretationCode></observation><observation><code displayName=\"粘液\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"5740\"/><type codeSystem=\"STD_OBSERVATION_TYPE\" code=\"CD\">文本型</type><value>未检出</value><unit>null</unit><referenceRange><observationRange><notes>null</notes><low><value>null</value><unit>null</unit></low><high><value>null</value><unit>null</unit></high></observationRange></referenceRange><effectiveTime>2016-07-11 11:19:44.0</effectiveTime><interpretationCode codeSystem=\"2.16.840.1.113883.5.83\" code=\"N\">正常</interpretationCode></observation><observation><code displayName=\"真菌\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"5728\"/><type codeSystem=\"STD_OBSERVATION_TYPE\" code=\"CD\">文本型</type><value>未检出</value><unit>null</unit><referenceRange><observationRange><notes>null</notes><low><value>null</value><unit>null</unit></low><high><value>null</value><unit>null</unit></high></observationRange></referenceRange><effectiveTime>2016-07-11 11:19:44.0</effectiveTime><interpretationCode codeSystem=\"2.16.840.1.113883.5.83\" code=\"N\">正常</interpretationCode></observation><observation><code displayName=\"脂肪球\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"5761\"/><type codeSystem=\"STD_OBSERVATION_TYPE\" code=\"CD\">文本型</type><value>未检出</value><unit>null</unit><referenceRange><observationRange><notes>null</notes><low><value>null</value><unit>null</unit></low><high><value>null</value><unit>null</unit></high></observationRange></referenceRange><effectiveTime>2016-07-11 11:19:44.0</effectiveTime><interpretationCode codeSystem=\"2.16.840.1.113883.5.83\" code=\"N\">正常</interpretationCode></observation><observation><code displayName=\"脓球\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"5741\"/><type codeSystem=\"STD_OBSERVATION_TYPE\" code=\"CD\">文本型</type><value>未检出</value><unit>个/HP</unit><referenceRange><observationRange><notes>null</notes><low><value>null</value><unit>个/HP</unit></low><high><value>null</value><unit>个/HP</unit></high></observationRange></referenceRange><effectiveTime>2016-07-11 11:19:44.0</effectiveTime><interpretationCode codeSystem=\"2.16.840.1.113883.5.83\" code=\"N\">正常</interpretationCode></observation><observation><code displayName=\"钩虫卵\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"5746\"/><type codeSystem=\"STD_OBSERVATION_TYPE\" code=\"CD\">文本型</type><value>未检出</value><unit>null</unit><referenceRange><observationRange><notes>null</notes><low><value>null</value><unit>null</unit></low><high><value>null</value><unit>null</unit></high></observationRange></referenceRange><effectiveTime>2016-07-11 11:19:44.0</effectiveTime><interpretationCode codeSystem=\"2.16.840.1.113883.5.83\" code=\"N\">正常</interpretationCode></observation><observation><code displayName=\"硬度\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"5732\"/><type codeSystem=\"STD_OBSERVATION_TYPE\" code=\"CD\">文本型</type><value>软</value><unit>null</unit><referenceRange><observationRange><notes>null</notes><low><value>null</value><unit>null</unit></low><high><value>null</value><unit>null</unit></high></observationRange></referenceRange><effectiveTime>2016-07-11 11:19:44.0</effectiveTime><interpretationCode codeSystem=\"2.16.840.1.113883.5.83\" code=\"N\">正常</interpretationCode></observation><observation><code displayName=\"鞭虫卵\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"5745\"/><type codeSystem=\"STD_OBSERVATION_TYPE\" code=\"CD\">文本型</type><value>未检出</value><unit>null</unit><referenceRange><observationRange><notes>null</notes><low><value>null</value><unit>null</unit></low><high><value>null</value><unit>null</unit></high></observationRange></referenceRange><effectiveTime>2016-07-11 11:19:44.0</effectiveTime><interpretationCode codeSystem=\"2.16.840.1.113883.5.83\" code=\"N\">正常</interpretationCode></observation><observation><code displayName=\"蛔虫卵\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"5744\"/><type codeSystem=\"STD_OBSERVATION_TYPE\" code=\"CD\">文本型</type><value>未检出</value><unit>null</unit><referenceRange><observationRange><notes>null</notes><low><value>null</value><unit>null</unit></low><high><value>null</value><unit>null</unit></high></observationRange></referenceRange><effectiveTime>2016-07-11 11:19:44.0</effectiveTime><interpretationCode codeSystem=\"2.16.840.1.113883.5.83\" code=\"N\">正常</interpretationCode></observation><observation><code displayName=\"白细胞\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"5743\"/><type codeSystem=\"STD_OBSERVATION_TYPE\" code=\"CD\">文本型</type><value>未检出</value><unit>个/HP</unit><referenceRange><observationRange><notes>null</notes><low><value>null</value><unit>个/HP</unit></low><high><value>null</value><unit>个/HP</unit></high></observationRange></referenceRange><effectiveTime>2016-07-11 11:19:44.0</effectiveTime><interpretationCode codeSystem=\"2.16.840.1.113883.5.83\" code=\"N\">正常</interpretationCode></observation><observation><code displayName=\"血\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"5739\"/><type codeSystem=\"STD_OBSERVATION_TYPE\" code=\"CD\">文本型</type><value>未检出</value><unit>null</unit><referenceRange><observationRange><notes>null</notes><low><value>null</value><unit>null</unit></low><high><value>null</value><unit>null</unit></high></observationRange></referenceRange><effectiveTime>2016-07-11 11:19:44.0</effectiveTime><interpretationCode codeSystem=\"2.16.840.1.113883.5.83\" code=\"N\">正常</interpretationCode></observation><observation><code displayName=\"血吸虫卵\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"5747\"/><type codeSystem=\"STD_OBSERVATION_TYPE\" code=\"CD\">文本型</type><value>未检出</value><unit>null</unit><referenceRange><observationRange><notes>null</notes><low><value>null</value><unit>null</unit></low><high><value>null</value><unit>null</unit></high></observationRange></referenceRange><effectiveTime>2016-07-11 11:19:44.0</effectiveTime><interpretationCode codeSystem=\"2.16.840.1.113883.5.83\" code=\"N\">正常</interpretationCode></observation></entry></section></component></ClinicalDocument>";
        String xmlJson = XMLUtil.xml2json(xml);
        Map result = objectMapper.readValue(xmlJson, Map.class);
        return result;
    }

    /**
     * 获取门诊查验明细 0131
     * @return
     * @throws Exception
     */
    public Map getOutpatientExamReport() throws Exception {
        //TODO  示例数据，未转成前端需要
        String xml = "<ClinicalDocument><version date=\"2009-12-01\" code=\"2.0.0.0\">根据卫生部标准第一次修订</version><ehr codeSystem=\"STD_EHR\" code=\"0131\">门诊检查报告</ehr><title>放射检查报告</title><org codeSystem=\"STD_HEALTH_ORG\" code=\"350211A1049\"/><id eventno=\"2912822001\" extension=\"00003127611\"/><effectiveTime value=\"2016-07-11 15:29:16.0\"/><recordTarget><patient><id extension=\"\"/><name>何强</name><sex codeSystem=\"GB/T 2261.1-2003\" code=\"null\">男</sex></patient></recordTarget><author><time>2016-07-10 15:02:54.0</time><id extension=\"null\"/><name>李艳</name></author><authenticator><time>2016-07-11 15:29:16.0</time><id extension=\"null\"/><name>李萍</name></authenticator><participant><time>2016-07-10 14:47:28.0</time><id extension=\"null\"/><name>朱赵</name><dept>急诊科</dept></participant><inFulfillmentOf><order><id>null</id><priority codeSystem=\"HL7 27\" code=\"null\">null</priority></order></inFulfillmentOf><component><section><code examName=\"DR右足正斜位片;\" examCode=\"null\" bodyPartName=\"null\" bodyPartCode=\"null\" displayName=\"放射\" code=\"null\"/><entry><performer><assignedEntity>放射影像科</assignedEntity><name>null</name><time>2016-07-10 14:58:20.0</time></performer><playingDevice><name>云平台</name></playingDevice><clinicDiagnosis>下肢损伤</clinicDiagnosis><patientCondition>null</patientCondition><examCause>null</examCause><description>正位片示右足跟骨外缘一小斑片状致密影，邻近骨皮质尚完整；余右足诸骨骨质连续，未见骨折征象，各关节关系正常。</description><isAbnormal codeSystem=\"\" code=\"N正常、Y异常\">Y</isAbnormal></entry></section></component></ClinicalDocument>";
        String xmlJson = XMLUtil.xml2json(xml);
        Map result = objectMapper.readValue(xmlJson, Map.class);
        return result;
    }

    /**
     * 获取门诊用药记录明细 0141
     * @return
     * @throws Exception
     */
    public Map getOutpatientDrugs() throws Exception {
        //TODO  示例数据，未转成前端需要
        String xml = "<ClinicalDocument><version date=\"2011-06-01\" code=\"2.0.0.1\">根据卫生部标准第2次修订</version><ehr codeSystem=\"STD_EHR\" code=\"0141\">门诊用药记录</ehr><title>门诊用药记录</title><org codeSystem=\"STD_HEALTH_ORG\" code=\"350211A1049\"/><id eventno=\"\" extension=\"\"/><effectiveTime/><recordTarget><patient><id extension=\"D6387464X\"/><name>胡明高</name></patient></recordTarget><component><section><code displayName=\"门诊用药记录\" codeSystem=\"\" code=\"common\"/><entry><group><method codeSystem=\"CV5201.22\" code=\"1\">口服</method><freq>t.i.d.</freq><days>3</days><startDate>2016-07-02 09:27:39.0</startDate><endDate/><medicine><offertime>2016-07-02 09:36:08.0</offertime><value code=\"11204005109289910501\">盐酸阿米替林</value><DiaCode/><custome code=\"65457\">盐酸阿米替林片</custome><cnType codeSystem=\"CV5301.05\" code=\"1\">未使用</cnType><type codeSystem=\"CV5301.06\" code=\"1203\"/><form codeSystem=\"CV5301.01\" code=\"60\">吸入药剂(鼻吸式),粉雾剂</form><totalQuantity>9</totalQuantity><totalUnit>片</totalUnit><doseQuantity>25</doseQuantity><doseUnit>mg</doseUnit><spec>25mg*100片</spec><notes>null</notes></medicine><medicine><offertime>2016-07-02 09:36:08.0</offertime><value code=\"10602004109084910501\">维生素B1</value><DiaCode/><custome code=\"1337268\">维生素B1片</custome><cnType codeSystem=\"CV5301.05\" code=\"1\">未使用</cnType><type codeSystem=\"CV5301.06\" code=\"0600\"/><form codeSystem=\"CV5301.01\" code=\"60\">吸入药剂(鼻吸式),粉雾剂</form><totalQuantity>42</totalQuantity><totalUnit>片</totalUnit><doseQuantity>20</doseQuantity><doseUnit>mg</doseUnit><spec>10mg*42片</spec><notes>null</notes></medicine><medicine><offertime>2016-07-02 09:36:08.0</offertime><value code=\"10102022234108210101\">头孢克洛</value><DiaCode/><custome code=\"1337096\">头孢克洛胶囊</custome><cnType codeSystem=\"CV5301.05\" code=\"1\">未使用</cnType><type codeSystem=\"CV5301.06\" code=\"0102\"/><form codeSystem=\"CV5301.01\" code=\"45\">滴耳剂,洗耳剂</form><totalQuantity>18</totalQuantity><totalUnit>粒</totalUnit><doseQuantity>2</doseQuantity><doseUnit>粒</doseUnit><spec>0.25g*12粒</spec><notes>null</notes></medicine></group><group><method codeSystem=\"CV5201.22\" code=\"1\">口服</method><freq>b.i.d.</freq><days>3</days><startDate>2016-07-02 09:27:39.0</startDate><endDate>2016-07-04 00:00:00.0</endDate><medicine><offertime>2016-07-02 09:36:08.0</offertime><value code=\"10401079195314110101\">西乐葆</value><DiaCode/><custome code=\"69363\">塞来昔布胶囊(西乐葆)</custome><cnType codeSystem=\"CV5301.05\" code=\"1\">未使用</cnType><type codeSystem=\"CV5301.06\" code=\"0401\">解热镇痛药</type><form codeSystem=\"CV5301.01\" code=\"45\">滴耳剂,洗耳剂</form><totalQuantity>6</totalQuantity><totalUnit>g</totalUnit><doseQuantity>0.2</doseQuantity><doseUnit>g</doseUnit><spec>0.2g*6粒/盒</spec><notes>null</notes></medicine></group></entry></section></component></ClinicalDocument>";
        String xmlJson = XMLUtil.xml2json(xml);
        Map result = objectMapper.readValue(xmlJson, Map.class);
        return result;
    }


    public Map xmlToJson(String xml) throws Exception {
        //TODO  示例数据，未转成前端需要
        String xmlJson = XMLUtil.xml2json(xml);
        Map result = objectMapper.readValue(xmlJson, Map.class);
        return result;
    }


}
