Fixes #5576 CCDA fix null sections (#5577)
[openemr.git] / ccdaservice / oe-blue-button-generate / lib / entryLevel / procedureEntryLevel.js
blob7ff27b0761c67112ae986143b0c64cd3ce1987e2
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 sharedEntryLevel = require("./sharedEntryLevel");
10 var key = contentModifier.key;
11 var required = contentModifier.required;
12 var dataKey = contentModifier.dataKey;
14 exports.procedureActivityAct = {
15     key: "act",
16     attributes: {
17         classCode: "ACT",
18         moodCode: "INT" // not constant in the specification
19     },
20     content: [
21         fieldLevel.templateId("2.16.840.1.113883.10.20.22.4.12"),
22         fieldLevel.uniqueId,
23         fieldLevel.id, {
24             key: "code",
25             attributes: leafLevel.code,
26             content: [{
27                 key: "originalText",
28                 content: [{
29                     key: "reference",
30                     attributes: {
31                         "value": leafLevel.nextReference("procedure")
32                     }
33                 }]
34             }],
35             dataKey: "procedure",
36             required: true
37         }, {
38             key: "statusCode",
39             attributes: {
40                 code: leafLevel.inputProperty("status")
41             },
42             required: true
43         },
44         fieldLevel.effectiveTime, {
45             key: "priorityCode",
46             attributes: leafLevel.code,
47             dataKey: "priority"
48         }, {
49             key: "targetSiteCode",
50             attributes: leafLevel.code,
51             dataKey: "body_sites"
52         },
53         [fieldLevel.performer, dataKey("performer")], {
54             key: "participant",
55             attributes: {
56                 typeCode: "LOC"
57             },
58             content: [
59                 [sharedEntryLevel.serviceDeliveryLocation, required]
60             ],
61             dataKey: "locations"
62         }
63     ],
64     existsWhen: condition.propertyEquals("procedure_type", "act"),
65     toDo: ["moodCode should be variable"],
66     notImplemented: [
67         "entryRelationship:encounter",
68         "entryRelationship:indication",
69         "entryRelationship:medicationActivity"
70     ]
73 exports.procedureActivityProcedure = {
74     key: "procedure",
75     attributes: {
76         classCode: "PROC",
77         moodCode: "EVN"
78     },
79     content: [
80         fieldLevel.templateId("2.16.840.1.113883.10.20.22.4.14"),
81         fieldLevel.uniqueId,
82         fieldLevel.id, {
83             key: "code",
84             attributes: leafLevel.code,
85             content: [{
86                 key: "originalText",
87                 content: [{
88                     key: "reference",
89                     attributes: {
90                         "value": leafLevel.nextReference("procedure")
91                     }
92                 }]
93             }],
94             dataKey: "procedure",
95             required: true
96         }, {
97             key: "statusCode",
98             attributes: {
99                 code: leafLevel.inputProperty("status")
100             },
101             required: true
102         },
103         fieldLevel.effectiveTime, {
104             key: "priorityCode",
105             attributes: leafLevel.code,
106             dataKey: "priority"
107         }, {
108             key: "targetSiteCode",
109             attributes: leafLevel.code,
110             dataKey: "body_sites"
111         }, {
112             key: "specimen",
113             attributes: {
114                 typeCode: "SPC"
115             },
116             content: {
117                 key: "specimenRole",
118                 attributes: {
119                     classCode: "SPEC"
120                 },
121                 content: [
122                     fieldLevel.id, {
123                         key: "specimenPlayingEntity",
124                         content: {
125                             key: "code",
126                             attributes: leafLevel.code,
127                             dataKey: "code"
128                         },
129                         existsWhen: condition.keyExists("code")
130                     }
131                 ],
132                 required: true
133             },
134             dataKey: "specimen"
135         },
136         [fieldLevel.performer, dataKey("performer")]
137         ,fieldLevel.author
138         , {
139             key: "participant",
140             attributes: {
141                 typeCode: "LOC"
142             },
143             content: [
144                 [sharedEntryLevel.serviceDeliveryLocation, required]
145             ],
146             dataKey: "locations"
147         }
148     ],
149     existsWhen: condition.propertyEquals("procedure_type", "procedure"),
150     toDo: ["moodCode should be variable"],
151     notImplemented: [
152         "methodCode",
153         "participant:productInstance",
154         "entryRelationship:encounter",
155         "entryRelationship:instructions",
156         "entryRelationship:indication",
157         "entryRelationship:medicationActivity"
158     ]
161 exports.procedureActivityObservation = {
162     key: "observation",
163     attributes: {
164         classCode: "OBS",
165         moodCode: "EVN" // not constant in the specification
166     },
167     content: [
168         fieldLevel.templateId("2.16.840.1.113883.10.20.22.4.13"),
169         fieldLevel.uniqueId,
170         fieldLevel.id, {
171             key: "code",
172             attributes: leafLevel.code,
173             content: [{
174                 key: "originalText",
175                 content: [{
176                     key: "reference",
177                     attributes: {
178                         "value": leafLevel.nextReference("procedure")
179                     }
180                 }]
181             }],
182             dataKey: "procedure",
183             required: true
184         }, {
185             key: "statusCode",
186             attributes: {
187                 code: leafLevel.inputProperty("status")
188             },
189             required: true
190         },
191         fieldLevel.effectiveTime, {
192             key: "priorityCode",
193             attributes: leafLevel.code,
194             dataKey: "priority"
195         }, {
196             key: "value",
197             attributes: {
198                 "xsi:type": "CD"
199             }
200         }, {
201             key: "targetSiteCode",
202             attributes: leafLevel.code,
203             dataKey: "body_sites"
204         },
205         [fieldLevel.performer, dataKey("performers")], {
206             key: "participant",
207             attributes: {
208                 typeCode: "LOC"
209             },
210             content: [
211                 [sharedEntryLevel.serviceDeliveryLocation, required]
212             ],
213             dataKey: "locations"
214         }
215     ],
216     existsWhen: condition.propertyEquals("procedure_type", "observation"),
217     toDo: ["moodCode should be variable"],
218     notImplemented: [
219         "entryRelationship:encounter",
220         "entryRelationship:instructions",
221         "entryRelationship:indication",
222         "entryRelationship:medicationActivity"
223     ]