Search in sources :

Example 61 with Enumeration

use of org.hl7.fhir.r4b.model.Enumeration in project gpconnect-demonstrator by nhsconnect.

the class AppointmentValidation method validateParticipantStatus.

public void validateParticipantStatus(ParticipationStatus participationStatus, Enumeration<ParticipationStatus> enumeration, Enumeration<ParticipationStatus> enumeration2) {
    Boolean validStatus = false;
    String participantStatusErr = "is a requirement but is missing.";
    if (participationStatus != null) {
        participantStatusErr = String.format("%s is not a valid ParticipationStatus code", participationStatus);
        EnumSet<ParticipationStatus> statusList = EnumSet.allOf(ParticipationStatus.class);
        validStatus = statusList.contains(enumeration.getValue());
    }
    if (!validStatus) {
        throw OperationOutcomeFactory.buildOperationOutcomeException(new UnprocessableEntityException(String.format("Appointment Participant %s Status %s", enumeration2, participantStatusErr)), SystemCode.INVALID_RESOURCE, IssueType.INVALID);
    }
}
Also used : UnprocessableEntityException(ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException) ParticipationStatus(org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus)

Example 62 with Enumeration

use of org.hl7.fhir.r4b.model.Enumeration in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceFhirResourceProviderIntegrationTest method shouldUpdateExistingAllergyAsJson.

@Test
public void shouldUpdateExistingAllergyAsJson() throws Exception {
    // get the existing record
    MockHttpServletResponse response = get("/AllergyIntolerance/" + ALLERGY_UUID).accept(FhirMediaTypes.JSON).go();
    AllergyIntolerance allergy = readResponse(response);
    // update the existing record
    Enumeration<AllergyIntolerance.AllergyIntoleranceCategory> category = new Enumeration<>(new AllergyIntolerance.AllergyIntoleranceCategoryEnumFactory());
    category.setValue(AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT);
    allergy.getCategory().set(0, category);
    // send the update to the server
    response = put("/AllergyIntolerance/" + ALLERGY_UUID).jsonContent(toJson(allergy)).accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    // read the updated record
    AllergyIntolerance updatedAllergy = readResponse(response);
    assertThat(updatedAllergy, notNullValue());
    assertThat(updatedAllergy.getIdElement().getIdPart(), equalTo(ALLERGY_UUID));
    assertThat(updatedAllergy.getCategory().get(0).getValue().toCode(), equalTo("environment"));
    assertThat(updatedAllergy, validResource());
    // double-check the record returned via get
    response = get("/AllergyIntolerance/" + ALLERGY_UUID).accept(FhirMediaTypes.JSON).go();
    AllergyIntolerance reReadAllergy = readResponse(response);
    assertThat(reReadAllergy.getCategory().get(0).getValue().toCode(), equalTo("environment"));
}
Also used : AllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance) Enumeration(org.hl7.fhir.dstu3.model.Enumeration) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 63 with Enumeration

use of org.hl7.fhir.r4b.model.Enumeration in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceFhirResourceProviderIntegrationTest method shouldUpdateExistingAllergyAsJson.

