medplum / medplum

Medplum is a healthcare platform that helps you quickly develop high-quality compliant applications.
https://medplum.com
Apache License 2.0
1.41k stars 403 forks source link

Note that profiles support regex in documentation #5221

Open reshmakh opened 2 months ago

reshmakh commented 2 months ago

User driven question: if a patient name has a limit of 100 characters, is that able to be represented in a profile

I believe the answer is yes.

We should note in the documentation that Profiles support anything in FHIRPath, and FHIRPath does indeed include regexes: https://hl7.org/fhirpath/#matchesregex-string-boolean

This is the documentation https://www.medplum.com/docs/fhir-datastore/profiles

codyebberson commented 2 months ago

Discussion: https://medplum.slack.com/archives/C02AMUU6SBH/p1726093198950829

Profiles support anything in FHIRPath, and FHIRPath does indeed include regexes: https://hl7.org/fhirpath/#matchesregex-string-boolean

{
  "resourceType": "StructureDefinition",
  "id": "my-organization-profile",
  "url": "http://example.com/fhir/StructureDefinition/my-organization-profile",
  "name": "MyOrganizationProfile",
  "status": "draft",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "Organization",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Organization",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Organization.name",
        "path": "Organization.name",
        "constraint": [
          {
            "key": "org-name-format",
            "severity": "error",
            "human": "Organization name must start with a capital letter and contain only letters, spaces, and hyphens",
            "expression": "matches('^[A-Z][a-zA-Z -]*$')",
            "source": "http://example.com/fhir/StructureDefinition/my-organization-profile"
          }
        ]
      }
    ]
  }
}

Note that is a "differential" profile. You would need to convert it to a "snapshot" profile.