## MedplumClient.createResourceIfNoneExist() method  
Conditionally create a new FHIR resource only if some equivalent resource does not already exist on the server.  
The return value is the existing resource or the newly created resource, including the ID and meta.

**Signature:**  
```typescript  
createResourceIfNoneExist<T extends Resource>(resource: T, query: string, options?: MedplumRequestOptions): Promise<WithId<T>>;  
```

## Parameters  
| Parameter | Type | Description |  
| --- | --- | --- |  
| resource | T | The FHIR resource to create. |  
| query | string | The search query for an equivalent resource (should not include resource type or "?"). |  
| options | [MedplumRequestOptions](/content/docs/sdk/core.medplumrequestoptions) | _(Optional)_ Optional fetch options. |

**Returns:**  
Promise<[WithId](/content/docs/sdk/core.withid)<T>>  
The result of the create operation.

## Example  
Example:  
```typescript  
const result = await medplum.createResourceIfNoneExist(  
  {  
    resourceType: 'Patient',  
    identifier: [{  
     system: 'http://example.com/mrn',  
     value: '123'  
    }]  
    name: [{  
     family: 'Smith',  
     given: ['John']  
    }]  
  },  
  'identifier=123'  
);  
console.log(result.id);  
```  
This method is syntactic sugar for:  
```typescript  
return searchOne(resourceType, query) ?? createResource(resource);  
```  
The query parameter only contains the search parameters (what would be in the URL following the "?").

See the [FHIR "conditional create" operation](https://www.hl7.org/fhir/http.html#create) for full details.  
- [MedplumClient.createResourceIfNoneExist() method](/content/docs/sdk/core.medplumclient.createresourceifnoneexist#medplumclientcreateresourceifnoneexist-method/index.html)  
- [Parameters](/content/docs/sdk/core.medplumclient.createresourceifnoneexist#parameters/index.html)  
- [Example](/content/docs/sdk/core.medplumclient.createresourceifnoneexist#example/index.html)
