Search in sources :

Example 1 with AdministrativeGender

use of org.hl7.fhir.r4.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.r4.model.Enumerations.AdministrativeGender in project quality-measure-and-cohort-service by Alvearie.

the class FhirTestBase method mockPatientRetrievalTimeout.

protected Patient mockPatientRetrievalTimeout(String id, AdministrativeGender gender, int ageInYears, int delayMillis) {
    Patient patient = getPatient(id, gender, ageInYears);
    mockeDelayedFhirResourceRetrieval(get(urlEqualTo("/" + patient.getClass().getSimpleName() + "/" + patient.getId() + "?_format=json")), getFhirParser(), patient, getFhirServerConfig(), 200, delayMillis);
    return patient;
}
Also used : Patient(org.hl7.fhir.r4.model.Patient)

Example 3 with AdministrativeGender

use of org.hl7.fhir.r4.model.Enumerations.AdministrativeGender in project quality-measure-and-cohort-service by Alvearie.

the class FhirTestBase method getPatient.

protected Patient getPatient(String id, AdministrativeGender gender, int ageInYears) {
    OffsetDateTime birthDate;
    Patient patient = new Patient();
    patient.setId(id);
    patient.setGender(gender);
    birthDate = OffsetDateTime.now().minusYears(ageInYears);
    patient.setBirthDate(Date.from(birthDate.toInstant()));
    return patient;
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Patient(org.hl7.fhir.r4.model.Patient)

Example 4 with AdministrativeGender

use of org.hl7.fhir.r4.model.Enumerations.AdministrativeGender in project quality-measure-and-cohort-service by Alvearie.

the class FhirTestBase method getPatient.

protected Patient getPatient(String id, Enumerations.AdministrativeGender administrativeGender, String birthDateStr) throws ParseException {
    Patient patient = new Patient();
    patient.setId(id);
    patient.setGender(administrativeGender);
    if (birthDateStr != null) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date birthDate = format.parse(birthDateStr);
        patient.setBirthDate(birthDate);
    }
    return patient;
}
Also used : Patient(org.hl7.fhir.r4.model.Patient) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 5 with AdministrativeGender

use of org.hl7.fhir.r4.model.Enumerations.AdministrativeGender in project quality-measure-and-cohort-service by Alvearie.

the class R4DataProviderFactoryTest method verifyDataProviderMap.

private void verifyDataProviderMap(Map<String, CqlDataProvider> dataProviderMap) {
    Assert.assertEquals(1, dataProviderMap.size());
    DataProvider dataProvider = dataProviderMap.get(R4DataProviderFactory.FHIR_R4_URL);
    Iterable<Object> iterable = dataProvider.retrieve("Patient", "id", PATIENT_ID, "Patient", null, null, null, null, null, null, null, null);
    List<Object> list = new ArrayList<>();
    iterable.forEach(list::add);
    Assert.assertEquals(1, list.size());
    Object possiblePatient = list.get(0);
    Assert.assertTrue("Returned value not type Patient", possiblePatient instanceof Patient);
    Patient patient = (Patient) possiblePatient;
    AdministrativeGender actual = patient.getGender();
    Assert.assertEquals(AdministrativeGender.OTHER, actual);
}
Also used : CqlDataProvider(com.ibm.cohort.cql.data.CqlDataProvider) DataProvider(org.opencds.cqf.cql.engine.data.DataProvider) ArrayList(java.util.ArrayList) Patient(org.hl7.fhir.r4.model.Patient) AdministrativeGender(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender)

Aggregations

Patient (org.hl7.fhir.r4.model.Patient)6 AdministrativeGender (org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender)2 AdministrativeGender (org.hl7.fhir.r4.model.Enumerations.AdministrativeGender)2 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)1 CqlDataProvider (com.ibm.cohort.cql.data.CqlDataProvider)1 SimpleDateFormat (java.text.SimpleDateFormat)1 OffsetDateTime (java.time.OffsetDateTime)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 AdministrativeGenderEnumFactory (org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGenderEnumFactory)1 AdministrativeGenderEnumFactory (org.hl7.fhir.dstu2016may.model.Enumerations.AdministrativeGenderEnumFactory)1 AdministrativeGenderEnumFactory (org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGenderEnumFactory)1 DataProvider (org.opencds.cqf.cql.engine.data.DataProvider)1