public ConstraintParser(IObjectRepository tdb, IConstraint constraint, ImplementationGuideType igType, SimpleSchema igTypeSchema, IEnumerable <Template> allTemplates, string valueSetFile = "voc.xml", VocabularyOutputType vocabularyOutputType = VocabularyOutputType.Default) { this.tdb = tdb; this.constraint = constraint; this.valueSetFile = valueSetFile; this.igType = igType; this.igTypeSchema = igTypeSchema; this.allTemplates = allTemplates; this.igTypePlugin = igType.GetPlugin(); if (!string.IsNullOrEmpty(this.constraint.Cardinality)) { this.constraintCardinalityType = CardinalityParser.Parse(this.constraint.Cardinality); } if (!string.IsNullOrEmpty(this.constraint.Conformance)) { this.constraintConformanceType = ConformanceParser.Parse(this.constraint.Conformance); } this.prefix = igType.SchemaPrefix; this.vocabularyOutputType = vocabularyOutputType; }
public static Conformance GetSparkConformance() { Conformance conformance = ConformanceBuilder.CreateServer("CDS-Spark", Info.Version, "ONC", fhirVersion: "0.5.0"); // Knowledge Modules conformance.AddSingleResourceComponent ( "OperationDefinition", false, true, Conformance.ResourceVersionPolicy.NoVersion, new ResourceReference { Reference = "/fhir/StructureDefinition/knowledgemodule-cqf-cqf-knowledgemodule" } ); // Guidance Operation conformance.AddOperation("guidance", new ResourceReference { Reference = "/fhir/OperationDefinition/Basic-guidance" }); // GuidanceRequirements Operation conformance.AddOperation("guidanceRequirements", new ResourceReference { Reference = "/fhir/OperationDefinition/Basic-guidancerequirements" }); conformance.AcceptUnknown = true; conformance.Experimental = true; conformance.Format = new string[] { "xml", "json" }; conformance.Description = "This FHIR SERVER is a prototype implementation of the FHIR-Based Clinical Quality Framework Implementation Guide built in C# and based on the Spark FHIR Server"; return(conformance); }
public Conformance MetaData() { Conformance thisConformance = new Conformance(); thisConformance.Description = "This is an test implementation of FHIR server which wrappes around the existing iPM APIs Using DSTU 2"; thisConformance.Date = DateTime.UtcNow.ToString("s"); thisConformance.Experimental = true; thisConformance.AcceptUnknown = Conformance.UnknownContentCode.No; thisConformance.FhirVersion = "Fhir.DSTU2 0.91.1.1"; thisConformance.Name = "FHIR Server for Patient Resources"; thisConformance.Rest = new List <Conformance.RestComponent>(); Conformance.RestComponent rc = new Conformance.RestComponent() { Mode = Conformance.RestfulConformanceMode.Server, Resource = new List <Conformance.ResourceComponent>() }; foreach (var servant in _servants.Values) { rc.Resource.Add(servant.Metadata()); } thisConformance.Rest.Add(rc); return(thisConformance); }
public void SimpleValueSupport() { Conformance c = new Conformance(); Assert.IsNull(c.AcceptUnknown); c.AcceptUnknown = true; Assert.IsTrue(c.AcceptUnknown.GetValueOrDefault()); Assert.IsNotNull(c.AcceptUnknownElement); Assert.IsTrue(c.AcceptUnknownElement.Value.GetValueOrDefault()); c.PublisherElement = new FhirString("Furore"); Assert.AreEqual("Furore", c.Publisher); c.Publisher = null; Assert.IsNull(c.PublisherElement); c.Publisher = "Furore"; Assert.IsNotNull(c.PublisherElement); c.Format = new string[] { "json", "xml" }; Assert.IsNotNull(c.FormatElement); Assert.AreEqual(2, c.FormatElement.Count); Assert.AreEqual("json", c.FormatElement.First().Value); c.FormatElement = new List <Code>(); c.FormatElement.Add(new Code("csv")); Assert.IsNotNull(c.Format); Assert.AreEqual(1, c.Format.Count()); }
/// <summary> /// Returns true if PdfConvertToPDFAParameters instances are equal /// </summary> /// <param name="input">Instance of PdfConvertToPDFAParameters to be compared</param> /// <returns>Boolean</returns> public bool Equals(PdfConvertToPDFAParameters input) { if (input == null) { return(false); } return (( FileId == input.FileId || (FileId != null && FileId.Equals(input.FileId)) ) && ( Conformance == input.Conformance || Conformance.Equals(input.Conformance) ) && ( AllowVectorization == input.AllowVectorization || AllowVectorization.Equals(input.AllowVectorization) ) && ( AllowRasterization == input.AllowRasterization || AllowRasterization.Equals(input.AllowRasterization) )); }
/// <summary> /// Gets the conformance reflecting the capabilities of all registred servants. /// </summary> /// <returns>Conformance.</returns> public Conformance Metadata() { var conformance = new Conformance { Description = "This is an example implementation of an FHIR server - for demonstration purpose only.", Date = DateTime.UtcNow.ToString("s"), Experimental = true, AcceptUnknown = false, FhirVersion = "DSTU 1.1", Name = "FHIR Server for Patient Resources", Publisher = "MSDN Code Gallery, Stefan Heesch", Telecom = new List <Contact> { new Contact { System = Contact.ContactSystem.Url, Value = "https://twitter.com/hb9tws" } }, Rest = new List <Conformance.ConformanceRestComponent>() }; var rc = new Conformance.ConformanceRestComponent { Mode = Conformance.RestfulConformanceMode.Server, Resource = new List <Conformance.ConformanceRestResourceComponent>() }; foreach (var servant in _servants.Values) { rc.Resource.Add(servant.Metadata()); } conformance.Rest.Add(rc); return(conformance); }
public static Conformance AddOperationDefintion(this Conformance conformance, IEnumerable <IFhirService> services) { var operationComponents = new List <Conformance.OperationComponent>(); foreach (var service in services) { var queryService = service; var operationDefintion = queryService?.GetOperationDefinition(); if (!string.IsNullOrEmpty(operationDefintion?.Url)) { operationComponents.Add(new Conformance.OperationComponent { Name = operationDefintion.Name, Definition = new ResourceReference { Reference = operationDefintion.Url } }); } } if (operationComponents.Count > 0) { conformance.Server().Operation.AddRange(operationComponents); } return(conformance); }
internal Conformance GetMinimumConformanceForConstraint(TemplateConstraint aConstraint) { if (aConstraint == null) { return(Conformance.UNKNOWN); } Conformance minLevel = aConstraint.BusinessConformanceType; TemplateConstraint constraint = aConstraint; if (!IsBranchDescendent(aConstraint) || (aConstraint.IsPrimitive && aConstraint.IsSchRooted)) { return(minLevel); } while (constraint != null) { if (minLevel < constraint.BusinessConformanceType) { minLevel = constraint.BusinessConformanceType; } if (constraint.IsBranch) { break; } constraint = constraint.ParentConstraint; } return(minLevel); }
///<summary> ///Constructor. ///</summary> internal GXDLMSSettings(bool server, InterfaceType interfaceType) { InterfaceType = interfaceType; UseCustomChallenge = false; StartingBlockIndex = BlockIndex = 1; DLMSVersion = 6; InvokeID = 0x1; Priority = Priority.High; ServiceClass = ServiceClass.Confirmed; MaxServerPDUSize = MaxPduSize = DefaultMaxReceivePduSize; IsServer = server; Objects = new GXDLMSObjectCollection(); //This is removed later. Hdlc = new GXDLMSLimits(this); Gateway = null; ProposedConformance = GXDLMSClient.GetInitialConformance(false); if (server) { ProposedConformance |= Conformance.GeneralProtection; } ResetFrameSequence(); WindowSize = 1; UserId = -1; Standard = Standard.DLMS; Plc = new GXPlcSettings(this); }
public static Conformance AddAllSystemInteractions(this Conformance conformance) { foreach (Conformance.SystemRestfulInteraction code in Enum.GetValues(typeof(Conformance.SystemRestfulInteraction))) { conformance.AddSystemInteraction(code); } return(conformance); }
public static Conformance AddMultipleResourceComponents(this Conformance conformance, List <String> resourcetypes, Boolean readhistory, Boolean updatecreate, Conformance.ResourceVersionPolicy versioning) { foreach (var type in resourcetypes) { AddSingleResourceComponent(conformance, type, readhistory, updatecreate, versioning); } return(conformance); }
public static Conformance AddSearchSetInteraction(this Conformance conformance) { var searchSet = Conformance.SystemRestfulInteraction.SearchSystem; conformance.AddSystemInteraction(searchSet); return(conformance); }
public static void AddSystemInteraction(this Conformance conformance, Conformance.SystemRestfulInteraction code) { var interaction = new Conformance.SystemInteractionComponent(); interaction.Code = code; conformance.Rest().Interaction.Add(interaction); }
public static Conformance AddAllCoreResources(this Conformance conformance, Boolean readhistory, Boolean updatecreate, Conformance.ResourceVersionPolicy versioning) { foreach (var resource in ModelInfo.SupportedResources) { conformance.AddSingleResourceComponent(resource, readhistory, updatecreate, versioning); } return(conformance); }
/// <summary> /// The role of this method is to take a list of constraints and produce a pattern with rules and assertions. /// </summary> /// <param name="constraints"></param> /// <param name="phase"></param> /// <param name="patternName"></param> /// <param name="context"></param> internal Pattern GeneratePattern(Conformance aMinimumConformance, IEnumerable <TemplateConstraint> constraints, Phase phase, string patternName, string ruleId, string context, string impliedPatternId = null, string impliedRuleId = null, bool isImplied = false) { var pattern = new Pattern(); pattern.IsImplied = isImplied; pattern.ID = patternName; pattern.Name = patternName; pattern.IsA = impliedPatternId; var rule = new Rule(); rule.Id = ruleId; rule.Context = context; rule.Extends = impliedRuleId; pattern.Rules.Add(rule); foreach (var constraint in constraints) { if (!constraint.CategoryIsMatch(this.categories)) { continue; } try { Conformance conformance = GetMinimumConformanceForConstraint(constraint); //ShouldSkipConstraint and turn on flag to skip any descendent of a branch b/c these get handled inside the branch context rules if (ShouldSkipConstraint(constraint, true) || !MeetsConformance(aMinimumConformance, conformance)) { continue; } //MAYs directly on the constraint should not be outputted (parent MAYs can be outputted, but not constraints with conformance MAY) if (constraint.BusinessConformanceType == Conformance.MAY || constraint.BusinessConformanceType == Conformance.MAY_NOT) { continue; } rule.Assertions.Add(GetAssertion(constraint)); } catch (Exception ex) { Log.For(this).Error("Error getting assertion for constraint {0} on template {1}.", ex, constraint.Id, constraint.TemplateId); throw ex; } } if (rule.Assertions.Count == 0) { rule.Assertions.Add(GenerateBlankAssertion()); } // TODO: This should probably be moved to it's calling function phase.ActivePatterns.Add(pattern); return(pattern); //return the newly created pattern }
public static Conformance AddAllInteractionsForAllResources(this Conformance conformance) { foreach (var r in conformance.Rest.FirstOrDefault().Resource.ToList()) { conformance.Rest().Resource.Remove(r); conformance.Rest().Resource.Add(AddAllResourceInteractions(r)); } return(conformance); }
public static Conformance AddCoreSearchParamsAllResources(this Conformance conformance) { foreach (var r in conformance.Rest.FirstOrDefault().Resource.ToList()) { conformance.Rest().Resource.Remove(r); conformance.Rest().Resource.Add(AddCoreSearchParamsResource(r)); } return(conformance); }
public static void AddOperation(this Conformance conformance, String name, ResourceReference definition) { var operation = new Conformance.OperationComponent(); operation.Name = name; operation.Definition = definition; conformance.Server().Operation.Add(operation); }
/// <summary> /// Helper function which creates an AssertionLineBuilder for an element given the constraint. This function will examine the constraint's value and datatype /// and add those to the builder if necessary. Also if aGenerateContext == true then it will add the context of the element. /// </summary> /// <param name="aElement">Element to base the AssertionLineBuilder from</param> /// <param name="aTemplateConstraint">TemplateConstraint which has the necessary properties (e.g. Element Value, Data Type) to add to the AssertionLineBuilder</param> /// <param name="aGenerateContext">Flag to determine whether a context should be added as part of the AssertionLineBuilder</param> /// <returns>A new AssertionLineBuilder for the aElement passed in</returns> private AssertionLineBuilder CreateAssertionLineBuilderForElement(DocumentTemplateElement aElement, IConstraint aTemplateConstraint, ref string aParentContext, bool aGenerateContext = true) { //add the value and data type ConstraintToDocumentElementHelper.AddElementValueAndDataType(this.prefix, aElement, aTemplateConstraint); //create builders var builder = new AssertionLineBuilder(this.tdb, aElement, this.igType, this.igTypeSchema); if (aGenerateContext) { ContextBuilder contextBuilder = null; if (aElement.ParentElement != null) //build the context { contextBuilder = new ContextBuilder(aElement.ParentElement, this.prefix); //the context will start from the first parent (or root) builder.WithinContext(string.Format("{0}", contextBuilder.GetFullyQualifiedContextString())); } } var containedTemplates = (from tcr in aTemplateConstraint.References join t in this.allTemplates on tcr.ReferenceIdentifier equals t.Oid where tcr.ReferenceType == ConstraintReferenceTypes.Template select new { Identifier = t.Oid, t.PrimaryContextType }); foreach (var containedTemplate in containedTemplates) { builder.ContainsTemplate(containedTemplate.Identifier, containedTemplate.PrimaryContextType); if (aTemplateConstraint.Parent != null && aTemplateConstraint.Parent.IsBranch) { builder.WithinContext(aParentContext, ContextWrapper.Slash); //put the parent context into the element context, this is a special case where we want the full context within the template assertion aParentContext = string.Empty; //clear the parent context b/c we have put it within the element's context } } if (aTemplateConstraint.Parent != null) { Conformance conformance = ConformanceParser.Parse(aTemplateConstraint.Parent.Conformance); if (conformance == Conformance.SHOULD) { builder.HasOptionalParentContext(); } } //TODO: Refactor this out, hardcoding these special cases for QRDA if (this.prefix.ToLower().Contains("cda")) { aElement.ElementToAttributeOverrideMapping.Add("code", "code"); aElement.ElementToAttributeOverrideMapping.Add("statusCode", "code"); aElement.ElementToAttributeOverrideMapping.Add("realmCode", "code"); aElement.ElementToAttributeOverrideMapping.Add("externalDocument", "classCode"); } return(builder); }
public static Conformance AddSummaryForAllResources(this Conformance conformance) { foreach (var resource in conformance.Rest.FirstOrDefault().Resource.ToList()) { var p = new Conformance.SearchParamComponent(); p.Name = "_summary"; p.Type = SearchParamType.String; p.Documentation = "Summary for resource"; resource.SearchParam.Add(p); } return(conformance); }
public static Conformance AddSingleResourceComponent(this Conformance conformance, String resourcetype, Boolean readhistory, Boolean updatecreate, Conformance.ResourceVersionPolicy versioning, ResourceReference profile = null) { var resource = new Conformance.ResourceComponent(); resource.Type = Hacky.GetResourceTypeForResourceName(resourcetype); resource.Profile = profile; resource.ReadHistory = readhistory; resource.UpdateCreate = updatecreate; resource.Versioning = versioning; conformance.Server().Resource.Add(resource); return(conformance); }
/// <summary> /// Get conformance /// </summary> public Conformance GetOptions() { this.ThrowIfNotReady(); var retVal = new Conformance(); // ConformanceUtil.GetConformanceStatement(); WebOperationContext.Current.OutgoingResponse.Headers.Add("Content-Location", String.Format("{0}Conformance/{1}/_history/{2}", WebOperationContext.Current.IncomingRequest.UriTemplateMatch.BaseUri, retVal.Id, retVal.VersionId)); WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.OK; WebOperationContext.Current.OutgoingResponse.Headers.Remove("Content-Disposition"); WebOperationContext.Current.OutgoingResponse.Headers.Add("Content-Disposition", "filename=\"conformance.xml\""); return(retVal); }
public void FetchConformance() { FhirClient client = new FhirClient(testEndpoint); Conformance c = client.Conformance().Resource; Assert.IsNotNull(c); Assert.AreEqual("HL7Connect", c.Software.Name); Assert.AreEqual(Conformance.RestfulConformanceMode.Server, c.Rest[0].Mode.Value); Assert.AreEqual(ContentType.XML_CONTENT_HEADER, client.LastResponseDetails.ContentType.ToLower()); Assert.AreEqual(HttpStatusCode.OK, client.LastResponseDetails.Result); }
public Conformance Get() { var conformance = new Conformance(); conformance.ConformsTo = new List <string>() { "http://www.opengis.net/spec/ogcapi-features-1/1.0/req/core", "http://www.opengis.net/spec/ogcapi-features-1/1.0/req/oas30", "http://www.opengis.net/spec/ogcapi-features-1/1.0/req/html", "http://www.opengis.net/spec/ogcapi-features-1/1.0/req/geojson" }; return(conformance); }
public static Conformance.RestComponent AddRestComponent(this Conformance conformance, Boolean isServer, String documentation = null) { var server = new Conformance.RestComponent(); server.Mode = (isServer) ? Conformance.RestfulConformanceMode.Server : Conformance.RestfulConformanceMode.Client; if (documentation != null) { server.Documentation = documentation; } conformance.Rest.Add(server); return(server); }
/// <summary> /// Returns true if ImageSaveAsPDFMRCParameters instances are equal /// </summary> /// <param name="input">Instance of ImageSaveAsPDFMRCParameters to be compared</param> /// <returns>Boolean</returns> public bool Equals(ImageSaveAsPDFMRCParameters input) { if (input == null) { return(false); } return (( FileId == input.FileId || (FileId != null && FileId.Equals(input.FileId)) ) && ( PageRange == input.PageRange || (PageRange != null && PageRange.Equals(input.PageRange)) ) && ( Conformance == input.Conformance || Conformance.Equals(input.Conformance) ) && ( ColorImageCompression == input.ColorImageCompression || ColorImageCompression.Equals(input.ColorImageCompression) ) && ( BitonalImageCompression == input.BitonalImageCompression || BitonalImageCompression.Equals(input.BitonalImageCompression) ) && ( ImageQuality == input.ImageQuality || ImageQuality.Equals(input.ImageQuality) ) && ( DownscaleResolution == input.DownscaleResolution || DownscaleResolution.Equals(input.DownscaleResolution) ) && ( PreserveSmoothing == input.PreserveSmoothing || PreserveSmoothing.Equals(input.PreserveSmoothing) ) && ( FastWebView == input.FastWebView || FastWebView.Equals(input.FastWebView) ) && ( JBIG2PMSThreshold == input.JBIG2PMSThreshold || JBIG2PMSThreshold.Equals(input.JBIG2PMSThreshold) )); }
public static Conformance AddSingleResourceComponent(this Conformance conformance, string resourcetype, bool readhistory, bool updatecreate, Conformance.ResourceVersionPolicy versioning, ResourceReference profile = null) { var resource = new Conformance.ResourceComponent { Type = (ResourceType)Enum.Parse(typeof(ResourceType), resourcetype, true), Profile = profile, ReadHistory = readhistory, UpdateCreate = updatecreate, Versioning = versioning }; conformance.Server().Resource.Add(resource); return(conformance); }
public static Conformance AddSearchTypeInteractionForResources(this Conformance conformance) { var firstOrDefault = conformance.Rest.FirstOrDefault(); if (firstOrDefault != null) { foreach (var r in firstOrDefault.Resource.ToList()) { conformance.Rest().Resource.Remove(r); conformance.Rest().Resource.Add(AddSearchType(r)); } } return(conformance); }
public static Conformance CreateServer(string server, string serverVersion, string publisher, string fhirVersion) { var conformance = new Conformance { Name = server, Publisher = publisher, Version = serverVersion, FhirVersion = fhirVersion, AcceptUnknown = Conformance.UnknownContentCode.No, Date = Date.Today().Value }; conformance.AddServer(); return(conformance); }
public static Conformance.RestComponent AddRestComponent(this Conformance conformance, bool isServer, string documentation = null) { var server = new Conformance.RestComponent { Mode = isServer ? Conformance.RestfulConformanceMode.Server : Conformance.RestfulConformanceMode.Client }; if (documentation != null) { server.Documentation = documentation; } conformance.Rest.Add(server); return(server); }