Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1971 from MeasureAuthoringTool/MAT-3202
Browse files Browse the repository at this point in the history
Added new attribute for MedicationRequest
  • Loading branch information
adongare authored Aug 3, 2021
2 parents f960f26 + 652991a commit aa49782
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app/assets/javascripts/helpers/data_criteria_helpers.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1180,12 +1180,24 @@
fhirResource.dispenseRequest.validityPeriod = period
types: ['Period']
},
{
path: 'dosageInstruction.timing'
title: 'dosageInstruction.timing'
getValue: (fhirResource) -> fhirResource?.dosageInstruction?[0]?.timing
setValue: (fhirResource, timing) ->
if !timing?
fhirResource?.dosageInstruction?[0]?.timing = null
else
fhirResource.dosageInstruction = [ new cqm.models.Dosage() ] unless fhirResource?.dosageInstruction
fhirResource.dosageInstruction[0].timing = timing
types: ['Timing']
},
{
path: 'dosageInstruction.doseAndRate.rate'
title: 'dosageInstruction.doseAndRate.rate'
getValue: (fhirResource) ->
if cqm.models.SimpleQuantity.isSimpleQuantity(fhirResource?.dosageInstruction?[0]?.doseAndRate?[0]?.rate)
# Widget supports only Quantity: convert SimpleQuantity -> Quantity
# Widget supports only Quantity: convert SimpleQuantity -> Quantity
return cqm.models.Quantity.parse(fhirResource?.dosageInstruction?[0]?.doseAndRate?[0]?.rate.toJSON())
else
return fhirResource?.dosageInstruction?[0]?.doseAndRate?[0]?.rate
Expand All @@ -1196,7 +1208,7 @@
fhirResource.dosageInstruction = [ new cqm.models.Dosage() ] unless fhirResource?.dosageInstruction
fhirResource.dosageInstruction[0].doseAndRate = [ new cqm.models.DosageDoseAndRate() ] unless fhirResource?.dosageInstruction?[0]?.doseAndRate
if cqm.models.Quantity.isQuantity(rate)
# Widget supports only Quantity: convert Quantity -> SimpleQuantity
# Widget supports only Quantity: convert Quantity -> SimpleQuantity
fhirResource.dosageInstruction[0].doseAndRate[0].rate = cqm.models.SimpleQuantity.parse(rate.toJSON())
else
fhirResource.dosageInstruction[0].doseAndRate[0].rate = rate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,26 @@ describe 'DataCriteriaHelpers', ->

expect(value.start.value).toEqual '2020-09-02T13:54:57'
expect(value.end.value).toEqual '2020-10-02T13:54:57'

it 'should support MedicationRequest.dosageInstruction.timing', ->
attrs = DataCriteriaHelpers.DATA_ELEMENT_ATTRIBUTES['MedicationRequest']
attr = attrs.find (attr) -> attr.path is 'dosageInstruction.timing'
expect(attr.path).toEqual 'dosageInstruction.timing'
expect(attr.title).toEqual 'dosageInstruction.timing'
expect(attr.types).toEqual [ 'Timing' ]

fhirResource = new cqm.models['MedicationRequest']()

# set Timing
timing = new cqm.models.Timing()
timing.code = new cqm.models.CodeableConcept()
timing.code.coding = [ new cqm.models.Coding() ]
timing.code.coding[0].system = cqm.models.PrimitiveUri.parsePrimitive('a system')
timing.code.coding[0].code = cqm.models.PrimitiveCode.parsePrimitive('a code')

attr.setValue(fhirResource, timing)

value = attr.getValue(fhirResource.clone())
expect(value).toBeDefined()
expect(value.code.coding[0].system.value).toBe 'a system'
expect(value.code.coding[0].code.value).toBe 'a code'

0 comments on commit aa49782

Please sign in to comment.