I'm trying to get this Fit on FHIR project working, and I got stuck creating a new patient after the user confirmed access to GoogleFit data. This is the code for creating a new patient.
if (patient == null) {
patient = await _resourceManagementService.EnsureResourceByIdentityAsync < Patient > (
platformIdentifier,
platformSystem,
(p, id) => p.Identifier = new List < Identifier > {
id
});
identifierToAdd = new Identifier(externalSystem, externalPatientId);
}
where _resourceManagementService is of type Microsoft.Health.Extensions.Fhir.Service.ResourceManagementService
The parameters passed to the function are:
string platformIdentifier = 000000000000000000000 (Google Subject frow JWT)
string platformSystem = https://accounts.google.com
EnsureResourceByIdentityAsync method makes two requests:
- HTTP GET - to check if a resource exists.
- HTTP PUT - If a resource doesn't exist, it creates it
When the PUT request is executed, the FHIR returns this error: BadRequest: Conditional operation on Patient was not attempted because search criteria was not selective enough
What am I doing wrong?