CCDA and Other (#4382)
[openemr.git] / ccdaservice / oe-blue-button-generate / lib / entryLevel / allergyEntryLevel.js
blobc34b751544bd89c55c28f5785a1963fc6f47dd87
1 "use strict";
3 var fieldLevel = require('../fieldLevel');
4 var leafLevel = require('../leafLevel');
5 var condition = require('../condition');
6 var contentModifier = require("../contentModifier");
8 var sel = require("./sharedEntryLevel");
10 var key = contentModifier.key;
11 var required = contentModifier.required;
12 var dataKey = contentModifier.dataKey;
14 var allergyStatusObservation = {
15     key: "observation",
16     attributes: {
17         "classCode": "OBS",
18         "moodCode": "EVN"
19     },
20     content: [
21         fieldLevel.templateId("2.16.840.1.113883.10.20.22.4.28"),
22         fieldLevel.templateCode("AllergyStatusObservation"),
23         fieldLevel.statusCodeCompleted, {
24             key: "value",
25             attributes: [
26                 leafLevel.typeCE,
27                 leafLevel.code
28             ],
29             existsWhen: condition.codeOrDisplayname,
30             required: true
31         }
32     ],
33     dataKey: "status"
36 var allergyIntoleranceObservation = exports.allergyIntoleranceObservation = {
37     key: "observation",
38     attributes: {
39         "classCode": "OBS",
40         "moodCode": "EVN",
41         "negationInd": leafLevel.boolInputProperty("negation_indicator")
42     },
43     content: [
44         fieldLevel.templateIdExt("2.16.840.1.113883.10.20.22.4.7", "2014-06-09"),
45         fieldLevel.templateId("2.16.840.1.113883.10.20.22.4.7"),
46         fieldLevel.id,
47         fieldLevel.templateCode("AllergyObservation"),
48         fieldLevel.statusCodeCompleted, [fieldLevel.effectiveTime, required], {
49             key: "value",
50             attributes: [
51                 leafLevel.typeCD,
52                 leafLevel.code
53             ],
54             content: {
55                 key: "originalText",
56                 content: {
57                     key: "reference",
58                     attributes: {
59                         "value": leafLevel.nextReference("reaction")
60                     }
61                 }
62             },
63             dataKey: 'intolerance',
64             existsWhen: condition.codeOrDisplayname,
65             required: true
66         }, {
67             key: "participant",
68             attributes: {
69                 "typeCode": "CSM"
70             },
71             content: [{
72                 key: "participantRole",
73                 attributes: {
74                     "classCode": "MANU"
75                 },
76                 content: [{
77                     key: "playingEntity",
78                     attributes: {
79                         classCode: "MMAT"
80                     },
81                     content: [{
82                         key: "code",
83                         attributes: leafLevel.code,
84                         content: [{
85                             key: "originalText",
86                             content: [{
87                                 key: "reference",
88                                 attributes: {
89                                     "value": leafLevel.sameReference("reaction")
90                                 }
91                             }]
92                         }, {
93                             key: "translation",
94                             attributes: leafLevel.code,
95                             dataKey: "translations"
96                         }],
97                         require: true
98                     }]
99                 }],
100                 required: true
101             }],
102             dataKey: 'allergen'
103         }, {
104             key: "entryRelationship",
105             attributes: {
106                 "typeCode": "SUBJ",
107                 "inversionInd": "true"
108             },
109             content: [
110                 [allergyStatusObservation, required]
111             ],
112             existsWhen: condition.keyExists("status")
113         }, {
114             key: "entryRelationship",
115             attributes: {
116                 "typeCode": "MFST",
117                 "inversionInd": "true"
118             },
119             content: [
120                 [sel.reactionObservation, required]
121             ],
122             dataKey: 'reactions',
123             existsWhen: condition.keyExists('reaction')
124         }, {
125             key: "entryRelationship",
126             attributes: {
127                 "typeCode": "SUBJ",
128                 "inversionInd": "true"
129             },
130             content: [
131                 [sel.severityObservation, required]
132             ],
133             existsWhen: condition.keyExists('severity')
134         }
135     ],
136     dataKey: "observation",
137     warning: [
138         "negationInd attribute is not specified in specification"
139     ]
142 var allergyProblemAct = exports.allergyProblemAct = {
143     key: "act",
144     attributes: {
145         classCode: "ACT",
146         moodCode: "EVN"
147     },
148     content: [
149         fieldLevel.templateIdExt("2.16.840.1.113883.10.20.22.4.30", "2015-08-01"),
150         fieldLevel.templateId("2.16.840.1.113883.10.20.22.4.30"),
151         fieldLevel.uniqueId,
152         fieldLevel.id,
153         fieldLevel.templateCode("AllergyProblemAct"),
154         fieldLevel.statusCodeActive, [fieldLevel.effectiveTime, required], {
155             key: "entryRelationship",
156             attributes: {
157                 typeCode: "SUBJ",
158                 inversionInd: "true"
159             },
160             content: [allergyIntoleranceObservation, required],
161             existsWhen: condition.keyExists('observation'),
162             required: true,
163             warning: "inversionInd is not in spec"
164         }
165     ],
166     warning: "statusCode is not constant in spec"