3 var fieldLevel = require('./fieldLevel');
4 var leafLevel = require('./leafLevel');
5 var condition = require('./condition');
6 var contentModifier = require("./contentModifier");
7 var translate = require("./translate");
8 var key = contentModifier.key;
9 var required = contentModifier.required;
10 var dataKey = contentModifier.dataKey;
12 var patientName = Object.create(fieldLevel.usRealmName);
13 patientName.attributes = {
17 var patient = exports.patient = {
28 text: leafLevel.inputProperty("first")
31 text: leafLevel.inputProperty("middle"),
32 existsWhen: condition.propertyNotEmpty("middle")
38 text: leafLevel.inputProperty("last")
40 dataKey: "birth_name",
41 existsWhen: condition.propertyNotEmpty("last")
43 key: "administrativeGenderCode",
45 code: function (input) {
46 if (Object.prototype.toString.call(input) === "[object String]")
47 return input.substring(0, 1);
48 else return input.code.substring(0, 1);
50 codeSystem: "2.16.840.1.113883.5.1",
51 codeSystemName: "HL7 AdministrativeGender",
52 displayName: leafLevel.input
56 [fieldLevel.effectiveTime, key("birthTime"), dataKey("dob")], {
57 key: "maritalStatusCode",
59 code: function (input) {
60 if (Object.prototype.toString.call(input) === "[object String]") {
61 return input.substring(0, 1);
63 return input.code.substring(0, 1);
66 displayName: leafLevel.input,
67 codeSystem: "2.16.840.1.113883.5.2",
68 codeSystemName: "HL7 Marital Status"
70 dataKey: "marital_status",
72 key: "religiousAffiliationCode",
73 attributes: leafLevel.codeFromName("2.16.840.1.113883.5.1076"),
77 attributes: leafLevel.codeFromName("2.16.840.1.113883.6.238"),
81 attributes: leafLevel.codeFromName("2.16.840.1.113883.6.238"),
82 dataKey: "race_additional"
84 key: "ethnicGroupCode",
85 attributes: leafLevel.codeFromName("2.16.840.1.113883.6.238"),
91 attributes: leafLevel.codeFromName("2.16.840.1.113883.5.111"),
94 [fieldLevel.usRealmAddress, dataKey("addresses")],
96 key: "guardianPerson",
101 text: leafLevel.inputProperty("first")
104 text: leafLevel.inputProperty("last")
116 [fieldLevel.usRealmAddress, dataKey("birthplace")]
119 existsWhen: condition.keyExists("birthplace")
121 key: "languageCommunication",
125 code: leafLevel.input
130 attributes: leafLevel.codeFromName("2.16.840.1.113883.5.60"),
133 key: "proficiencyLevelCode",
135 code: function (input) {
136 if (Object.prototype.toString.call(input) === "[object String]")
137 return input.substring(0, 1);
138 else return input.code.substring(0, 1);
140 displayName: leafLevel.input,
141 codeSystem: "2.16.840.1.113883.5.61",
142 codeSystemName: "LanguageAbilityProficiency"
144 dataKey: "proficiency"
146 key: "preferenceInd",
148 value: function (input) {
149 return input.toString();
159 var provider = exports.provider = [{
169 "displayName": "Primary Performer",
170 "codeSystem": "2.16.840.1.113883.12.443",
171 "codeSystemName": "Provider Role"
173 existsWhen: condition.propertyNotEmpty('function_code'),
174 content: [{key: "originalText", text: "Primary Care Provider"}]
177 key: "assignedEntity",
181 root: leafLevel.inputProperty("root"),
182 extension: leafLevel.inputProperty("extension")
187 attributes: leafLevel.code,
188 content: [{key: "originalText", text: "Care Team Member"}],
191 fieldLevel.usRealmAddress,
194 key: "assignedPerson",
195 content: fieldLevel.usRealmName
200 dataKey: "providers.provider"
203 var providers = exports.providers = {
204 key: "documentationOf",
216 attributes: leafLevel.code,
217 existsWhen: condition.propertyNotEmpty('code'),
218 dataKey: "providers.code"
220 [fieldLevel.effectiveTime, key("effectiveTime"), dataKey("providers.date_time"), required],
224 dataKey: "data.demographics"
227 var participants = (exports.participant = [
231 typeCode: leafLevel.inputProperty("typeCode"),
233 // TODO: check if this middle element can be removed
234 /* eslint-disable-next-line no-sparse-arrays */
236 [fieldLevel.effectiveTime, required, key("time")],
239 fieldLevel.associatedEntity,
241 dataKey: "meta.ccda_header.participants",
245 var attributed_provider = exports.attributed_provider = {
246 key: "providerOrganization",
250 root: leafLevel.inputProperty("root"),
251 extension: leafLevel.inputProperty("extension")
256 text: leafLevel.inputProperty("full"),
262 value: function (input) {
270 use: leafLevel.use("use")
274 text: leafLevel.inputProperty("country")
277 text: leafLevel.inputProperty("state")
280 text: leafLevel.inputProperty("city")
283 text: leafLevel.inputProperty("zip")
285 key: "streetAddressLine",
286 text: leafLevel.input,
287 dataKey: "street_lines"
291 dataKey: "attributed_provider"
294 var recordTarget = exports.recordTarget = {
299 fieldLevel.id, [fieldLevel.usRealmAddress, dataKey("addresses")],
305 dataKey: "data.demographics"
308 var headerAuthor = exports.headerAuthor = {
311 [fieldLevel.effectiveTime, required, key("time")],
313 key: "assignedAuthor",
317 root: leafLevel.inputProperty("identifier"),
318 extension: leafLevel.inputProperty("extension")
320 dataKey: 'identifiers',
323 attributes: leafLevel.code,
324 existsWhen: condition.propertyNotEmpty('code'),
329 use: leafLevel.use("use")
333 text: leafLevel.inputProperty("country")
336 text: leafLevel.inputProperty("state")
339 text: leafLevel.inputProperty("city")
342 text: leafLevel.inputProperty("zip")
344 key: "streetAddressLine",
345 text: leafLevel.input,
346 dataKey: "street_lines"
352 value: leafLevel.inputProperty("value"),
353 use: leafLevel.inputProperty("use")
355 dataTransform: translate.telecom
357 key: "assignedPerson",
363 text: leafLevel.inputProperty("family")
366 text: leafLevel.input,
370 text: leafLevel.inputProperty("prefix")
373 text: leafLevel.inputProperty("suffix")
376 dataTransform: translate.name
379 key: "representedOrganization",
384 root: leafLevel.inputProperty("root")
389 text: leafLevel.input,
394 value: leafLevel.inputProperty("value"),
395 use: leafLevel.inputProperty("use")
397 dataTransform: translate.telecom,
403 use: leafLevel.use("use")
407 text: leafLevel.inputProperty("country")
410 text: leafLevel.inputProperty("state")
413 text: leafLevel.inputProperty("city")
416 text: leafLevel.inputProperty("zip")
418 key: "streetAddressLine",
419 text: leafLevel.input,
420 dataKey: "street_lines"
425 dataKey: "organization"
430 dataKey: "meta.ccda_header.author"
432 var headerInformant = exports.headerInformant = {
435 key: "assignedEntity",
440 root: leafLevel.inputProperty("identifier")
442 dataKey: "identifiers"
445 key: "representedOrganization",
449 root: leafLevel.inputProperty("identifier")
451 dataKey: "identifiers"
454 text: leafLevel.inputProperty("name"),
459 dataKey: "meta.ccda_header.informant"
461 var headerCustodian = exports.headerCustodian = {
464 key: "assignedCustodian",
467 key: "representedCustodianOrganization",
472 root: leafLevel.inputProperty("root"),
473 extension: leafLevel.inputProperty("extension")
478 text: leafLevel.input,
484 value: leafLevel.inputProperty("value"),
485 use: leafLevel.inputProperty("use")
487 dataTransform: translate.telecom,
493 use: leafLevel.use("use")
497 text: leafLevel.inputProperty("country")
500 text: leafLevel.inputProperty("state")
503 text: leafLevel.inputProperty("city")
506 text: leafLevel.inputProperty("zip")
508 key: "streetAddressLine",
509 text: leafLevel.input,
510 dataKey: "street_lines"
517 dataKey: "meta.ccda_header.custodian"
519 var headerInformationRecipient = exports.headerInformationRecipient = {
520 key: "informationRecipient",
522 key: "intendedRecipient",
524 key: "informationRecipient",
530 text: leafLevel.inputProperty("family")
533 text: leafLevel.input,
537 text: leafLevel.inputProperty("prefix")
540 text: leafLevel.inputProperty("suffix")
543 dataTransform: translate.name,
547 key: "receivedOrganization",
550 text: leafLevel.inputProperty("name"),
551 dataKey: "organization"
555 dataKey: "meta.ccda_header.information_recipient"
559 key: "receivedOrganization",
562 text: leafLevel.inputProperty("name"),
563 dataKey: "organization"
567 var headerComponentOf = exports.headerComponentOf = {
570 key: "encompassingEncounter",
575 attributes: leafLevel.code,
576 existsWhen: condition.propertyNotEmpty('code'),
579 [fieldLevel.effectiveTime, key("effectiveTime"), dataKey("date_time"), required],
580 fieldLevel.responsibleParty,
582 key: "encounterParticipant",
587 key: "assignedEntity",
591 root: leafLevel.inputProperty("root")
594 , fieldLevel.usRealmAddress
597 key: "assignedPerson",
598 content: fieldLevel.usRealmName
601 dataKey: "encounter_participant",
602 existsWhen: condition.propertyValueNotEmpty("name.last")
606 dataKey: "meta.ccda_header.component_of"