private static string GetOrCreateStructureDefinition(string structureDefinitionName) { var sdSearchParams = new SearchParams(); sdSearchParams.Add("name", structureDefinitionName); var sd = FhirClient.Search <Hl7.Fhir.Model.StructureDefinition>(sdSearchParams); var sdReference = sd .With(x => x.Entry) .With(x => x.FirstOrDefault()) .With(x => FhirHelper.CreateReference(x.Resource)); if (sdReference == null) { var structureDefinition = new Hl7.Fhir.Model.StructureDefinition { Name = structureDefinitionName }; var createdSd = FhirClient.Create(structureDefinition); return(FhirHelper.CreateReference(createdSd).Reference); } else { return(sdReference.Reference); } }
public static Order GetOrder(Patient patient, Practitioner orderPractitioner, Organization orderOrganization, Resource diagnosticOrder) { var order = new Order { Identifier = new List <Identifier> { new Identifier(Systems.ORGANIZATIONS, GetCodeBySystem(Systems.ORGANIZATIONS)) { Assigner = FhirHelper.CreateReference(orderOrganization) }, }, Date = DateTime.Today.ToString(CultureInfo.CurrentCulture), When = new Order.OrderWhenComponent { Code = new CodeableConcept { Coding = new List <Coding> { new Coding(Systems.PRIORIRY, GetCodeBySystem(Systems.PRIORIRY)) } } }, Subject = FhirHelper.CreateReference(patient), Source = FhirHelper.CreateReference(orderPractitioner), Target = FhirHelper.CreateReference(orderOrganization), Detail = new List <ResourceReference> { FhirHelper.CreateBundleReference(diagnosticOrder) }, }; return(order); }
public static Encounter CreateEncounter(Patient patient, Condition condition, Organization orderOrganization) { var encounter = new Encounter { Identifier = new List <Identifier> { new Identifier(Systems.ORGANIZATIONS, GetCodeBySystem(Systems.ORGANIZATIONS)) { Assigner = FhirHelper.CreateReference(orderOrganization) } }, Type = new List <CodeableConcept> { new CodeableConcept(Systems.ENCOUNTER_TYPE, GetCodeBySystem(Systems.ENCOUNTER_TYPE)) }, Class = Encounter.EncounterClass.Outpatient, Status = Encounter.EncounterState.Arrived, Patient = FhirHelper.CreateReference(patient), Indication = new List <ResourceReference> { new ResourceReference { Reference = condition.Id } }, Reason = new List <CodeableConcept> { new CodeableConcept(Systems.REASON_CODE, GetCodeBySystem(Systems.REASON_CODE)) }, ServiceProvider = FhirHelper.CreateReference(orderOrganization), }; return(FhirClient.Create(encounter)); }
public static Specimen GetSpecimen(Patient patient, Organization orderOrganization) { var specimen = new Specimen { Id = Guid.NewGuid().ToString(), Collection = new Specimen.SpecimenCollectionComponent { Collected = new Date(DateTime.Today.ToString(CultureInfo.CurrentCulture)) }, Type = new CodeableConcept(Systems.BIOMATERIAL, Guid.NewGuid().ToString()), Container = new List <Specimen.SpecimenContainerComponent> { new Specimen.SpecimenContainerComponent { Identifier = new List <Identifier> { new Identifier(Systems.ORGANIZATIONS, GetCodeBySystem(Systems.ORGANIZATIONS)) { Assigner = FhirHelper.CreateReference(orderOrganization) } }, Type = new CodeableConcept(Systems.CONTAINER_TYPE, Guid.NewGuid().ToString()) } }, Subject = FhirHelper.CreateReference(patient) }; return(specimen); }
public static Resource GetOrderResponse(Order order, DiagnosticReport[] reports) { return(new OrderResponse { Identifier = new List <Identifier> { new Identifier(Systems.ORGANIZATIONS, GetCodeBySystem(Systems.ORGANIZATIONS)) }, Request = FhirHelper.CreateReference(order), Date = DateTime.Now.ToString(CultureInfo.CurrentCulture), Who = order.Source, OrderStatus_ = OrderResponse.OrderStatus.Completed, Description = "Комментарий к заказу", Fulfillment = reports.Select(FhirHelper.CreateBundleReference).ToList() }); }
public static Practitioner CreatePractitioner(Organization orderOrganization) { var practitioner = new Practitioner { Identifier = new List <Identifier> { new Identifier(Systems.ORGANIZATIONS, GetCodeBySystem(Systems.ORGANIZATIONS)) { Assigner = FhirHelper.CreateReference(orderOrganization) } }, Name = new HumanName { Family = new List <string> { "Врач" }, Given = new List <string> { "Врач" } }, PractitionerRole = new List <Practitioner.PractitionerPractitionerRoleComponent> { new Practitioner.PractitionerPractitionerRoleComponent { ManagingOrganization = FhirHelper.CreateReference(orderOrganization), Role = new CodeableConcept(Systems.PRACTITIONER_ROLE, GetCodeBySystem(Systems.PRACTITIONER_ROLE)), Specialty = new List <CodeableConcept> { new CodeableConcept(Systems.PRACTITIONER_SPECIALITY, GetCodeBySystem(Systems.PRACTITIONER_SPECIALITY)) } } } }; try { return(FhirClient.Create(practitioner)); } catch (FhirOperationException ex) { var st = ex.StackTrace; foreach (var operationOutcomeIssueComponent in ex.Outcome.Issue) { } } return(null); }
public static Condition GetCondition(Patient patient) { var condition = new Condition { Id = Guid.NewGuid().ToString(), Identifier = new List <Identifier> { new Identifier(Systems.MES, GetCodeBySystem(Systems.MES)) }, Patient = FhirHelper.CreateReference(patient), DateAsserted = DateTime.Now.ToString(CultureInfo.CurrentCulture), Code = new CodeableConcept(Systems.MKB10, GetCodeBySystem(Systems.MKB10)), Category = new CodeableConcept(Systems.CONDITION_CATEGORY, GetCodeBySystem(Systems.CONDITION_CATEGORY)), ClinicalStatus = Condition.ConditionClinicalStatus.Confirmed, Notes = "Condition notes", }; return(condition); }
public static Order GetOrderByDiagnosticOrder(DiagnosticOrder diagnosticOrder) { var result = FhirClient.Search <Order>(new[] { string.Format("detail={0}", FhirHelper.CreateReference(diagnosticOrder).Reference) }); Assert.That(result, Is.Not.Null); Assert.That(result.Entry, Is.Not.Null); Assert.That(result.Entry.Count, Is.GreaterThanOrEqualTo(1)); return((Order)result.Entry.First().Resource); }
public static DiagnosticOrder SearchDiagnosticOrderBySpecimen(Specimen specimen) { var result = FhirClient.Search <DiagnosticOrder>(new[] { string.Format("specimen={0}", FhirHelper.CreateReference(specimen).Reference) }); Assert.That(result, Is.Not.Null); Assert.That(result.Entry, Is.Not.Null); Assert.That(result.Entry.Count, Is.GreaterThanOrEqualTo(1)); return((DiagnosticOrder)result.Entry.First().Resource); }
public static DiagnosticOrder GetDiagnosticOrder(Patient patient, Practitioner diagnosticOrderPractitioner, Encounter encounter, Observation observation, Observation observation1, Specimen specimen, Specimen specimen1) { var diagnosticOrder = new DiagnosticOrder { Id = Guid.NewGuid().ToString(), Subject = FhirHelper.CreateReference(patient), Orderer = FhirHelper.CreateReference(diagnosticOrderPractitioner), Encounter = FhirHelper.CreateReference(encounter), SupportingInformation = new List <ResourceReference> { FhirHelper.CreateBundleReference(observation), FhirHelper.CreateBundleReference(observation1), }, Specimen = new List <ResourceReference> { FhirHelper.CreateBundleReference(specimen), FhirHelper.CreateBundleReference(specimen1) }, Status = DiagnosticOrder.DiagnosticOrderStatus.Requested, Item = new List <DiagnosticOrder.DiagnosticOrderItemComponent> { new DiagnosticOrder.DiagnosticOrderItemComponent { Code = new CodeableConcept { Text = "Услуга 1", Coding = new List <Coding> { new Coding(Systems.DIAGNOSTIC_ORDER_CODE, Systems.DIAGNOSTIC_ORDER_CODE), }, Extension = new List <Extension> { new Extension(Systems.DIAGNOSTIC_ORDER_FINANCIAL_EXTENSION, new CodeableConcept(Systems.FINANCIAL, GetCodeBySystem(Systems.FINANCIAL))), new Extension(Systems.DIAGNOSTIC_ORDER_INSURANCE_EXTENSION, new ResourceReference { Reference = Guid.NewGuid().ToString() }) } }, }, new DiagnosticOrder.DiagnosticOrderItemComponent { Code = new CodeableConcept { Text = "Услуга 2", Coding = new List <Coding> { new Coding(Systems.DIAGNOSTIC_ORDER_CODE, Guid.NewGuid().ToString()), }, Extension = new List <Extension> { new Extension(Systems.DIAGNOSTIC_ORDER_FINANCIAL_EXTENSION, new CodeableConcept(Systems.FINANCIAL, GetCodeBySystem(Systems.FINANCIAL))), new Extension(Systems.DIAGNOSTIC_ORDER_INSURANCE_EXTENSION, new ResourceReference { Reference = Guid.NewGuid().ToString() }) } }, } } }; return(diagnosticOrder); }