@medplum/fhir-router 2.0.23 → 2.0.24

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.
@@ -52,7 +52,7 @@ class BatchProcessor {
52
52
  const rewritten = this.rewriteIdsInObject(entry);
53
53
  // If the resource 'id' element is specified, we want to replace teh `urn:uuid:*` string and
54
54
  // remove the `resourceType` prefix
55
- if (entry?.resource?.id) {
55
+ if (entry.resource?.id) {
56
56
  rewritten.resource.id = this.rewriteIdsInString(entry.resource.id, true);
57
57
  }
58
58
  try {
@@ -80,7 +80,7 @@ class BatchProcessor {
80
80
  const baseUrl = `https://example.com/${entry.resource.resourceType}`;
81
81
  const searchUrl = new URL('?' + request.ifNoneExist, baseUrl);
82
82
  const searchBundle = await this.repo.search(parseSearchUrl(searchUrl));
83
- const entries = searchBundle?.entry;
83
+ const entries = searchBundle.entry;
84
84
  if (entries.length > 1) {
85
85
  return buildBundleResponse(badRequest('Multiple matches'));
86
86
  }
@@ -136,7 +136,7 @@ class BatchProcessor {
136
136
  return JSON.parse(Buffer.from(patchResource.data, 'base64').toString('utf8'));
137
137
  }
138
138
  addReplacementId(fullUrl, resource) {
139
- if (fullUrl?.startsWith('urn:uuid:')) {
139
+ if (fullUrl.startsWith('urn:uuid:')) {
140
140
  this.ids[fullUrl] = resource;
141
141
  }
142
142
  }
@@ -13475,7 +13475,7 @@ function getDepth(path) {
13475
13475
  */
13476
13476
  function isFieldRequested(info, fieldName) {
13477
13477
  return info.fieldNodes.some((fieldNode) => fieldNode.selectionSet?.selections.some((selection) => {
13478
- return selection.kind === 'Field' && selection.name.value === fieldName;
13478
+ return selection.kind === Kind.FIELD && selection.name.value === fieldName;
13479
13479
  }));
13480
13480
  }
13481
13481
  /**
@@ -13730,7 +13730,7 @@ function buildReverseLookupFields(resourceType, fields) {
13730
13730
  let count = 0;
13731
13731
  if (childSearchParams) {
13732
13732
  for (const [code, searchParam] of Object.entries(childSearchParams)) {
13733
- if (searchParam.target && searchParam.target.includes(resourceType)) {
13733
+ if (searchParam.target?.includes(resourceType)) {
13734
13734
  enumValues[fhirParamToGraphQLField(code)] = { value: code };
13735
13735
  count++;
13736
13736
  }
@@ -13755,9 +13755,12 @@ function buildReverseLookupFields(resourceType, fields) {
13755
13755
  }
13756
13756
  }
13757
13757
  function getOutputPropertyType(elementDefinition, typeName) {
13758
- const graphqlType = getGraphQLOutputType(typeName);
13758
+ let graphqlType = getGraphQLOutputType(typeName);
13759
13759
  if (elementDefinition.max === '*') {
13760
- return new GraphQLList(graphqlType);
13760
+ graphqlType = new GraphQLList(graphqlType);
13761
+ }
13762
+ if (elementDefinition.min !== 0 && !elementDefinition.path?.endsWith('[x]')) {
13763
+ graphqlType = new GraphQLNonNull(graphqlType);
13761
13764
  }
13762
13765
  return graphqlType;
13763
13766
  }
@@ -13965,7 +13968,7 @@ function buildRootSchema() {
13965
13968
  function buildCreateArgs(resourceType) {
13966
13969
  const args = {
13967
13970
  res: {
13968
- type: getGraphQLInputType(resourceType, 'Create'),
13971
+ type: new GraphQLNonNull(getGraphQLInputType(resourceType, 'Create')),
13969
13972
  description: resourceType + ' Create',
13970
13973
  },
13971
13974
  };
@@ -13978,7 +13981,7 @@ function buildUpdateArgs(resourceType) {
13978
13981
  description: resourceType + ' ID',
13979
13982
  },
13980
13983
  res: {
13981
- type: getGraphQLInputType(resourceType, 'Update'),
13984
+ type: new GraphQLNonNull(getGraphQLInputType(resourceType, 'Update')),
13982
13985
  description: resourceType + ' Update',
13983
13986
  },
13984
13987
  };
@@ -14351,10 +14354,10 @@ class MemoryRepository extends BaseRepository {
14351
14354
  if (!result.meta) {
14352
14355
  result.meta = {};
14353
14356
  }
14354
- if (!result.meta?.versionId) {
14357
+ if (!result.meta.versionId) {
14355
14358
  result.meta.versionId = generateId();
14356
14359
  }
14357
- if (!result.meta?.lastUpdated) {
14360
+ if (!result.meta.lastUpdated) {
14358
14361
  result.meta.lastUpdated = new Date().toISOString();
14359
14362
  }
14360
14363
  const { resourceType, id } = result;
@@ -14476,7 +14479,7 @@ class MemoryRepository extends BaseRepository {
14476
14479
  }
14477
14480
  }
14478
14481
  const sortComparator = (a, b, sortRule) => {
14479
- const searchParam = globalSchema.types[a.resourceType]?.searchParams?.[sortRule.code];
14482
+ const searchParam = globalSchema.types[a.resourceType].searchParams?.[sortRule.code];
14480
14483
  const expression = searchParam?.expression;
14481
14484
  if (!expression) {
14482
14485
  return 0;