I have an array of diagnoses, all of which have specific indexes as seen below from the console:
{M24.2: {…}, M51.2: {…}, S03.5: {…}, J10.1: {…}, J06.9: {…}, …}
F43.2
:
{code: 'F43.2', name: 'Adjustment disorders', latin: 'Perturbationes adaptationis'}
H35.29
:
{code: 'H35.29', name: 'Other proliferative retinopathy', latin: 'Alia retinopathia proliferativa'}
H54.7
:
{code: 'H54.7', name: 'Unspecified visual loss', latin: 'Amblyopia NAS'}
J03.0
:
{code: 'J03.0', name: 'Streptococcal tonsillitis', latin: 'Tonsillitis (palatina) streptococcica'}
J06.9
:
{code: 'J06.9', name: 'Acute upper respiratory infection, unspecified', latin: 'Infectio acuta respiratoria superior non specificata'}
J10.1
:
{code: 'J10.1', name: 'Influenza with other respiratory manifestations, other influenza virus codeentified', latin: 'Influenza cum aliis manifestationibus respiratoriis ab agente virali codeentificato'}
L20
:
{code: 'L20', name: 'Atopic dermatitis', latin: 'Atopic dermatitis'}
L60.1
:
{code: 'L60.1', name: 'Onycholysis', latin: 'Onycholysis'}
M24.2
:
{code: 'M24.2', name: 'Disorder of ligament', latin: 'Morbositas ligamenti'}
M51.2
:
{code: 'M51.2', name: 'Other specified intervertebral disc displacement', latin: 'Alia dislocatio disci intervertebralis specificata'}
N30.0
:
{code: 'N30.0', name: 'Acute cystitis', latin: 'Cystitis acuta'}
S03.5
:
{code: 'S03.5', name: 'Sprain and strain of joints and ligaments of other and unspecified parts of head', latin: 'Distorsio et/sive distensio articulationum et/sive…m partium aliarum sive non specificatarum capitis'}
S62.5
:
{code: 'S62.5', name: 'Fracture of thumb', latin: 'Fractura [ossis/ossium] pollicis'}
Z57.1
:
{code: 'Z57.1', name: 'Occupational exposure to radiation'}
Z74.3
:
{code: 'Z74.3', name: 'Need for continuous supervision'}
[[Prototype]]
:
Object
I have an array of codes stored in the variable below:
const codes = ['Z57.1', 'Z74.3', 'M51.2']
How would I only return the diagnoses that have the indexes listed in the variable "codes"?
Expected result would be:
Z57.1
{code: 'Z57.1', name: 'Occupational exposure to radiation'}
Z74.3
:
{code: 'Z74.3', name: 'Need for continuous supervision'}
M51.2
:
{code: 'M51.2', name: 'Other specified intervertebral disc displacement', latin: 'Alia dislocatio disci intervertebralis specificata'}
I have tried
codes.map(d => diagnoses[d]) but this didn't work.
Object.entries()to convert it to an array of[key, value]elements.Array.prototype.filter