idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
32,800
public void visit ( IBaseResource theResource , IModelVisitor theVisitor ) { BaseRuntimeElementCompositeDefinition < ? > def = myContext . getResourceDefinition ( theResource ) ; visit ( new IdentityHashMap < Object , Object > ( ) , theResource , theResource , null , null , def , theVisitor ) ; }
Visit all elements in a given resource
32,801
public SubscriptionMatchResult match ( String theCriteria , IBaseResource theResource , ResourceIndexedSearchParams theSearchParams ) { RuntimeResourceDefinition resourceDefinition ; if ( theResource == null ) { resourceDefinition = UrlUtil . parseUrlResourceType ( myFhirContext , theCriteria ) ; } else { resourceDefinition = myFhirContext . getResourceDefinition ( theResource ) ; } SearchParameterMap searchParameterMap ; try { searchParameterMap = myMatchUrlService . translateMatchUrl ( theCriteria , resourceDefinition ) ; } catch ( UnsupportedOperationException e ) { return SubscriptionMatchResult . unsupportedFromReason ( SubscriptionMatchResult . PARSE_FAIL ) ; } searchParameterMap . clean ( ) ; if ( searchParameterMap . getLastUpdated ( ) != null ) { return SubscriptionMatchResult . unsupportedFromParameterAndReason ( Constants . PARAM_LASTUPDATED , SubscriptionMatchResult . STANDARD_PARAMETER ) ; } for ( Map . Entry < String , List < List < IQueryParameterType > > > entry : searchParameterMap . entrySet ( ) ) { String theParamName = entry . getKey ( ) ; List < List < IQueryParameterType > > theAndOrParams = entry . getValue ( ) ; SubscriptionMatchResult result = matchIdsWithAndOr ( theParamName , theAndOrParams , resourceDefinition , theResource , theSearchParams ) ; if ( ! result . matched ( ) ) { return result ; } } return SubscriptionMatchResult . successfulMatch ( ) ; }
This method is called in two different scenarios . With a null theResource it determines whether database matching might be required . Otherwise it tries to perform the match in - memory returning UNSUPPORTED if it s not possible .
32,802
public void registerOsgiProvider ( Object provider ) throws FhirConfigurationException { if ( null == provider ) { throw new NullPointerException ( "FHIR Provider cannot be null" ) ; } try { super . registerProvider ( provider ) ; log . trace ( "registered provider. class [" + provider . getClass ( ) . getName ( ) + "]" ) ; this . serverProviders . add ( provider ) ; } catch ( Exception e ) { log . error ( "Error registering FHIR Provider" , e ) ; throw new FhirConfigurationException ( "Error registering FHIR Provider" , e ) ; } }
Dynamically registers a single provider with the RestfulServer
32,803
public void unregisterOsgiProvider ( Object provider ) throws FhirConfigurationException { if ( null == provider ) { throw new NullPointerException ( "FHIR Provider cannot be null" ) ; } try { this . serverProviders . remove ( provider ) ; log . trace ( "unregistered provider. class [" + provider . getClass ( ) . getName ( ) + "]" ) ; super . unregisterProvider ( provider ) ; } catch ( Exception e ) { log . error ( "Error unregistering FHIR Provider" , e ) ; throw new FhirConfigurationException ( "Error unregistering FHIR Provider" , e ) ; } }
Dynamically unregisters a single provider with the RestfulServer
32,804
public void registerOsgiProviders ( Collection < Object > providers ) throws FhirConfigurationException { if ( null == providers ) { throw new NullPointerException ( "FHIR Provider list cannot be null" ) ; } try { super . registerProviders ( providers ) ; for ( Object provider : providers ) { log . trace ( "registered provider. class [" + provider . getClass ( ) . getName ( ) + "]" ) ; this . serverProviders . add ( provider ) ; } } catch ( Exception e ) { log . error ( "Error registering FHIR Providers" , e ) ; throw new FhirConfigurationException ( "Error registering FHIR Providers" , e ) ; } }
Dynamically registers a list of providers with the RestfulServer
32,805
public void unregisterOsgiProviders ( Collection < Object > providers ) throws FhirConfigurationException { if ( null == providers ) { throw new NullPointerException ( "FHIR Provider list cannot be null" ) ; } try { for ( Object provider : providers ) { log . trace ( "unregistered provider. class [" + provider . getClass ( ) . getName ( ) + "]" ) ; this . serverProviders . remove ( provider ) ; } super . unregisterProvider ( providers ) ; } catch ( Exception e ) { log . error ( "Error unregistering FHIR Providers" , e ) ; throw new FhirConfigurationException ( "Error unregistering FHIR Providers" , e ) ; } }
Dynamically unregisters a list of providers with the RestfulServer
32,806
public void unregisterOsgiProviders ( ) throws FhirConfigurationException { Collection < Object > providers = new ArrayList < Object > ( ) ; providers . addAll ( this . serverProviders ) ; this . unregisterOsgiProviders ( providers ) ; }
Dynamically unregisters all of providers currently registered
32,807
public List < Patient > search ( @ RequiredParam ( name = "family" ) StringParam theParam ) { List < Patient > retVal = new ArrayList < Patient > ( ) ; for ( Patient next : myPatients . values ( ) ) { String familyName = next . getNameFirstRep ( ) . getFamilyAsSingleString ( ) . toLowerCase ( ) ; if ( familyName . contains ( theParam . getValue ( ) . toLowerCase ( ) ) == false ) { continue ; } retVal . add ( next ) ; } return retVal ; }
A search with a parameter
32,808
String extractPrefixAndReturnRest ( String theString ) { int offset = 0 ; while ( true ) { if ( theString . length ( ) == offset ) { break ; } else { char nextChar = theString . charAt ( offset ) ; if ( nextChar == '-' || Character . isDigit ( nextChar ) ) { break ; } } offset ++ ; } String prefix = theString . substring ( 0 , offset ) ; if ( ! isBlank ( prefix ) ) { myPrefix = ParamPrefixEnum . forValue ( prefix ) ; if ( myPrefix == null ) { switch ( prefix ) { case ">=" : myPrefix = ParamPrefixEnum . GREATERTHAN_OR_EQUALS ; break ; case ">" : myPrefix = ParamPrefixEnum . GREATERTHAN ; break ; case "<=" : myPrefix = ParamPrefixEnum . LESSTHAN_OR_EQUALS ; break ; case "<" : myPrefix = ParamPrefixEnum . LESSTHAN ; break ; case "~" : myPrefix = ParamPrefixEnum . APPROXIMATE ; break ; default : ourLog . warn ( "Invalid prefix being ignored: {}" , prefix ) ; break ; } if ( myPrefix != null ) { ourLog . warn ( "Date parameter has legacy prefix '{}' which has been removed from FHIR. This should be replaced with '{}'" , prefix , myPrefix ) ; } } } return theString . substring ( offset ) ; }
Eg . if this is invoked with gt2012 - 11 - 02 sets the prefix to GREATER_THAN and returns 2012 - 11 - 02
32,809
protected void preProcessResourceForStorage ( T theResource ) { String type = getContext ( ) . getResourceDefinition ( theResource ) . getName ( ) ; if ( ! getResourceName ( ) . equals ( type ) ) { throw new InvalidRequestException ( getContext ( ) . getLocalizer ( ) . getMessage ( BaseHapiFhirResourceDao . class , "incorrectResourceType" , type , getResourceName ( ) ) ) ; } if ( theResource . getIdElement ( ) . hasIdPart ( ) ) { if ( ! theResource . getIdElement ( ) . isIdPartValid ( ) ) { throw new InvalidRequestException ( getContext ( ) . getLocalizer ( ) . getMessage ( BaseHapiFhirResourceDao . class , "failedToCreateWithInvalidId" , theResource . getIdElement ( ) . getIdPart ( ) ) ) ; } } if ( getConfig ( ) . getTreatBaseUrlsAsLocal ( ) . isEmpty ( ) == false ) { FhirTerser t = getContext ( ) . newTerser ( ) ; List < ResourceReferenceInfo > refs = t . getAllResourceReferences ( theResource ) ; for ( ResourceReferenceInfo nextRef : refs ) { IIdType refId = nextRef . getResourceReference ( ) . getReferenceElement ( ) ; if ( refId != null && refId . hasBaseUrl ( ) ) { if ( getConfig ( ) . getTreatBaseUrlsAsLocal ( ) . contains ( refId . getBaseUrl ( ) ) ) { IIdType newRefId = refId . toUnqualified ( ) ; nextRef . getResourceReference ( ) . setReference ( newRefId . getValue ( ) ) ; } } } } }
May be overridden by subclasses to validate resources prior to storage
32,810
public RuntimeResourceDefinition validateCriteriaAndReturnResourceDefinition ( String criteria ) { String resourceName ; if ( criteria == null || criteria . trim ( ) . isEmpty ( ) ) { throw new IllegalArgumentException ( "Criteria cannot be empty" ) ; } if ( criteria . contains ( "?" ) ) { resourceName = criteria . substring ( 0 , criteria . indexOf ( "?" ) ) ; } else { resourceName = criteria ; } return getContext ( ) . getResourceDefinition ( resourceName ) ; }
Get the resource definition from the criteria which specifies the resource type
32,811
public DateTimeType makeDateTimeFromIVL ( Element ivl ) throws Exception { if ( ivl == null ) return null ; if ( ivl . hasAttribute ( "value" ) ) return makeDateTimeFromTS ( ivl ) ; Element high = cda . getChild ( ivl , "high" ) ; if ( high != null ) return makeDateTimeFromTS ( high ) ; Element low = cda . getChild ( ivl , "low" ) ; if ( low != null ) return makeDateTimeFromTS ( low ) ; return null ; }
this is a weird one - where CDA has an IVL and FHIR has a date
32,812
public String analyse ( String unit ) throws UcumException { if ( Utilities . noString ( unit ) ) return "(unity)" ; assert checkStringParam ( unit ) : paramError ( "analyse" , "unit" , "must not be null or empty" ) ; Term term = new ExpressionParser ( model ) . parse ( unit ) ; return new FormalStructureComposer ( ) . compose ( term ) ; }
given a unit return a formal description of what the units stand for using full names
32,813
public static String determineServletContextPath ( HttpServletRequest theRequest , RestfulServer server ) { String retVal ; if ( server . getServletContext ( ) != null ) { if ( server . getServletContext ( ) . getMajorVersion ( ) >= 3 || ( server . getServletContext ( ) . getMajorVersion ( ) > 2 && server . getServletContext ( ) . getMinorVersion ( ) >= 5 ) ) { retVal = server . getServletContext ( ) . getContextPath ( ) ; } else { retVal = theRequest . getContextPath ( ) ; } } else { retVal = theRequest . getContextPath ( ) ; } retVal = StringUtils . defaultString ( retVal ) ; return retVal ; }
Determines the servlet s context path .
32,814
public static List < String > getOtherChildren ( CodeSystem cs , ConceptDefinitionComponent c ) { List < String > res = new ArrayList < String > ( ) ; for ( ConceptPropertyComponent p : c . getProperty ( ) ) { if ( "parent" . equals ( p . getCode ( ) ) ) { res . add ( p . getValue ( ) . primitiveValue ( ) ) ; } } return res ; }
returns additional parents not in the heirarchy
32,815
public Boolean equalsUsingFhirPathRules ( BaseDateTimeType theOther ) { BaseDateTimeType me = this ; int lowestPrecision = Math . min ( me . getPrecision ( ) . ordinal ( ) , theOther . getPrecision ( ) . ordinal ( ) ) ; TemporalPrecisionEnum lowestPrecisionEnum = TemporalPrecisionEnum . values ( ) [ lowestPrecision ] ; if ( me . getPrecision ( ) != lowestPrecisionEnum ) { me = new DateTimeType ( me . getValueAsString ( ) ) ; me . setPrecision ( lowestPrecisionEnum ) ; } if ( theOther . getPrecision ( ) != lowestPrecisionEnum ) { theOther = new DateTimeType ( theOther . getValueAsString ( ) ) ; theOther . setPrecision ( lowestPrecisionEnum ) ; } if ( me . hasTimezoneIfRequired ( ) != theOther . hasTimezoneIfRequired ( ) ) { if ( me . getPrecision ( ) == theOther . getPrecision ( ) ) { if ( me . getPrecision ( ) . ordinal ( ) >= TemporalPrecisionEnum . MINUTE . ordinal ( ) && theOther . getPrecision ( ) . ordinal ( ) >= TemporalPrecisionEnum . MINUTE . ordinal ( ) ) { boolean couldBeTheSameTime = couldBeTheSameTime ( me , theOther ) || couldBeTheSameTime ( theOther , me ) ; if ( ! couldBeTheSameTime ) { return false ; } } } return null ; } if ( me . getPrecision ( ) == theOther . getPrecision ( ) ) { if ( me . getPrecision ( ) . ordinal ( ) >= TemporalPrecisionEnum . MINUTE . ordinal ( ) ) { long leftTime = me . getValue ( ) . getTime ( ) ; long rightTime = theOther . getValue ( ) . getTime ( ) ; return leftTime == rightTime ; } else { String leftTime = me . getValueAsString ( ) ; String rightTime = theOther . getValueAsString ( ) ; return leftTime . equals ( rightTime ) ; } } if ( ( ( Integer ) 0 ) . equals ( me . getMillis ( ) ) ) { if ( ( ( Integer ) 0 ) . equals ( theOther . getMillis ( ) ) ) { if ( me . getPrecision ( ) . ordinal ( ) >= TemporalPrecisionEnum . SECOND . ordinal ( ) ) { if ( theOther . getPrecision ( ) . ordinal ( ) >= TemporalPrecisionEnum . SECOND . ordinal ( ) ) { return me . getValue ( ) . getTime ( ) == theOther . getValue ( ) . getTime ( ) ; } } } } return false ; }
This method implements a datetime equality check using the rules as defined by FHIRPath .
32,816
public String getSubscriptionId ( FhirContext theFhirContext ) { String retVal = null ; if ( getSubscription ( ) != null ) { retVal = getSubscription ( ) . getIdElement ( theFhirContext ) . getValue ( ) ; } return retVal ; }
Helper method to fetch the subscription ID
32,817
public boolean ensureSearchEntityLoaded ( ) { if ( mySearchEntity == null ) { ensureDependenciesInjected ( ) ; TransactionTemplate txTemplate = new TransactionTemplate ( myPlatformTransactionManager ) ; txTemplate . setPropagationBehavior ( TransactionDefinition . PROPAGATION_REQUIRED ) ; txTemplate . setIsolationLevel ( TransactionDefinition . ISOLATION_READ_COMMITTED ) ; return txTemplate . execute ( s -> { try { setSearchEntity ( mySearchDao . findByUuid ( myUuid ) ) ; if ( mySearchEntity == null ) { return false ; } ourLog . trace ( "Retrieved search with version {} and total {}" , mySearchEntity . getVersion ( ) , mySearchEntity . getTotalCount ( ) ) ; mySearchEntity . getIncludes ( ) . size ( ) ; return true ; } catch ( NoResultException e ) { return false ; } } ) ; } return true ; }
Returns false if the entity can t be found
32,818
@ SuppressWarnings ( "deprecation" ) public boolean equalsIgnoreBase ( IdDt theId ) { if ( theId == null ) { return false ; } if ( theId . isEmpty ( ) ) { return isEmpty ( ) ; } return ObjectUtils . equals ( getResourceType ( ) , theId . getResourceType ( ) ) && ObjectUtils . equals ( getIdPart ( ) , theId . getIdPart ( ) ) && ObjectUtils . equals ( getVersionIdPart ( ) , theId . getVersionIdPart ( ) ) ; }
Returns true if this IdDt matches the given IdDt in terms of resource type and ID but ignores the URL base
32,819
public Object intercept ( final InvocationContext ctx ) throws JaxRsResponseException { try { return ctx . proceed ( ) ; } catch ( final Exception theException ) { final AbstractJaxRsProvider theServer = ( AbstractJaxRsProvider ) ctx . getTarget ( ) ; throw convertException ( theServer , theException ) ; } }
This interceptor will catch all exception and convert them using the exceptionhandler
32,820
public JaxRsResponseException convertException ( final AbstractJaxRsProvider theServer , final Throwable theException ) { if ( theServer . withStackTrace ( ) ) { exceptionHandler . setReturnStackTracesForExceptionTypes ( Throwable . class ) ; } final JaxRsRequest requestDetails = theServer . getRequest ( null , null ) . build ( ) ; final BaseServerResponseException convertedException = preprocessException ( theException , requestDetails ) ; return new JaxRsResponseException ( convertedException ) ; }
This method convert an exception to a JaxRsResponseException
32,821
public Response convertExceptionIntoResponse ( final JaxRsRequest theRequest , final JaxRsResponseException theException ) throws IOException { return handleExceptionWithoutServletError ( theRequest , theException ) ; }
This method converts an exception into a response
32,822
public static < T > T getTargetObject ( Object proxy , Class < T > clazz ) throws Exception { while ( ( AopUtils . isJdkDynamicProxy ( proxy ) ) ) { return clazz . cast ( getTargetObject ( ( ( Advised ) proxy ) . getTargetSource ( ) . getTarget ( ) , clazz ) ) ; } return clazz . cast ( proxy ) ; }
Retrieve the Spring proxy object s target object
32,823
public static IBundleProvider newEmptyList ( ) { final InstantDt published = InstantDt . withCurrentTime ( ) ; return new IBundleProvider ( ) { public List < IBaseResource > getResources ( int theFromIndex , int theToIndex ) { return Collections . emptyList ( ) ; } public Integer size ( ) { return 0 ; } public InstantDt getPublished ( ) { return published ; } public Integer preferredPageSize ( ) { return null ; } public String getUuid ( ) { return null ; } } ; }
Create a new unmodifiable empty resource list with the current time as the publish date .
32,824
private List < String > getHeaderValues ( String headerName ) { if ( additionalHttpHeaders . get ( headerName ) == null ) { additionalHttpHeaders . put ( headerName , new ArrayList < String > ( ) ) ; } return additionalHttpHeaders . get ( headerName ) ; }
Gets the header values list for a given header . If the header doesn t have any values an empty list will be returned .
32,825
public void interceptRequest ( IHttpRequest theRequest ) { for ( Map . Entry < String , List < String > > header : additionalHttpHeaders . entrySet ( ) ) { for ( String headerValue : header . getValue ( ) ) { if ( headerValue != null ) { theRequest . addHeader ( header . getKey ( ) , headerValue ) ; } } } }
Adds the additional header values to the HTTP request .
32,826
void sealAndInitialize ( FhirContext theContext , Map < Class < ? extends IBase > , BaseRuntimeElementDefinition < ? > > theClassToElementDefinitions ) { for ( BaseRuntimeChildDefinition next : myExtensions ) { next . sealAndInitialize ( theContext , theClassToElementDefinitions ) ; } for ( RuntimeChildDeclaredExtensionDefinition next : myExtensions ) { String extUrl = next . getExtensionUrl ( ) ; if ( myUrlToExtension . containsKey ( extUrl ) ) { throw new ConfigurationException ( "Duplicate extension URL[" + extUrl + "] in Element[" + getName ( ) + "]" ) ; } myUrlToExtension . put ( extUrl , next ) ; if ( next . isModifier ( ) ) { myExtensionsModifier . add ( next ) ; } else { myExtensionsNonModifier . add ( next ) ; } } myExtensions = Collections . unmodifiableList ( myExtensions ) ; }
Invoked prior to use to perform any initialization and make object mutable .
32,827
private String emitInnerTypes ( ) { StringBuilder itDefs = new StringBuilder ( ) ; while ( emittedInnerTypes . size ( ) < innerTypes . size ( ) ) { for ( Pair < StructureDefinition , ElementDefinition > it : new HashSet < Pair < StructureDefinition , ElementDefinition > > ( innerTypes ) ) { if ( ! emittedInnerTypes . contains ( it ) ) { itDefs . append ( "\n" ) . append ( genInnerTypeDef ( it . getLeft ( ) , it . getRight ( ) ) ) ; emittedInnerTypes . add ( it ) ; } } } return itDefs . toString ( ) ; }
Generate a flattened definition for the inner types
32,828
private String emitDataTypes ( ) { StringBuilder dtDefs = new StringBuilder ( ) ; while ( emittedDatatypes . size ( ) < datatypes . size ( ) ) { for ( String dt : new HashSet < String > ( datatypes ) ) { if ( ! emittedDatatypes . contains ( dt ) ) { StructureDefinition sd = context . fetchResource ( StructureDefinition . class , ProfileUtilities . sdNs ( dt , null ) ) ; if ( sd != null && ! uniq_structure_urls . contains ( sd . getUrl ( ) ) ) dtDefs . append ( "\n" ) . append ( genShapeDefinition ( sd , false ) ) ; emittedDatatypes . add ( dt ) ; } } } return dtDefs . toString ( ) ; }
Generate a shape definition for the current set of datatypes
32,829
private String simpleElement ( StructureDefinition sd , ElementDefinition ed , String typ ) { String addldef = "" ; ElementDefinition . ElementDefinitionBindingComponent binding = ed . getBinding ( ) ; if ( binding . hasStrength ( ) && binding . getStrength ( ) == Enumerations . BindingStrength . REQUIRED && "code" . equals ( typ ) ) { ValueSet vs = resolveBindingReference ( sd , binding . getValueSet ( ) ) ; if ( vs != null ) { addldef = tmplt ( VALUESET_DEFN_TEMPLATE ) . add ( "vsn" , vsprefix ( vs . getUrl ( ) ) ) . render ( ) ; required_value_sets . add ( vs ) ; } } if ( ed . hasFixed ( ) ) { addldef = tmplt ( FIXED_VALUE_TEMPLATE ) . add ( "val" , ed . getFixed ( ) . primitiveValue ( ) ) . render ( ) ; } return tmplt ( SIMPLE_ELEMENT_DEFN_TEMPLATE ) . add ( "typ" , typ ) . add ( "vsdef" , addldef ) . render ( ) ; }
Generate a type reference and optional value set definition
32,830
private String genTypeRef ( StructureDefinition sd , ElementDefinition ed , String id , ElementDefinition . TypeRefComponent typ ) { if ( typ . hasProfile ( ) ) { if ( typ . getCode ( ) . equals ( "Reference" ) ) return genReference ( "" , typ ) ; else if ( ProfileUtilities . getChildList ( sd , ed ) . size ( ) > 0 ) { innerTypes . add ( new ImmutablePair < StructureDefinition , ElementDefinition > ( sd , ed ) ) ; return simpleElement ( sd , ed , id ) ; } else { String ref = getTypeName ( typ ) ; datatypes . add ( ref ) ; return simpleElement ( sd , ed , ref ) ; } } else if ( typ . getCodeElement ( ) . getExtensionsByUrl ( ToolingExtensions . EXT_RDF_TYPE ) . size ( ) > 0 ) { String xt = null ; try { xt = typ . getCodeElement ( ) . getExtensionString ( ToolingExtensions . EXT_RDF_TYPE ) ; } catch ( FHIRException e ) { e . printStackTrace ( ) ; } ST td_entry = tmplt ( PRIMITIVE_ELEMENT_DEFN_TEMPLATE ) . add ( "typ" , xt . replace ( "xsd:token" , "xsd:string" ) . replace ( "xsd:int" , "xsd:integer" ) ) ; StringBuilder facets = new StringBuilder ( ) ; if ( ed . hasMinValue ( ) ) { Type mv = ed . getMinValue ( ) ; facets . append ( tmplt ( MINVALUE_TEMPLATE ) . add ( "val" , mv . primitiveValue ( ) ) . render ( ) ) ; } if ( ed . hasMaxValue ( ) ) { Type mv = ed . getMaxValue ( ) ; facets . append ( tmplt ( MAXVALUE_TEMPLATE ) . add ( "val" , mv . primitiveValue ( ) ) . render ( ) ) ; } if ( ed . hasMaxLength ( ) ) { int ml = ed . getMaxLength ( ) ; facets . append ( tmplt ( MAXLENGTH_TEMPLATE ) . add ( "val" , ml ) . render ( ) ) ; } if ( ed . hasPattern ( ) ) { Type pat = ed . getPattern ( ) ; facets . append ( tmplt ( PATTERN_TEMPLATE ) . add ( "val" , pat . primitiveValue ( ) ) . render ( ) ) ; } td_entry . add ( "facets" , facets . toString ( ) ) ; return td_entry . render ( ) ; } else if ( typ . getCode ( ) == null ) { ST primitive_entry = tmplt ( PRIMITIVE_ELEMENT_DEFN_TEMPLATE ) ; primitive_entry . add ( "typ" , "xsd:string" ) ; return primitive_entry . render ( ) ; } else if ( typ . getCode ( ) . equals ( "xhtml" ) ) { return tmplt ( XHTML_TYPE_TEMPLATE ) . render ( ) ; } else { datatypes . add ( typ . getCode ( ) ) ; return simpleElement ( sd , ed , typ . getCode ( ) ) ; } }
Generate a type reference
32,831
private ST genAlternativeTypes ( ElementDefinition ed , String id , String shortId ) { ST shex_alt = tmplt ( ALTERNATIVE_SHAPES_TEMPLATE ) ; List < String > altEntries = new ArrayList < String > ( ) ; for ( ElementDefinition . TypeRefComponent typ : ed . getType ( ) ) { altEntries . add ( genAltEntry ( id , typ ) ) ; } shex_alt . add ( "altEntries" , StringUtils . join ( altEntries , " OR\n " ) ) ; return shex_alt ; }
Generate a set of alternative shapes
32,832
private String genAltEntry ( String id , ElementDefinition . TypeRefComponent typ ) { if ( ! typ . getCode ( ) . equals ( "Reference" ) ) throw new AssertionError ( "We do not handle " + typ . getCode ( ) + " alternatives" ) ; return genReference ( id , typ ) ; }
Generate an alternative shape for a reference
32,833
private String genChoiceEntry ( StructureDefinition sd , ElementDefinition ed , String id , String base , ElementDefinition . TypeRefComponent typ ) { ST shex_choice_entry = tmplt ( ELEMENT_TEMPLATE ) ; String ext = typ . getCode ( ) ; shex_choice_entry . add ( "id" , "fhir:" + base + Character . toUpperCase ( ext . charAt ( 0 ) ) + ext . substring ( 1 ) + " " ) ; shex_choice_entry . add ( "card" , "" ) ; shex_choice_entry . add ( "defn" , genTypeRef ( sd , ed , id , typ ) ) ; shex_choice_entry . add ( "comment" , " " ) ; return shex_choice_entry . render ( ) ; }
Generate an entry in a choice list
32,834
private String genInnerTypeDef ( StructureDefinition sd , ElementDefinition ed ) { String path = ed . hasBase ( ) ? ed . getBase ( ) . getPath ( ) : ed . getPath ( ) ; ; ST element_reference = tmplt ( SHAPE_DEFINITION_TEMPLATE ) ; element_reference . add ( "resourceDecl" , "" ) ; element_reference . add ( "id" , path ) ; String comment = ed . getShort ( ) ; element_reference . add ( "comment" , comment == null ? " " : "# " + comment ) ; List < String > elements = new ArrayList < String > ( ) ; for ( ElementDefinition child : ProfileUtilities . getChildList ( sd , path , null ) ) elements . add ( genElementDefinition ( sd , child ) ) ; element_reference . add ( "elements" , StringUtils . join ( elements , "\n" ) ) ; return element_reference . render ( ) ; }
Generate a definition for a referenced element
32,835
private String genReference ( String id , ElementDefinition . TypeRefComponent typ ) { ST shex_ref = tmplt ( REFERENCE_DEFN_TEMPLATE ) ; String ref = getTypeName ( typ ) ; shex_ref . add ( "id" , id ) ; shex_ref . add ( "ref" , ref ) ; references . add ( ref ) ; return shex_ref . render ( ) ; }
Generate a reference to a resource
32,836
private String getTypeName ( ElementDefinition . TypeRefComponent typ ) { if ( typ . hasTargetProfile ( ) ) { String [ ] els = typ . getTargetProfile ( ) . get ( 0 ) . getValue ( ) . split ( "/" ) ; return els [ els . length - 1 ] ; } else if ( typ . hasProfile ( ) ) { String [ ] els = typ . getProfile ( ) . get ( 0 ) . getValue ( ) . split ( "/" ) ; return els [ els . length - 1 ] ; } else { return typ . getCode ( ) ; } }
Return the type name for typ
32,837
public IMatches < IAndUnits > withPrefix ( final ParamPrefixEnum thePrefix ) { return new NumberClientParam . IMatches < IAndUnits > ( ) { public IAndUnits number ( long theNumber ) { return new AndUnits ( thePrefix , Long . toString ( theNumber ) ) ; } public IAndUnits number ( String theNumber ) { return new AndUnits ( thePrefix , theNumber ) ; } } ; }
Use the given quantity prefix
32,838
public BaseMethodBinding < ? > determineResourceMethod ( RequestDetails requestDetails , String requestPath ) { RequestTypeEnum requestType = requestDetails . getRequestType ( ) ; ResourceBinding resourceBinding = null ; BaseMethodBinding < ? > resourceMethod = null ; String resourceName = requestDetails . getResourceName ( ) ; if ( myServerConformanceMethod . incomingServerRequestMatchesMethod ( requestDetails ) ) { resourceMethod = myServerConformanceMethod ; } else if ( resourceName == null ) { resourceBinding = myServerBinding ; } else { resourceBinding = myResourceNameToBinding . get ( resourceName ) ; if ( resourceBinding == null ) { throwUnknownResourceTypeException ( resourceName ) ; } } if ( resourceMethod == null ) { if ( resourceBinding != null ) { resourceMethod = resourceBinding . getMethod ( requestDetails ) ; } if ( resourceMethod == null ) { resourceMethod = myGlobalBinding . getMethod ( requestDetails ) ; } } if ( resourceMethod == null ) { if ( isBlank ( requestPath ) ) { throw new InvalidRequestException ( myFhirContext . getLocalizer ( ) . getMessage ( RestfulServer . class , "rootRequest" ) ) ; } throwUnknownFhirOperationException ( requestDetails , requestPath , requestType ) ; } return resourceMethod ; }
Figure out and return whichever method binding is appropriate for the given request
32,839
public List < IServerInterceptor > getInterceptors_ ( ) { List < IServerInterceptor > retVal = getInterceptorService ( ) . getAllRegisteredInterceptors ( ) . stream ( ) . filter ( t -> t instanceof IServerInterceptor ) . map ( t -> ( IServerInterceptor ) t ) . collect ( Collectors . toList ( ) ) ; return Collections . unmodifiableList ( retVal ) ; }
Returns a list of all registered server interceptors
32,840
public void setPlainProviders ( Collection < Object > theProviders ) { Validate . noNullElements ( theProviders , "theProviders must not contain any null elements" ) ; myPlainProviders . clear ( ) ; if ( theProviders != null ) { myPlainProviders . addAll ( theProviders ) ; } }
Sets the non - resource specific providers which implement method calls on this server .
32,841
public void registerProvider ( Object provider ) { if ( provider != null ) { Collection < Object > providerList = new ArrayList < > ( 1 ) ; providerList . add ( provider ) ; registerProviders ( providerList ) ; } }
Register a single provider . This could be a Resource Provider or a plain provider not associated with any resource .
32,842
public void registerProviders ( Collection < ? > theProviders ) { Validate . noNullElements ( theProviders , "theProviders must not contain any null elements" ) ; myProviderRegistrationMutex . lock ( ) ; try { if ( ! myStarted ) { for ( Object provider : theProviders ) { ourLog . info ( "Registration of provider [" + provider . getClass ( ) . getName ( ) + "] will be delayed until FHIR server startup" ) ; if ( provider instanceof IResourceProvider ) { myResourceProviders . add ( ( IResourceProvider ) provider ) ; } else { myPlainProviders . add ( provider ) ; } } return ; } } finally { myProviderRegistrationMutex . unlock ( ) ; } registerProviders ( theProviders , false ) ; }
Register a group of theProviders . These could be Resource Providers plain theProviders or a mixture of the two .
32,843
public void setProviders ( Object ... theProviders ) { Validate . noNullElements ( theProviders , "theProviders must not contain any null elements" ) ; myPlainProviders . clear ( ) ; if ( theProviders != null ) { myPlainProviders . addAll ( Arrays . asList ( theProviders ) ) ; } }
Sets the non - resource specific providers which implement method calls on this server
32,844
public void unregisterInterceptor ( Object theInterceptor ) { Validate . notNull ( theInterceptor , "Interceptor can not be null" ) ; getInterceptorService ( ) . unregisterInterceptor ( theInterceptor ) ; }
Unregisters an interceptor
32,845
public void submitResourceModified ( final ResourceModifiedMessage theMsg ) { if ( TransactionSynchronizationManager . isSynchronizationActive ( ) ) { TransactionSynchronizationManager . registerSynchronization ( new TransactionSynchronizationAdapter ( ) { public int getOrder ( ) { return 0 ; } public void afterCommit ( ) { sendToProcessingChannel ( theMsg ) ; } } ) ; } else { sendToProcessingChannel ( theMsg ) ; } }
This is an internal API - Use with caution!
32,846
public static Template parse ( String input ) { return new Template ( input , Tag . getTags ( ) , Filter . getFilters ( ) ) ; }
Returns a new Template instance from a given input string .
32,847
public String toStringAST ( ) { StringBuilder builder = new StringBuilder ( ) ; walk ( root , builder ) ; return builder . toString ( ) ; }
Returns a string representation of the AST of the parsed input source .
32,848
private < T extends BaseResourceIndex > void tryToReuseIndexEntities ( List < T > theIndexesToRemove , List < T > theIndexesToAdd ) { for ( int addIndex = 0 ; addIndex < theIndexesToAdd . size ( ) ; addIndex ++ ) { if ( theIndexesToRemove . isEmpty ( ) ) { break ; } T targetEntity = theIndexesToAdd . get ( addIndex ) ; if ( targetEntity . getId ( ) != null ) { continue ; } T entityToReuse = theIndexesToRemove . remove ( theIndexesToRemove . size ( ) - 1 ) ; targetEntity . setId ( entityToReuse . getId ( ) ) ; } }
The logic here is that often times when we update a resource we are dropping one index row and adding another . This method tries to reuse rows that would otherwise have been deleted by updating them with the contents of rows that would have otherwise been added . In other words we re trying to replace one delete + one insert with one update
32,849
private ConcurrentHashMap < String , BaseMethodBinding < ? > > getMapForOperation ( RestOperationTypeEnum operationType ) { ConcurrentHashMap < String , BaseMethodBinding < ? > > result = operationBindings . get ( operationType ) ; if ( result == null ) { operationBindings . putIfAbsent ( operationType , new ConcurrentHashMap < String , BaseMethodBinding < ? > > ( ) ) ; return getMapForOperation ( operationType ) ; } else { return result ; } }
Get the map for the given operation type . If no map exists for this operation type create a new hashmap for this operation type and add it to the operation bindings .
32,850
public BaseMethodBinding < ? > getBinding ( RestOperationTypeEnum operationType , String theBindingKey ) { String bindingKey = StringUtils . defaultIfBlank ( theBindingKey , DEFAULT_METHOD_KEY ) ; ConcurrentHashMap < String , BaseMethodBinding < ? > > map = getMapForOperation ( operationType ) ; if ( map == null || ! map . containsKey ( bindingKey ) ) { throw new NotImplementedOperationException ( "Operation not implemented" ) ; } else { return map . get ( bindingKey ) ; } }
Get the binding
32,851
public static JaxRsMethodBindings getMethodBindings ( AbstractJaxRsProvider theProvider , Class < ? extends AbstractJaxRsProvider > theProviderClass ) { if ( ! getClassBindings ( ) . containsKey ( theProviderClass ) ) { JaxRsMethodBindings foundBindings = new JaxRsMethodBindings ( theProvider , theProviderClass ) ; getClassBindings ( ) . putIfAbsent ( theProviderClass , foundBindings ) ; } return getClassBindings ( ) . get ( theProviderClass ) ; }
Get the method bindings for the given class . If this class is not yet contained in the classBindings they will be added for this class
32,852
public void addExecuteOnlyIfColumnExists ( String theTableName , String theColumnName ) { myConditionalOnExistenceOf . add ( new TableAndColumn ( theTableName , theColumnName ) ) ; }
This task will only execute if the following column exists
32,853
public String pluralize ( Object word ) { if ( word == null ) return null ; String wordStr = word . toString ( ) . trim ( ) ; if ( wordStr . length ( ) == 0 ) return wordStr ; if ( isUncountable ( wordStr ) ) return wordStr ; for ( Rule rule : this . plurals ) { String result = rule . apply ( wordStr ) ; if ( result != null ) return result ; } return wordStr ; }
Returns the plural form of the word in the string .
32,854
public String singularize ( Object word ) { if ( word == null ) return null ; String wordStr = word . toString ( ) . trim ( ) ; if ( wordStr . length ( ) == 0 ) return wordStr ; if ( isUncountable ( wordStr ) ) return wordStr ; for ( Rule rule : this . singulars ) { String result = rule . apply ( wordStr ) ; if ( result != null ) return result ; } return wordStr ; }
Returns the singular form of the word in the string .
32,855
public String capitalize ( String words ) { if ( words == null ) return null ; String result = words . trim ( ) ; if ( result . length ( ) == 0 ) return "" ; if ( result . length ( ) == 1 ) return result . toUpperCase ( ) ; return "" + Character . toUpperCase ( result . charAt ( 0 ) ) + result . substring ( 1 ) . toLowerCase ( ) ; }
Returns a copy of the input with the first character converted to uppercase and the remainder to lowercase .
32,856
public boolean outgoingResponse ( RequestDetails theRequestDetails , Bundle theResponseObject , HttpServletRequest theServletRequest , HttpServletResponse theServletResponse ) throws AuthenticationException { if ( myClientParamsOptional && myDataStore == null ) { log . debug ( "No auditing configured." ) ; return true ; } if ( theResponseObject == null || theResponseObject . isEmpty ( ) ) { log . debug ( "No bundle to audit" ) ; return true ; } try { log . info ( "Auditing bundle: " + theResponseObject + " from request " + theRequestDetails ) ; SecurityEvent auditEvent = new SecurityEvent ( ) ; auditEvent . setEvent ( getEventInfo ( theRequestDetails ) ) ; Participant participant = getParticipant ( theServletRequest ) ; if ( participant == null ) { log . debug ( "No participant to audit" ) ; return true ; } List < Participant > participants = new ArrayList < SecurityEvent . Participant > ( 1 ) ; participants . add ( participant ) ; auditEvent . setParticipant ( participants ) ; SecurityEventObjectLifecycleEnum lifecycle = mapResourceTypeToSecurityLifecycle ( theRequestDetails . getRestOperationType ( ) ) ; byte [ ] query = getQueryFromRequestDetails ( theRequestDetails ) ; List < ObjectElement > auditableObjects = new ArrayList < SecurityEvent . ObjectElement > ( ) ; for ( BundleEntry entry : theResponseObject . getEntries ( ) ) { IResource resource = entry . getResource ( ) ; ObjectElement auditableObject = getObjectElement ( resource , lifecycle , query ) ; if ( auditableObject != null ) auditableObjects . add ( auditableObject ) ; } if ( auditableObjects . isEmpty ( ) ) { log . debug ( "No auditable resources to audit." ) ; return true ; } else { log . debug ( "Auditing " + auditableObjects . size ( ) + " resources." ) ; } auditEvent . setObject ( auditableObjects ) ; auditEvent . setSource ( getSourceElement ( theServletRequest ) ) ; store ( auditEvent ) ; return true ; } catch ( Exception e ) { log . error ( "Unable to audit resource: " + theResponseObject + " from request: " + theRequestDetails , e ) ; throw new InternalErrorException ( "Auditing failed, unable to complete request" , e ) ; } }
Intercept the outgoing response to perform auditing of the request data if the bundle contains auditable resources .
32,857
protected Event getEventInfo ( RequestDetails theRequestDetails ) { Event event = new Event ( ) ; event . setAction ( mapResourceTypeToSecurityEventAction ( theRequestDetails . getRestOperationType ( ) ) ) ; event . setDateTimeWithMillisPrecision ( new Date ( ) ) ; event . setOutcome ( SecurityEventOutcomeEnum . SUCCESS ) ; return event ; }
Generates the Event segment of the SecurityEvent based on the incoming request details
32,858
protected byte [ ] getQueryFromRequestDetails ( RequestDetails theRequestDetails ) { byte [ ] query ; try { query = theRequestDetails . getCompleteUrl ( ) . getBytes ( "UTF-8" ) ; } catch ( UnsupportedEncodingException e1 ) { log . warn ( "Unable to encode URL to bytes in UTF-8, defaulting to platform default charset." , e1 ) ; query = theRequestDetails . getCompleteUrl ( ) . getBytes ( ) ; } return query ; }
Return the query URL encoded to bytes to be set as the Object . query on the Security Event
32,859
protected ObjectElement getObjectElement ( IResource resource , SecurityEventObjectLifecycleEnum lifecycle , byte [ ] query ) throws InstantiationException , IllegalAccessException { String resourceType = resource . getResourceName ( ) ; if ( myAuditableResources . containsKey ( resourceType ) ) { log . debug ( "Found auditable resource of type: " + resourceType ) ; @ SuppressWarnings ( "unchecked" ) IResourceAuditor < IResource > auditableResource = ( IResourceAuditor < IResource > ) myAuditableResources . get ( resourceType ) . newInstance ( ) ; auditableResource . setResource ( resource ) ; if ( auditableResource . isAuditable ( ) ) { ObjectElement object = new ObjectElement ( ) ; object . setReference ( new ResourceReferenceDt ( resource . getId ( ) ) ) ; object . setLifecycle ( lifecycle ) ; object . setQuery ( query ) ; object . setName ( auditableResource . getName ( ) ) ; object . setIdentifier ( ( IdentifierDt ) auditableResource . getIdentifier ( ) ) ; object . setType ( auditableResource . getType ( ) ) ; object . setDescription ( auditableResource . getDescription ( ) ) ; Map < String , String > detailMap = auditableResource . getDetail ( ) ; if ( detailMap != null && ! detailMap . isEmpty ( ) ) { List < ObjectDetail > details = new ArrayList < SecurityEvent . ObjectDetail > ( ) ; for ( Entry < String , String > entry : detailMap . entrySet ( ) ) { ObjectDetail detail = makeObjectDetail ( entry . getKey ( ) , entry . getValue ( ) ) ; details . add ( detail ) ; } object . setDetail ( details ) ; } if ( auditableResource . getSensitivity ( ) != null ) { CodingDt coding = object . getSensitivity ( ) . addCoding ( ) ; coding . setSystem ( auditableResource . getSensitivity ( ) . getSystemElement ( ) . getValue ( ) ) ; coding . setCode ( auditableResource . getSensitivity ( ) . getCodeElement ( ) . getValue ( ) ) ; coding . setDisplay ( auditableResource . getSensitivity ( ) . getDisplayElement ( ) . getValue ( ) ) ; } return object ; } else { log . debug ( "Resource is not auditable" ) ; } } else { log . debug ( "No auditor configured for resource type " + resourceType ) ; } return null ; }
If the resource is considered an auditable resource containing PHI create an ObjectElement otherwise return null
32,860
protected ObjectDetail makeObjectDetail ( String type , String value ) { ObjectDetail detail = new ObjectDetail ( ) ; if ( type != null ) detail . setType ( type ) ; if ( value != null ) detail . setValue ( value . getBytes ( ) ) ; return detail ; }
Helper method to create an ObjectDetail from a pair of Strings .
32,861
protected List < CodingDt > getAccessType ( HttpServletRequest theServletRequest ) { List < CodingDt > types = new ArrayList < CodingDt > ( ) ; if ( theServletRequest . getHeader ( Constants . HEADER_AUTHORIZATION ) != null && theServletRequest . getHeader ( Constants . HEADER_AUTHORIZATION ) . startsWith ( "OAuth" ) ) { types . add ( new CodingDt ( SecurityEventSourceTypeEnum . USER_DEVICE . getSystem ( ) , SecurityEventSourceTypeEnum . USER_DEVICE . getCode ( ) ) ) ; } else { String userId = theServletRequest . getHeader ( UserInfoInterceptor . HEADER_USER_ID ) ; String appId = theServletRequest . getHeader ( UserInfoInterceptor . HEADER_APPLICATION_NAME ) ; if ( userId == null && appId != null ) types . add ( new CodingDt ( SecurityEventSourceTypeEnum . APPLICATION_SERVER . getSystem ( ) , SecurityEventSourceTypeEnum . APPLICATION_SERVER . getCode ( ) ) ) ; else types . add ( new CodingDt ( SecurityEventSourceTypeEnum . USER_DEVICE . getSystem ( ) , SecurityEventSourceTypeEnum . USER_DEVICE . getCode ( ) ) ) ; } return types ; }
Return the access type for this request
32,862
protected SecurityEventActionEnum mapResourceTypeToSecurityEventAction ( ca . uhn . fhir . rest . api . RestOperationTypeEnum theRestfulOperationTypeEnum ) { if ( theRestfulOperationTypeEnum == null ) return null ; switch ( theRestfulOperationTypeEnum ) { case READ : return SecurityEventActionEnum . READ_VIEW_PRINT ; case CREATE : return SecurityEventActionEnum . CREATE ; case DELETE : return SecurityEventActionEnum . DELETE ; case HISTORY_INSTANCE : return SecurityEventActionEnum . READ_VIEW_PRINT ; case HISTORY_TYPE : return SecurityEventActionEnum . READ_VIEW_PRINT ; case SEARCH_TYPE : return SecurityEventActionEnum . READ_VIEW_PRINT ; case UPDATE : return SecurityEventActionEnum . UPDATE ; case VALIDATE : return SecurityEventActionEnum . READ_VIEW_PRINT ; case VREAD : return SecurityEventActionEnum . READ_VIEW_PRINT ; default : return SecurityEventActionEnum . READ_VIEW_PRINT ; } }
Returns the SecurityEventActionEnum corresponding to the specified RestfulOperationTypeEnum
32,863
protected SecurityEventObjectLifecycleEnum mapResourceTypeToSecurityLifecycle ( ca . uhn . fhir . rest . api . RestOperationTypeEnum theRestfulOperationTypeEnum ) { if ( theRestfulOperationTypeEnum == null ) return null ; switch ( theRestfulOperationTypeEnum ) { case READ : return SecurityEventObjectLifecycleEnum . ACCESS_OR_USE ; case CREATE : return SecurityEventObjectLifecycleEnum . ORIGINATION_OR_CREATION ; case DELETE : return SecurityEventObjectLifecycleEnum . LOGICAL_DELETION ; case HISTORY_INSTANCE : return SecurityEventObjectLifecycleEnum . ACCESS_OR_USE ; case HISTORY_TYPE : return SecurityEventObjectLifecycleEnum . ACCESS_OR_USE ; case SEARCH_TYPE : return SecurityEventObjectLifecycleEnum . ACCESS_OR_USE ; case UPDATE : return SecurityEventObjectLifecycleEnum . AMENDMENT ; case VALIDATE : return SecurityEventObjectLifecycleEnum . VERIFICATION ; case VREAD : return SecurityEventObjectLifecycleEnum . ACCESS_OR_USE ; default : return SecurityEventObjectLifecycleEnum . ACCESS_OR_USE ; } }
Returns the SecurityEventObjectLifecycleEnum corresponding to the specified RestfulOperationTypeEnum
32,864
public void addAuditableResource ( String resourceType , Class < ? extends IResourceAuditor < ? extends IResource > > auditableResource ) { if ( myAuditableResources == null ) myAuditableResources = new HashMap < String , Class < ? extends IResourceAuditor < ? extends IResource > > > ( ) ; myAuditableResources . put ( resourceType , auditableResource ) ; }
Add a type of auditable resource and its auditor to this AuditingInterceptor s resource map
32,865
public IBaseOperationOutcome toOperationOutcome ( ) { IBaseOperationOutcome oo = ( IBaseOperationOutcome ) myCtx . getResourceDefinition ( "OperationOutcome" ) . newInstance ( ) ; populateOperationOutcome ( oo ) ; return oo ; }
Create an OperationOutcome resource which contains all of the messages found as a result of this validation
32,866
public void populateOperationOutcome ( IBaseOperationOutcome theOperationOutcome ) { for ( SingleValidationMessage next : myMessages ) { String location ; if ( isNotBlank ( next . getLocationString ( ) ) ) { location = next . getLocationString ( ) ; } else if ( next . getLocationLine ( ) != null || next . getLocationCol ( ) != null ) { location = "Line[" + next . getLocationLine ( ) + "] Col[" + next . getLocationCol ( ) + "]" ; } else { location = null ; } String severity = next . getSeverity ( ) != null ? next . getSeverity ( ) . getCode ( ) : null ; OperationOutcomeUtil . addIssue ( myCtx , theOperationOutcome , severity , next . getMessage ( ) , location , Constants . OO_INFOSTATUS_PROCESSING ) ; } if ( myMessages . isEmpty ( ) ) { String message = myCtx . getLocalizer ( ) . getMessage ( ValidationResult . class , "noIssuesDetected" ) ; OperationOutcomeUtil . addIssue ( myCtx , theOperationOutcome , "information" , message , null , "informational" ) ; } }
Populate an operation outcome with the results of the validation
32,867
public void initialize ( ) { try { Class . forName ( "org.hl7.fhir.instance.model.QuestionnaireResponse" ) ; myValidateResponses = true ; } catch ( ClassNotFoundException e ) { myValidateResponses = Boolean . FALSE ; } }
Initialize the bean
32,868
public void compose ( JsonCreator writer , Resource resource ) throws IOException { json = writer ; composeResource ( resource ) ; }
Compose a resource using a pre - existing JsonWriter
32,869
public static String escapeXML ( String rawContent , String charset , boolean isNoLines ) { if ( rawContent == null ) return "" ; else { StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < rawContent . length ( ) ; i ++ ) { char ch = rawContent . charAt ( i ) ; if ( ch == '\'' ) sb . append ( "&#39;" ) ; else if ( ch == '&' ) sb . append ( "&amp;" ) ; else if ( ch == '"' ) sb . append ( "&quot;" ) ; else if ( ch == '<' ) sb . append ( "&lt;" ) ; else if ( ch == '>' ) sb . append ( "&gt;" ) ; else if ( ch > '~' && charset != null && charSetImpliesAscii ( charset ) ) sb . append ( "&#x" + Integer . toHexString ( ch ) . toUpperCase ( ) + ";" ) ; else if ( isNoLines ) { if ( ch == '\r' ) sb . append ( "&#xA;" ) ; else if ( ch != '\n' ) sb . append ( ch ) ; } else sb . append ( ch ) ; } return sb . toString ( ) ; } }
Converts the raw characters to XML escape characters .
32,870
public List < Property > children ( ) { List < Property > result = new ArrayList < Property > ( ) ; listChildren ( result ) ; return result ; }
Supports iterating the children elements in some generic processor or browser All defined children will be listed even if they have no value on this instance
32,871
public synchronized void registerValidatorModule ( IValidatorModule theValidator ) { Validate . notNull ( theValidator , "theValidator must not be null" ) ; ArrayList < IValidatorModule > newValidators = new ArrayList < IValidatorModule > ( myValidators . size ( ) + 1 ) ; newValidators . addAll ( myValidators ) ; newValidators . add ( theValidator ) ; myValidators = newValidators ; }
Add a new validator module to this validator . You may register as many modules as you like at any time .
32,872
public synchronized void unregisterValidatorModule ( IValidatorModule theValidator ) { Validate . notNull ( theValidator , "theValidator must not be null" ) ; ArrayList < IValidatorModule > newValidators = new ArrayList < IValidatorModule > ( myValidators . size ( ) + 1 ) ; newValidators . addAll ( myValidators ) ; newValidators . remove ( theValidator ) ; myValidators = newValidators ; }
Removes a validator module from this validator . You may register as many modules as you like and remove them at any time .
32,873
private IBundleProvider performSearch ( String theCriteria ) { IFhirResourceDao < ? > subscriptionDao = myDaoRegistry . getSubscriptionDao ( ) ; RuntimeResourceDefinition responseResourceDef = subscriptionDao . validateCriteriaAndReturnResourceDefinition ( theCriteria ) ; SearchParameterMap responseCriteriaUrl = myMatchUrlService . translateMatchUrl ( theCriteria , responseResourceDef ) ; IFhirResourceDao < ? extends IBaseResource > responseDao = myDaoRegistry . getResourceDao ( responseResourceDef . getImplementingClass ( ) ) ; responseCriteriaUrl . setLoadSynchronousUpTo ( 1 ) ; TransactionTemplate txTemplate = new TransactionTemplate ( myTxManager ) ; txTemplate . setPropagationBehavior ( TransactionDefinition . PROPAGATION_REQUIRES_NEW ) ; return txTemplate . execute ( t -> responseDao . search ( responseCriteriaUrl ) ) ; }
Search based on a query criteria
32,874
private ProfilingWrapper wrap ( Base object ) { ProfilingWrapper res = new ProfilingWrapper ( context , resource , object ) ; res . cache = cache ; res . engine = engine ; return res ; }
This is a convenient called for
32,875
private void start ( List < ValidationMessage > errors , WrapperElement resource , WrapperElement element , StructureDefinition profile , NodeStack stack ) throws FHIRException { if ( rule ( errors , IssueType . STRUCTURE , element . line ( ) , element . col ( ) , stack . getLiteralPath ( ) , profile . hasSnapshot ( ) , "StructureDefinition has no snapshot - validation is against the snapshot, so it must be provided" ) ) { validateElement ( errors , profile , profile . getSnapshot ( ) . getElement ( ) . get ( 0 ) , null , null , resource , element , element . getName ( ) , stack , false ) ; checkDeclaredProfiles ( errors , resource , element , stack ) ; if ( element . getResourceType ( ) . equals ( "Bundle" ) ) validateBundle ( errors , element , stack ) ; if ( element . getResourceType ( ) . equals ( "Observation" ) ) validateObservation ( errors , element , stack ) ; } }
the instance validator had no issues against the base resource profile
32,876
public Response create ( final String resource ) throws IOException { return execute ( getResourceRequest ( RequestTypeEnum . POST , RestOperationTypeEnum . CREATE ) . resource ( resource ) ) ; }
Create a new resource with a server assigned id
32,877
public Response conditionalUpdate ( final String resource ) throws IOException { return execute ( getResourceRequest ( RequestTypeEnum . PUT , RestOperationTypeEnum . UPDATE ) . resource ( resource ) ) ; }
Update an existing resource based on the given condition
32,878
public Response delete ( ) throws IOException { return execute ( getResourceRequest ( RequestTypeEnum . DELETE , RestOperationTypeEnum . DELETE ) ) ; }
Delete a resource based on the given condition
32,879
@ Path ( "/{id}" ) public Response delete ( @ PathParam ( "id" ) final String id ) throws IOException { return execute ( getResourceRequest ( RequestTypeEnum . DELETE , RestOperationTypeEnum . DELETE ) . id ( id ) ) ; }
Delete a resource
32,880
@ Path ( "/{id}" ) public Response find ( @ PathParam ( "id" ) final String id ) throws IOException { return execute ( getResourceRequest ( RequestTypeEnum . GET , RestOperationTypeEnum . READ ) . id ( id ) ) ; }
Read the current state of the resource
32,881
protected Response customOperation ( final String resource , final RequestTypeEnum requestType , final String id , final String operationName , final RestOperationTypeEnum operationType ) throws IOException { final Builder request = getResourceRequest ( requestType , operationType ) . resource ( resource ) . id ( id ) ; return execute ( request , operationName ) ; }
Execute a custom operation
32,882
@ Path ( "/{id}/_history/{version}" ) public Response findHistory ( @ PathParam ( "id" ) final String id , @ PathParam ( "version" ) final String version ) throws IOException { final Builder theRequest = getResourceRequest ( RequestTypeEnum . GET , RestOperationTypeEnum . VREAD ) . id ( id ) . version ( version ) ; return execute ( theRequest ) ; }
Retrieve the update history for a particular resource
32,883
@ Path ( "/{id}/{compartment}" ) public Response findCompartment ( @ PathParam ( "id" ) final String id , @ PathParam ( "compartment" ) final String compartment ) throws IOException { final Builder theRequest = getResourceRequest ( RequestTypeEnum . GET , RestOperationTypeEnum . SEARCH_TYPE ) . id ( id ) . compartment ( compartment ) ; return execute ( theRequest , compartment ) ; }
Compartment Based Access
32,884
private Response execute ( final Builder theRequestBuilder , final String methodKey ) throws IOException { final JaxRsRequest theRequest = theRequestBuilder . build ( ) ; final BaseMethodBinding < ? > method = getBinding ( theRequest . getRestOperationType ( ) , methodKey ) ; try { return ( Response ) method . invokeServer ( this , theRequest ) ; } catch ( final Throwable theException ) { return handleException ( theRequest , theException ) ; } }
Execute the method described by the requestBuilder and methodKey
32,885
protected BaseMethodBinding < ? > getBinding ( final RestOperationTypeEnum restOperation , final String theBindingKey ) { return getBindings ( ) . getBinding ( restOperation , theBindingKey ) ; }
Return the method binding for the given rest operation
32,886
private Builder getResourceRequest ( final RequestTypeEnum requestType , final RestOperationTypeEnum restOperation ) { return getRequest ( requestType , restOperation , getResourceType ( ) . getSimpleName ( ) ) ; }
Return the request builder based on the resource name for the server
32,887
public void reset ( ) { fieldDelimiter = DEFAULT_DELIMITER_FIELD ; componentDelimiter = DEFAULT_DELIMITER_COMPONENT ; subComponentDelimiter = DEFAULT_DELIMITER_SUBCOMPONENT ; repetitionDelimiter = DEFAULT_DELIMITER_REPETITION ; escapeCharacter = DEFAULT_CHARACTER_ESCAPE ; }
reset to default HL7 values
32,888
public void check ( ) throws FHIRException { rule ( componentDelimiter != fieldDelimiter , "Delimiter Error: \"" + componentDelimiter + "\" is used for both CPComponent and CPField" ) ; rule ( subComponentDelimiter != fieldDelimiter , "Delimiter Error: \"" + subComponentDelimiter + "\" is used for both CPSubComponent and CPField" ) ; rule ( subComponentDelimiter != componentDelimiter , "Delimiter Error: \"" + subComponentDelimiter + "\" is used for both CPSubComponent and CPComponent" ) ; rule ( repetitionDelimiter != fieldDelimiter , "Delimiter Error: \"" + repetitionDelimiter + "\" is used for both Repetition and CPField" ) ; rule ( repetitionDelimiter != componentDelimiter , "Delimiter Error: \"" + repetitionDelimiter + "\" is used for both Repetition and CPComponent" ) ; rule ( repetitionDelimiter != subComponentDelimiter , "Delimiter Error: \"" + repetitionDelimiter + "\" is used for both Repetition and CPSubComponent" ) ; rule ( escapeCharacter != fieldDelimiter , "Delimiter Error: \"" + escapeCharacter + "\" is used for both Escape and CPField" ) ; rule ( escapeCharacter != componentDelimiter , "Delimiter Error: \"" + escapeCharacter + "\" is used for both Escape and CPComponent" ) ; rule ( escapeCharacter != subComponentDelimiter , "Delimiter Error: \"" + escapeCharacter + "\" is used for both Escape and CPSubComponent" ) ; rule ( escapeCharacter != repetitionDelimiter , "Delimiter Error: \"" + escapeCharacter + "\" is used for both Escape and Repetition" ) ; }
check that the delimiters are valid
32,889
public String getEscape ( char ch ) { if ( ch == escapeCharacter ) return escapeCharacter + "E" + escapeCharacter ; else if ( ch == fieldDelimiter ) return escapeCharacter + "F" + escapeCharacter ; else if ( ch == componentDelimiter ) return escapeCharacter + "S" + escapeCharacter ; else if ( ch == subComponentDelimiter ) return escapeCharacter + "T" + escapeCharacter ; else if ( ch == repetitionDelimiter ) return escapeCharacter + "R" + escapeCharacter ; else return null ; }
get the escape for a character
32,890
public char getDelimiterEscapeChar ( char ch ) throws DefinitionException { if ( ch == 'E' ) return escapeCharacter ; else if ( ch == 'F' ) return fieldDelimiter ; else if ( ch == 'S' ) return componentDelimiter ; else if ( ch == 'T' ) return subComponentDelimiter ; else if ( ch == 'R' ) return repetitionDelimiter ; else throw new DefinitionException ( "internal error in getDelimiterEscapeChar" ) ; }
get escape for ch in an escape
32,891
public Response getPages ( @ QueryParam ( Constants . PARAM_PAGINGACTION ) String thePageId ) throws IOException { JaxRsRequest theRequest = getRequest ( RequestTypeEnum . GET , RestOperationTypeEnum . GET_PAGE ) . build ( ) ; try { return ( Response ) myBinding . invokeServer ( this , theRequest ) ; } catch ( JaxRsResponseException theException ) { return new JaxRsExceptionInterceptor ( ) . convertExceptionIntoResponse ( theRequest , theException ) ; } }
This method implements the getpages action
32,892
@ SuppressWarnings ( "unchecked" ) public static < T extends IBaseResource > List < T > toListOfResourcesOfType ( FhirContext theContext , IBaseBundle theBundle , Class < T > theTypeToInclude ) { Objects . requireNonNull ( theTypeToInclude , "ResourceType must not be null" ) ; List < T > retVal = new ArrayList < > ( ) ; RuntimeResourceDefinition def = theContext . getResourceDefinition ( theBundle ) ; BaseRuntimeChildDefinition entryChild = def . getChildByName ( "entry" ) ; List < IBase > entries = entryChild . getAccessor ( ) . getValues ( theBundle ) ; BaseRuntimeElementCompositeDefinition < ? > entryChildElem = ( BaseRuntimeElementCompositeDefinition < ? > ) entryChild . getChildByName ( "entry" ) ; BaseRuntimeChildDefinition resourceChild = entryChildElem . getChildByName ( "resource" ) ; for ( IBase nextEntry : entries ) { for ( IBase next : resourceChild . getAccessor ( ) . getValues ( nextEntry ) ) { if ( theTypeToInclude . isAssignableFrom ( next . getClass ( ) ) ) { retVal . add ( ( T ) next ) ; } } } return retVal ; }
Extract all of the resources of a given type from a given bundle
32,893
public boolean isAllParametersHaveNoModifier ( ) { for ( List < List < IQueryParameterType > > nextParamName : values ( ) ) { for ( List < IQueryParameterType > nextAnd : nextParamName ) { for ( IQueryParameterType nextOr : nextAnd ) { if ( isNotBlank ( nextOr . getQueryParameterQualifier ( ) ) ) { return false ; } } } } return true ; }
This will only return true if all parameters have no modifier of any kind
32,894
public DateRangeParam setLowerBoundInclusive ( Date theLowerBound ) { validateAndSet ( new DateParam ( ParamPrefixEnum . GREATERTHAN_OR_EQUALS , theLowerBound ) , myUpperBound ) ; return this ; }
Sets the lower bound to be greaterthan or equal to the given date
32,895
public DateRangeParam setUpperBoundInclusive ( Date theUpperBound ) { validateAndSet ( myLowerBound , new DateParam ( ParamPrefixEnum . LESSTHAN_OR_EQUALS , theUpperBound ) ) ; return this ; }
Sets the upper bound to be greaterthan or equal to the given date
32,896
public DateRangeParam setLowerBoundExclusive ( Date theLowerBound ) { validateAndSet ( new DateParam ( ParamPrefixEnum . GREATERTHAN , theLowerBound ) , myUpperBound ) ; return this ; }
Sets the lower bound to be greaterthan to the given date
32,897
public DateRangeParam setUpperBoundExclusive ( Date theUpperBound ) { validateAndSet ( myLowerBound , new DateParam ( ParamPrefixEnum . LESSTHAN , theUpperBound ) ) ; return this ; }
Sets the upper bound to be greaterthan to the given date
32,898
public void setRangeFromDatesInclusive ( IPrimitiveType < Date > theLowerBound , IPrimitiveType < Date > theUpperBound ) { IPrimitiveType < Date > lowerBound = theLowerBound ; IPrimitiveType < Date > upperBound = theUpperBound ; if ( lowerBound != null && lowerBound . getValue ( ) != null && upperBound != null && upperBound . getValue ( ) != null ) { if ( lowerBound . getValue ( ) . after ( upperBound . getValue ( ) ) ) { IPrimitiveType < Date > temp = lowerBound ; lowerBound = upperBound ; upperBound = temp ; } } validateAndSet ( lowerBound != null ? new DateParam ( GREATERTHAN_OR_EQUALS , lowerBound ) : null , upperBound != null ? new DateParam ( LESSTHAN_OR_EQUALS , upperBound ) : null ) ; }
Sets the range from a pair of dates inclusive on both ends . Note that if theLowerBound is after theUpperBound thie method will automatically reverse the order of the arguments in order to create an inclusive range .
32,899
public void setPropertyFile ( String ... thePropertyFile ) { Validate . notNull ( thePropertyFile , "Property file can not be null" ) ; myPropertyFile = Arrays . asList ( thePropertyFile ) ; }
Set the property file to use