我正在尝试使用以下 API Url 在 EPIC 沙盒中创建患者 https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/Patient
我正在使用 firely .Net Sdk 进行 EPIC FHIR API 集成。 在 Postman 中,我可以使用沙盒环境本身的以下示例有效负载创建患者。
{
"resourceType": "Patient",
"identifier": [
{
"use": "usual",
"system": "urn:oid:2.16.840.1.113883.4.1",
"value": "000-00-0000"
}
],
"name": [
{
"use": "usual",
"family": "family",
"given": [
"firstName",
"lastName"
]
}
],
"gender": "male",
"birthDate": "2000-01-01"
}
但是 Firely SDK Patient 类会生成以下有效负载:
{
"identifier": [
{
"system": {
"value": "urn:oid:2.16.840.1.113883.4.1"
},
"value": {
"value": "000-00-0000"
}
}
],
"name": [
{
"family": {
"value": "family"
},
"given": [
{
"value": "firstName"
},
{
"value": "lastName"
}
]
}
],
"gender": {
"value": "male"
},
"birthDate": {
"value": "2000-10-10"
}
}
请找到下面的代码(忽略硬编码)我用来创建患者
public Patient CreatePatient()
{
Patient newPatient = new Patient();
// Add identifier
newPatient.Identifier.Add(new Identifier
{
Use = Identifier.IdentifierUse.Usual,
System = "urn:oid:2.16.840.1.113883.4.1",
Value = "000-00-0000"
});
// Add name
newPatient.Name.Add(new HumanName
{
Use = HumanName.NameUse.Usual,
Family = "family",
Given = new string[] { "firstName", "lastName" }
});
// Set gender
newPatient.Gender = AdministrativeGender.Male;
// Set birth date
newPatient.BirthDate = "2000-10-10";
// Send FHIR request to create patient on the server
var response = _fhirService.Execute(client => client.Create(newPatient));
if (response is NewPatient patient)
{
return patient;
}
else
{
throw new Exception("Failed to create patient");
}
}
为了解决问题,我也尝试了以下代码
// Serialize the Patient instance to JSON
var serializer = new FhirJsonSerializer();
string json = serializer.SerializeToString(newPatient);
尽管如此,我仍无法创建患者,因为它给出了以下错误:
<OperationOutcome xmlns="http://hl7.org/fhir">
<issue>
<severity value="fatal" />
<code value="structure" />
<diagnostics value="Failed to parse; structural issues in the content." />
<expression value="$this" />
</issue>
请参阅https://github.com/FirelyTeam/firely-net-sdk/issues/2657的讨论,我们试图深入了解这一点。
Firely SDK 序列化得很好,其中的 FhirClient 也可以正常工作。导致问题的主要嫌疑是自定义 FhirService 中的 Execute 方法,该方法不是 SDK 的一部分。