void SfmInitPatient() { if (p == null) { return; } p.Id = Guid.NewGuid().ToString(); if (p.Meta == null) { p.Meta = new Meta(); } p.Meta.VersionId = "1"; p.Meta.LastUpdatedElement = Instant.Now(); p.Meta.Profile = new List <string>() { ProfileSfmPatientURL }; // Wait with this for now! // Add extension for Citizenship //Extension citizenship = new Extension(ExtCitizenURL, ) //p.Extension.Add(citizenship); p.Active = true; p.Gender = AdministrativeGender.Male; }
public CapabilityStatement GetConformance(ModelBaseInputs request, SummaryType summary) { CapabilityStatement con = new CapabilityStatement { Url = request.BaseUri + "metadata", Description = new Markdown("CDR based FHIR server"), DateElement = new Hl7.Fhir.Model.FhirDateTime("2017-04-30"), Version = "1.0.0.0", Name = "CDR FHIR API", Experimental = true, Status = PublicationStatus.Active, FhirVersion = Hl7.Fhir.Model.ModelInfo.Version, AcceptUnknown = CapabilityStatement.UnknownContentCode.Extensions, Format = new string[] { "xml", "json" }, Kind = CapabilityStatement.CapabilityStatementKind.Instance, Meta = new Meta() }; con.Meta.LastUpdatedElement = Instant.Now(); con.Rest = new List <CapabilityStatement.RestComponent>() { new CapabilityStatement.RestComponent { Mode = CapabilityStatement.RestfulCapabilityMode.Server, Resource = new List <CapabilityStatement.ResourceComponent>(), Operation = new List <CapabilityStatement.OperationComponent>(), Security = new CapabilityStatement.SecurityComponent { Extension = new List <Extension>() { new Extension() { Url = "http://fhir-registry.smarthealthit.org/StructureDefinition/oauth-uris", Extension = new List <Extension>() { new Extension { Url = "token", Value = new FhirString("https://teams-fhir-auth.dapasoft.com/connect/token") }, new Extension { Url = "authorize", Value = new FhirString("https://teams-fhir-auth.dapasoft.com/connect/authorize") } } } } } } }; //foreach (var model in ModelFactory.GetAllModels(GetInputs(buri))) //{ // con.Rest[0].Resource.Add(model.GetRestResourceComponent()); //} return(con); }
public static DocumentReference DocumentToDocumentReference(Composition composition, Bundle bundle, Binary bin, Uri binLocation) { var reference = new DocumentReference(); reference.MasterIdentifier = new Identifier(Identifier.SYSTMEM_URI, bundle.Id.ToString()); reference.Identifier = composition.Identifier != null ? new List <Identifier>() { composition.Identifier } : null; reference.Subject = composition.Subject; reference.Type = composition.Type; reference.Class = composition.Class; reference.Author = new List <ResourceReference>(composition.Author); reference.Custodian = composition.Custodian; reference.Authenticator = composition.Attester != null?composition.Attester.Where(att => att.Mode.Any(am => am == Composition.CompositionAttestationMode.Professional || am == Composition.CompositionAttestationMode.Legal) && att.Party != null).Select(att => att.Party).Last() : null; reference.CreatedElement = composition.Date != null ? new FhirDateTime(composition.Date) : null; reference.IndexedElement = Instant.Now(); reference.Status = DocumentReference.DocumentReferenceStatus.Current; reference.DocStatus = composition.Status != null ? new CodeableConcept { Coding = new List <Coding>() { new Coding("http://hl7.org/fhir/composition-status", composition.Status.ToString()) } } : null; // todo: Use proper Enumerator conversion for composition.Status reference.Description = composition.Title; reference.Confidentiality = composition.Confidentiality != null ? new List <CodeableConcept>() { new CodeableConcept() { Coding = new List <Coding>() { composition.Confidentiality } } } : null; reference.PrimaryLanguage = composition.Language; reference.MimeType = bin.ContentType; reference.Format = new List <string>(bundle.Tags.FilterOnFhirSchemes().Where(t => t.Scheme != Tag.FHIRTAGSCHEME_SECURITY).Select(tg => tg.Term)); reference.Size = bin.Content.Length; reference.Hash = calculateSHA1(bin.Content); reference.Location = binLocation.ToString(); if (composition.Event != null) { reference.Context = new DocumentReference.DocumentReferenceContextComponent(); reference.Context.Event = composition.Event.Code != null ? new List <CodeableConcept>(composition.Event.Code) : null; reference.Context.Period = composition.Event.Period != null ? composition.Event.Period : null; } return(reference); }
public Task <CapabilityStatement> GetConformance(ModelBaseInputs request, SummaryType summary) { Hl7.Fhir.Model.CapabilityStatement con = new Hl7.Fhir.Model.CapabilityStatement(); con.Url = request.BaseUri + "metadata"; con.Description = new Markdown("Demonstration Directory based FHIR server"); con.DateElement = new Hl7.Fhir.Model.FhirDateTime("2017-04-30"); con.Version = "1.0.0.0"; con.Name = ""; con.Experimental = true; con.Status = PublicationStatus.Active; con.FhirVersion = Hl7.Fhir.Model.ModelInfo.Version; con.AcceptUnknown = CapabilityStatement.UnknownContentCode.Extensions; con.Format = new string[] { "xml", "json" }; con.Kind = CapabilityStatement.CapabilityStatementKind.Instance; con.Meta = new Meta(); con.Meta.LastUpdatedElement = Instant.Now(); con.Rest = new List <Hl7.Fhir.Model.CapabilityStatement.RestComponent> { new Hl7.Fhir.Model.CapabilityStatement.RestComponent() { Operation = new List <Hl7.Fhir.Model.CapabilityStatement.OperationComponent>() } }; con.Rest[0].Mode = CapabilityStatement.RestfulCapabilityMode.Server; con.Rest[0].Resource = new List <Hl7.Fhir.Model.CapabilityStatement.ResourceComponent>(); //foreach (var model in ModelFactory.GetAllModels(GetInputs(buri))) //{ // con.Rest[0].Resource.Add(model.GetRestResourceComponent()); //} foreach (var member in Members()) { try { // create a connection with the supported format type FhirClient server = new FhirClient(member.Url); member.PrepareFhirClientSecurity(server); System.Diagnostics.Trace.WriteLine($"Retrieving CapabilityStatement {member.Url} {member.Name}"); server.PreferCompressedResponses = true; server.PreferredFormat = member.Format; CapabilityStatement csMember = server.CapabilityStatement(); if (con.Rest[0].Resource.Count == 0) { // just clone all the resources from this one! // a great start foreach (var item in csMember.Rest?.FirstOrDefault()?.Resource) { item.AddExtension("http://example.org/Federation-member-name", new FhirString(member.Name)); con.Rest[0].Resource.Add(item); // remove the non supported actions item.ConditionalCreate = null; item.ConditionalUpdate = null; item.ConditionalDelete = null; item.UpdateCreate = null; if (item.Type != ResourceType.Endpoint) { item.Interaction.RemoveAll(i => i.Code == CapabilityStatement.TypeRestfulInteraction.Create || i.Code == CapabilityStatement.TypeRestfulInteraction.Update || i.Code == CapabilityStatement.TypeRestfulInteraction.Delete ); } } } else { // Tag all these with others foreach (var item in con.Rest?.FirstOrDefault()?.Resource) { if (csMember.Rest[0].Resource.Where(c => c.Type == item.Type).Any()) { item.AddExtension("http://example.org/Federation-member-name", new FhirString(member.Name)); } } } } catch (FhirOperationException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); //if (ex.Outcome != null) // result.Entry.Add(new Bundle.EntryComponent() // { // Search = new Bundle.SearchComponent() { Mode = Bundle.SearchEntryMode.Outcome }, // Resource = ex.Outcome // }); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); //// some other weirdness went on //OperationOutcome oe = new OperationOutcome(); //oe.Issue.Add(new OperationOutcome.IssueComponent() //{ // Severity = OperationOutcome.IssueSeverity.Error, // Code = OperationOutcome.IssueType.Exception, // Diagnostics = ex.Message //}); //result.Entry.Add(new Bundle.EntryComponent() //{ // Search = new Bundle.SearchComponent() { Mode = Bundle.SearchEntryMode.Outcome }, // Resource = oe //}); } } return(System.Threading.Tasks.Task.FromResult(con)); }