"use strict";

var whenGiven = [{
    property: 'low',
    path: 'start',
    type: 'date'
}, {
    property: 'high',
    path: 'end',
    type: 'date'
}];

var quantity = [{
    property: 'value',
    path: 'value'
}, {
    property: 'unit',
    path: 'units'
}];

var dosage = [{
    property: 'route',
    path: 'route.coding.0',
    type: 'concept'
}, {
    property: 'site',
    path: 'site.coding.0',
    type: 'concept'
}, {
    property: 'dose',
    path: 'quantity',
    type: 'template',
    typeParam: quantity
}];

var repeat = [{
    property: 'period.value',
    path: 'duration'
}, {
    property: 'period.unit',
    path: 'units'
}, {
    property: 'frequency',
    type: 'constant',
    typeParam: true
}];

var prescription = [{
    property: 'administration.interval',
    path: 'dosageInstruction.0.timingSchedule.repeat',
    type: 'template',
    typeParam: repeat
}];

exports.template = [{
    property: 'date_time',
    path: 'whenGiven',
    type: 'template',
    typeParam: whenGiven
}, {
    property: 'status',
    type: 'constant',
    typeParam: 'Completed'
}, {
    property: 'administration',
    path: 'dosage.0',
    type: 'template',
    typeParam: dosage
}, {
    property: 'precondition.value',
    path: 'dosage.0.asNeededCodeableConcept.coding.0',
    type: 'concept'
}, {
    property: 'product.product',
    path: 'medication.reference.code.coding.0',
    type: 'concept'
}, {
    path: 'prescription.reference',
    type: 'template',
    typeParam: prescription
}];

exports.type = 'medication';

@@ -880,16 +880,63 @@
  repeat%0A
+%7D, %7B%0A    property: 'sig',%0A    path: 'text.div'%0A
 %7D%5D;%0A%0Aexp

generate sig form administered medications