Search in sources :

Example 1 with BiometricSubject

use of org.openmrs.module.registrationcore.api.biometrics.model.BiometricSubject in project openmrs-module-pihcore by PIH.

the class RestBiometricEngine method update.

@Override
public BiometricSubject update(BiometricSubject subject) {
    RestTemplate restTemplate = new RestTemplate();
    String url = getSubjectUrl();
    ResponseEntity<BiometricSubject> response = restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<BiometricSubject>(subject), BiometricSubject.class);
    if (HttpStatus.OK.equals(response.getStatusCode()) || HttpStatus.CREATED.equals(response.getStatusCode())) {
        return response.getBody();
    } else {
        throw new IllegalStateException("Error updating biometric subject at URL <" + url + ">.  Response status code: " + response.getStatusCode());
    }
}
Also used : BiometricSubject(org.openmrs.module.registrationcore.api.biometrics.model.BiometricSubject) RestTemplate(org.springframework.web.client.RestTemplate)

Example 2 with BiometricSubject

use of org.openmrs.module.registrationcore.api.biometrics.model.BiometricSubject in project openmrs-module-pihcore by PIH.

the class RestBiometricEngine method enroll.

@Override
public BiometricSubject enroll(BiometricSubject subject) {
    RestTemplate restTemplate = new RestTemplate();
    String url = getSubjectUrl();
    ResponseEntity<BiometricSubject> response = restTemplate.postForEntity(url, subject, BiometricSubject.class);
    if (HttpStatus.OK.equals(response.getStatusCode()) || HttpStatus.CREATED.equals(response.getStatusCode())) {
        return response.getBody();
    } else {
        throw new IllegalStateException("Error enrolling biometric subject at URL <" + url + ">.  Response status code: " + response.getStatusCode());
    }
}
Also used : BiometricSubject(org.openmrs.module.registrationcore.api.biometrics.model.BiometricSubject) RestTemplate(org.springframework.web.client.RestTemplate)

Example 3 with BiometricSubject

use of org.openmrs.module.registrationcore.api.biometrics.model.BiometricSubject in project openmrs-module-pihcore by PIH.

the class RestBiometricEngine method lookup.

@Override
public BiometricSubject lookup(String subjectId) {
    RestTemplate restTemplate = new RestTemplate();
    String url = getSubjectUrl() + "/" + subjectId;
    ResponseEntity<BiometricSubject> response = restTemplate.getForEntity(url, BiometricSubject.class);
    if (HttpStatus.OK.equals(response.getStatusCode())) {
        return response.getBody();
    } else if (HttpStatus.NOT_FOUND.equals(response.getStatusCode())) {
        return null;
    } else {
        throw new IllegalStateException("Error looking up biometric subject at URL <" + url + ">.  Response status code: " + response.getStatusCode());
    }
}
Also used : BiometricSubject(org.openmrs.module.registrationcore.api.biometrics.model.BiometricSubject) RestTemplate(org.springframework.web.client.RestTemplate)

Example 4 with BiometricSubject

use of org.openmrs.module.registrationcore.api.biometrics.model.BiometricSubject in project openmrs-module-pihcore by PIH.

the class RestBiometricEngine method updateSubjectId.

@Override
public BiometricSubject updateSubjectId(String oldId, String newId) {
    BiometricSubject subject = lookup(oldId);
    if (subject == null) {
        throw new IllegalStateException("Error updating subject id.  Existing subject with id of " + oldId + " is not found");
    }
    subject.setSubjectId(newId);
    enroll(subject);
    delete(oldId);
    return subject;
}
Also used : BiometricSubject(org.openmrs.module.registrationcore.api.biometrics.model.BiometricSubject)

Aggregations

BiometricSubject (org.openmrs.module.registrationcore.api.biometrics.model.BiometricSubject)4 RestTemplate (org.springframework.web.client.RestTemplate)3