Module: HealthCards::Exporter

Defined in:
lib/health_cards/exporter.rb

Overview

Converts a JWS to formats needed by endpoints (e.g. $issue-health-card, download and qr code)

Class Method Summary collapse

Class Method Details

.file_download(jws) ⇒ String

Export JWS for file download

Parameters:

  • An (Array<JWS, String>)

    array of JWS objects to be exported

Returns:

  • (String)

    JSON string containing file download contents



10
11
12
# File 'lib/health_cards/exporter.rb', line 10

def file_download(jws)
  { verifiableCredential: jws.map(&:to_s) }.to_json
end

.issue(fhir_params) ⇒ String

Export JWS for $issue-health-card endpoint Expects block to return JWS instances for those types

Parameters:

  • A (FHIR::Parameters)

    FHIR::Parameters object

Returns:

  • (String)

    JSON string containing a FHIR Parameters resource



19
20
21
22
23
24
25
# File 'lib/health_cards/exporter.rb', line 19

def issue(fhir_params)
  *jws = yield extract_types!(fhir_params)

  params = jws.compact.map { |j| FHIR::Parameters::Parameter.new(name: 'verifiableCredential', valueString: j) }

  FHIR::Parameters.new(parameter: params).to_json
end

.qr_codes(jws) ⇒ Object



27
28
29
# File 'lib/health_cards/exporter.rb', line 27

def qr_codes(jws)
  QRCodes.from_jws(jws)
end