我不熟悉 JSON 和 FHIR。 我向返回药物分配对象的 FHIR 服务器发出请求。这是包含在字符串中的请求结果
{"resourceType":"Bundle","type":"document","entry":[{"fullUrl":"/medicationdispense/c7c7e373-02c0-4ffc-9894-eee0de249a25/1000424","resource":{"resourceType":"MedicationDispense","id":"1","extension":[{"url":"uri:domedic:pharmacy:uuid","valueString":"dc28f64f-aef4-4d64-8cb5-b5a2020fdcdc"},{"url":"uri:domedic:prescription:renewals:left","valueInteger":24},{"url":"uri:domedic:medication:isoob","valueBoolean":true}],"status":"on-hold","category":{"coding":[{"system":"http://terminology.hl7.org/CodeSystem/medicationrequest-category","code":"community"}],"text":"Includes requests for medications to be administered or consumed by the patient in their home (this would include long term care or nursing homes, hospices, etc.)"},"medicationCodeableConcept":{"extension":[{"url":"uri:domedic:medication:name","valueString":"SANDOZ FENTANYL"},{"url":"uri:domedic:medication:strength","valueString":"50 MCG-H"},{"url":"uri:domedic:medication:form","valueString":"TIMBRE"},{"url":"http://hl7.org/fhir/NamingSystem/ca-hc-din","valueString":"02327147"}],"coding":[{"system":"http://hl7.org/fhir/NamingSystem/ca-hc-din","code":"02327147","display":"SANDOZ FENTANYL 50 MCG-H"}],"text":"SANDOZ FENTANYL 50 MCG-H"},"subject":{"reference":"patient/c7c7e373-02c0-4ffc-9894-eee0de249a25","identifier":{"use":"official","system":"uri:domedic:patient:uuid","value":"c7c7e373-02c0-4ffc-9894-eee0de249a25"}},"authorizingPrescription":[{"reference":"medicationrequest/c7c7e373-02c0-4ffc-9894-eee0de249a25/1000424","identifier":{"use":"usual","system":"uri:domedic:medicationrequest:number","value":"1000424"}}],"quantity":{"value":2.0000},"whenPrepared":"2021-10-29T00:00:00+00:00","dosageInstruction":[{"extension":[{"url":"uri:domedic:dosage:discriminator","valueInteger":2},{"url":"uri:domedic:dosage:id","valueInteger":12042}],"sequence":1,"text":"1ERE RX EN DATE DU JOUR PUIS LES 2 AUTRES SERONT DES REN. POSTDATES. CESSATION FUTURE SUIVRA","timing":{"event":["2021-10-29T08:00:00+00:00","2021-10-29T21:00:00+00:00"],"repeat":{"boundsPeriod":{"start":"2021-10-29T00:00:00+00:00"},"period":3.0,"periodUnit":"d"}},"doseAndRate":[{"doseQuantity":{"value":1.0000}}]},{"extension":[{"url":"uri:domedic:dosage:discriminator","valueInteger":2},{"url":"uri:domedic:dosage:id","valueInteger":12042}],"sequence":2,"text":"1ERE RX EN DATE DU JOUR PUIS LES 2 AUTRES SERONT DES REN. POSTDATES. CESSATION FUTURE SUIVRA","timing":{"event":["2021-10-30T08:00:00+00:00","2021-10-30T21:00:00+00:00","2021-10-31T08:00:00+00:00","2021-10-31T21:00:00+00:00"],"repeat":{"boundsPeriod":{"start":"2021-10-29T00:00:00+00:00"},"period":3.0,"periodUnit":"d"}},"doseAndRate":[{"doseQuantity":{"value":0.0000}}]}]}}]}
我需要将其“转换”为 HL7.FHIR.Model.MedicationDispense 类型的对象,但我找不到该怎么做。
有人可以帮我吗? 感谢您的时间和帮助
我在这里写了一篇关于如何构建 util 方法以从 FHIR 包中提取数据的文章: https://toreaurstad.blogspot.com/2022/06/making-use-of-extension-methods-to.html
你说你使用HL7.Fhir,所以检查你是否有这些包(版本可能因你的需要而异)
<PackageReference Include="Hl7.Fhir.R4" Version="4.0.0" />
<PackageReference Include="Hl7.Fhir.Serialization" Version="4.0.0" />
<PackageReference Include="Hl7.Fhir.Support" Version="4.0.0" />
<PackageReference Include="Hl7.Fhir.Support.Poco" Version="4.0.0" />
要提取药物声明剂量,这是 FHIR 中的一个概念,您可以:
在将成为您的领域模型的类中创建一个具有逻辑的包装器属性。这只是一个包含您的数据的类,它将从 Json 包内的 datda 构建。
public int? Fentanyl
{
get
{
var dosageQuantity = _bundle.SearchMedicationStatements("http://someacme.no/fhir/MedicationStatement/")
?.GetMedicationDosageQuantity("Fentanyl", "ug");
//value is already a decimal? data type and must be parsed
if (int.TryParse(dosageQuantity?.Value?.ToString(), out var dosageQuantityParsed))
{
return dosageQuantityParsed;
}
return null;
}
}
public static List<MedicationStatement>? SearchMedicationStatements(this Bundle bundle, string resourcePath)
{
var medicationStatementsMatching = bundle?.Entry?.Where(e => e.FullUrl.StartsWith(resourcePath))?.Select(m => m.Resource)?.OfType<MedicationStatement>()?.ToList();
return medicationStatementsMatching;
}
public static Dosage? GetMedicationDosageDosage(this List<MedicationStatement> medicationStatements, string displayText)
{
//find dosage with given display text
foreach (var medicationStatement in medicationStatements)
{
var medicationStatementMedication = medicationStatement?.Medication as CodeableConcept;
if (medicationStatementMedication == null)
{
continue;
}
var medicationCoding = medicationStatementMedication?.Coding?.FirstOrDefault(med => med.Display?.Equals(displayText, StringComparison.InvariantCultureIgnoreCase) == true);
if (medicationCoding != null)
{
var quantity = medicationStatement?.Dosage?.FirstOrDefault();
return quantity;
}
}
return null;
}
当然,这不仅仅是您的领域模型。您必须将 Bundle 类型的包传递到此域模型中,例如通过域模型的构造函数。
像这样的东西:
var bundle = new FhirJsonParser().Parse(await result.Content.ReadAsStringAsync());
我建议您使用以下方法处理您的 FHIR 映射: