gdc-common-utils-ts 2.0.11 → 2.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/dist/examples/employee.d.ts +9 -1
- package/dist/examples/employee.js +7 -4
- package/dist/examples/shared.d.ts +1 -1
- package/dist/examples/shared.js +6 -2
- package/dist/models/consent-rule.d.ts +2 -2
- package/dist/models/consent-rule.js +1 -1
- package/dist/utils/actor.d.ts +3 -1
- package/package.json +1 -5
- package/dist/examples/communication-bundle-session.d.ts +0 -22
- package/dist/examples/communication-bundle-session.js +0 -79
- package/dist/interfaces/IWallet.d.ts +0 -55
- package/dist/interfaces/IWallet.js +0 -3
- package/dist/models/fhir-related-person.d.ts +0 -61
- package/dist/models/fhir-related-person.js +0 -108
- package/dist/models/related-profile.d.ts +0 -42
- package/dist/models/related-profile.js +0 -16
- package/dist/utils/allergy-intolerance-claim-helpers.d.ts +0 -10
- package/dist/utils/allergy-intolerance-claim-helpers.js +0 -47
- package/dist/utils/appointment-claim-helpers.d.ts +0 -10
- package/dist/utils/appointment-claim-helpers.js +0 -26
- package/dist/utils/appointment-response-claim-helpers.d.ts +0 -8
- package/dist/utils/appointment-response-claim-helpers.js +0 -20
- package/dist/utils/claim-list-helpers.d.ts +0 -21
- package/dist/utils/claim-list-helpers.js +0 -50
- package/dist/utils/clinical-impression-claim-helpers.d.ts +0 -10
- package/dist/utils/clinical-impression-claim-helpers.js +0 -26
- package/dist/utils/communication-bundle-session.d.ts +0 -175
- package/dist/utils/communication-bundle-session.js +0 -524
- package/dist/utils/composition-claim-helpers.d.ts +0 -12
- package/dist/utils/composition-claim-helpers.js +0 -32
- package/dist/utils/condition-claim-helpers.d.ts +0 -10
- package/dist/utils/condition-claim-helpers.js +0 -47
- package/dist/utils/convert-allergy-intolerance.d.ts +0 -3
- package/dist/utils/convert-allergy-intolerance.js +0 -34
- package/dist/utils/convert-appointment-response.d.ts +0 -3
- package/dist/utils/convert-appointment-response.js +0 -32
- package/dist/utils/convert-appointment.d.ts +0 -3
- package/dist/utils/convert-appointment.js +0 -61
- package/dist/utils/convert-care-plan.d.ts +0 -3
- package/dist/utils/convert-care-plan.js +0 -58
- package/dist/utils/convert-clinical-impression.d.ts +0 -3
- package/dist/utils/convert-clinical-impression.js +0 -42
- package/dist/utils/convert-composition.d.ts +0 -3
- package/dist/utils/convert-composition.js +0 -35
- package/dist/utils/convert-condition.d.ts +0 -3
- package/dist/utils/convert-condition.js +0 -24
- package/dist/utils/convert-coverage.d.ts +0 -3
- package/dist/utils/convert-coverage.js +0 -51
- package/dist/utils/convert-device-use-statement.d.ts +0 -3
- package/dist/utils/convert-device-use-statement.js +0 -28
- package/dist/utils/convert-device.d.ts +0 -3
- package/dist/utils/convert-device.js +0 -37
- package/dist/utils/convert-diagnostic-report.d.ts +0 -3
- package/dist/utils/convert-diagnostic-report.js +0 -55
- package/dist/utils/convert-document-reference.d.ts +0 -3
- package/dist/utils/convert-document-reference.js +0 -35
- package/dist/utils/convert-encounter.d.ts +0 -3
- package/dist/utils/convert-encounter.js +0 -68
- package/dist/utils/convert-flag.d.ts +0 -3
- package/dist/utils/convert-flag.js +0 -34
- package/dist/utils/convert-immunization.d.ts +0 -3
- package/dist/utils/convert-immunization.js +0 -56
- package/dist/utils/convert-medication-statement.d.ts +0 -3
- package/dist/utils/convert-medication-statement.js +0 -64
- package/dist/utils/convert-observation.d.ts +0 -3
- package/dist/utils/convert-observation.js +0 -57
- package/dist/utils/convert-procedure.d.ts +0 -3
- package/dist/utils/convert-procedure.js +0 -50
- package/dist/utils/convert-related-person.d.ts +0 -3
- package/dist/utils/convert-related-person.js +0 -31
- package/dist/utils/convert-shared.d.ts +0 -34
- package/dist/utils/convert-shared.js +0 -179
- package/dist/utils/coverage-claim-helpers.d.ts +0 -10
- package/dist/utils/coverage-claim-helpers.js +0 -26
- package/dist/utils/diagnostic-report-claim-helpers.d.ts +0 -12
- package/dist/utils/diagnostic-report-claim-helpers.js +0 -32
- package/dist/utils/employee-editor.d.ts +0 -24
- package/dist/utils/employee-editor.js +0 -41
- package/dist/utils/encounter-claim-helpers.d.ts +0 -10
- package/dist/utils/encounter-claim-helpers.js +0 -26
- package/dist/utils/gateway-index-params.d.ts +0 -44
- package/dist/utils/gateway-index-params.js +0 -80
- package/dist/utils/medication-claim-helpers.d.ts +0 -88
- package/dist/utils/medication-claim-helpers.js +0 -259
- package/dist/utils/normalize-subject-uuid.d.ts +0 -1
- package/dist/utils/normalize-subject-uuid.js +0 -24
- package/dist/utils/related-person-claim-helpers.d.ts +0 -8
- package/dist/utils/related-person-claim-helpers.js +0 -20
- package/dist/utils/search-parameter-catalog.d.ts +0 -31
- package/dist/utils/search-parameter-catalog.js +0 -81
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Conéctate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
|
|
2
|
-
// File: src/utils/convert-appointment-response.ts
|
|
3
|
-
import { AppointmentResponseClaim } from '../models/interoperable-claims/appointment-response-claims.js';
|
|
4
|
-
import { codingFromValue, codingToValue, referenceToValue } from './convert-shared.js';
|
|
5
|
-
export function appointmentResponseFlatToFhirR4(claims) {
|
|
6
|
-
return {
|
|
7
|
-
resourceType: 'AppointmentResponse',
|
|
8
|
-
identifier: claims[AppointmentResponseClaim.Identifier] ? [{ value: claims[AppointmentResponseClaim.Identifier] }] : undefined,
|
|
9
|
-
appointment: claims[AppointmentResponseClaim.Appointment] ? { reference: claims[AppointmentResponseClaim.Appointment] } : undefined,
|
|
10
|
-
actor: claims[AppointmentResponseClaim.Actor] ? { reference: claims[AppointmentResponseClaim.Actor] } : undefined,
|
|
11
|
-
participantStatus: claims[AppointmentResponseClaim.ParticipantStatus],
|
|
12
|
-
participantType: claims[AppointmentResponseClaim.ParticipantType] ? [{ coding: codingFromValue(claims[AppointmentResponseClaim.ParticipantType]) }] : undefined,
|
|
13
|
-
start: claims[AppointmentResponseClaim.Start],
|
|
14
|
-
end: claims[AppointmentResponseClaim.End],
|
|
15
|
-
comment: claims[AppointmentResponseClaim.Comment],
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export function appointmentResponseFhirR4ToFlat(resource) {
|
|
19
|
-
return {
|
|
20
|
-
[AppointmentResponseClaim.Actor]: referenceToValue(resource.actor),
|
|
21
|
-
[AppointmentResponseClaim.Appointment]: referenceToValue(resource.appointment),
|
|
22
|
-
[AppointmentResponseClaim.Comment]: resource.comment,
|
|
23
|
-
[AppointmentResponseClaim.Identifier]: resource.identifier?.[0]?.value,
|
|
24
|
-
[AppointmentResponseClaim.Start]: resource.start,
|
|
25
|
-
[AppointmentResponseClaim.End]: resource.end,
|
|
26
|
-
[AppointmentResponseClaim.ParticipantType]: codingToValue(resource.participantType?.[0]?.coding?.[0]),
|
|
27
|
-
[AppointmentResponseClaim.ParticipantStatus]: resource.participantStatus,
|
|
28
|
-
[AppointmentResponseClaim.Patient]: undefined,
|
|
29
|
-
[AppointmentResponseClaim.Practitioner]: undefined,
|
|
30
|
-
[AppointmentResponseClaim.Location]: undefined,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Conéctate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
|
|
2
|
-
// File: src/utils/convert-appointment.ts
|
|
3
|
-
import { AppointmentClaim } from '../models/interoperable-claims/appointment-claims.js';
|
|
4
|
-
import { codingFromValue, codingToValue, referenceListToCsv, referenceToValue } from './convert-shared.js';
|
|
5
|
-
export function appointmentFlatToFhirR4(claims) {
|
|
6
|
-
return {
|
|
7
|
-
resourceType: 'Appointment',
|
|
8
|
-
identifier: claims[AppointmentClaim.Identifier] ? [{ value: claims[AppointmentClaim.Identifier] }] : undefined,
|
|
9
|
-
status: claims[AppointmentClaim.Status],
|
|
10
|
-
serviceCategory: claims[AppointmentClaim.ServiceCategory] ? [{ coding: codingFromValue(claims[AppointmentClaim.ServiceCategory]) }] : undefined,
|
|
11
|
-
serviceType: claims[AppointmentClaim.ServiceType] ? [{ coding: codingFromValue(claims[AppointmentClaim.ServiceType]) }] : undefined,
|
|
12
|
-
specialty: claims[AppointmentClaim.Specialty] ? [{ coding: codingFromValue(claims[AppointmentClaim.Specialty]) }] : undefined,
|
|
13
|
-
appointmentType: claims[AppointmentClaim.AppointmentType] ? { coding: codingFromValue(claims[AppointmentClaim.AppointmentType]) } : undefined,
|
|
14
|
-
reasonCode: claims[AppointmentClaim.ReasonCode] ? [{ coding: codingFromValue(claims[AppointmentClaim.ReasonCode]) }] : undefined,
|
|
15
|
-
reasonReference: claims[AppointmentClaim.ReasonReference] ? claims[AppointmentClaim.ReasonReference].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
16
|
-
description: claims[AppointmentClaim.Description],
|
|
17
|
-
start: claims[AppointmentClaim.Start],
|
|
18
|
-
end: claims[AppointmentClaim.End],
|
|
19
|
-
minutesDuration: claims[AppointmentClaim.MinutesDuration] ? Number(claims[AppointmentClaim.MinutesDuration]) : undefined,
|
|
20
|
-
created: claims[AppointmentClaim.Created],
|
|
21
|
-
note: claims[AppointmentClaim.NoteText] ? [{ text: claims[AppointmentClaim.NoteText] }] : undefined,
|
|
22
|
-
patientInstruction: claims[AppointmentClaim.PatientInstruction],
|
|
23
|
-
basedOn: claims[AppointmentClaim.BasedOn] ? claims[AppointmentClaim.BasedOn].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
24
|
-
participant: claims[AppointmentClaim.ParticipantActor]
|
|
25
|
-
? claims[AppointmentClaim.ParticipantActor].split(',').map((reference) => ({
|
|
26
|
-
actor: { reference: reference.trim() },
|
|
27
|
-
status: claims[AppointmentClaim.ParticipantStatus],
|
|
28
|
-
type: claims[AppointmentClaim.ParticipantType] ? [{ coding: codingFromValue(claims[AppointmentClaim.ParticipantType]) }] : undefined,
|
|
29
|
-
}))
|
|
30
|
-
: undefined,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export function appointmentFhirR4ToFlat(resource) {
|
|
34
|
-
const participant = Array.isArray(resource.participant) ? resource.participant[0] : undefined;
|
|
35
|
-
return {
|
|
36
|
-
[AppointmentClaim.Identifier]: resource.identifier?.[0]?.value,
|
|
37
|
-
[AppointmentClaim.Status]: resource.status,
|
|
38
|
-
[AppointmentClaim.ServiceCategory]: codingToValue(resource.serviceCategory?.[0]?.coding?.[0]),
|
|
39
|
-
[AppointmentClaim.ServiceType]: codingToValue(resource.serviceType?.[0]?.coding?.[0]),
|
|
40
|
-
[AppointmentClaim.Specialty]: codingToValue(resource.specialty?.[0]?.coding?.[0]),
|
|
41
|
-
[AppointmentClaim.AppointmentType]: codingToValue(resource.appointmentType?.coding?.[0]),
|
|
42
|
-
[AppointmentClaim.ReasonCode]: codingToValue(resource.reasonCode?.[0]?.coding?.[0]),
|
|
43
|
-
[AppointmentClaim.ReasonReference]: referenceListToCsv(resource.reasonReference),
|
|
44
|
-
[AppointmentClaim.Description]: resource.description,
|
|
45
|
-
[AppointmentClaim.Start]: resource.start,
|
|
46
|
-
[AppointmentClaim.End]: resource.end,
|
|
47
|
-
[AppointmentClaim.MinutesDuration]: resource.minutesDuration === undefined ? undefined : String(resource.minutesDuration),
|
|
48
|
-
[AppointmentClaim.Created]: resource.created,
|
|
49
|
-
[AppointmentClaim.NoteText]: resource.note?.[0]?.text,
|
|
50
|
-
[AppointmentClaim.PatientInstruction]: resource.patientInstruction,
|
|
51
|
-
[AppointmentClaim.BasedOn]: referenceListToCsv(resource.basedOn),
|
|
52
|
-
[AppointmentClaim.ParticipantActor]: Array.isArray(resource.participant)
|
|
53
|
-
? resource.participant
|
|
54
|
-
.map((item) => referenceToValue(item?.actor))
|
|
55
|
-
.filter((item) => Boolean(item))
|
|
56
|
-
.join(',')
|
|
57
|
-
: undefined,
|
|
58
|
-
[AppointmentClaim.ParticipantStatus]: participant?.status,
|
|
59
|
-
[AppointmentClaim.ParticipantType]: codingToValue(participant?.type?.[0]?.coding?.[0]),
|
|
60
|
-
};
|
|
61
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Conéctate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
|
|
2
|
-
// File: src/utils/convert-care-plan.ts
|
|
3
|
-
import { CarePlanClaim } from '../models/interoperable-claims/care-plan-claims.js';
|
|
4
|
-
import { codingFromValue, codingToValue, referenceListToCsv, referenceToValue } from './convert-shared.js';
|
|
5
|
-
export function carePlanFlatToFhirR4(claims) {
|
|
6
|
-
const subject = claims[CarePlanClaim.Subject] ?? claims[CarePlanClaim.Patient];
|
|
7
|
-
return {
|
|
8
|
-
resourceType: 'CarePlan',
|
|
9
|
-
identifier: claims[CarePlanClaim.Identifier] ? [{ value: claims[CarePlanClaim.Identifier] }] : undefined,
|
|
10
|
-
status: claims[CarePlanClaim.Status],
|
|
11
|
-
intent: claims[CarePlanClaim.Intent],
|
|
12
|
-
subject: subject ? { reference: subject } : undefined,
|
|
13
|
-
category: claims[CarePlanClaim.Category] ? [{ coding: codingFromValue(claims[CarePlanClaim.Category]) }] : undefined,
|
|
14
|
-
created: claims[CarePlanClaim.Date],
|
|
15
|
-
note: claims[CarePlanClaim.Note] ? [{ text: claims[CarePlanClaim.Note] }] : undefined,
|
|
16
|
-
basedOn: claims[CarePlanClaim.BasedOn] ? claims[CarePlanClaim.BasedOn].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
17
|
-
careTeam: claims[CarePlanClaim.CareTeam] ? claims[CarePlanClaim.CareTeam].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
18
|
-
addresses: claims[CarePlanClaim.Condition] ? claims[CarePlanClaim.Condition].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
19
|
-
encounter: claims[CarePlanClaim.Encounter] ? { reference: claims[CarePlanClaim.Encounter] } : undefined,
|
|
20
|
-
goal: claims[CarePlanClaim.Goal] ? claims[CarePlanClaim.Goal].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
21
|
-
partOf: claims[CarePlanClaim.PartOf] ? claims[CarePlanClaim.PartOf].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
22
|
-
replaces: claims[CarePlanClaim.Replaces] ? claims[CarePlanClaim.Replaces].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
23
|
-
activity: (claims[CarePlanClaim.ActivityCode] || claims[CarePlanClaim.ActivityDate] || claims[CarePlanClaim.ActivityReference] || claims[CarePlanClaim.Performer]) ? [{
|
|
24
|
-
reference: claims[CarePlanClaim.ActivityReference] ? { reference: claims[CarePlanClaim.ActivityReference] } : undefined,
|
|
25
|
-
detail: {
|
|
26
|
-
code: claims[CarePlanClaim.ActivityCode] ? { coding: codingFromValue(claims[CarePlanClaim.ActivityCode]) } : undefined,
|
|
27
|
-
scheduledString: claims[CarePlanClaim.ActivityDate],
|
|
28
|
-
performer: claims[CarePlanClaim.Performer] ? claims[CarePlanClaim.Performer].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
29
|
-
},
|
|
30
|
-
}] : undefined,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export function carePlanFhirR4ToFlat(resource) {
|
|
34
|
-
const activity = Array.isArray(resource.activity) ? resource.activity[0] : undefined;
|
|
35
|
-
const detail = activity?.detail;
|
|
36
|
-
const period = resource.period;
|
|
37
|
-
return {
|
|
38
|
-
[CarePlanClaim.ActivityCode]: codingToValue(detail?.code?.coding?.[0]),
|
|
39
|
-
[CarePlanClaim.ActivityDate]: detail?.scheduledString,
|
|
40
|
-
[CarePlanClaim.ActivityReference]: referenceToValue(activity?.reference),
|
|
41
|
-
[CarePlanClaim.BasedOn]: referenceListToCsv(resource.basedOn),
|
|
42
|
-
[CarePlanClaim.CareTeam]: referenceListToCsv(resource.careTeam),
|
|
43
|
-
[CarePlanClaim.Category]: codingToValue(resource.category?.[0]?.coding?.[0]),
|
|
44
|
-
[CarePlanClaim.Condition]: referenceListToCsv(resource.addresses),
|
|
45
|
-
[CarePlanClaim.Date]: resource.created || period?.start,
|
|
46
|
-
[CarePlanClaim.Encounter]: referenceToValue(resource.encounter),
|
|
47
|
-
[CarePlanClaim.Goal]: referenceListToCsv(resource.goal),
|
|
48
|
-
[CarePlanClaim.Identifier]: resource.identifier?.[0]?.value,
|
|
49
|
-
[CarePlanClaim.Intent]: resource.intent,
|
|
50
|
-
[CarePlanClaim.PartOf]: referenceListToCsv(resource.partOf),
|
|
51
|
-
[CarePlanClaim.Patient]: referenceToValue(resource.subject),
|
|
52
|
-
[CarePlanClaim.Performer]: referenceListToCsv(detail?.performer),
|
|
53
|
-
[CarePlanClaim.Replaces]: referenceListToCsv(resource.replaces),
|
|
54
|
-
[CarePlanClaim.Status]: resource.status,
|
|
55
|
-
[CarePlanClaim.Subject]: referenceToValue(resource.subject),
|
|
56
|
-
[CarePlanClaim.Note]: resource.note?.[0]?.text,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Conéctate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
|
|
2
|
-
// File: src/utils/convert-clinical-impression.ts
|
|
3
|
-
import { ClinicalImpressionClaim } from '../models/interoperable-claims/clinical-impression-claims.js';
|
|
4
|
-
import { codingFromValue, codingToValue, referenceListToCsv, referenceToValue } from './convert-shared.js';
|
|
5
|
-
export function clinicalImpressionFlatToFhirR4(claims) {
|
|
6
|
-
return {
|
|
7
|
-
resourceType: 'ClinicalImpression',
|
|
8
|
-
identifier: claims[ClinicalImpressionClaim.Identifier] ? [{ value: claims[ClinicalImpressionClaim.Identifier] }] : undefined,
|
|
9
|
-
status: claims[ClinicalImpressionClaim.Status],
|
|
10
|
-
description: claims[ClinicalImpressionClaim.Description],
|
|
11
|
-
subject: claims[ClinicalImpressionClaim.Subject] ? { reference: claims[ClinicalImpressionClaim.Subject] } : undefined,
|
|
12
|
-
encounter: claims[ClinicalImpressionClaim.Encounter] ? { reference: claims[ClinicalImpressionClaim.Encounter] } : undefined,
|
|
13
|
-
effectiveDateTime: claims[ClinicalImpressionClaim.EffectiveDateTime],
|
|
14
|
-
date: claims[ClinicalImpressionClaim.Date],
|
|
15
|
-
assessor: claims[ClinicalImpressionClaim.Assessor] ? { reference: claims[ClinicalImpressionClaim.Assessor] } : undefined,
|
|
16
|
-
problem: claims[ClinicalImpressionClaim.Problem] ? claims[ClinicalImpressionClaim.Problem].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
17
|
-
finding: claims[ClinicalImpressionClaim.Finding] ? claims[ClinicalImpressionClaim.Finding].split(',').map((reference) => ({ itemReference: { reference: reference.trim() } })) : undefined,
|
|
18
|
-
prognosisCodeableConcept: claims[ClinicalImpressionClaim.PrognosisCode] ? [{ coding: codingFromValue(claims[ClinicalImpressionClaim.PrognosisCode]) }] : undefined,
|
|
19
|
-
summary: claims[ClinicalImpressionClaim.Summary],
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export function clinicalImpressionFhirR4ToFlat(resource) {
|
|
23
|
-
return {
|
|
24
|
-
[ClinicalImpressionClaim.Identifier]: resource.identifier?.[0]?.value,
|
|
25
|
-
[ClinicalImpressionClaim.Status]: resource.status,
|
|
26
|
-
[ClinicalImpressionClaim.Description]: resource.description,
|
|
27
|
-
[ClinicalImpressionClaim.Subject]: referenceToValue(resource.subject),
|
|
28
|
-
[ClinicalImpressionClaim.Encounter]: referenceToValue(resource.encounter),
|
|
29
|
-
[ClinicalImpressionClaim.EffectiveDateTime]: resource.effectiveDateTime,
|
|
30
|
-
[ClinicalImpressionClaim.Date]: resource.date,
|
|
31
|
-
[ClinicalImpressionClaim.Assessor]: referenceToValue(resource.assessor),
|
|
32
|
-
[ClinicalImpressionClaim.Problem]: referenceListToCsv(resource.problem),
|
|
33
|
-
[ClinicalImpressionClaim.Finding]: Array.isArray(resource.finding)
|
|
34
|
-
? resource.finding
|
|
35
|
-
.map((item) => referenceToValue(item?.itemReference))
|
|
36
|
-
.filter((item) => Boolean(item))
|
|
37
|
-
.join(',')
|
|
38
|
-
: undefined,
|
|
39
|
-
[ClinicalImpressionClaim.PrognosisCode]: codingToValue(resource.prognosisCodeableConcept?.[0]?.coding?.[0]),
|
|
40
|
-
[ClinicalImpressionClaim.Summary]: resource.summary,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Conéctate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
|
|
2
|
-
// File: src/utils/convert-composition.ts
|
|
3
|
-
import { CompositionClaim } from '../models/interoperable-claims/composition-claims.js';
|
|
4
|
-
import { codingFromValue, codingToValue, referenceListToCsv, referenceToValue } from './convert-shared.js';
|
|
5
|
-
export function compositionFlatToFhirR4(claims) {
|
|
6
|
-
return {
|
|
7
|
-
resourceType: 'Composition',
|
|
8
|
-
identifier: claims[CompositionClaim.Identifier] ? { value: claims[CompositionClaim.Identifier] } : undefined,
|
|
9
|
-
subject: claims[CompositionClaim.Subject] ? { reference: claims[CompositionClaim.Subject] } : undefined,
|
|
10
|
-
author: claims[CompositionClaim.Author] ? claims[CompositionClaim.Author].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
11
|
-
date: claims[CompositionClaim.Date],
|
|
12
|
-
title: claims[CompositionClaim.Title],
|
|
13
|
-
type: claims[CompositionClaim.Type] ? { coding: codingFromValue(claims[CompositionClaim.Type]) } : undefined,
|
|
14
|
-
section: claims[CompositionClaim.Section]
|
|
15
|
-
? claims[CompositionClaim.Section].split(',').map((value) => ({ code: { coding: codingFromValue(value.trim()) } }))
|
|
16
|
-
: undefined,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export function compositionFhirR4ToFlat(resource) {
|
|
20
|
-
const sectionValues = Array.isArray(resource.section)
|
|
21
|
-
? resource.section
|
|
22
|
-
.map((item) => codingToValue(item?.code?.coding?.[0]))
|
|
23
|
-
.filter((item) => Boolean(item))
|
|
24
|
-
: [];
|
|
25
|
-
return {
|
|
26
|
-
[CompositionClaim.Subject]: referenceToValue(resource.subject),
|
|
27
|
-
[CompositionClaim.Section]: sectionValues.length ? sectionValues.join(',') : undefined,
|
|
28
|
-
[CompositionClaim.Author]: referenceListToCsv(resource.author),
|
|
29
|
-
[CompositionClaim.Date]: resource.date,
|
|
30
|
-
[CompositionClaim.Entry]: undefined,
|
|
31
|
-
[CompositionClaim.Type]: codingToValue(resource.type?.coding?.[0]),
|
|
32
|
-
[CompositionClaim.Identifier]: resource.identifier?.value,
|
|
33
|
-
[CompositionClaim.Title]: resource.title,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Conéctate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
|
|
2
|
-
// File: src/utils/convert-condition.ts
|
|
3
|
-
import { ConditionClaim } from '../models/interoperable-claims/condition-claims.js';
|
|
4
|
-
import { codingFromValue, codingToValue, requireClaim } from './convert-shared.js';
|
|
5
|
-
export function conditionFlatToFhirR4(claims) {
|
|
6
|
-
const subject = requireClaim(claims, ConditionClaim.Subject);
|
|
7
|
-
return {
|
|
8
|
-
resourceType: 'Condition',
|
|
9
|
-
identifier: claims[ConditionClaim.Identifier] ? [{ value: claims[ConditionClaim.Identifier] }] : undefined,
|
|
10
|
-
subject: { reference: subject },
|
|
11
|
-
code: claims[ConditionClaim.Code] ? { coding: codingFromValue(claims[ConditionClaim.Code]) } : undefined,
|
|
12
|
-
clinicalStatus: claims[ConditionClaim.ClinicalStatus] ? { coding: [{ code: claims[ConditionClaim.ClinicalStatus] }] } : undefined,
|
|
13
|
-
verificationStatus: claims[ConditionClaim.VerificationStatus] ? { coding: [{ code: claims[ConditionClaim.VerificationStatus] }] } : undefined,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export function conditionFhirR4ToFlat(resource) {
|
|
17
|
-
return {
|
|
18
|
-
[ConditionClaim.Identifier]: resource.identifier?.[0]?.value,
|
|
19
|
-
[ConditionClaim.Subject]: resource.subject?.reference,
|
|
20
|
-
[ConditionClaim.Code]: codingToValue(resource.code?.coding?.[0]),
|
|
21
|
-
[ConditionClaim.ClinicalStatus]: resource.clinicalStatus?.coding?.[0]?.code,
|
|
22
|
-
[ConditionClaim.VerificationStatus]: resource.verificationStatus?.coding?.[0]?.code,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Conéctate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
|
|
2
|
-
// File: src/utils/convert-coverage.ts
|
|
3
|
-
import { CoverageClaim } from '../models/interoperable-claims/coverage-claims.js';
|
|
4
|
-
import { codingFromValue, codingToValue, referenceListToCsv, referenceToValue } from './convert-shared.js';
|
|
5
|
-
export function coverageFlatToFhirR4(claims) {
|
|
6
|
-
return {
|
|
7
|
-
resourceType: 'Coverage',
|
|
8
|
-
identifier: claims[CoverageClaim.Identifier] ? [{ value: claims[CoverageClaim.Identifier] }] : undefined,
|
|
9
|
-
status: claims[CoverageClaim.Status],
|
|
10
|
-
type: claims[CoverageClaim.Type] ? { coding: codingFromValue(claims[CoverageClaim.Type]) } : undefined,
|
|
11
|
-
policyHolder: claims[CoverageClaim.PolicyHolder] ? { reference: claims[CoverageClaim.PolicyHolder] } : undefined,
|
|
12
|
-
subscriber: claims[CoverageClaim.Subscriber] ? { reference: claims[CoverageClaim.Subscriber] } : undefined,
|
|
13
|
-
beneficiary: claims[CoverageClaim.Beneficiary] ? { reference: claims[CoverageClaim.Beneficiary] } : undefined,
|
|
14
|
-
relationship: claims[CoverageClaim.Relationship] ? { coding: codingFromValue(claims[CoverageClaim.Relationship]) } : undefined,
|
|
15
|
-
period: (claims[CoverageClaim.PeriodStart] || claims[CoverageClaim.PeriodEnd]) ? {
|
|
16
|
-
start: claims[CoverageClaim.PeriodStart],
|
|
17
|
-
end: claims[CoverageClaim.PeriodEnd],
|
|
18
|
-
} : undefined,
|
|
19
|
-
payor: claims[CoverageClaim.Payor] ? claims[CoverageClaim.Payor].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
20
|
-
class: claims[CoverageClaim.Class]
|
|
21
|
-
? claims[CoverageClaim.Class].split(',').map((value) => {
|
|
22
|
-
const [type, val] = value.trim().split('|');
|
|
23
|
-
return { type: { text: type }, value: val ?? type };
|
|
24
|
-
})
|
|
25
|
-
: undefined,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export function coverageFhirR4ToFlat(resource) {
|
|
29
|
-
const classValues = Array.isArray(resource.class)
|
|
30
|
-
? resource.class
|
|
31
|
-
.map((item) => {
|
|
32
|
-
const type = item?.type?.text;
|
|
33
|
-
const value = item?.value;
|
|
34
|
-
return type && value ? `${type}|${value}` : undefined;
|
|
35
|
-
})
|
|
36
|
-
.filter((item) => Boolean(item))
|
|
37
|
-
: [];
|
|
38
|
-
return {
|
|
39
|
-
[CoverageClaim.Identifier]: resource.identifier?.[0]?.value,
|
|
40
|
-
[CoverageClaim.Status]: resource.status,
|
|
41
|
-
[CoverageClaim.Type]: codingToValue(resource.type?.coding?.[0]),
|
|
42
|
-
[CoverageClaim.PolicyHolder]: referenceToValue(resource.policyHolder),
|
|
43
|
-
[CoverageClaim.Subscriber]: referenceToValue(resource.subscriber),
|
|
44
|
-
[CoverageClaim.Beneficiary]: referenceToValue(resource.beneficiary),
|
|
45
|
-
[CoverageClaim.Relationship]: codingToValue(resource.relationship?.coding?.[0]),
|
|
46
|
-
[CoverageClaim.PeriodStart]: resource.period?.start,
|
|
47
|
-
[CoverageClaim.PeriodEnd]: resource.period?.end,
|
|
48
|
-
[CoverageClaim.Payor]: referenceListToCsv(resource.payor),
|
|
49
|
-
[CoverageClaim.Class]: classValues.length ? classValues.join(',') : undefined,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Conéctate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
|
|
2
|
-
// File: src/utils/convert-device-use-statement.ts
|
|
3
|
-
import { DeviceUseStatementClaim } from '../models/interoperable-claims/device-use-statement-claims.js';
|
|
4
|
-
import { requireClaim } from './convert-shared.js';
|
|
5
|
-
export function deviceUseStatementFlatToFhirR4(claims) {
|
|
6
|
-
const subject = requireClaim(claims, DeviceUseStatementClaim.Subject);
|
|
7
|
-
const device = requireClaim(claims, DeviceUseStatementClaim.Device);
|
|
8
|
-
const status = requireClaim(claims, DeviceUseStatementClaim.Status);
|
|
9
|
-
return {
|
|
10
|
-
resourceType: 'DeviceUseStatement',
|
|
11
|
-
identifier: claims[DeviceUseStatementClaim.Identifier] ? [{ value: claims[DeviceUseStatementClaim.Identifier] }] : undefined,
|
|
12
|
-
subject: { reference: subject },
|
|
13
|
-
device: { reference: device },
|
|
14
|
-
status,
|
|
15
|
-
recordedOn: claims[DeviceUseStatementClaim.RecordedOn],
|
|
16
|
-
timingDateTime: claims[DeviceUseStatementClaim.TimingDateTime],
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export function deviceUseStatementFhirR4ToFlat(resource) {
|
|
20
|
-
return {
|
|
21
|
-
[DeviceUseStatementClaim.Identifier]: resource.identifier?.[0]?.value,
|
|
22
|
-
[DeviceUseStatementClaim.Subject]: resource.subject?.reference,
|
|
23
|
-
[DeviceUseStatementClaim.Device]: resource.device?.reference,
|
|
24
|
-
[DeviceUseStatementClaim.Status]: resource.status,
|
|
25
|
-
[DeviceUseStatementClaim.RecordedOn]: resource.recordedOn,
|
|
26
|
-
[DeviceUseStatementClaim.TimingDateTime]: resource.timingDateTime,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Conéctate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
|
|
2
|
-
// File: src/utils/convert-device.ts
|
|
3
|
-
import { DeviceClaim } from '../models/interoperable-claims/device-claims.js';
|
|
4
|
-
import { codingFromValue, codingToValue, referenceToValue } from './convert-shared.js';
|
|
5
|
-
export function deviceFlatToFhirR4(claims) {
|
|
6
|
-
return {
|
|
7
|
-
resourceType: 'Device',
|
|
8
|
-
identifier: claims[DeviceClaim.Identifier] ? [{ value: claims[DeviceClaim.Identifier] }] : undefined,
|
|
9
|
-
deviceName: claims[DeviceClaim.DeviceName] ? [{ name: claims[DeviceClaim.DeviceName] }] : undefined,
|
|
10
|
-
location: claims[DeviceClaim.Location] ? { reference: claims[DeviceClaim.Location] } : undefined,
|
|
11
|
-
manufacturer: claims[DeviceClaim.Manufacturer],
|
|
12
|
-
modelNumber: claims[DeviceClaim.Model],
|
|
13
|
-
owner: claims[DeviceClaim.Organization] ? { reference: claims[DeviceClaim.Organization] } : undefined,
|
|
14
|
-
patient: claims[DeviceClaim.Patient] ? { reference: claims[DeviceClaim.Patient] } : undefined,
|
|
15
|
-
serialNumber: claims[DeviceClaim.SerialNumber],
|
|
16
|
-
status: claims[DeviceClaim.Status],
|
|
17
|
-
type: claims[DeviceClaim.Type] ? { coding: codingFromValue(claims[DeviceClaim.Type]) } : undefined,
|
|
18
|
-
udiCarrier: claims[DeviceClaim.UdiCarrier] ? [{ carrierHRF: claims[DeviceClaim.UdiCarrier] }] : undefined,
|
|
19
|
-
url: claims[DeviceClaim.Url],
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export function deviceFhirR4ToFlat(resource) {
|
|
23
|
-
return {
|
|
24
|
-
[DeviceClaim.DeviceName]: resource.deviceName?.[0]?.name,
|
|
25
|
-
[DeviceClaim.Identifier]: resource.identifier?.[0]?.value,
|
|
26
|
-
[DeviceClaim.Location]: referenceToValue(resource.location),
|
|
27
|
-
[DeviceClaim.Manufacturer]: resource.manufacturer,
|
|
28
|
-
[DeviceClaim.Model]: resource.modelNumber || resource.model,
|
|
29
|
-
[DeviceClaim.Organization]: referenceToValue(resource.owner),
|
|
30
|
-
[DeviceClaim.Patient]: referenceToValue(resource.patient),
|
|
31
|
-
[DeviceClaim.SerialNumber]: resource.serialNumber,
|
|
32
|
-
[DeviceClaim.Status]: resource.status,
|
|
33
|
-
[DeviceClaim.Type]: codingToValue(resource.type?.coding?.[0]),
|
|
34
|
-
[DeviceClaim.UdiCarrier]: resource.udiCarrier?.[0]?.carrierHRF,
|
|
35
|
-
[DeviceClaim.Url]: resource.url,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Conéctate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
|
|
2
|
-
// File: src/utils/convert-diagnostic-report.ts
|
|
3
|
-
import { DiagnosticReportClaim } from '../models/interoperable-claims/diagnostic-report-claims.js';
|
|
4
|
-
import { codingFromValue, codingToValue, referenceListToCsv, referenceToValue } from './convert-shared.js';
|
|
5
|
-
export function diagnosticReportFlatToFhirR4(claims) {
|
|
6
|
-
const subject = claims[DiagnosticReportClaim.Subject] ?? claims[DiagnosticReportClaim.Patient];
|
|
7
|
-
return {
|
|
8
|
-
resourceType: 'DiagnosticReport',
|
|
9
|
-
identifier: claims[DiagnosticReportClaim.Identifier] ? [{ value: claims[DiagnosticReportClaim.Identifier] }] : undefined,
|
|
10
|
-
status: claims[DiagnosticReportClaim.Status],
|
|
11
|
-
category: claims[DiagnosticReportClaim.Category] ? [{ coding: codingFromValue(claims[DiagnosticReportClaim.Category]) }] : undefined,
|
|
12
|
-
code: claims[DiagnosticReportClaim.Code] ? { coding: codingFromValue(claims[DiagnosticReportClaim.Code]) } : undefined,
|
|
13
|
-
subject: subject ? { reference: subject } : undefined,
|
|
14
|
-
encounter: claims[DiagnosticReportClaim.Encounter] ? { reference: claims[DiagnosticReportClaim.Encounter] } : undefined,
|
|
15
|
-
effectiveDateTime: claims[DiagnosticReportClaim.Date],
|
|
16
|
-
basedOn: claims[DiagnosticReportClaim.BasedOn] ? claims[DiagnosticReportClaim.BasedOn].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
17
|
-
performer: claims[DiagnosticReportClaim.Performer] ? claims[DiagnosticReportClaim.Performer].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
18
|
-
result: claims[DiagnosticReportClaim.Result] ? claims[DiagnosticReportClaim.Result].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
19
|
-
resultsInterpreter: claims[DiagnosticReportClaim.ResultsInterpreter] ? claims[DiagnosticReportClaim.ResultsInterpreter].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
20
|
-
specimen: claims[DiagnosticReportClaim.Specimen] ? claims[DiagnosticReportClaim.Specimen].split(',').map((reference) => ({ reference: reference.trim() })) : undefined,
|
|
21
|
-
media: claims[DiagnosticReportClaim.Media] ? claims[DiagnosticReportClaim.Media].split(',').map((reference) => ({ link: { reference: reference.trim() } })) : undefined,
|
|
22
|
-
presentedForm: (claims[DiagnosticReportClaim.PresentedFormContentType] || claims[DiagnosticReportClaim.PresentedFormData] || claims[DiagnosticReportClaim.PresentedFormUrl]) ? [{
|
|
23
|
-
contentType: claims[DiagnosticReportClaim.PresentedFormContentType],
|
|
24
|
-
data: claims[DiagnosticReportClaim.PresentedFormData],
|
|
25
|
-
url: claims[DiagnosticReportClaim.PresentedFormUrl],
|
|
26
|
-
}] : undefined,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export function diagnosticReportFhirR4ToFlat(resource) {
|
|
30
|
-
const form = Array.isArray(resource.presentedForm) ? resource.presentedForm[0] : undefined;
|
|
31
|
-
const media = Array.isArray(resource.media)
|
|
32
|
-
? resource.media
|
|
33
|
-
.map((item) => referenceToValue(item?.link))
|
|
34
|
-
.filter((item) => Boolean(item))
|
|
35
|
-
: [];
|
|
36
|
-
return {
|
|
37
|
-
[DiagnosticReportClaim.BasedOn]: referenceListToCsv(resource.basedOn),
|
|
38
|
-
[DiagnosticReportClaim.Category]: codingToValue(resource.category?.[0]?.coding?.[0]),
|
|
39
|
-
[DiagnosticReportClaim.Code]: codingToValue(resource.code?.coding?.[0]),
|
|
40
|
-
[DiagnosticReportClaim.Date]: resource.effectiveDateTime || resource.issued,
|
|
41
|
-
[DiagnosticReportClaim.Encounter]: referenceToValue(resource.encounter),
|
|
42
|
-
[DiagnosticReportClaim.Identifier]: resource.identifier?.[0]?.value,
|
|
43
|
-
[DiagnosticReportClaim.Media]: media.length ? media.join(',') : undefined,
|
|
44
|
-
[DiagnosticReportClaim.Patient]: referenceToValue(resource.subject),
|
|
45
|
-
[DiagnosticReportClaim.Performer]: referenceListToCsv(resource.performer),
|
|
46
|
-
[DiagnosticReportClaim.Result]: referenceListToCsv(resource.result),
|
|
47
|
-
[DiagnosticReportClaim.ResultsInterpreter]: referenceListToCsv(resource.resultsInterpreter),
|
|
48
|
-
[DiagnosticReportClaim.Specimen]: referenceListToCsv(resource.specimen),
|
|
49
|
-
[DiagnosticReportClaim.Status]: resource.status,
|
|
50
|
-
[DiagnosticReportClaim.Subject]: referenceToValue(resource.subject),
|
|
51
|
-
[DiagnosticReportClaim.PresentedFormContentType]: form?.contentType,
|
|
52
|
-
[DiagnosticReportClaim.PresentedFormData]: form?.data,
|
|
53
|
-
[DiagnosticReportClaim.PresentedFormUrl]: form?.url,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Conéctate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
|
|
2
|
-
// File: src/utils/convert-document-reference.ts
|
|
3
|
-
import { DocumentReferenceClaim } from '../models/interoperable-claims/document-reference-claims.js';
|
|
4
|
-
import { requireClaim } from './convert-shared.js';
|
|
5
|
-
export function documentReferenceFlatToFhirR4(claims) {
|
|
6
|
-
const subject = requireClaim(claims, DocumentReferenceClaim.Subject);
|
|
7
|
-
return {
|
|
8
|
-
resourceType: 'DocumentReference',
|
|
9
|
-
identifier: claims[DocumentReferenceClaim.Identifier] ? [{ value: claims[DocumentReferenceClaim.Identifier] }] : undefined,
|
|
10
|
-
subject: { reference: subject },
|
|
11
|
-
description: claims[DocumentReferenceClaim.Description],
|
|
12
|
-
date: claims[DocumentReferenceClaim.Date],
|
|
13
|
-
content: [{ attachment: {
|
|
14
|
-
contentType: claims[DocumentReferenceClaim.ContentType],
|
|
15
|
-
data: claims[DocumentReferenceClaim.ContentData],
|
|
16
|
-
url: claims[DocumentReferenceClaim.Location],
|
|
17
|
-
hash: claims[DocumentReferenceClaim.ContentHash],
|
|
18
|
-
language: claims[DocumentReferenceClaim.Language],
|
|
19
|
-
} }],
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export function documentReferenceFhirR4ToFlat(resource) {
|
|
23
|
-
const attachment = resource.content?.[0]?.attachment;
|
|
24
|
-
return {
|
|
25
|
-
[DocumentReferenceClaim.Identifier]: resource.identifier?.[0]?.value,
|
|
26
|
-
[DocumentReferenceClaim.Subject]: resource.subject?.reference,
|
|
27
|
-
[DocumentReferenceClaim.Description]: resource.description,
|
|
28
|
-
[DocumentReferenceClaim.Date]: resource.date,
|
|
29
|
-
[DocumentReferenceClaim.ContentType]: attachment?.contentType,
|
|
30
|
-
[DocumentReferenceClaim.ContentData]: attachment?.data,
|
|
31
|
-
[DocumentReferenceClaim.Location]: attachment?.url,
|
|
32
|
-
[DocumentReferenceClaim.ContentHash]: attachment?.hash,
|
|
33
|
-
[DocumentReferenceClaim.Language]: attachment?.language,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Conéctate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
|
|
2
|
-
// File: src/utils/convert-encounter.ts
|
|
3
|
-
import { EncounterClaim } from '../models/interoperable-claims/encounter-claims.js';
|
|
4
|
-
import { codingFromValue, codingToValue, referenceToValue } from './convert-shared.js';
|
|
5
|
-
export function encounterFlatToFhirR4(claims) {
|
|
6
|
-
const subject = claims[EncounterClaim.Subject] ?? claims[EncounterClaim.Patient];
|
|
7
|
-
return {
|
|
8
|
-
resourceType: 'Encounter',
|
|
9
|
-
identifier: claims[EncounterClaim.Identifier] ? [{ value: claims[EncounterClaim.Identifier] }] : undefined,
|
|
10
|
-
status: claims[EncounterClaim.Status],
|
|
11
|
-
class: claims[EncounterClaim.Class]
|
|
12
|
-
? (() => {
|
|
13
|
-
const [system, code] = claims[EncounterClaim.Class].split('|');
|
|
14
|
-
return code ? { system, code } : { code: system };
|
|
15
|
-
})()
|
|
16
|
-
: undefined,
|
|
17
|
-
type: claims[EncounterClaim.Type] ? [{ coding: codingFromValue(claims[EncounterClaim.Type]) }] : undefined,
|
|
18
|
-
subject: subject ? { reference: subject } : undefined,
|
|
19
|
-
participant: claims[EncounterClaim.Participant]
|
|
20
|
-
? claims[EncounterClaim.Participant].split(',').map((reference) => ({ individual: { reference: reference.trim() } }))
|
|
21
|
-
: undefined,
|
|
22
|
-
serviceProvider: claims[EncounterClaim.ServiceProvider] ? { reference: claims[EncounterClaim.ServiceProvider] } : undefined,
|
|
23
|
-
period: (claims[EncounterClaim.PeriodStart] || claims[EncounterClaim.PeriodEnd]) ? {
|
|
24
|
-
start: claims[EncounterClaim.PeriodStart],
|
|
25
|
-
end: claims[EncounterClaim.PeriodEnd],
|
|
26
|
-
} : undefined,
|
|
27
|
-
reasonCode: claims[EncounterClaim.ReasonCode] ? [{ coding: codingFromValue(claims[EncounterClaim.ReasonCode]) }] : undefined,
|
|
28
|
-
diagnosis: claims[EncounterClaim.Diagnosis]
|
|
29
|
-
? claims[EncounterClaim.Diagnosis].split(',').map((reference) => ({ condition: { reference: reference.trim() } }))
|
|
30
|
-
: undefined,
|
|
31
|
-
location: claims[EncounterClaim.Location]
|
|
32
|
-
? claims[EncounterClaim.Location].split(',').map((reference) => ({ location: { reference: reference.trim() } }))
|
|
33
|
-
: undefined,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export function encounterFhirR4ToFlat(resource) {
|
|
37
|
-
const klass = resource.class;
|
|
38
|
-
return {
|
|
39
|
-
[EncounterClaim.Identifier]: resource.identifier?.[0]?.value,
|
|
40
|
-
[EncounterClaim.Status]: resource.status,
|
|
41
|
-
[EncounterClaim.Class]: klass?.code ? (klass.system ? `${klass.system}|${klass.code}` : klass.code) : undefined,
|
|
42
|
-
[EncounterClaim.Type]: codingToValue(resource.type?.[0]?.coding?.[0]),
|
|
43
|
-
[EncounterClaim.Subject]: referenceToValue(resource.subject),
|
|
44
|
-
[EncounterClaim.Patient]: referenceToValue(resource.subject),
|
|
45
|
-
[EncounterClaim.Participant]: Array.isArray(resource.participant)
|
|
46
|
-
? resource.participant
|
|
47
|
-
.map((item) => referenceToValue(item?.individual))
|
|
48
|
-
.filter((item) => Boolean(item))
|
|
49
|
-
.join(',')
|
|
50
|
-
: undefined,
|
|
51
|
-
[EncounterClaim.ServiceProvider]: referenceToValue(resource.serviceProvider),
|
|
52
|
-
[EncounterClaim.PeriodStart]: resource.period?.start,
|
|
53
|
-
[EncounterClaim.PeriodEnd]: resource.period?.end,
|
|
54
|
-
[EncounterClaim.ReasonCode]: codingToValue(resource.reasonCode?.[0]?.coding?.[0]),
|
|
55
|
-
[EncounterClaim.Diagnosis]: Array.isArray(resource.diagnosis)
|
|
56
|
-
? resource.diagnosis
|
|
57
|
-
.map((item) => referenceToValue(item?.condition))
|
|
58
|
-
.filter((item) => Boolean(item))
|
|
59
|
-
.join(',')
|
|
60
|
-
: undefined,
|
|
61
|
-
[EncounterClaim.Location]: Array.isArray(resource.location)
|
|
62
|
-
? resource.location
|
|
63
|
-
.map((item) => referenceToValue(item?.location))
|
|
64
|
-
.filter((item) => Boolean(item))
|
|
65
|
-
.join(',')
|
|
66
|
-
: undefined,
|
|
67
|
-
};
|
|
68
|
-
}
|