【发布时间】:2026-01-08 02:20:02
【问题描述】:
我设置了一个基本的 springboot 应用程序,它将在 get 调用时返回字符串值,但是当我尝试返回一个模拟 Patient 对象时,我得到一个奇怪的错误
我的代码:
@RequestMapping("/test2")
Patient test2(){
Patient patient = new Patient();
patient.setId("1");
patient.addName().setFamily("Bar").addGiven("Foo").addGiven("M");
patient.addAddress().addLine("Address Line 1");
patient.addAddress().setCity("City Name");
patient.addAddress().setCountry("Country Name");
patient.addTelecom().setValue("555-555-1111");
return patient;
}
错误似乎是创建的json是递归的并且永无止境。响应的 sn-p 是:
{"formatCommentsPre":[],"formatCommentsPost":[],"id":"1","meta":{"formatCommentsPre":[],"formatCommentsPost":[],"id":null,"extension":[],"versionId":null,"lastUpdated":null,"profile":[],"security":[],"tag":[],"empty":true,"tagFirstRep":{"formatCommentsPre":[],"formatCommentsPost":[],"id":null,"extension":[],"system":null,"version":null,"code":null,"display":null,"userSelected":false,"empty":true,"displayElement":{"formatCommentsPre":[],"formatCommentsPost":[],"id":null,"extension":[],"valueNotNull":"","primitive":true,"empty":true,"value":null,"valueAsString":null,"idElement":{"formatCommentsPre":[],"formatCommentsPost":[],"id":null,"extension":[],"valueNotNull":"","primitive":true,"empty":true,"value":null,"valueAsString":null,"idElement":{"formatCommentsPre":[],"formatCommentsPost":[],"id":null,"extension":[],"valueNotNull":"","primitive":true,"empty":true,"value":null,"valueAsString":null,"idElement":{"formatCommentsPre":[],"formatCommentsPost":[],"id":null,"extension":[],"valueNotNull":"","primitive":true,"empty":true,"value":null,"valueAsString":null,"idElement":{"formatCommentsPre":[],"formatCommentsPost":[],"id":null,"extension":[],"valueNotNull":"","primitive":true,"empty":true,"value":null,"valueAsString":null,"idElement":{"formatCommentsPre":[],"formatCommentsPost":[],"id":null,"extension":[],"valueNotNull":"","primitive":true,"empty":true,"value":null,"valueAsString":null,"idElement":{"formatCommentsPre":[],"formatCommentsPost":[],"id":null,"extension":[],"valueNotNull":"","primitive":true,"empty":true,"value":null,"valueAsString":null,"idElement":{"formatCommentsPre":[],"formatCommentsPost":[],"id":null,"extension":[],"valueNotNull":"","primitive":true,"empty":true,"value":null,"valueAsString":null,"idElement":{"formatCommentsPre":[],"formatCommentsPost":[],"id":null,"extension":
是否有人知道我做错了什么以及为患者发送 FHIR 响应的正确方法是什么?
【问题讨论】:
标签: java spring-boot rest hl7-fhir hapi-fhir