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