About neohope

一直在努力,还没想过要放弃...

eXistDB简单通讯02

  • 保存文件
  • 取回文件
  • 查询
  • 嵌套查询

1、Base.java

package com.neohope.existdb.test;

import org.exist.util.serializer.SAXSerializer;
import org.exist.util.serializer.SerializerPool;

import javax.xml.transform.OutputKeys;
import java.io.OutputStreamWriter;
import java.util.Properties;

public class Base {
    protected final static String URI = "xmldb:exist://localhost:8080/exist/xmlrpc";
    protected final static String driver = "org.exist.xmldb.DatabaseImpl";
    protected static  Class<?> cl = null;

    static{
        try {
            cl = Class.forName(driver);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    protected static SAXSerializer getSAXSerializer()
    {
        Properties outputProperties = new Properties();
        outputProperties.setProperty(OutputKeys.INDENT, "yes");
        SAXSerializer serializer = (SAXSerializer) SerializerPool.getInstance().borrowObject(SAXSerializer.class);
        serializer.setOutput(new OutputStreamWriter(System.out), outputProperties);
        return serializer;
    }

    protected static void releaseSAXSerializer(SAXSerializer serializer) {
        SerializerPool.getInstance().returnObject(serializer);
    }
}

Continue reading eXistDB简单通讯02

eXistDB简单通讯01

  • 保存文件
  • 取回文件
  • 查询
  • 嵌套查询

1、Base.java

package com.neohope.existdb.test;

import org.exist.util.serializer.SAXSerializer;
import org.exist.util.serializer.SerializerPool;

import javax.xml.transform.OutputKeys;
import java.io.OutputStreamWriter;
import java.util.Properties;

public class Base {
    protected final static String URI = "xmldb:exist://localhost:8080/exist/xmlrpc";
    protected final static String driver = "org.exist.xmldb.DatabaseImpl";
    protected static  Class<?> cl = null;

    static{
        try {
            cl = Class.forName(driver);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    protected static SAXSerializer getSAXSerializer()
    {
        Properties outputProperties = new Properties();
        outputProperties.setProperty(OutputKeys.INDENT, "yes");
        SAXSerializer serializer = (SAXSerializer) SerializerPool.getInstance().borrowObject(SAXSerializer.class);
        serializer.setOutput(new OutputStreamWriter(System.out), outputProperties);
        return serializer;
    }

    protected static void releaseSAXSerializer(SAXSerializer serializer) {
        SerializerPool.getInstance().returnObject(serializer);
    }
}

Continue reading eXistDB简单通讯01

eXistDB查询测试04入院记录HX

xquery version "3.0";
(:查询入院记录,并并给出住院号:)
collection('/db/HX_RYJL')/DocObjContent/NewCtrl[@Id='53119AC4B15CC61B_住院号']/Content_Text
xquery version "3.0";
(:查询入院记录,并并给出个人信息:)
for $DocObjContent in collection('/db/HX_RYJL')/DocObjContent
return
    <patient>
        <patientId value='{$DocObjContent/NewCtrl[@Id='53119AC4B15CC61B_住院号']}'></patientId>
        <area value='{$DocObjContent/NewCtrl[@Id='CB608F4C0FA682EF_病区名称']}'></area>
        <patientName value='{$DocObjContent/NewCtrl[@Id='19BD50BF516552A7_患者姓名']}'></patientName>
        <breath value='{$DocObjContent/NewCtrl[@Id='77423F11443D7D11_性别中文']}'></breath>
        <patientId value='{$DocObjContent/NewCtrl[@Id='5F513A94E1DA8BD3_年龄']}'> </patientId>
    </patient>
xquery version "3.0";
(:查询入院记录,并并给出常用信息:)
for $DocObjContent in collection('/db/HX_RYJL')/DocObjContent
return
    <patient>
        <patientId value='{$DocObjContent/NewCtrl[@Id='53119AC4B15CC61B_住院号']}'></patientId>
        <area value='{$DocObjContent/NewCtrl[@Id='CB608F4C0FA682EF_病区名称']}'></area>
        <patientName value='{$DocObjContent/NewCtrl[@Id='19BD50BF516552A7_患者姓名']}'></patientName>
        <breath value='{$DocObjContent/NewCtrl[@Id='77423F11443D7D11_性别中文']}'></breath>
        <patientId value='{$DocObjContent/NewCtrl[@Id='5F513A94E1DA8BD3_年龄']}'> </patientId>
        <chiefComplaint value='{$DocObjContent/NewCtrl[@Id='主诉']}'> </chiefComplaint>
        <ethnic value='{$DocObjContent/NewCtrl[@Id='9B787211E2563732_民族']}'> </ethnic>
        <address value='{$DocObjContent/NewCtrl[@Id='BF4E1AEA9E7094D7_户口地址']}'> </address>
        <married value='{$DocObjContent/NewCtrl[@Id='AC26C755C722B756_婚否']}'> </married>
    </patient>

eXistDB查询测试03入院护理评估单

xquery version "3.0";
(:查询入院护理评估单CDA,并并给出患者体温:)
collection('/db/ZS_RYHLPGD')/ClinicalDocument/component/structuredBody/component/section/text/McsDocFormList/HiupMcsDocForm/hiupMcsDocFormRecordsList/HiupMcsDocFormRecords[nodeId='12365']/text
xquery version "3.0";
(:查询入院护理评估单CDA,并并给出患者的体温脉搏呼吸:)
for $RecordList in collection('/db/ZS_RYHLPGD')/ClinicalDocument/component/structuredBody/component/section/text/McsDocFormList/HiupMcsDocForm/hiupMcsDocFormRecordsList
return
    <patient>
        <tempture value='{$RecordList/HiupMcsDocFormRecords[nodeId='12365']/text}摄氏度'></tempture>
        <pulse value='{$RecordList/HiupMcsDocFormRecords[nodeId='12366']/text}次每分'></pulse>
        <bloodpressure value='{$RecordList/HiupMcsDocFormRecords[nodeId='12368']/text}'></bloodpressure>
        <breath value='{$RecordList/HiupMcsDocFormRecords[nodeId='12367']/text}次每分'></breath>
        <patientId value='{$RecordList/HiupMcsDocFormRecords[nodeId='12350']/text}'> </patientId>
    </patient>
xquery version "3.0";
(:查询入院护理评估单CDA,并并给出患者常用信息:)
for $RecordList in collection('/db/ZS_RYHLPGD')/ClinicalDocument/component/structuredBody/component/section/text/McsDocFormList/HiupMcsDocForm
return
    <patient>
        <name value='{$RecordList/hiupMcsDocFormRecordsList/HiupMcsDocFormRecords[nodeId='12347']/text}'></name>
        <age value='{$RecordList/hiupMcsDocFormRecordsList/HiupMcsDocFormRecords[nodeId='12355']/text}'></age>
        <sex value='{$RecordList/hiupMcsDocFormRecordsList/HiupMcsDocFormRecords[nodeId='12352']/text}'></sex>
        
        <tempture value='{$RecordList/hiupMcsDocFormRecordsList/HiupMcsDocFormRecords[nodeId='12365']/text}摄氏度'></tempture>
        <pulse value='{$RecordList/hiupMcsDocFormRecordsList/HiupMcsDocFormRecords[nodeId='12366']/text}次每分'></pulse>
        <bloodpressure value='{$RecordList/hiupMcsDocFormRecordsList/HiupMcsDocFormRecords[nodeId='12368']/text}'></bloodpressure>
        <breath value='{$RecordList/hiupMcsDocFormRecordsList/HiupMcsDocFormRecords[nodeId='12367']/text}次每分'></breath>
        
        <patientId value='{$RecordList/hiupMcsDocFormRecordsList/HiupMcsDocFormRecords[nodeId='12350']/text}'> </patientId>
        <flowId value='{$RecordList/patientId}'> </flowId>
        <area value='{$RecordList/hiupMcsDocFormRecordsList/HiupMcsDocFormRecords[nodeId='12348']/text}'></area>
        <bedno value='{$RecordList/hiupMcsDocFormRecordsList/HiupMcsDocFormRecords[nodeId='12349']/text}'></bedno>
        <indate value='{$RecordList/hiupMcsDocFormRecordsList/HiupMcsDocFormRecords[nodeId='12370']/text}'></indate>
    </patient>

eXistDB查询测试02病案首页HT

xquery version "3.0";
(:查询病案首页CDA,并并给出患者姓名:)
collection('/db/ZS_FrontPageEMR')/ClinicalDocument/component/structuredBody/component/section/text/List/BAVisit/baidname
xquery version "3.0";
(:查询病案首页CDA,并并给出患者的基本信息:)
for $ClinicalList in collection('/db/ZS_FrontPageEMR')/ClinicalDocument/component/structuredBody/component/section/text/List
return
    <patient>
        <name value='{$ClinicalList/BAVisit/baidname}'></name>
        <sex value='{$ClinicalList/BAVisit/baidsexname}'></sex>
        <birthTime value='{$ClinicalList/BAVisit/baidbirthday}'></birthTime>
        <age value='{$ClinicalList/BAVisit/bamxage}'></age>
        <nationality value='{$ClinicalList/BAVisit/baidnative}'></nationality>
        <address value='{$ClinicalList/BAPatientRecordInfo/baidxzz}'></address>
        <ethnic value='{$ClinicalList/BAVisit/baidnation}'></ethnic>
        <phone value='{$ClinicalList/BAPatientRecordInfo/bamxlxtele}'></phone>
        
        <patientId value='{$ClinicalList/BAVisit/bamxprn}'> </patientId>
        <flowId value='{$ClinicalList/BAVisit/bamxjzh}'> </flowId>
    </patient>

Continue reading eXistDB查询测试02病案首页HT

eXistDB查询测试01病案首页EMR

(:查询文档标题:)
xquery version "3.0";
collection('/db/ZS_FrontPageBA/病案首页01')/ClinicalDocument/title
(:查询患者ID:)
xquery version "3.0";
collection('/db/ZS_FrontPageBA')/ClinicalDocument/recordTarget/patientRole/id[@assigningAuthorityName='XDS.Patientid' and @root='2.16.840.1.113883.4.487.2.1.4']
xquery version "3.0";
(:查询患者的id,并修改返回结构:)
for $anid in collection('/db/ZS_FrontPageBA')/ClinicalDocument/recordTarget/patientRole/id[@assigningAuthorityName='XDS.Patientid' and @root='2.16.840.1.113883.4.487.2.1.4']
return
    <patient patientId='{$anid/@extension}' patientDomain='{$anid/@root}'> </patient>
(:查询患者入院诊断:)
xquery version "3.0";
for $diagnose in collection('/db/ZS_FrontPageBA')/ClinicalDocument/component/structuredBody/component/section[title="入院诊断"]/text
return
    <indiagnose value='{$diagnose}'></indiagnose>

Continue reading eXistDB查询测试01病案首页EMR

QPID通讯代码04

  • TextMessage
  • ListMessage
  • MapMesage
  • StreamMessage

1、MqConsumerStream.java

package com.neohope.qpid.test;

import org.apache.qpid.client.AMQAnyDestination;
import org.apache.qpid.client.AMQConnection;

import javax.jms.*;

public class MqConsumerStream {
    public static void main(String[] args) throws Exception {
        Connection connection =
                new AMQConnection("amqp://guest:guest@test/?brokerlist='tcp://localhost:5672'");

        connection.start();

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination queue = new AMQAnyDestination("ADDR:message_queue; {create: always}");
        MessageConsumer consumer = session.createConsumer(queue);

        System.out.println("Receiving as StreamMessage");
        StreamMessage m = (StreamMessage) consumer.receive();
        System.out.println(m);
        System.out.println("==========================================");
        System.out.println("Printing stream contents:");
        try {
            while (true)
                System.out.println(m.readObject());
        } catch (MessageEOFException e) {
            // DONE
        }
    }
}

Continue reading QPID通讯代码04

QPID通讯代码03

  • TextMessage
  • ListMessage
  • MapMesage
  • StreamMessage

1、MqConsumerMap.java

package com.neohope.qpid.test;

import org.apache.qpid.client.AMQAnyDestination;
import org.apache.qpid.client.AMQConnection;

import javax.jms.*;
import java.util.Enumeration;

public class MqConsumerMap {
    public static void main(String[] args) throws Exception {
        Connection connection =
                new AMQConnection("amqp://guest:guest@test/?brokerlist='tcp://localhost:5672'");

        connection.start();

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination queue = new AMQAnyDestination("ADDR:message_queue; {create: always}");
        MessageConsumer consumer = session.createConsumer(queue);

        System.out.println("Receiving as MapMessage");
        MapMessage m = (MapMessage) consumer.receive();
        System.out.println(m);
        System.out.println("==========================================");
        System.out.println("Printing map contents:");
        Enumeration keys = m.getMapNames();
        while (keys.hasMoreElements()) {
            String key = (String) keys.nextElement();
            System.out.println(key + " => " + m.getObject(key));
        }
    }
}

Continue reading QPID通讯代码03

QPID通讯代码02

  • TextMessage
  • ListMessage
  • MapMesage
  • StreamMessage

1、MqConsumerList.java

package com.neohope.qpid.test;

import org.apache.qpid.client.AMQAnyDestination;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.jms.ListMessage;

import javax.jms.*;
import java.util.Enumeration;
import java.util.Iterator;

public class MqConsumerList {
    public static void main(String[] args) throws Exception {
        Connection connection =
                new AMQConnection("amqp://guest:guest@test/?brokerlist='tcp://localhost:5672'");

        connection.start();

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination queue = new AMQAnyDestination("ADDR:message_queue; {create: always}");
        MessageConsumer consumer = session.createConsumer(queue);

        System.out.println("Receiving as ListMessage");
        ListMessage m = (ListMessage) consumer.receive();
        System.out.println(m);
        System.out.println("==========================================");
        System.out.println("Printing list contents:");
        Iterator i = m.iterator();
        while (i.hasNext())
            System.out.println(i.next());

        connection.close();
    }
}

Continue reading QPID通讯代码02

QPID通讯代码01

  • TextMessage
  • ListMessage
  • MapMesage
  • StreamMessage

1、MqConsumerText.java

package com.neohope.qpid.test;

import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;

public class MqConsumerText {

    public static void main(String[] args)
    {
        try
        {
            Properties properties = new Properties();
            properties.setProperty("java.naming.factory.initial", "org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
            properties.setProperty("connectionfactory.qpidConnectionfactory","amqp://guest:guest@clientid/?brokerlist='tcp://localhost:5672'");
            properties.setProperty("destination.topicExchange","amq.topic");

            Context context = new InitialContext(properties);

            ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("qpidConnectionfactory");
            Connection connection = connectionFactory.createConnection();
            connection.start();

            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            Destination destination = (Destination) context.lookup("topicExchange");

            MessageConsumer messageConsumer = session.createConsumer(destination);
            TextMessage message = (TextMessage)messageConsumer.receive();
            System.out.println(message.getText());

            connection.close();
            context.close();
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }
}

Continue reading QPID通讯代码01