use of org.hl7.fhir.dstu2016may.model.IntegerType in project org.hl7.fhir.core by hapifhir.
the class ProfileUtilitiesTests method testMinValueChange.
/**
* Change min value
*/
@Test
void testMinValueChange() {
// Given
StructureDefinition focus = new StructureDefinition();
StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Appointment").copy();
focus.setUrl(Utilities.makeUuidUrn());
focus.setBaseDefinition(base.getUrl());
focus.setType(base.getType());
focus.setDerivation(TypeDerivationRule.CONSTRAINT);
ElementDefinition id = focus.getDifferential().addElement();
id.setPath("Appointment.minutesDuration");
id.setMinValue(new IntegerType(1));
List<ValidationMessage> messages = new ArrayList<>();
// When
new ProfileUtilities(TestingUtilities.context(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test");
// Then
boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size();
for (int i = 0; i < base.getSnapshot().getElement().size(); i++) {
if (ok) {
ElementDefinition b = base.getSnapshot().getElement().get(i);
ElementDefinition f = focus.getSnapshot().getElement().get(i);
b.setRequirements(null);
f.setRequirements(null);
for (ElementDefinitionConstraintComponent c : b.getConstraint()) {
c.setSource(null);
}
for (ElementDefinitionConstraintComponent c : f.getConstraint()) {
c.setSource(null);
}
if (!f.hasBase() || !b.getPath().equals(f.getPath())) {
ok = false;
} else {
if (f.getPath().equals("Appointment.minutesDuration")) {
ok = f.getMinValue() instanceof IntegerType && ((IntegerType) f.getMinValue()).getValue() == 1;
if (ok) {
// Can't set minValue to null so change base minValue to IntegerType(1)
b.setMinValue(new IntegerType(1));
}
}
if (!Base.compareDeep(b, f, true)) {
ok = false;
}
}
}
}
Assertions.assertTrue(ok);
}
use of org.hl7.fhir.dstu2016may.model.IntegerType in project org.hl7.fhir.core by hapifhir.
the class IntegerTypeNullTest method equalsDeep.
@Test
@DisplayName("Test null value equalsDeep()")
void equalsDeep() {
IntegerType nullInteger = new IntegerType();
IntegerType validInteger = new IntegerType("42");
Assertions.assertFalse(nullInteger.equalsDeep(validInteger));
}
use of org.hl7.fhir.dstu2016may.model.IntegerType in project org.hl7.fhir.core by hapifhir.
the class IntegerTypeNullTest method copy.
@Test
@DisplayName("Test null value copy()")
void copy() {
IntegerType nullInteger = new IntegerType();
IntegerType copyInteger = nullInteger.copy();
Assertions.assertNull(copyInteger.getValue());
}
use of org.hl7.fhir.dstu2016may.model.IntegerType in project org.hl7.fhir.core by hapifhir.
the class IntegerTypeNullTest method typedCopy.
@Test
@DisplayName("Test null value typedCopy()")
void typedCopy() {
IntegerType nullInteger = new IntegerType();
IntegerType copyInteger = (IntegerType) nullInteger.typedCopy();
Assertions.assertNull(copyInteger.getValue());
}
use of org.hl7.fhir.dstu2016may.model.IntegerType in project odm2fhir by num-codex.
the class SOFAScore method createObservation.
private Observation createObservation(List<ItemData> itemDatas, ItemData sofaTotalScore, ItemData dateCoding) {
var observation = (Observation) new Observation().addIdentifier(createIdentifier(OBSERVATION, sofaTotalScore).setType(OBI).setAssigner(getOrganizationReference())).setStatus(FINAL).setEffective(createDateTimeType(dateCoding)).addCategory(SURVEY).setCode(createCodeableConcept(createCoding(ECRF_PARAMETER_CODES, "06", "SOFA-Score")).setText("Sepsis-related organ failure assessment score")).setMeta(createMeta(NUMStructureDefinition.SOFA_SCORE));
itemDatas.stream().map(ItemData::getValue).filter(StringUtils::isNotBlank).forEach(code -> observation.addComponent(new ObservationComponentComponent().setCode(createCodeableConcept(createCoding(SOFA_SCORE, chop(code), getDisplay(chop(code)))).setText(getDefinition(chop(code)))).setValue(createCodeableConcept(createCoding(SOFA_SCORE, code, getDisplay(code))).setText(getDefinition(code)))));
if (sofaTotalScore.isEmpty()) {
observation.setDataAbsentReason(UNKNOWN);
} else {
observation.setValue(new IntegerType().setValue(Integer.valueOf(sofaTotalScore.getValue())));
}
return observation;
}
Aggregations