一、后台配置
- service层
net.carefx.da.server.service.BI中增加查询随访的接口(IFollowUpService)和实现类(FollowUpServiceImpl)
//接口
public interface IFollowUpService {
public abstract String querymetaSetCode(@Param("moduleName")String moduleName);
public abstract int querySourceId(@Param("params")Map<String, String> params);
}
//实现类
public class FollowUpServiceImpl implements IFollowUpService{
private static final Logger logger = new Logger (FollowUpServiceImpl.class.getName ());
private DaFollowUpMapper m_daFollowUpMapper;
public DaFollowUpMapper getDaFollowUpMapper() {
return m_daFollowUpMapper;
}
public void setDaFollowUpMapper(DaFollowUpMapper m_daFollowUpMapper) {
this.m_daFollowUpMapper = m_daFollowUpMapper;
}
@Override
public String querymetaSetCode(String moduleName) {
if(moduleName != null){
String metaSetCode = m_daFollowUpMapper.querymetaSetCode(moduleName);
return metaSetCode;
}
return null;
}
@Override
public int querySourceId(Map<String, String> params) {
if(params != null){
return m_daFollowUpMapper.querySourceId(params);
}
return 0;
}
}
2.dao层
net.carefx.da.server.dao增加接口DaFollowUpMapper及sql映射文件
//DaFollowUpMapper接口
public abstract interface DaFollowUpMapper {
public abstract String querymetaSetCode(@Param("moduleName")String moduleName);
public abstract Integer querySourceId(@Param("params")Map<String, String> params);
}
sql映射文件(参考HypertensionVisitMapping.sqlmap.xml,高血压随访),nameSpace对应dao接口
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD iBatis Mapper 3.0 //EN" "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<!-- define mapping from database to class -->
<mapper namespace="net.carefx.da.server.dao.DaFollowUpMapper">
<!-- <resultMap id="HypertensionVisitResultMap" type="net.carefx.da.server.model.HypertensionVisit" ></resultMap> -->
<select id="querymetaSetCode" resultType="String" parameterType="String">
select t.cdatype from cda_header t where t.modulename like '%'||#{moduleName}||'%'
</select>
<select id="querySourceId" resultType="Integer" parameterType="String">
<!-- 高血压随访 -->
<if test="params.tableName == 'T_MDC_Hypertension_Visit'">
select t.pid from T_MDC_Hypertension_Visit t
<where>
1 =1
<if test="params.head_idcard != null and head_idcard !=''">
and t.head_idcard = #{params.head_idcard}
</if>
<if test="params.sfsj != null and params.sfsj !=''">
and to_char(t.visitdate, 'yyyy-MM-dd') = #{params.sfsj}
</if>
</where>
</if>
</select>
</mapper>
3.配置文件---main.resource.pms(该查询用的是BSC_HIE表空间,对应pms配置文件,BSC_HIA对应platform映射文件),该后台代码没有配置service,将service放置到前台配置了
pms-config.mybatis.xml文件引入FollowUpMapping.sqlmap.xml(sql查询文件)
pms-db.spring.xml引入dao接口配置,注意bean的id大小写
单元测试后台代码
@ContextConfiguration("classpath:pms/pms-db.spring.xml")
public class FollowUpTest extends AbstractJUnit38SpringContextTests {
@Autowired
private DaFollowUpMapper m_DaFollowUpMapper;
public void test_getFollowUp() {
/*String moduleName = "高血压随访";
String metaSetCode = m_DaFollowUpMapper.querymetaSetCode(moduleName);
System.out.println("高血压随访编码"+metaSetCode);*/
Map<String, String> map = new HashMap<String, String>();
map.put("tableName", "T_MDC_Psychosis_Visit");
map.put("head_idcard", "422727196903214698");
map.put("sfsj","2014-10-26");
Integer sourceId = m_DaFollowUpMapper.querySourceId(map);
if(sourceId == null){
sourceId = 0;
}
System.out.println("sorceId:"+sourceId);
}
}
二、前台配置(flex),本次是增加点击事件跳转到PHR健康档案浏览器
1.UserManager.mxml添加点击事件,调用后台方法,并增加方法处理返回结果
2.不要忘记/DA/WebRoot/WEB-INF/flex的remoting-config.xml文件,/DA/dist/WEB-INF/flex中添加service的spring映射,否则后台方法无法调用
destination与上图一致
3.pms-service-local.spring.xml映射service,此处service的id与上图source一致,property对应后台set,get方法的属性名,此处导入dao层接口
4.pms-db.spring.xml配置dao层接口,此处id与service一致,注意id大小写
5.pms-config.mybatis.xml中引入sql映射语句
三、添加数据源
添加数据源需要修改配置文件
在DA/WebRoot/WEB-INF/web.xml文件中引入新增的配置文件
<param-value>
classpath:framework-common.spring.xml,
classpath:pms/pms-db.spring.xml,
classpath:pms/pms-manager.spring.xml,
classpath:pms/pms-manager-translator.spring.xml,
classpath:pms/pms-service-local.spring.xml,
classpath:framework-cache.spring.xml,
classpath:platform/platform-db.spring.xml,
classpath:platform/platform-manager.spring.xml,
classpath:platform/ehr-db.spring.xml
</param-value>
需要在db.Spring.xml文件中引入config配置文件
<bean id="ehrSqlSessionFactory" class="net.carefx.framework.mybatis.SqlSessionFactoryBean">
<property name="dataSource" ref="ehrDataSource" />
<property name="configLocation" value="classpath:platform/ehr-config.mybatis.xml" />
<property name="dialectManager" ref="dialectManager" />
</bean>