@Test
public void shouldUpdateExistingAllergyAsJson() throws Exception {
    // get the existing record
    MockHttpServletResponse response = get("/AllergyIntolerance/" + ALLERGY_UUID).accept(FhirMediaTypes.JSON).go();
    AllergyIntolerance allergy = readResponse(response);
    // update the existing record
    Enumeration<AllergyIntolerance.AllergyIntoleranceCategory> category = new Enumeration<>(new AllergyIntolerance.AllergyIntoleranceCategoryEnumFactory());
    category.setValue(AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT);
    allergy.getCategory().set(0, category);
    // send the update to the server
    response = put("/AllergyIntolerance/" + ALLERGY_UUID).jsonContent(toJson(allergy)).accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    // read the updated record
    AllergyIntolerance updatedAllergy = readResponse(response);
    assertThat(updatedAllergy, notNullValue());
    assertThat(updatedAllergy.getIdElement().getIdPart(), equalTo(ALLERGY_UUID));
    assertThat(updatedAllergy.getCategory().get(0).getCode(), equalTo("environment"));
    assertThat(updatedAllergy, validResource());
    // double-check the record returned via get
    response = get("/AllergyIntolerance/" + ALLERGY_UUID).accept(FhirMediaTypes.JSON).go();
    AllergyIntolerance reReadAllergy = readResponse(response);
    assertThat(reReadAllergy.getCategory().get(0).getCode(), equalTo("environment"));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Enumeration(org.hl7.fhir.r4.model.Enumeration) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 64 with Enumeration

use of org.hl7.fhir.r4b.model.Enumeration in project openmrs-module-fhir2 by openmrs.

the class AllergyIntoleranceFhirResourceProviderIntegrationTest method shouldUpdateExistingAllergyAsXML.

@Test
public void shouldUpdateExistingAllergyAsXML() throws Exception {
    // get the existing record
    MockHttpServletResponse response = get("/AllergyIntolerance/" + ALLERGY_UUID).accept(FhirMediaTypes.XML).go();
    AllergyIntolerance allergy = readResponse(response);
    // update the existing record
    Enumeration<AllergyIntolerance.AllergyIntoleranceCategory> category = new Enumeration<>(new AllergyIntolerance.AllergyIntoleranceCategoryEnumFactory());
    category.setValue(AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT);
    allergy.getCategory().set(0, category);
    // send the update to the server
    response = put("/AllergyIntolerance/" + ALLERGY_UUID).xmlContent(toXML(allergy)).accept(FhirMediaTypes.XML).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    // read the updated record
    AllergyIntolerance updatedAllergy = readResponse(response);
    assertThat(updatedAllergy, notNullValue());
    assertThat(updatedAllergy.getIdElement().getIdPart(), equalTo(ALLERGY_UUID));
    assertThat(updatedAllergy.getCategory().get(0).getCode(), equalTo("environment"));
    assertThat(updatedAllergy, validResource());
    // double-check the record returned via get
    response = get("/AllergyIntolerance/" + ALLERGY_UUID).accept(FhirMediaTypes.XML).go();
    AllergyIntolerance reReadAllergy = readResponse(response);
    assertThat(reReadAllergy.getCategory().get(0).getCode(), equalTo("environment"));
}
Also used : AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Enumeration(org.hl7.fhir.r4.model.Enumeration) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 65 with Enumeration

use of org.hl7.fhir.r4b.model.Enumeration in project kindling by HL7.

the class CDAGenerator method dumpPaths.

private void dumpPaths() {
    for (StructureDefinition sd : structures) {
        if (sd.hasBaseDefinition())
            System.out.println("Class " + sd.getId() + " : " + sd.getBaseDefinition().substring(40));
        else
            System.out.println("Class " + sd.getId());
        for (ElementDefinition ed : sd.getDifferential().getElement()) {
            CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
            for (TypeRefComponent t : ed.getType()) {
                b.append(t.getWorkingCode());
            }
            CommaSeparatedStringBuilder b2 = new CommaSeparatedStringBuilder();
            for (Enumeration<PropertyRepresentation> r : ed.getRepresentation()) if (!r.asStringValue().equals("typeAttr"))
                b2.append(r.asStringValue());
            String s = Utilities.noString(b2.toString()) ? "" : " <<" + b2.toString() + ">>";
            if (ed.hasContentReference())
                s = " <<see " + ed.getContentReference().substring(1) + ">>";
            System.out.println("  " + ed.getPath() + " [" + ed.getMin() + ".." + ed.getMax() + "] : " + b.toString() + s);
        }
    }
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) PropertyRepresentation(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation) TypeRefComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition)

Aggregations

CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)14 ArrayList (java.util.ArrayList)11 NotImplementedException (org.apache.commons.lang3.NotImplementedException)11 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)10 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)10 FHIRException (org.hl7.fhir.exceptions.FHIRException)7 StringType (org.hl7.fhir.r5.model.StringType)7 ConformanceResourceStatusEnumFactory (org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatusEnumFactory)6 Enumeration (org.hl7.fhir.dstu3.model.Enumeration)6 Enumeration (org.hl7.fhir.r4.model.Enumeration)6 StringType (org.hl7.fhir.r4b.model.StringType)6 Enumeration (org.hl7.fhir.r5.model.Enumeration)6 UriType (org.hl7.fhir.r5.model.UriType)6 Base64 (org.apache.commons.codec.binary.Base64)5 PublicationStatusEnumFactory (org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory)5 StringType (org.hl7.fhir.dstu3.model.StringType)5 Enumeration (org.hl7.fhir.dstu2.model.Enumeration)4 Reference (org.hl7.fhir.dstu2.model.Reference)4 StringType (org.hl7.fhir.dstu2.model.StringType)4 Patient (org.hl7.fhir.r4.model.Patient)4