Skip to content

Commit

Permalink
0.0.17
Browse files Browse the repository at this point in the history
  • Loading branch information
josephjclark committed Sep 23, 2024
1 parent 241083e commit b2b5384
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
6 changes: 6 additions & 0 deletions packages/fhir-jembi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @openfn/language-fhir-jembi


## 0.0.17

- support more types in addExtension


## 0.0.16

- Add `text` to each resource type
Expand Down
2 changes: 1 addition & 1 deletion packages/fhir-jembi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-fhir-jembi",
"version": "0.0.16",
"version": "0.0.17",
"description": "OpenFn fhir-jembi adaptor",
"type": "module",
"exports": {
Expand Down
9 changes: 3 additions & 6 deletions packages/fhir-jembi/src/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,7 @@ export const addExtension = (resource, url, value) => {
url: url,
};

if (value.coding) {
obj.valueCodeableConcept = value;
} else {
obj.value = value;
}
// TODO we have to infer every value type here
composite(obj, 'value', value)

resource.extension ??= [];
resource.extension.push(obj);
Expand Down Expand Up @@ -201,6 +196,8 @@ export const composite = (object, key, value) => {
} else if (value.start || value.end) {
// TODO maybe we should test that start/end are datetimes using that fancy regex?
k.push('Period')
} else if (value.dateTime) {
k.push('DateTime')
} else if (typeof value === 'string') {
if (datetimeregex.test(value)) {
k.push('DateTime')
Expand Down
20 changes: 16 additions & 4 deletions packages/fhir-jembi/test/Utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,25 @@ describe('addExtension', () => {
const resource = {
extension: [{ url: 'xyz' }],
};
addExtension(resource, 'www', {});
addExtension(resource, 'www', 'x');

expect(resource.extension).to.eql([
{ url: 'xyz' },
{
url: 'www',
value: {},
valueString: 'x',
},
]);
});

it('should add a new extensions array to a resource', () => {
const resource = {};
addExtension(resource, 'www', {});
addExtension(resource, 'www', 'y');

expect(resource.extension).to.eql([
{
url: 'www',
value: {},
valueString: 'y'
},
]);
});
Expand Down Expand Up @@ -212,6 +212,18 @@ describe('addExtension', () => {
]);
});

it('should add datetime extension as a string', () => {
const resource = {};
addExtension(resource, 'www', '2001-01-01');

expect(resource.extension).to.eql([
{
url: 'www',
valueDateTime: '2001-01-01'
},
]);
});

it('should add a Codeable Concept extension with the util helper', () => {
const resource = {};
addExtension(
Expand Down

0 comments on commit b2b5384

Please sign in to comment.