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);
}
}
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"));
}
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"));
}
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"));
}
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);
}
}
}
Aggregations