hapi-fhir - Hapi Fhir 查询与 AND / OR 与地图
问题描述
使用 Hapi Fhir,我尝试编写一个查询以使用地图传递 where 条件,如下所示:
Map<String, List<IQueryParameterType>> hmParameter = criteria.getMapForWhere();
Bundle bundle = fhirClientR4Configuration.clientFhihrR4().search().forResource(ServiceRequest.class)
.where(hmParameter).returnBundle(Bundle.class).execute();
我的条件对象有一个方法getMapForWhere()
,我用包装器前端对象中的信息填充此映射,如下所示:
public Map<String, List<IQueryParameterType>> getMapForWhere() {
Map<String, List<IQueryParameterType>> hmOut = new HashMap<String, List<IQueryParameterType>>();
// Adding STATUS
if (this.status != null && !this.status.equals("")) {
StringParam sp = new StringParam();
sp.setValue(this.status);
List<IQueryParameterType> lst = new ArrayList<IQueryParameterType>();
lst.add(sp);
hmOut.put(ServiceRequest.SP_STATUS, lst);
}
// Adding INTENT
if (this.intent != null && !this.intent.equals("")) {
StringParam sp = new StringParam();
sp.setValue(this.intent);
List<IQueryParameterType> lst = new ArrayList<IQueryParameterType>();
lst.add(sp);
hmOut.put(ServiceRequest.SP_INTENT, lst);
}
return hmOut;
}
当我想用所有 AND 编写查询时,此代码工作正常。
但是如果我想添加另一个条件如下:
List<IQueryParameterOr> lstOr = new ArrayList<IQueryParameterOr>();
StringOrListParam lstServices = new StringOrListParam();
StringParam sp = new StringParam();
StringParam sg = new StringParam();
sp.setValue(MEDICAL_SERVICE_PAI);
sg.setValue(SOCIAL_SERVICE_PAI);
lstServices.addOr(sp);
lstServices.addOr(sg);
lstOr.add(lstServices);
hmOut.put(ServiceRequest.SP_CATEGORY, lstOr);
显然 hmOut 出错了,因为该映射的定义不同。但我不知道如何转换IParameterOr
为IParameterType
.
解决方案
推荐阅读
- php - Wordpress 操作计划程序未运行
- rest - 在 Dynatrace 中分析性能
- flutter - 如何从我给定了一些值的类构造函数中访问数据。到另一个变量
- django - Django View 导致 Psycopg2 光标存在/不存在错误
- python - Django 应用程序在部署到 Heroku 时崩溃 - 错误 H10
- java - 在 SQL Server 中将数据写入具有关系的表
- regex - 如何使用 Regex 和 JavaScript 替换字符串中包含下划线的所有单词?
- c# - 如何解决自定义DataGrid中的控件命名错误?
- laravel - Testing Laravel lighthouse mutations with database
- php - 使用 $wpdb get_result 加载更多帖子