public void Setup() { // Force load of the DLL var p = FbCharset.Ascii; TestApplicationContext.TestAssembly = typeof(TestRelatedPersonResourceHandler).Assembly; TestApplicationContext.Initialize(TestContext.CurrentContext.TestDirectory); this.m_serviceManager = ApplicationServiceContext.Current.GetService <IServiceManager>(); var testConfiguration = new FhirServiceConfigurationSection { Resources = new List <string> { "Practitioner" } }; using (AuthenticationContext.EnterSystemContext()) { FhirResourceHandlerUtil.Initialize(testConfiguration, this.m_serviceManager); ExtensionUtil.Initialize(testConfiguration); } }
public void Setup() { // Force load of the DLL var p = FbCharset.Ascii; TestApplicationContext.TestAssembly = typeof(TestRelatedPersonResourceHandler).Assembly; TestApplicationContext.Initialize(TestContext.CurrentContext.TestDirectory); this.m_serviceManager = ApplicationServiceContext.Current.GetService <IServiceManager>(); var testConfiguration = new FhirServiceConfigurationSection { Resources = new List <string> { "Patient", "Practitioner", "AdverseEvent", "Location" }, OperationHandlers = new List <TypeReferenceConfiguration>(), ExtensionHandlers = new List <TypeReferenceConfiguration>(), ProfileHandlers = new List <TypeReferenceConfiguration>(), MessageHandlers = new List <TypeReferenceConfiguration> { new TypeReferenceConfiguration(typeof(PractitionerResourceHandler)), new TypeReferenceConfiguration(typeof(AdverseEventResourceHandler)), new TypeReferenceConfiguration(typeof(PatientResourceHandler)), new TypeReferenceConfiguration(typeof(LocationResourceHandler)) } }; using (AuthenticationContext.EnterSystemContext()) { FhirResourceHandlerUtil.Initialize(testConfiguration, this.m_serviceManager); ExtensionUtil.Initialize(testConfiguration); } }
/// <summary> /// Invoke the process message operation /// </summary> public Resource Invoke(Parameters parameters) { // Extract the parameters var contentParameter = parameters.Parameter.Find(o => o.Name == "content")?.Resource as Bundle; var asyncParameter = parameters.Parameter.Find(o => o.Name == "async")?.Value as FhirBoolean; if (contentParameter == null) { this.m_tracer.TraceError("Missing content parameter"); throw new ArgumentNullException(m_localizationService.GetString("error.type.ArgumentNullException")); } else if (asyncParameter?.Value.GetValueOrDefault() == true) { this.m_tracer.TraceError("Asynchronous messaging is not supported by this repository"); throw new InvalidOperationException(m_localizationService.GetString("error.type.NotSupportedException")); } // Message must have a message header var messageHeader = contentParameter.Entry.Find(o => o.Resource.TryDeriveResourceType(out ResourceType rt) && rt == ResourceType.MessageHeader)?.Resource as MessageHeader; if (messageHeader == null) { this.m_tracer.TraceError("Message bundle does not contain a MessageHeader"); throw new ArgumentException(m_localizationService.GetString("error.type.ArgumentNullException")); } // Determine the appropriate action handler if (messageHeader.Event is FhirUri eventUri) { var handler = ExtensionUtil.GetMessageOperationHandler(new Uri(eventUri.Value)); if (handler == null) { this.m_tracer.TraceError($"There is no message handler for event {eventUri}"); throw new NotSupportedException(m_localizationService.GetString("error.type.NotSupportedException")); } var retVal = new Bundle(); // Return for operation retVal.Meta = new Meta() { LastUpdated = DateTimeOffset.Now }; var uuid = Guid.NewGuid(); try { // HACK: The .EndsWith is a total hack - FHIR wants .FullUrl to be absolute, but many senders will send relative references which var opReturn = handler.Invoke(messageHeader, contentParameter.Entry.Where(o => messageHeader.Focus.Any(f => o.FullUrl == f.Reference || $"{o.Resource.TypeName}/{o.Resource.Id}" == f.Reference)).ToArray()); retVal.Entry.Add(new Bundle.EntryComponent() { FullUrl = $"urn:uuid:{uuid}", Resource = new MessageHeader() { Id = uuid.ToString(), Response = new MessageHeader.ResponseComponent() { Code = MessageHeader.ResponseType.Ok, Details = new ResourceReference($"urn:uuid:{opReturn.Id}") } } }); // HACK: Another hack - FullUrl is assumed to be a UUID because I'm not turning an id of XXX and trying to derive a fullUrl for something that is in a // bundle anyways retVal.Entry.Add(new Bundle.EntryComponent() { FullUrl = $"urn:uuid:{opReturn.Id}", Resource = opReturn }); } catch (Exception e) { var outcome = DataTypeConverter.CreateErrorResult(e); outcome.Id = Guid.NewGuid().ToString(); retVal.Entry.Add(new Bundle.EntryComponent() { FullUrl = $"urn:uuid:{uuid}", Resource = new MessageHeader() { Id = uuid.ToString(), Response = new MessageHeader.ResponseComponent() { Code = MessageHeader.ResponseType.FatalError, Details = new ResourceReference($"urn:uuid:{outcome.Id}") } } }); retVal.Entry.Add(new Bundle.EntryComponent() { FullUrl = $"urn:uuid:{outcome.Id}", Resource = outcome }); throw new FhirException((System.Net.HttpStatusCode)FhirErrorEndpointBehavior.ClassifyErrorCode(e), retVal, m_localizationService.GetString("error.type.FhirException"), e); } finally { retVal.Timestamp = DateTime.Now; retVal.Type = Bundle.BundleType.Message; } return(retVal); } else { this.m_tracer.TraceError("Currently message headers with EventCoding are not supported"); throw new InvalidOperationException(m_localizationService.GetString("error.type.NotSupportedException.userMessage")); } }
/// <summary> /// Convert an address to a address set /// </summary> internal AddressSet ConvertAddress(Address address, List <IResultDetail> dtls) { if (address == null) { return(null); } AddressSet retVal = new AddressSet(); if (address.Use != null) // convert use { retVal.Use = HackishCodeMapping.Lookup(HackishCodeMapping.ADDRESS_USE, address.Use); retVal.Use |= ExtensionUtil.ParseADUseExtension(address.Use.Extension, dtls); } if (address.Text != null) // Convert text? this is discarded { dtls.Add(new UnsupportedFhirDatatypePropertyResultDetail(ResultDetailType.Warning, "Text", "Address")); address.Text = null; } foreach (var itm in address.Line) { retVal.Parts.Add(new AddressPart() { AddressValue = itm.Value, PartType = AddressPart.AddressPartType.StreetAddressLine }); } if (address.City != null) { retVal.Parts.Add(new AddressPart() { AddressValue = address.City, PartType = AddressPart.AddressPartType.City }); } if (address.State != null) { retVal.Parts.Add(new AddressPart() { AddressValue = address.State, PartType = AddressPart.AddressPartType.State }); } if (address.Zip != null) { retVal.Parts.Add(new AddressPart() { AddressValue = address.Zip, PartType = AddressPart.AddressPartType.PostalCode }); } if (address.Country != null) { retVal.Parts.Add(new AddressPart() { AddressValue = address.Country, PartType = AddressPart.AddressPartType.Country }); } retVal.Parts.AddRange(ExtensionUtil.ParseADExtension(address.Extension, dtls)); // Period of operation if (address.Period != null) { dtls.Add(new UnsupportedFhirDatatypePropertyResultDetail(ResultDetailType.Warning, "Period", "Address")); address.Period = null; } retVal.Parts.RemoveAll(o => String.IsNullOrEmpty(o.AddressValue)); return(retVal); }
public bool IsBeingSeenByCamera(Camera camera) { return(ExtensionUtil.IsVisibleFrom(objectRenderer, camera)); }
public override SVC.Messaging.FHIR.Resources.ResourceBase ProcessComponent(System.ComponentModel.IComponent component, List <Everest.Connectors.IResultDetail> dtls) { // Create a component HealthcareParticipant ptcpt = component as HealthcareParticipant; if (ptcpt.Classifier != HealthcareParticipant.HealthcareParticipantType.Organization) { ; // Not an organization pass off } // Organization Organization retVal = new Organization(); retVal.Id = ptcpt.Id.ToString(); retVal.VersionId = ptcpt.Id.ToString(); // Other identifiers foreach (var id in ptcpt.AlternateIdentifiers) { retVal.Extension.Add(ExtensionUtil.CreateIdentificationExtension(id)); } if (ptcpt.Type != null) { retVal.Type = base.ConvertCode(ptcpt.Type); } retVal.Name = ptcpt.LegalName.Parts[0].Value; retVal.Active = true; // Address if (ptcpt.PrimaryAddress != null) { retVal.Address = base.ConvertAddressSet(ptcpt.PrimaryAddress); } // Telecoms if (ptcpt.TelecomAddresses != null) { foreach (var tel in ptcpt.TelecomAddresses) { retVal.Telecom.AddRange(base.ConvertTelecom(tel)); } } var contacts = ptcpt.FindAllComponents(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.RepresentitiveOf); foreach (HealthcareParticipant contact in contacts) { ContactEntity ce = new ContactEntity(); // Link var processor = FhirMessageProcessorUtil.GetComponentProcessor(contact.GetType()); var processResult = processor.ProcessComponent(contact, dtls); if (processResult is Practictioner) { var prac = processResult as Practictioner; ce.Name = prac.Name[0]; ce.Address = prac.Address[0]; ce.Gender = prac.Gender; ce.Telecom = prac.Telecom; } if (ce.Name != null) { ce.Name = base.ConvertNameSet(contact.LegalName); } if (contact.TelecomAddresses != null) { foreach (var t in contact.TelecomAddresses) { ce.Telecom.AddRange(base.ConvertTelecom(t)); } } if (contact.PrimaryAddress != null) { ce.Address = base.ConvertAddressSet(contact.PrimaryAddress)[0]; } retVal.ContactEntity.Add(ce); } return(retVal); }
protected override Expression VisitBinary(BinaryExpression node) { _build.Append("("); Visit(node.Left); if (node.Right is ConstantExpression && (node.NodeType == ExpressionType.Equal || node.NodeType == ExpressionType.NotEqual) && (node.Right as ConstantExpression).Value == null) { _operator = node.NodeType == ExpressionType.Equal ? ExtensionUtil.GetOperator(nameof(ExtensionUtil.IsNull)) : ExtensionUtil.GetOperator(nameof(ExtensionUtil.IsNotNull)); _build.AppendFormat(" {0}", _operator); } else { _operator = ExtensionUtil.GetOperator(node.NodeType); _build.AppendFormat(" {0} ", _operator); Visit(node.Right); } _build.Append(")"); return(node); }
/// <summary> /// determines the nuspec file from the project if any /// </summary> /// <param name="activeProject">the project that is to be deployed</param> private void CheckNuSpecFile(Project activeProject, PackageInformation packageInfo) { LoggingManager.Instance.Logger.Debug("check nuspec file started"); //----- this is just the initial location of the nuspec file, there might already be one in the project, at which point its location will be changed packageInfo.NuSpecFileFullName = Path.Combine(Path.GetDirectoryName(activeProject.FullName), string.Format("{0}{1}", packageInfo.NuSpecPackage.Metadata.Id, Resources.NuSpecExtension)); //-----try to find a nuSpec file in the project if it shall be used if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.UseAny) { LoggingManager.Instance.Logger.Debug("nuspec file usage enabled"); ProjectItem nuSpecFile = ExtensionUtil.GetItemByExtension(Resources.NuSpecExtension, activeProject.ProjectItems); if (nuSpecFile != null) { LoggingManager.Instance.Logger.Debug("nuspec file found"); packageInfo.NuSpecFileFullName = ExtensionUtil.GetPropertyValue <string>(nuSpecFile.Properties, Resources.PropertyFullpath, null); //-----parse the existing nuspec file and use all the informat which are needed Xml.NuGet.NuSpec.Package newNuSpecPackage = null; try { newNuSpecPackage = XmlUtil.Deserialize <Xml.NuGet.NuSpec.Package>(packageInfo.NuSpecFileFullName); } catch (Exception ex) { if (ex is ThreadAbortException || ex is ThreadInterruptedException) { throw; } LoggingManager.Instance.Logger.Warn("could not deserialize nuspec package", ex); } //-----use the nuspec file if (newNuSpecPackage != null) { if (newNuSpecPackage.Metadata != null) { if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Id.Use && !string.IsNullOrEmpty(newNuSpecPackage.Metadata.Id)) { LoggingManager.Instance.Logger.Debug("id will be used"); packageInfo.NuSpecPackage.Metadata.Id = newNuSpecPackage.Metadata.Id; } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Version.Use && !string.IsNullOrEmpty(newNuSpecPackage.Metadata.Version)) { LoggingManager.Instance.Logger.Debug("version will be used"); packageInfo.NuSpecPackage.Metadata.Version = newNuSpecPackage.Metadata.Version; } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Title.Use && !string.IsNullOrEmpty(newNuSpecPackage.Metadata.Title)) { LoggingManager.Instance.Logger.Debug("title will be used"); packageInfo.NuSpecPackage.Metadata.Title = newNuSpecPackage.Metadata.Title; } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Authors.Use && !string.IsNullOrEmpty(newNuSpecPackage.Metadata.Authors)) { LoggingManager.Instance.Logger.Debug("authors will be used"); packageInfo.NuSpecPackage.Metadata.Authors = newNuSpecPackage.Metadata.Authors; } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Owners && !string.IsNullOrEmpty(newNuSpecPackage.Metadata.Owners)) { LoggingManager.Instance.Logger.Debug("owners will be used"); packageInfo.NuSpecPackage.Metadata.Owners = newNuSpecPackage.Metadata.Owners; } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Description.Use && !string.IsNullOrEmpty(newNuSpecPackage.Metadata.Description)) { LoggingManager.Instance.Logger.Debug("description will be used"); packageInfo.NuSpecPackage.Metadata.Description = newNuSpecPackage.Metadata.Description; } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.ReleaseNotes && !string.IsNullOrEmpty(newNuSpecPackage.Metadata.ReleaseNotes)) { LoggingManager.Instance.Logger.Debug("release notes will be used"); packageInfo.NuSpecPackage.Metadata.ReleaseNotes = newNuSpecPackage.Metadata.ReleaseNotes; } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Summary && !string.IsNullOrEmpty(newNuSpecPackage.Metadata.Summary)) { packageInfo.NuSpecPackage.Metadata.Summary = newNuSpecPackage.Metadata.Summary; LoggingManager.Instance.Logger.Debug("summary will be used"); } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Language.Use && !string.IsNullOrEmpty(newNuSpecPackage.Metadata.Language)) { LoggingManager.Instance.Logger.Debug("language will be used"); packageInfo.NuSpecPackage.Metadata.Language = newNuSpecPackage.Metadata.Language; } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.ProjectUrl && !string.IsNullOrEmpty(newNuSpecPackage.Metadata.ProjectUrl)) { LoggingManager.Instance.Logger.Debug("project url will be used"); packageInfo.NuSpecPackage.Metadata.ProjectUrl = newNuSpecPackage.Metadata.ProjectUrl; } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.IconUrl && !string.IsNullOrEmpty(newNuSpecPackage.Metadata.IconUrl)) { LoggingManager.Instance.Logger.Debug("icon url will be used"); packageInfo.NuSpecPackage.Metadata.IconUrl = newNuSpecPackage.Metadata.IconUrl; } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.LicenseUrl && !string.IsNullOrEmpty(newNuSpecPackage.Metadata.LicenseUrl)) { LoggingManager.Instance.Logger.Debug("license url will be used"); packageInfo.NuSpecPackage.Metadata.LicenseUrl = newNuSpecPackage.Metadata.LicenseUrl; } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Copyright.Use && !string.IsNullOrEmpty(newNuSpecPackage.Metadata.Copyright)) { LoggingManager.Instance.Logger.Debug("copyright will be used"); packageInfo.NuSpecPackage.Metadata.Copyright = newNuSpecPackage.Metadata.Copyright; } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Tags && !string.IsNullOrEmpty(newNuSpecPackage.Metadata.Tags)) { LoggingManager.Instance.Logger.Debug("tags will be used"); packageInfo.NuSpecPackage.Metadata.Tags = newNuSpecPackage.Metadata.Tags; } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.RequireLicenseAcceptance) { LoggingManager.Instance.Logger.Debug("requireLicenseAcceptance will be used"); packageInfo.NuSpecPackage.Metadata.RequireLicenseAcceptance = newNuSpecPackage.Metadata.RequireLicenseAcceptance; } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.DevelopmentDependency) { LoggingManager.Instance.Logger.Debug("developmentDependency will be used"); packageInfo.NuSpecPackage.Metadata.DevelopmentDependency = newNuSpecPackage.Metadata.DevelopmentDependency; } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Dependencies && (newNuSpecPackage.Metadata.DependencyGroups != null && newNuSpecPackage.Metadata.DependencyGroups.Count > 0)) { LoggingManager.Instance.Logger.Debug("dependencies will be used"); packageInfo.NuSpecPackage.Metadata.DependencyGroups = newNuSpecPackage.Metadata.DependencyGroups; } } else { LoggingManager.Instance.Logger.Debug("nuspec file does not provide metadata"); } if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Files.UseFromSettings && (newNuSpecPackage.Files != null && newNuSpecPackage.Files.Count > 0)) { LoggingManager.Instance.Logger.Debug("nuspec files will be used"); packageInfo.NuSpecPackage.Files = newNuSpecPackage.Files; } } } else { LoggingManager.Instance.Logger.Debug("no nuspec file found, new one will be added"); } } else { LoggingManager.Instance.Logger.Debug("nuspec file usage disabled"); } LoggingManager.Instance.Logger.Debug(string.Format("project nuspec filepath: {0}", packageInfo.NuSpecFileFullName)); LoggingManager.Instance.Logger.Debug("check nuspec file finished"); }
/// <summary> /// determines the build option of the project from the active configuration /// </summary> /// <param name="activeProject">the active project that is to be deployed</param> /// <param name="packageInfo">package information to use</param> private void DetermineBuildOptions(Project activeProject, PackageInformation packageInfo, ProjectInformation projectInformation) { LoggingManager.Instance.Logger.Debug("determine build options started"); //-----build info packageInfo.Build.PlatformName = activeProject.ConfigurationManager.ActiveConfiguration.PlatformName; packageInfo.Build.ConfigurationName = activeProject.ConfigurationManager.ActiveConfiguration.ConfigurationName; packageInfo.Build.BuildPath = Path.Combine(Path.GetDirectoryName(packageInfo.ProjectFullName), ExtensionUtil.GetPropertyValue(activeProject.ConfigurationManager.ActiveConfiguration.Properties, projectInformation.OutputPath, "")); packageInfo.Build.BuildPath = packageInfo.Build.BuildPath.TrimEnd(Path.DirectorySeparatorChar); //-----optimize if (packageInfo.ProjectOptions.MsBuildOptions.Usage.Optimize.Useage != Enumerations.Useage.None) { if (packageInfo.ProjectOptions.MsBuildOptions.Usage.Optimize.Useage == Enumerations.Useage.Project) { packageInfo.Build.Optimize = ExtensionUtil.GetPropertyValue <bool?>(activeProject.ConfigurationManager.ActiveConfiguration.Properties, projectInformation.Optimize, null); } else { packageInfo.Build.Optimize = packageInfo.ProjectOptions.MsBuildOptions.Usage.Optimize.Value; } } //-----debug constants if (packageInfo.ProjectOptions.MsBuildOptions.Usage.DebugConstants.Useage != Enumerations.Useage.None) { if (packageInfo.ProjectOptions.MsBuildOptions.Usage.DebugConstants.Useage == Enumerations.Useage.Project) { packageInfo.Build.DebugConstants = ExtensionUtil.GetPropertyValue <string>(activeProject.ConfigurationManager.ActiveConfiguration.Properties, projectInformation.DefineConstants, null); } else { packageInfo.Build.DebugConstants = packageInfo.ProjectOptions.MsBuildOptions.Usage.DebugConstants.Value; } } //-----debug info if (packageInfo.ProjectOptions.MsBuildOptions.Usage.DebugInfo.Useage != Enumerations.Useage.None) { if (packageInfo.ProjectOptions.MsBuildOptions.Usage.DebugInfo.Useage == Enumerations.Useage.Project) { packageInfo.Build.DebugInfo = ExtensionUtil.GetPropertyValue(activeProject.ConfigurationManager.ActiveConfiguration.Properties, projectInformation.DebugInfo, Resources.DebugInfoNone); } else { packageInfo.Build.DebugInfo = packageInfo.ProjectOptions.MsBuildOptions.Usage.DebugInfo.Value; } } //-----log LoggingManager.Instance.Logger.Debug(string.Format("project platform: {0}", packageInfo.Build.PlatformName)); LoggingManager.Instance.Logger.Debug(string.Format("project configuration: {0}", packageInfo.Build.ConfigurationName)); LoggingManager.Instance.Logger.Debug(string.Format("project build path: {0}", packageInfo.Build.BuildPath)); LoggingManager.Instance.Logger.Debug(string.Format("project optimize: {0}", packageInfo.Build.Optimize)); LoggingManager.Instance.Logger.Debug(string.Format("project define constants: {0}", packageInfo.Build.DebugConstants)); LoggingManager.Instance.Logger.Debug(string.Format("project debug info: {0}", packageInfo.Build.DebugInfo)); LoggingManager.Instance.Logger.Debug("determine build options finished"); }