Skip to content

Instantly share code, notes, and snippets.

View brianpos's full-sized avatar

Brian Postlethwaite brianpos

View GitHub Profile
@brianpos
brianpos / QuestionnaireResponse_Extract_Template.cs
Last active November 13, 2024 08:40
POC implementation of the proposed SDC template based $extract
using Hl7.Fhir.Model;
using Hl7.Fhir.Utility;
using Hl7.FhirPath;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Hl7.Fhir.FhirPath;
using Hl7.Fhir.ElementModel;
@brianpos
brianpos / QuestionnaireResponse_Extract_Definition.cs
Last active November 13, 2024 08:39
Demonstration implementation (WIP) for the definition based FHIR Questionniare data extraction
using Hl7.Fhir.Model;
using Hl7.Fhir.Specification;
using Hl7.Fhir.Specification.Navigation;
using Hl7.Fhir.Specification.Snapshot;
using Hl7.Fhir.Specification.Source;
using Hl7.Fhir.Utility;
using Hl7.Fhir.WebApi;
using Hl7.FhirPath;
using System;
using System.Collections;
@brianpos
brianpos / fhirpath-async.ts
Last active March 25, 2024 02:11
POC showing one possible way to do async functions in the fhirpath.js library without forcing the entire library to be async.
import type { CodeableConcept, Coding, OperationOutcome, OperationOutcomeIssue, Reference, Resource, Parameters } from "fhir/r4b";
import fhirpath from "fhirpath";
import { logMessage, CreateOperationOutcome } from "~/utils/create-outcome";
// --------------------------------------------------------------------------
// The concept of this POC is to demonstrate an approach to perform some
// async based methods as functions inside the fhirpath engine without
// converting the entire engine to process things asynchronously.
// e.g. Terminology functions such as memberOf, subsumes, or resolve()
//
@brianpos
brianpos / sdc-questionnaire-validation.md
Last active October 27, 2023 21:04
FHIR Questionnaire Definition Validation

Questionnaire top level validation should consider:

  • Check the canonical versioning algorithm and version don't contradict each other
  • Add a warning that the canonical URL is highly recommended
  • if status = published, ensure that has a canonical URL
  • information/warning if derivedFRom isn't a versioned canonical URL
  • Should subjectType and launch context be the same?
  • Check the copyright label is from the set of approved licenses?
  • Should there be some date checks on the approved, review and date etc?
  • definitionBased flag
  • anything needed for the replaces extension?
@brianpos
brianpos / FhirPathVistor.cs
Last active June 16, 2023 22:20
Static validation on a FhirPath Expression to verify validity against a specific fhir version (via object model)
using Hl7.Fhir.Introspection;
using Hl7.Fhir.Support;
using Hl7.Fhir.Utility;
using Hl7.FhirPath.Expressions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Text;
@brianpos
brianpos / ProcessPackageCache.cs
Created June 1, 2023 03:36
Scan over a directory that contains directories of expanded FHIR packages and extract a file called sds.json summarizing its contents
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using Hl7.Fhir.Model;
using Hl7.Fhir.Rest;
using Hl7.Fhir.Serialization;
using Hl7.Fhir.Utility;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using Hl7.Fhir.Model;
using Hl7.FhirPath;
using Hl7.FhirPath.Expressions;
using NaturalSort.Extension;
using System;
using System.Collections.Generic;
using System.Linq;
// Requires these 2 nuget packages
// <PackageReference Include="NaturalSort.Extension" Version="3.2.0" />
@brianpos
brianpos / EvaluateFhirPathTesterExpression.cs
Last active June 7, 2022 18:30
Sample function for a custom operation to evaluate the results of a fhirpath operation for testing
if (operation == "fhirpath")
{
Resource resource = operationParameters.GetResource("resource");
string resourceId = operationParameters.GetString("resource");
string terminologyServerUrl = operationParameters.GetString("terminologyserver");
if (resource == null && !string.IsNullOrEmpty(resourceId))
{
// load the resource from another server
ResourceIdentity ri = new ResourceIdentity(resourceId);
if (!string.IsNullOrEmpty(ri.BaseUri?.OriginalString))
@brianpos
brianpos / QuestionnaireResponse_Validator.cs
Created May 17, 2022 07:41
A more complete version of the subset of QuestionnaireResponse Validations in dotnet
public class QuestionnaireResponse_Validator
{
public QuestionnaireResponse_Validator(ValidationSettings settings = null)
{
_settings = settings ?? new ValidationSettings()
{
TerminologyServerAddress = "https://sqlonfhir-r4.azurewebsites.net/fhir",
TerminologyServerFhirClientSettings = new FhirClientSettings()
{
VerifyFhirVersion = false,
@brianpos
brianpos / hl7.fhir.au.base.extensions.cs
Created April 26, 2022 08:09
Initial pass at Extension Methods code generated for the AU Base extensions.
// <auto-generated/>
// Contents of: hl7.fhir.au.base version: 2.2.0
using System;
using System.Buffers;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Linq;
using Hl7.Fhir.Model;