createOrModifyDataSampleFor method

  1. @override
Future<DataSample?> createOrModifyDataSampleFor(
  1. String patientId,
  2. DataSample dataSample
)
override

Create or update a DataSample for a patient

When modifying a data sample, you can't update the patient of it : For this, you need to delete the faulty data sample and create a new one. When modifying the data sample, you also need to keep the same batchId : It is not possible to change the batch of a data sample.

Parameters:

  • String patientId (required):

  • DataSample dataSample (required):

Implementation

@override
Future<DataSample?> createOrModifyDataSampleFor(String patientId, DataSample dataSample) async {
  final processedDataSample = (await createOrModifyDataSamplesFor(patientId, [dataSample]))?.single;
  if (processedDataSample == null) {
    throw StateError("Could not create / modify data sample ${dataSample.id} for patient ${patientId}");
  }
  return processedDataSample;
}