Search in sources :

Example 1 with AdministrativeGender

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender in project gpconnect-demonstrator by nhsconnect.

the class PatientResourceProvider method valiateGender.

private void valiateGender(Patient patient) {
    AdministrativeGender gender = patient.getGender();
    if (gender != null) {
        EnumSet<AdministrativeGender> genderList = EnumSet.allOf(AdministrativeGender.class);
        Boolean valid = false;
        for (AdministrativeGender genderItem : genderList) {
            if (genderItem.toCode().equalsIgnoreCase(gender.toString())) {
                valid = true;
                break;
            }
        }
        if (!valid) {
            throw OperationOutcomeFactory.buildOperationOutcomeException(new InvalidRequestException(String.format("The supplied Patient gender %s is an unrecognised type.", gender)), SystemCode.BAD_REQUEST, IssueType.INVALID);
        }
    }
}
Also used : InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) AdministrativeGender(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender)

Example 2 with AdministrativeGender

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender in project gpconnect-demonstrator by nhsconnect.

the class PatientResourceProvider method validateGender.

// validateTelecomAndAddress
private void validateGender(Patient patient) {
    AdministrativeGender gender = patient.getGender();
    if (gender != null) {
        EnumSet<AdministrativeGender> genderList = EnumSet.allOf(AdministrativeGender.class);
        Boolean valid = false;
        for (AdministrativeGender genderItem : genderList) {
            if (genderItem.toCode().equalsIgnoreCase(gender.toString())) {
                valid = true;
                break;
            }
        }
        if (!valid) {
            throwInvalidRequest400_BadRequestException(String.format("The supplied Patient gender %s is an unrecognised type.", gender));
        }
    }
}
Also used : AdministrativeGender(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender)

Aggregations

AdministrativeGender (org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender)2 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)1