Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | 1x 698x 1x 43x 1x 179x 1x 50x 9x 9x 18x 3x 6x 2x 7x 1x 42x 42x 46x 1x 1x 26x | { typeIsArray } = require '../util/util'
module.exports.Code = class Code
constructor: (@code, @system, @version, @display) ->
# Define a simple getter to allow type-checking of this class without instanceof
# and in a way that survives minification (as opposed to checking constructor.name)
Object.defineProperties @prototype,
isCode:
get: -> true
hasMatch: (code) ->
if typeof code is 'string'
# the specific behavior for this is not in the specification. Matching codesystem behavior.
code == @.code
else
codesInList(toCodeList(code), [@])
module.exports.Concept = class Concept
constructor: (@codes = [], @display) ->
# Define a simple getter to allow type-checking of this class without instanceof
# and in a way that survives minification (as opposed to checking constructor.name)
Object.defineProperties @prototype,
isConcept:
get: -> true
hasMatch: (code) ->
codesInList(toCodeList(code), @codes)
module.exports.ValueSet = class ValueSet
constructor: (@oid, @version, @codes = []) ->
Object.defineProperties @prototype,
isValueSet:
get: -> true
hasMatch: (code) ->
codesList = toCodeList(code)
# InValueSet String Overload
if codesList.length == 1 and typeof codesList[0] is 'string'
matchFound = false
multipleCodeSystemsExist = false
for codeItem in @codes
# Confirm all code systems match
if codeItem.system != @codes[0].system
multipleCodeSystemsExist = true
if codeItem.code == codesList[0]
matchFound = true
if multipleCodeSystemsExist and matchFound
throw new Error('In (valueset) is ambiguous -- multiple codes with multiple code systems exist in value set.')
return matchFound
else
codesInList(codesList, @codes)
toCodeList = (c) ->
if not c?
[]
else if typeIsArray c
list = []
for c2 in c
list = list.concat(toCodeList(c2))
list
else if typeIsArray c.codes
c.codes
else
[c]
codesInList = (cl1, cl2) ->
cl1.some (c1) -> (cl2.some (c2) ->
# only the left argument (cl1) can contain strings. cl2 will only contain codes.
if typeof c1 is 'string'
# for "string in codesystem" this should compare the string to
# the code's "code" field according to the specification.
c1 == c2.code
else
codesMatch(c1, c2))
codesMatch = (code1, code2) ->
code1.code == code2.code and code1.system == code2.system
module.exports.CodeSystem = class CodeSystem
constructor: (@id, @version) ->
|