2017-05-25 4 views
0

私は現在、DSTU2用にhapi-fhir 2.3を使用しています。 hapi-fhirクライアントAPIを使用してRiskAssessmentオブジェクトを作成した場合どのように標準のfhir json形式に変換できますか?hapi-fhir conver fhirオブジェクトからjson文字列

toSting()方法を使用している場合は、次の結果が生成されます。

{ 
"mySubject" : -{ 
"myReference" : -{ 
"myHaveComponentParts" : false, 
"myUnqualifiedId" : 005543907A, 
"myCoercedValue" : 005543907A, 
"myStringValue" : 005543907A 
} 
}, 
"myDate" : -{ 
"myFractionalSeconds" : 575, 
"myPrecision" : SECOND, 
"myTimeZone" : -{ 
"rawOffset" : 28800000, 
"rawOffsetDiff" : 0, 
"checksum" : -305565502, 
"dstSavings" : 0, 
"transitions" : -[ 
-9048018124800000, 
-8918966038528000, 
-3823593062399950, 
-3781140480000000, 
-3722379263999950, 
-3651969024000000, 
2111569920000050, 
2158623129600000, 
2232955699200050, 
2287440691200000, 
2361773260800050, 
2416258252800000, 
2493068083200050, 
2547553075200000, 
2621885644800050, 
2676370636800000, 
2750703206400050, 
2805188198400000, 
8660385792000000 
], 
"offsets" : -[ 
28800000, 
29143000, 
32400000, 
3600000 
], 
"willGMTOffsetChange" : false, 
"ID" : Asia/Shanghai 
}, 
"myTimeZoneZulu" : false, 
"myCoercedValue" : May 25, 2017 9:46:01 AM, 
"myStringValue" : 2017-05-25T09:46:01+08:00 
}, 
"myMethod" : -{ 
"myText" : -{ 
"myCoercedValue" : My risk score engine., 
"myStringValue" : My risk score engine. 
} 
}, 
"myPrediction" : -[ 
-{ 
"myOutcome" : -{ 
"myText" : -{ 
"myCoercedValue" : Remission, 
"myStringValue" : Remission 
} 
}, 
"myRelativeRisk" : -{ 
"myCoercedValue" : 0.6949999928474426, 
"myStringValue" : 0.6949999928474426 
} 
} 
] 
} 

私は何を期待していますがあるにリソースをエンコード」のドキュメントHAPI-FHIRセクションに

{ 
    "resourceType": "RiskAssessment", 
    "id": "prognosis", 
    "text": { 
    "status": "additional", 
    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n  <p>Moderate risk of permanent weakness of the left arm, but otherwise no permanent disability</p>\n </div>" 
    }, 
    "status": "final", 
    "occurrenceDateTime": "2010-11-22", 
    "condition": { 
    "reference": "Condition/stroke", 
    "display": "Ischemic Stroke" 
    }, 
    "prediction": [ 
    { 
     "outcome": { 
     "coding": [ 
      { 
      "system": "http://snomed.info/sct", 
      "code": "249943000:363698007=72098002,260868000=6934004" 
      } 
     ], 
     "text": "permanent weakness of the left arm" 
     }, 
     "qualitativeRisk": { 
     "coding": [ 
      { 
      "system": "http://hl7.org/fhir/risk-probability", 
      "code": "moderate", 
      "display": "moderate likelihood" 
      } 
     ] 
     } 
    } 
    ] 
} 

答えて

0
String riskAssessmentJson = FhirContext.forDstu2().newJsonParser().encodeResourceToString(resource); 
0

ルックのようなもの文字列"。 JSON表現が本当に必要ですか? HAPIクライアントは自動的にオブジェクト(リソース)をJSONに解析してからサーバーに送信し、サーバー側ではオブジェクトとなります。

関連する問題