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; }
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; }
@SuppressWarnings("unchecked") private Bundle doTransaction(ServletRequestDetails theRequestDetails, Bundle theRequest, String theActionName) { BundleTypeEnum transactionType = theRequest.getTypeElement().getValueAsEnum(); if (transactionType == BundleTypeEnum.BATCH) { return batch(theRequestDetails, theRequest); } return doTransaction(theRequestDetails, theRequest, theActionName, transactionType); }
@Override protected void validateResourceForStorage(SearchParameter theResource, ResourceTable theEntityToSave) { super.validateResourceForStorage(theResource, theEntityToSave); Enum<?> status = theResource.getStatusElement().getValueAsEnum(); List<BoundCodeDt<ResourceTypeEnum>> base = Collections.emptyList(); if (theResource.getBase() != null) { base = Arrays.asList(theResource.getBaseElement()); } String expression = theResource.getXpath(); FhirContext context = getContext(); SearchParamTypeEnum type = theResource.getTypeElement().getValueAsEnum(); FhirResourceDaoSearchParameterR4.validateSearchParam(type, status, base, expression, context, getConfig()); }
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); } }
RestSearchParameterTypeEnum paramType = null; RuntimeSearchParam.RuntimeSearchParamStatusEnum status = null; switch (theNextSp.getTypeElement().getValueAsEnum()) { case COMPOSITE: paramType = RestSearchParameterTypeEnum.COMPOSITE; switch (theNextSp.getStatusElement().getValueAsEnum()) { case ACTIVE: status = RuntimeSearchParam.RuntimeSearchParamStatusEnum.ACTIVE;
originalRequestOrder.put(theRequest.getEntry().get(i), i); response.addEntry(); if (theRequest.getEntry().get(i).getRequest().getMethodElement().getValueAsEnum() == HTTPVerbEnum.GET) { getEntries.add(theRequest.getEntry().get(i));
private void verifyActiveStatus(RestOperationTypeEnum theOperation, Subscription theSubscription, SubscriptionStatusEnum newStatus, SubscriptionStatusEnum theExistingStatus) { SubscriptionChannelTypeEnum channelType = theSubscription.getChannel().getTypeElement().getValueAsEnum(); if (channelType == null) { throw new UnprocessableEntityException("Subscription.channel.type must be populated"); } if (channelType == SubscriptionChannelTypeEnum.WEBSOCKET) { return; } if (theExistingStatus != null) { throw new UnprocessableEntityException("Subscription.status can not be changed from " + describeStatus(theExistingStatus) + " to " + describeStatus(newStatus)); } if (theSubscription.getStatus() == null) { throw new UnprocessableEntityException("Can not " + theOperation.getCode().toLowerCase() + " resource: Subscription.status must be populated on this server"); } throw new UnprocessableEntityException("Subscription.status must be '" + SubscriptionStatusEnum.OFF.getCode() + "' or '" + SubscriptionStatusEnum.REQUESTED.getCode() + "' on a newly created subscription"); }
try { Bundle nextResponseBundle; if (nextRequestEntry.getRequest().getMethodElement().getValueAsEnum() == HTTPVerbEnum.GET) {
@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 }
@Override protected void validateResourceForStorage(Subscription theResource, ResourceTable theEntityToSave) { super.validateResourceForStorage(theResource, theEntityToSave); RuntimeResourceDefinition resDef = validateCriteriaAndReturnResourceDefinition(theResource); IFhirResourceDao<? extends IBaseResource> dao = getDao(resDef.getImplementingClass()); if (dao == null) { throw new UnprocessableEntityException("Subscription.criteria contains invalid/unsupported resource type: " + resDef); } if (theResource.getChannel().getType() == null) { throw new UnprocessableEntityException("Subscription.channel.type must be populated on this server"); } SubscriptionStatusEnum status = theResource.getStatusElement().getValueAsEnum(); if (status == null) { throw new UnprocessableEntityException("Subscription.status must be populated on this server"); } }
ConditionalDeleteStatusEnum conditionalDelete = nextResource.getConditionalDeleteElement().getValueAsEnum(); if (conditionalDelete == ConditionalDeleteStatusEnum.MULTIPLE_DELETES_SUPPORTED && myDaoConfig.isAllowMultipleDelete() == false) { nextResource.setConditionalDelete(ConditionalDeleteStatusEnum.SINGLE_DELETES_SUPPORTED); if (nextParam.getTypeElement().getValueAsEnum() == SearchParamTypeEnum.REFERENCE) { List<BoundCodeDt<ResourceTypeEnum>> targets = nextParam.getTarget(); for (BoundCodeDt<ResourceTypeEnum> next : targets) {
HTTPVerbEnum verb = nextReqEntry.getRequest().getMethodElement().getValueAsEnum(); if (verb == null) { throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionEntryHasInvalidVerb", nextReqEntry.getRequest().getMethod())); if (nextEntry.getRequest().getMethodElement().getValueAsEnum() == HTTPVerbEnum.POST) { String matchUrl = nextEntry.getRequest().getIfNoneExist(); if (isNotBlank(matchUrl)) {
public static boolean isLocked(Encounter encounter) { BoundCodeDt<EncounterStateEnum> status = encounter.getStatusElement(); return status != null && status.getValueAsEnum() == EncounterStateEnum.FINISHED; }
@Override public int compare(RestResourceInteraction theO1, RestResourceInteraction theO2) { TypeRestfulInteractionEnum o1 = theO1.getCodeElement().getValueAsEnum(); TypeRestfulInteractionEnum o2 = theO2.getCodeElement().getValueAsEnum(); if (o1 == null && o2 == null) { return 0; } if (o1 == null) { return 1; } if (o2 == null) { return -1; } return o1.ordinal() - o2.ordinal(); } });
@SuppressWarnings("unchecked") private Bundle doTransaction(ServletRequestDetails theRequestDetails, Bundle theRequest, String theActionName) { BundleTypeEnum transactionType = theRequest.getTypeElement().getValueAsEnum(); if (transactionType == BundleTypeEnum.BATCH) { return batch(theRequestDetails, theRequest); } return doTransaction(theRequestDetails, theRequest, theActionName, transactionType); }
@Override protected void validateResourceForStorage(SearchParameter theResource, ResourceTable theEntityToSave) { super.validateResourceForStorage(theResource, theEntityToSave); Enum<?> status = theResource.getStatusElement().getValueAsEnum(); List<BoundCodeDt<ResourceTypeEnum>> base = Collections.emptyList(); if (theResource.getBase() != null) { base = Arrays.asList(theResource.getBaseElement()); } String expression = theResource.getXpath(); FhirContext context = getContext(); SearchParamTypeEnum type = theResource.getTypeElement().getValueAsEnum(); FhirResourceDaoSearchParameterR4.validateSearchParam(type, status, base, expression, context, getConfig()); }
private void verifyActiveStatus(RestOperationTypeEnum theOperation, Subscription theSubscription, SubscriptionStatusEnum newStatus, SubscriptionStatusEnum theExistingStatus) { SubscriptionChannelTypeEnum channelType = theSubscription.getChannel().getTypeElement().getValueAsEnum(); if (channelType == null) { throw new UnprocessableEntityException("Subscription.channel.type must be populated"); } if (channelType == SubscriptionChannelTypeEnum.WEBSOCKET) { return; } if (theExistingStatus != null) { throw new UnprocessableEntityException("Subscription.status can not be changed from " + describeStatus(theExistingStatus) + " to " + describeStatus(newStatus)); } if (theSubscription.getStatus() == null) { throw new UnprocessableEntityException("Can not " + theOperation.getCode().toLowerCase() + " resource: Subscription.status must be populated on this server"); } throw new UnprocessableEntityException("Subscription.status must be '" + SubscriptionStatusEnum.OFF.getCode() + "' or '" + SubscriptionStatusEnum.REQUESTED.getCode() + "' on a newly created subscription"); }
if (nextIssue.getSeverityElement().getValueAsEnum().ordinal() >= IssueSeverityEnum.ERROR.ordinal()) { System.out.println("We failed validation!");
@Override protected void validateResourceForStorage(Subscription theResource, ResourceTable theEntityToSave) { super.validateResourceForStorage(theResource, theEntityToSave); RuntimeResourceDefinition resDef = validateCriteriaAndReturnResourceDefinition(theResource); IFhirResourceDao<? extends IBaseResource> dao = getDao(resDef.getImplementingClass()); if (dao == null) { throw new UnprocessableEntityException("Subscription.criteria contains invalid/unsupported resource type: " + resDef); } if (theResource.getChannel().getType() == null) { throw new UnprocessableEntityException("Subscription.channel.type must be populated on this server"); } SubscriptionStatusEnum status = theResource.getStatusElement().getValueAsEnum(); if (status == null) { throw new UnprocessableEntityException("Subscription.status must be populated on this server"); } }