Aidbox / Issues

Issue tracker for Aidbox FHIR backend by Health Samurai
7 stars 0 forks source link

[BUG] Using`$ now()` in Mapping throws an error #556

Open vesnushka opened 1 year ago

vesnushka commented 1 year ago

Describe the bug We faced en error in extracting the questionnaire due to the use of $ now() in Mapping

Severity Critical

Steps to reproduce the behavior:

  1. The Mapping example with $ now() Note: the use of variables is required to reproduce the error
    body:
    $let:
    patientId: >-
      $
      fhirpath("QuestionnaireResponse.repeat(item).where(linkId='patientId').answer.value.string").0
    $body:
    type: transaction
    entry:
      - request:
          url: /Observation
          method: POST
        resource:
          code:
            coding:
              - code: 29463-7
                system: http://loinc.org
                display: Body weight
          value:
            Quantity:
              unit: kg
              value: 80
          status: final
          subject:
            id: $ patientId
            resourceType: Patient
          effective:
            dateTime: $ now()
          resourceType: Observation
    resourceType: Bundle
    id: test-now-extract
    resourceType: Mapping
  2. $debug returns correct result
    
    POST /Mapping/test-now-extract/$debug
    Content-Type: text/yaml

patientId: ede14f63-fffa-4ed0-aed8-b5b4f34f0055


Result:

type: transaction entry:

  1. But $apply returns the error
POST /Mapping/test-now-extract/$apply
Content-Type: text/yaml

patientId: ede14f63-fffa-4ed0-aed8-b5b4f34f0055

The answer

resourceType: OperationOutcome
...
text:
  status: generated
  div: >-
    Transaction failed at entry[0]. Response status is 422. Response body is
    {"resourceType":"OperationOutcome","text":{"status":"generated","div":"Invalid
    resource"},"issue":[{"severity":"fatal","code":"invalid","expression":["Observation.effective.dateTime"],"diagnostics":"expected
    type of string"}]}.
issue:
  - severity: fatal
    code: invalid
    diagnostics: expected type of string
    expression:
      - Observation.effective.dateTime

Expected behavior $apply should return FHIR dateTime with no error

Versions: