new ResourceWrapper(_config)
Represents a wrapper for a SanteDB resource
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| _config | any | The configuration object Properties
 | 
- Source:
Methods
(static) addAssociatedAsync(id, property, data, state, upstream) → {Promise}
Adds a new association to the specified parent object at the specified path
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The identifier of the container | 
| property | string | The associative property you want to add the value to | 
| data | any | The data to be added as an associative object (note: Most resources require that this object already exist) | 
| state | any | A stateful object for callback correlation | 
| upstream | boolean | True if the registration should be directly submitted to the upstream iCDR server | 
- Source:
- See:
Returns:
- Type
- Promise
(static) cancelAsync(id, state, upstream) → {Promise}
Performs a cancel on the specified object
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The unique identifier for the object to be cancelled | 
| state | any | A unique state object which is passed back to the caller | 
| upstream | boolean | True if the registration should be directly submitted to the upstream iCDR server | 
- Source:
Returns:
- Type
- Promise
(static) cancelAsync(id, upstream, state) → {Promise}
Performs an obsolete on the specified object
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The unique identifier for the object to be cancelled | 
| upstream | boolean | True if the registration should be directly submitted to the upstream iCDR server | 
| state | any | A unique state object which is passed back to the caller | 
- Source:
Returns:
- Type
- Promise
(static) copyAsync(id, state) → {Promise}
Performs a COPY operation on the specified resource (creating a copy from remote)
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The unique identifier for the object on which the invokation is to be called | 
| state | any | A unique state object which is passed back to the caller | 
- Source:
Returns:
- Type
- Promise
(static) deleteAsync(id, state, upstream) → {Promise}
Performs an obsolete (delete) operation on the server
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The unique identifier for the object to be deleted | 
| state | any | A unique state object which is passed back to the caller | 
| upstream | boolean | True if the delete should be directly submitted to the upstream iCDR server | 
- Source:
Returns:
- Type
- Promise
(static) find(query) → {Promise}
Queries for instances of the resource this wrapper wraps in a synchronous fashion
Parameters:
| Name | Type | Description | 
|---|---|---|
| query | any | The query for the object that you are looking for | 
- Source:
- See:
- 
        - {SanteDBWrapper.findAsync} For asynchronous method
 
Returns:
- Type
- Promise
(static) findAssociatedAsync(id, property, query, upstream, viewModel) → {Promise}
Performs a find operation on an associated object
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The identifier of the object whose children you want query | 
| property | string | The property path you would like to filter on | 
| query | any | The query you want to execute | 
| upstream | boolean | True if the registration should be directly submitted to the upstream iCDR server | 
| viewModel | string | The viewmodel asset to use to render the response | 
- Source:
- See:
Returns:
- Type
- Promise
Example
Get Groups a User belongs to
async getGroups(userName) {
 try {
     var users = await SanteDB.resources.securityUser.findAsync({ "userName" : userName });
     var userId = users.resource[0].id;
     // Fetch the groups
     var groups = await SanteDB.resources.securityUser.findAssociatedAsync(userId, 'groups');
     console.info(groups.resource)
 }
 catch(e) {
     console.error(e);
 }
}(static) findAsync(query, viewModel, state, upstream) → {Promise}
Queries for instances of the resource this wrapper wraps
Parameters:
| Name | Type | Description | 
|---|---|---|
| query | any | The HDSI query to filter on | 
| viewModel | any | The view model definition to use when loading | 
| state | any | A unique state object which is passed back to the caller | 
| upstream | boolean | True if the query should be directly submitted to the upstream iCDR server | 
- Source:
Returns:
- Type
- Promise
Example
Query for John or Jane Smith
  async function queryForJohnOrJane() {
      try {
          var results = await SanteDB.resources.patient.findAsync({
              "name.component[Given].value" : [ 'John', 'Jane' ],
              "name.component[Family].value" : 'Smith'
          }, 'full', false);
          console.info("Found " + results.total + " matching results");
          results.resource.forEach(r => console.info(r)); // output results
      }
      catch(e) {
          console.error(e);
      }
  }(static) getAssociatedAsync(id, property, associatedId, state) → {Promise}
Retrieves an existing associated object from the specified scoper
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The identifier of the container object | 
| property | string | The property path from which the object is to be retrieved | 
| associatedId | string | The identifier of the sub-object to be retrieved | 
| state | any | A state for correlating multiple requests | 
- Source:
- See:
Returns:
- Type
- Promise
(static) getAsync(id, viewModel, parms, state, upstream) → {Promise}
Retrieves a specific instance of the resource this wrapper wraps
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The unique identifier of the resource to retrieve | 
| viewModel | string | A unique state object which is passed back to the caller | 
| parms | any | Extra parameters to pass to the get function | 
| state | any | A unique state object which is passed back to the caller | 
| upstream | boolean | True if the get should be directly submitted to the upstream iCDR server | 
- Source:
Returns:
- Type
- Promise
Example
Fetch a patient by ID
  async function fetchPatient(id) {
      try {
          // fetch from local dCDR repository
          var local = await SanteDB.resource.patient.getAsync(id, "_full", null, false);
          // fetch from remote dCDR repository
          var remote = await SanteDB.resource.patient.getAsync(id, "_fall", null, true);
          console.info({ "local" : local, "remote" : remote });
      }
      catch(e) {
          console.error(e);
      }
  }(static) getUrl()
Gets the URL to this resource base
- Source:
(static) insertAsync(data, state, upstream) → {Promise}
Inserts a specific instance of the wrapped resource
Parameters:
| Name | Type | Description | 
|---|---|---|
| data | any | The data / resource which is to be created | 
| state | any | A unique state object which is passed back to the caller | 
| upstream | boolean | True if the registration should be directly submitted to the upstream iCDR server | 
- Source:
Returns:
- Type
- Promise
Example
Register a new Place
async function registerNewPlace(name) {
  try {
      var place = await SanteDB.resources.place.insertAsync(new Place({
          classConcept: EntityClassKeys.CityOrTown,
          name : {    
              OfficialRecord : [
                  {
                      component : {   
                          $other : [
                              name
                          ]
                      }
                  }
              ]
          }
      }));
      console.info("Registered place successfully!", place);
  }
  catch (e) {
      console.error(e);
  }
}(static) invokeOperationAsync(id, operation, parameters, upstream, viewModel, state, viewModel) → {Promise}
Invokes the specified method on the specified object
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The identifier of the container (null if global execute) | 
| operation | string | The operation you want to execute | 
| parameters | any | The parameters to the operation being executes (example: { clear: true, softFind: true }) | 
| upstream | bool | True if the operation shold be executed opstream | 
| viewModel | string | The view model which should be used to load data | 
| state | object | A tracking state to send to the callback | 
| viewModel | string | The view model to use to load returned properties | 
- Source:
Returns:
- Type
- Promise
Example
Start all Jobs
async function startAllJobs() {
  try {
      var jobs = await SanteDB.resources.jobInfo.findAsync();
      await Promise.all(jobs.resource.map(j => SanteDB.resources.jobInfo.invokeOperationAsync(j.id, "start")));
  }
  catch(e) {
      console.error(e);
  }
}(static) lockAsync(id, state, upstream) → {Promise}
Performs the specified LOCK operation on the server
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The unique identifier for the object on which the invokation is to be called | 
| state | any | A unique state object which is passed back to the caller | 
| upstream | boolean | True if the registration should be directly submitted to the upstream iCDR server | 
- Source:
Returns:
- Type
- Promise
(static) lockAsync(id, state, upstream) → {Promise}
Performs the specified CHECKOUT operation on the server
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The unique identifier for the object on which the invokation is to be called | 
| state | any | A unique state object which is passed back to the caller | 
| upstream | boolean | True if the registration should be directly submitted to the upstream iCDR server | 
- Source:
Returns:
- Type
- Promise
Example
Checkout / Update / Checkin
async loadPatient(id) {
  try {
      await SanteDB.resource.patient.checkoutAsync(id); // attempt to get a lock - this will throw an exception if unsuccessful
      var patient = await SanteDB.resources.patient.getAsync(id); // get the latest version no we're checked out
      $timeout(s => s.patient = patient); // Add to scope    
  }
  catch(e) {
      $timeout(s => s.isLockedOut = true);
  }
}
async savePatient(id, patient) {
  try {
      var patient = await SanteDB.resources.patient.updateAsync(id, patient);
      await SanteDB.resources.checkinAsync(id);
  }
  catch(e) {
      console.error(e);
  }
}(static) nullifyAsync(id, state, upstream) → {Promise}
Performs a nullify on the specified object
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The unique identifier for the object to be nullified | 
| state | any | A unique state object which is passed back to the caller | 
| upstream | boolean | True if the registration should be directly submitted to the upstream iCDR server | 
- Source:
Returns:
- Type
- Promise
(static) patchAsync(id, etag, upstream, patch, state) → {Promise}
Sends a patch to the service
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The identifier of the object to patch | 
| etag | string | The e-tag to assert | 
| upstream | boolean | True if the registration should be directly submitted to the upstream iCDR server | 
| patch | Patch | The patch to be applied | 
| state | any | A unique state object which is passed back to the caller | 
- Source:
Returns:
- Type
- Promise
(static) removeAssociatedAsync(id, property, associatedId, state, upstream) → {Promise}
Removes an existing associated object from the specified scoper
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The identifier of the container object | 
| property | string | The property path from which the object is to be removed | 
| associatedId | string | The identifier of the sub-object to be removed | 
| state | any | A state for correlating multiple requests | 
| upstream | Boolean | True if the query should be sent to upstream service | 
- Source:
- See:
Returns:
- Type
- Promise
(static) touchAsync(id, upstream, state) → {Promise}
Performs a TOUCH operation on the specified resource (updating it's modfiedOn time)
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The unique identifier for the object on which the invokation is to be called | 
| upstream | boolean | True if the registration should be directly submitted to the upstream iCDR server | 
| state | any | A unique state object which is passed back to the caller | 
- Source:
Returns:
- Type
- Promise
(static) unLockAsync(id, state, upstream) → {Promise}
Performs the specified UNLOCK operation on the server
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The unique identifier for the object on which the invokation is to be called | 
| state | any | A unique state object which is passed back to the caller | 
| upstream | boolean | True if the registration should be directly submitted to the upstream iCDR server | 
- Source:
Returns:
- Type
- Promise
(static) unLockAsync(id, state, upstream) → {Promise}
Performs the specified CHECKIN operation on the server
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The unique identifier for the object on which the invokation is to be called | 
| state | any | A unique state object which is passed back to the caller | 
| upstream | boolean | True if the registration should be directly submitted to the upstream iCDR server | 
- Source:
Returns:
- Type
- Promise
(static) updateAsync(id, data, state, upstream) → {Promise}
Updates the identified instance of the wrapped resource
Parameters:
| Name | Type | Description | 
|---|---|---|
| id | string | The unique identifier for the object to be updated | 
| data | any | The data / resource which is to be updated | 
| state | any | A unique state object which is passed back to the caller | 
| upstream | boolean | True if the update should be directly submitted to the upstream iCDR server | 
- Source:
Returns:
- Type
- Promise