private int toOrder(Entry theO1) { int o1 = 0; if (theO1.getRequest().getMethodElement().getValueAsEnum() != null) { switch (theO1.getRequest().getMethodElement().getValueAsEnum()) { case DELETE: o1 = 1; break; case POST: o1 = 2; break; case PUT: o1 = 3; break; case GET: o1 = 4; break; } } return o1; }
public T getValueAsEnum() { Validate.notNull(myBinder, "This object does not have a binder. Constructor BoundCodeDt() should not be called!"); T retVal = myBinder.fromCodeString(getValue()); if (retVal == null) { // TODO: throw special exception type? } return retVal; }
private static <T extends Enum<?>> String extractSystem(BoundCodeDt<T> theBoundCode) { if (theBoundCode.getValueAsEnum() != null) { IValueSetEnumBinder<T> binder = theBoundCode.getBinder(); return binder.toSystemString(theBoundCode.getValueAsEnum()); } return null; }
@SuppressWarnings("unused") public static void codes() { // START SNIPPET: codes Patient patient = new Patient(); // You can set this code using a String if you want. Note that // for "closed" valuesets (such as the one used for Patient.gender) // you must use one of the strings defined by the FHIR specification. // You must not define your own. patient.getGenderElement().setValue("male"); // HAPI also provides Java enumerated types which make it easier to // deal with coded values. This code achieves the exact same result // as the code above. patient.setGender(AdministrativeGenderEnum.MALE); // You can also retrieve coded values the same way String genderString = patient.getGenderElement().getValueAsString(); AdministrativeGenderEnum genderEnum = patient.getGenderElement().getValueAsEnum(); // The following is a shortcut to create patient.setMaritalStatus(MaritalStatusCodesEnum.M); // END SNIPPET: codes }
ConditionalDeleteStatusEnum conditionalDelete = nextResource.getConditionalDeleteElement().getValueAsEnum(); if (conditionalDelete == ConditionalDeleteStatusEnum.MULTIPLE_DELETES_SUPPORTED && myDaoConfig.isAllowMultipleDelete() == false) { nextResource.setConditionalDelete(ConditionalDeleteStatusEnum.SINGLE_DELETES_SUPPORTED); Long count = counts.get(nextResource.getTypeElement().getValueAsString()); if (count != null) { nextResource.addUndeclaredExtension(false, ExtensionConstants.CONF_RESOURCE_COUNT, new DecimalDt(count)); if (nextParam.getTypeElement().getValueAsEnum() == SearchParamTypeEnum.REFERENCE) { List<BoundCodeDt<ResourceTypeEnum>> targets = nextParam.getTarget(); for (BoundCodeDt<ResourceTypeEnum> next : targets) { RuntimeResourceDefinition def = ctx.getResourceDefinition(next.getValue()); for (RuntimeSearchParam nextChainedParam : def.getSearchParams()) { nextParam.addChain(nextChainedParam.getName());
public BoundCodeDt(IValueSetEnumBinder<T> theBinder, T theValue) { Validate.notNull(theBinder, "theBinder must not be null"); myBinder = theBinder; setValueAsEnum(theValue); }
private void verifyStatusOk(RestOperationTypeEnum theOperation, IBaseResource theOldResourceOrNull, IBaseResource theResource) { Subscription subscription = (Subscription) theResource; SubscriptionStatusEnum newStatus = subscription.getStatusElement().getValueAsEnum(); if (newStatus == SubscriptionStatusEnum.REQUESTED || newStatus == SubscriptionStatusEnum.OFF) { return; } if (newStatus == null) { String actualCode = subscription.getStatusElement().getValueAsString(); throw new UnprocessableEntityException("Can not " + theOperation.getCode() + " resource: Subscription.status must be populated on this server" + ((isNotBlank(actualCode)) ? " (invalid value " + actualCode + ")" : "")); } if (theOldResourceOrNull != null) { try { Subscription existing = (Subscription) theOldResourceOrNull; SubscriptionStatusEnum existingStatus = existing.getStatusElement().getValueAsEnum(); if (existingStatus != newStatus) { verifyActiveStatus(theOperation, subscription, newStatus, existingStatus); } } catch (ResourceNotFoundException e) { verifyActiveStatus(theOperation, subscription, newStatus, null); } } else { verifyActiveStatus(theOperation, subscription, newStatus, null); } }
BundleEntryTransactionMethodEnum httpVerb = ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.get(next); if (httpVerb != null) { entry.getRequest().getMethodElement().setValueAsString(httpVerb.getCode()); entry.getSearch().getModeElement().setValue(searchMode.getCode());
/** * Add a value for <b>aggregation</b> () * * <p> * <b>Definition:</b> * If the type is a reference to another resource, how the resource is or can be aggregated - is it a contained resource, or a reference, and if the context is a bundle, is it included in the bundle. * </p> */ public BoundCodeDt<AggregationModeEnum> addAggregation() { BoundCodeDt<AggregationModeEnum> retVal = new BoundCodeDt<AggregationModeEnum>(AggregationModeEnum.VALUESET_BINDER); getAggregation().add(retVal); return retVal; }
@Override public INarrative setStatusAsString(String theString) { getStatus().setValueAsString(theString); return this; }
@Override public void addRootPropertiesToBundle(String theId, String theServerBase, String theLinkSelf, String theLinkPrev, String theLinkNext, Integer theTotalResults, BundleTypeEnum theBundleType, IPrimitiveType<Date> theLastUpdated) { myBase = theServerBase; if (myBundle.getIdElement().isEmpty()) { myBundle.setId(theId); } if (myBundle.getId().isEmpty()) { myBundle.setId(UUID.randomUUID().toString()); } if (ResourceMetadataKeyEnum.UPDATED.get(myBundle) == null) { ResourceMetadataKeyEnum.UPDATED.put(myBundle, (InstantDt) theLastUpdated); } if (!hasLink(Constants.LINK_SELF, myBundle) && isNotBlank(theLinkSelf)) { myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theLinkSelf); } if (!hasLink(Constants.LINK_NEXT, myBundle) && isNotBlank(theLinkNext)) { myBundle.addLink().setRelation(Constants.LINK_NEXT).setUrl(theLinkNext); } if (!hasLink(Constants.LINK_PREVIOUS, myBundle) && isNotBlank(theLinkPrev)) { myBundle.addLink().setRelation(Constants.LINK_PREVIOUS).setUrl(theLinkPrev); } if (myBundle.getTypeElement().isEmpty() && theBundleType != null) { myBundle.getTypeElement().setValueAsString(theBundleType.getCode()); } if (myBundle.getTotalElement().isEmpty() && theTotalResults != null) { myBundle.getTotalElement().setValue(theTotalResults); } }
@Override public String getStatusAsString() { return getStatus().getValueAsString(); }
if (!needContactPointSystem.equals(nextValue.getSystemElement().getValueAsString())) { continue; systems.add(nextValue.getSystemElement().getValueAsString()); codes.add(nextValue.getValueElement().getValue()); } else if (nextObject instanceof BoundCodeDt) { BoundCodeDt<?> obj = (BoundCodeDt<?>) nextObject; String system = extractSystem(obj); String code = obj.getValue(); if (isNotBlank(code)) { systems.add(system);
BundleEntry entry = myBundle.addResource(next, myContext, theServerBase); if (myContext.getVersion().getVersion().isNewerThan(FhirVersionEnum.DSTU1)) { if (entry.getSearchMode().isEmpty()) { entry.getSearchMode().setValueAsEnum(BundleEntrySearchModeEnum.INCLUDE);
ConditionalDeleteStatusEnum conditionalDelete = nextResource.getConditionalDeleteElement().getValueAsEnum(); if (conditionalDelete == ConditionalDeleteStatusEnum.MULTIPLE_DELETES_SUPPORTED && myDaoConfig.isAllowMultipleDelete() == false) { nextResource.setConditionalDelete(ConditionalDeleteStatusEnum.SINGLE_DELETES_SUPPORTED); Long count = counts.get(nextResource.getTypeElement().getValueAsString()); if (count != null) { nextResource.addUndeclaredExtension(false, ExtensionConstants.CONF_RESOURCE_COUNT, new DecimalDt(count)); if (nextParam.getTypeElement().getValueAsEnum() == SearchParamTypeEnum.REFERENCE) { List<BoundCodeDt<ResourceTypeEnum>> targets = nextParam.getTarget(); for (BoundCodeDt<ResourceTypeEnum> next : targets) { RuntimeResourceDefinition def = ctx.getResourceDefinition(next.getValue()); for (RuntimeSearchParam nextChainedParam : def.getSearchParams()) { nextParam.addChain(nextChainedParam.getName());
/** * Sets the value(s) for <b>rules</b> () * * <p> * <b>Definition:</b> * Whether additional slices are allowed or not. When the slices are ordered, profile authors can also say that additional slices are only allowed at the end * </p> */ public Slicing setRules(SlicingRulesEnum theValue) { getRulesElement().setValueAsEnum(theValue); return this; }
private void verifyStatusOk(RestOperationTypeEnum theOperation, IBaseResource theOldResourceOrNull, IBaseResource theResource) { Subscription subscription = (Subscription) theResource; SubscriptionStatusEnum newStatus = subscription.getStatusElement().getValueAsEnum(); if (newStatus == SubscriptionStatusEnum.REQUESTED || newStatus == SubscriptionStatusEnum.OFF) { return; } if (newStatus == null) { String actualCode = subscription.getStatusElement().getValueAsString(); throw new UnprocessableEntityException("Can not " + theOperation.getCode() + " resource: Subscription.status must be populated on this server" + ((isNotBlank(actualCode)) ? " (invalid value " + actualCode + ")" : "")); } if (theOldResourceOrNull != null) { try { Subscription existing = (Subscription) theOldResourceOrNull; SubscriptionStatusEnum existingStatus = existing.getStatusElement().getValueAsEnum(); if (existingStatus != newStatus) { verifyActiveStatus(theOperation, subscription, newStatus, existingStatus); } } catch (ResourceNotFoundException e) { verifyActiveStatus(theOperation, subscription, newStatus, null); } } else { verifyActiveStatus(theOperation, subscription, newStatus, null); } }
BundleEntryTransactionMethodEnum httpVerb = ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.get(next); if (httpVerb != null) { entry.getRequest().getMethodElement().setValueAsString(httpVerb.getCode()); entry.getSearch().getModeElement().setValue(searchMode.getCode());
/** * Add a value for <b>representation</b> () * * <p> * <b>Definition:</b> * Codes that define how this element is represented in instances, when the deviation varies from the normal case * </p> */ public BoundCodeDt<PropertyRepresentationEnum> addRepresentation() { BoundCodeDt<PropertyRepresentationEnum> retVal = new BoundCodeDt<PropertyRepresentationEnum>(PropertyRepresentationEnum.VALUESET_BINDER); getRepresentation().add(retVal); return retVal; }