Lots more documentation and let users interact with link self/search

This commit is contained in:
jamesagnew 2014-08-16 17:46:30 -04:00
parent d67a29a366
commit 8078452f78
70 changed files with 1307 additions and 449 deletions

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/hapi-fhir-base"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

1
hapi-fhir-base/examples/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target/

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>hapi-fhir-base-examples</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,3 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding/<project>=UTF-8

View File

@ -0,0 +1,289 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
org.eclipse.jdt.core.formatter.comment.format_source_code=true
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
org.eclipse.jdt.core.formatter.comment.line_length=80
org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_empty_lines=false
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=3
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.join_lines_in_comments=true
org.eclipse.jdt.core.formatter.join_wrapped_lines=true
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
org.eclipse.jdt.core.formatter.lineSplit=160
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=3
org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=true
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true

View File

@ -0,0 +1,3 @@
eclipse.preferences.version=1
formatter_profile=_examples-format
formatter_settings_version=12

View File

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

View File

@ -0,0 +1,47 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>0.6-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>hapi-fhir-base-examples</artifactId>
<packaging>jar</packaging>
<name>HAPI FHIR - Examples (for site)</name>
<dependencies>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit_version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,89 @@
package example;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.client.IGenericClient;
import ca.uhn.fhir.rest.client.IRestfulClientFactory;
import ca.uhn.fhir.rest.client.api.IBasicClient;
import ca.uhn.fhir.rest.client.interceptor.BasicAuthInterceptor;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import ca.uhn.fhir.rest.server.EncodingEnum;
public class ClientExamples {
public interface IPatientClient extends IBasicClient {
// nothing yet
}
@SuppressWarnings("unused")
public void createProxy() {
// START SNIPPET: proxy
FhirContext ctx = new FhirContext();
ctx.getRestfulClientFactory().setProxy("example.com", 8888);
IGenericClient genericClient = ctx.newRestfulGenericClient("http://localhost:9999/fhir");
// END SNIPPET: proxy
}
@SuppressWarnings("unused")
public void createSecurity() {
// START SNIPPET: security
// Create a context and get the client factory so it can be configured
FhirContext ctx = new FhirContext();
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
// Create an HTTP basic auth interceptor
String username = "foobar";
String password = "boobear";
BasicAuthInterceptor authInterceptor = new BasicAuthInterceptor(username, password);
// Register the interceptor with your client (either style)
IPatientClient annotationClient = ctx.newRestfulClient(IPatientClient.class, "http://localhost:9999/fhir");
annotationClient.registerInterceptor(authInterceptor);
IGenericClient genericClient = ctx.newRestfulGenericClient("http://localhost:9999/fhir");
annotationClient.registerInterceptor(authInterceptor);
// END SNIPPET: security
}
@SuppressWarnings("unused")
public void createLogging() {
{
// START SNIPPET: logging
// Create a context and get the client factory so it can be configured
FhirContext ctx = new FhirContext();
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
// Create a logging interceptor
LoggingInterceptor loggingInterceptor = new LoggingInterceptor();
// Optionally you may configure the interceptor (by default only
// summary info is logged)
loggingInterceptor.setLogRequestSummary(true);
loggingInterceptor.setLogRequestBody(true);
// Register the interceptor with your client (either style)
IPatientClient annotationClient = ctx.newRestfulClient(IPatientClient.class, "http://localhost:9999/fhir");
annotationClient.registerInterceptor(loggingInterceptor);
IGenericClient genericClient = ctx.newRestfulGenericClient("http://localhost:9999/fhir");
genericClient.registerInterceptor(loggingInterceptor);
// END SNIPPET: logging
}
/******************************/
{
// START SNIPPET: clientConfig
// Create a client
FhirContext ctx = new FhirContext();
IPatientClient client = ctx.newRestfulClient(IPatientClient.class, "http://localhost:9999/");
// Request JSON encoding from the server (_format=json)
client.setEncoding(EncodingEnum.JSON);
// Request pretty printing from the server (_pretty=true)
client.setPrettyPrint(true);
// END SNIPPET: clientConfig
}
}
}

View File

@ -0,0 +1,66 @@
package example;
//START SNIPPET: client
import java.io.IOException;
import java.util.List;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.dstu.resource.Organization;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.rest.annotation.RequiredParam;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.client.api.IRestfulClient;
public class CompleteExampleClient {
/**
* This is a simple client interface. It can have many methods for various
* searches but in this case it has only 1.
*/
public static interface ClientInterface extends IRestfulClient {
/**
* This is translated into a URL similar to the following:
* http://fhir.healthintersections.com.au/open/Patient?identifier=urn:oid:1.2.36.146.595.217.0.1%7C12345
*/
@Search
List<Patient> findPatientsForMrn(@RequiredParam(name = Patient.SP_IDENTIFIER) IdentifierDt theIdentifier);
}
/**
* The main method here will directly call an open FHIR server and retrieve a
* list of resources matching a given criteria, then load a linked resource.
*/
public static void main(String[] args) throws IOException {
// Create a client factory
FhirContext ctx = new FhirContext();
// Create the client
String serverBase = "http://fhir.healthintersections.com.au/open";
ClientInterface client = ctx.newRestfulClient(ClientInterface.class, serverBase);
// Invoke the client to search for patient
List<Patient> patients = client.findPatientsForMrn(new IdentifierDt("urn:oid:1.2.36.146.595.217.0.1", "12345"));
System.out.println("Found " + patients.size() + " patients");
// Print a value from the loaded resource
Patient patient = patients.get(0);
System.out.println("Patient Last Name: " + patient.getName().get(0).getFamily().get(0).getValue());
// Load a referenced resource
ResourceReferenceDt managingRef = patient.getManagingOrganization();
Organization org = (Organization) managingRef.loadResource(client);
// Print organization name
System.out.println(org.getName().getValue());
}
}
// END SNIPPET: client

View File

@ -0,0 +1,86 @@
package example;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.api.annotation.Extension;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.model.primitive.DateTimeDt;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.parser.IParser;
public class MyPatientUse {
@ResourceDef
public static class MyPatient extends Patient {
@Child(name="petName")
@Extension(url="http://example.com/dontuse#petname", definedLocally=false, isModifier=false)
@Description(shortDefinition="The name of the patient's favourite pet")
private StringDt myPetName;
public StringDt getPetName() {
if(myPetName==null) {
myPetName = new StringDt();
}
return myPetName;
}
public void setPetName(StringDt thePetName) {
myPetName = thePetName;
}
public List<DateTimeDt> getImportantDates() {
if (myImportantDates==null) {
myImportantDates=new ArrayList<DateTimeDt>();
}
return myImportantDates;
}
public void setImportantDates(List<DateTimeDt> theImportantDates) {
myImportantDates = theImportantDates;
}
@Child(name="importantDates", max=Child.MAX_UNLIMITED)
@Extension(url="http://example.com/dontuse#importantDates", definedLocally=false, isModifier=true)
@Description(shortDefinition="Some dates of note for the patient")
private List<DateTimeDt> myImportantDates;
}
@SuppressWarnings("unused")
public static void main(String[] args) throws DataFormatException, IOException {
//START SNIPPET: patientUse
MyPatient patient = new MyPatient();
patient.setPetName(new StringDt("Fido"));
patient.getImportantDates().add(new DateTimeDt("2010-01-02"));
patient.getImportantDates().add(new DateTimeDt("2014-01-26T11:11:11"));
patient.addName().addFamily("Smith").addGiven("John").addGiven("Quincy").addSuffix("Jr");
IParser p = new FhirContext().newXmlParser().setPrettyPrint(true);
String messageString = p.encodeResourceToString(patient);
System.out.println(messageString);
//END SNIPPET: patientUse
//START SNIPPET: patientParse
IParser parser = new FhirContext().newXmlParser();
MyPatient newPatient = parser.parseResource(MyPatient.class, messageString);
//END SNIPPET: patientParse
{
FhirContext ctx2 = new FhirContext();
RuntimeResourceDefinition def = ctx2.getResourceDefinition(patient);
System.out.println(ctx2.newXmlParser().setPrettyPrint(true).encodeResourceToString(def.toProfile()));
}
}
}

View File

@ -19,7 +19,7 @@ import ca.uhn.fhir.model.api.Tag;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.api.annotation.TagListParam;
import ca.uhn.fhir.rest.annotation.TagListParam;
import ca.uhn.fhir.model.dstu.composite.CodingDt;
import ca.uhn.fhir.model.dstu.resource.Conformance;
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport;
@ -57,7 +57,6 @@ import ca.uhn.fhir.rest.annotation.Validate;
import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.api.SortOrderEnum;
import ca.uhn.fhir.rest.api.SortSpec;
import ca.uhn.fhir.rest.client.ITestClient;
import ca.uhn.fhir.rest.client.api.IBasicClient;
import ca.uhn.fhir.rest.client.api.IRestfulClient;
import ca.uhn.fhir.rest.param.CompositeParam;
@ -78,6 +77,14 @@ import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
@SuppressWarnings("unused")
public abstract class RestfulPatientResourceProviderMore implements IResourceProvider {
public interface ITestClient extends IBasicClient
{
@Search
List<Patient> getPatientByDob(@RequiredParam(name=Patient.SP_BIRTHDATE) DateParam theParam);
}
private boolean detectedVersionConflict;
private boolean conflictHappened;
private boolean couldntFindThisId;

View File

@ -0,0 +1,56 @@
package example;
import java.util.ArrayList;
import java.util.List;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.model.api.Tag;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.model.primitive.InstantDt;
import ca.uhn.fhir.rest.annotation.Search;
public class ServerMetadataExamples {
// START SNIPPET: serverMethod
@Search
public List<Patient> getAllPatients() {
ArrayList<Patient> retVal = new ArrayList<Patient>();
// Create a patient to return
Patient patient = new Patient();
retVal.add(patient);
patient.setId("Patient/123");
patient.addName().addFamily("Smith").addGiven("John");
// Create a tag list and add it to the resource
TagList tags = new TagList();
tags.addTag(Tag.HL7_ORG_FHIR_TAG, "http://foo/tag1.html", "Some tag");
tags.addTag(Tag.HL7_ORG_FHIR_TAG, "http://foo/tag2.html", "Another tag");
ResourceMetadataKeyEnum.TAG_LIST.put(patient, tags);
// Set some links (these can be provided as relative links or absolute)
// and the server will convert to absolute as appropriate
String linkAlternate = "Patient/7736";
ResourceMetadataKeyEnum.LINK_ALTERNATE.put(patient, linkAlternate);
String linkSearch = "Patient?name=smith&name=john";
ResourceMetadataKeyEnum.LINK_ALTERNATE.put(patient, linkSearch);
// Set the published and updated dates
InstantDt pubDate = new InstantDt("2011-02-22");
ResourceMetadataKeyEnum.PUBLISHED.put(patient, pubDate);
InstantDt updatedDate = new InstantDt("2014-07-12T11:22:27Z");
ResourceMetadataKeyEnum.UPDATED.put(patient, updatedDate);
// Set the resource title (note that if you are using HAPI's narrative
// generation capability, the narrative generator will often create
// useful titles automatically, and the server will create a default
// title if none is provided)
String title = "Patient John SMITH";
ResourceMetadataKeyEnum.TITLE.put(patient, title);
return retVal;
}
// END SNIPPET: serverMethod
}

View File

@ -0,0 +1,71 @@
package example;
import java.util.ArrayList;
import java.util.List;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.model.api.Tag;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.client.IGenericClient;
public class TagsExamples {
public static void main(String[] args) {
new TagsExamples().getResourceTags();
}
@SuppressWarnings("unused")
public void getResourceTags() {
// START SNIPPET: getResourceTags
IGenericClient client = new FhirContext().newRestfulGenericClient("http://fhir.healthintersections.com.au/open");
Patient p = client.read(Patient.class, "1");
// Retrieve the list of tags from the resource metadata
TagList tags = ResourceMetadataKeyEnum.TAG_LIST.get(p);
// tags may be null if no tags were read in
if (tags == null) {
System.out.println("No tags!");
} else {
// You may iterate over all the tags
for (Tag next : tags) {
System.out.println(next.getScheme() + " - " + next.getTerm());
}
// You may also get a list of tags matching a given scheme
List<Tag> someTags = tags.getTagsWithScheme("http://hl7.org/fhir/tag");
// Or a specific tag (by scheme and term)
Tag specificTag = tags.getTag("http://hl7.org/fhir/tag", "http://foo");
}
// END SNIPPET: getResourceTags
}
// START SNIPPET: serverMethod
@Search
public List<Patient> getAllPatients() {
ArrayList<Patient> retVal = new ArrayList<Patient>();
// Create a patient to return
Patient patient = new Patient();
patient.setId("Patient/123");
patient.addName().addFamily("Smith").addGiven("John");
// Create a tag list and add it to the resource
TagList tags = new TagList();
ResourceMetadataKeyEnum.TAG_LIST.put(patient, tags);
// Add some tags to the list
tags.addTag(Tag.HL7_ORG_FHIR_TAG, "http://foo/tag1.html", "Some tag");
tags.addTag(Tag.HL7_ORG_FHIR_TAG, "http://foo/tag2.html", "Another tag");
return retVal;
}
// END SNIPPET: serverMethod
}

View File

@ -8,10 +8,10 @@
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<packaging>jar</packaging>
<url>http://hl7api.sourceforge.net/hapi-fhir/</url>
<url>http://jamesagnew.github.io/hapi-fhir/</url>
<name>HAPI FHIR - Core Library</name>
@ -20,14 +20,11 @@
<id>git.server</id>
<url>scm:git:git@github.com:jamesagnew/hapi-fhir.git</url>
</site>
<!-- <site> <id>hl7api.sf.net</id> <url>scp://shell.sourceforge.net/home/project-web/hl7api/htdocs/hapi-fhir</url> </site> -->
</distributionManagement>
<dependencies>
<!-- JSON -->
<!-- <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.2.4</version> </dependency> -->
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>

View File

@ -80,6 +80,9 @@
Server search method for an unnamed query gets called if the client requests a named query
with the same parameter list. Thanks to Neal Acharya of University Health Network for reporting!
</action>
<action type="fix">
Category header (for tags) is correctly read in client for "read" operation
</action>
</release>
<release version="0.5" date="2014-Jul-30">
<action type="add">

View File

@ -204,8 +204,7 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil
if (values == null) {
return Collections.emptyList();
}
@SuppressWarnings("unchecked")
List<? extends IElement> retVal = (List<? extends IElement>) Collections.singletonList(values);
List<? extends IElement> retVal = (List<? extends IElement>) Collections.singletonList((IElement)values);
return retVal;
} catch (IllegalArgumentException e) {
throw new ConfigurationException("Failed to get value", e);

View File

@ -585,25 +585,37 @@ class ModelScanner {
private String scanResource(Class<? extends IResource> theClass, ResourceDef resourceDefinition) {
ourLog.debug("Scanning resource class: {}", theClass.getName());
boolean primaryNameProvider = true;
String resourceName = resourceDefinition.name();
if (isBlank(resourceName)) {
throw new ConfigurationException("Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
}
if (myNameToResourceDefinitions.containsKey(resourceName)) {
if (!myNameToResourceDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
// throw new
// ConfigurationException("Detected duplicate element name '" +
// resourceName + "' in types '" + theClass.getCanonicalName() +
// "' and '"
// +
// myNameToResourceDefinitions.get(resourceName).getImplementingClass()
// + "'");
} else {
return resourceName;
Class<?> parent = theClass.getSuperclass();
primaryNameProvider=false;
while (parent.equals(Object.class)==false && isBlank(resourceName)) {
ResourceDef nextDef = parent.getAnnotation(ResourceDef.class);
if (nextDef != null) {
resourceName = nextDef.name();
}
parent = parent.getSuperclass();
}
if (isBlank(resourceName)) {
throw new ConfigurationException("Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name(): " + theClass.getCanonicalName() + " - This is only allowed for types that extend other resource types ");
}
}
// if (myNameToResourceDefinitions.containsKey(resourceName)) {
// if (!myNameToResourceDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
// // throw new
// // ConfigurationException("Detected duplicate element name '" +
// // resourceName + "' in types '" + theClass.getCanonicalName() +
// // "' and '"
// // +
// // myNameToResourceDefinitions.get(resourceName).getImplementingClass()
// // + "'");
// } else {
// return resourceName;
// }
// }
String resourceId = resourceDefinition.id();
if (isBlank(resourceId)) {
// throw new ConfigurationException("Resource type @" +
@ -619,10 +631,11 @@ class ModelScanner {
String profile = resourceDefinition.profile();
RuntimeResourceDefinition resourceDef = new RuntimeResourceDefinition(theClass, resourceDefinition);
RuntimeResourceDefinition resourceDef = new RuntimeResourceDefinition(resourceName, theClass, resourceDefinition);
myClassToElementDefinitions.put(theClass, resourceDef);
myNameToResourceDefinitions.put(resourceName, resourceDef);
if (primaryNameProvider) {
myNameToResourceDefinitions.put(resourceName, resourceDef);
}
scanCompositeElementForChildren(theClass, resourceDef);
myIdToResourceDefinition.put(resourceId, resourceDef);

View File

@ -60,8 +60,8 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
private List<RuntimeSearchParam> mySearchParams;
private String myId;
public RuntimeResourceDefinition(Class<? extends IResource> theClass, ResourceDef theResourceAnnotation) {
super(theResourceAnnotation.name(), theClass);
public RuntimeResourceDefinition(String theResourceName, Class<? extends IResource> theClass, ResourceDef theResourceAnnotation) {
super(theResourceName, theClass);
myResourceProfile = theResourceAnnotation.profile();
myId = theResourceAnnotation.id();
}

View File

@ -20,7 +20,7 @@ package ca.uhn.fhir.model.api;
* #L%
*/
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.apache.commons.lang3.StringUtils.*;
import java.util.ArrayList;
import java.util.HashMap;
@ -38,6 +38,7 @@ import ca.uhn.fhir.model.primitive.InstantDt;
import ca.uhn.fhir.model.primitive.IntegerDt;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.util.UrlUtil;
public class Bundle extends BaseBundle /* implements IElement */{
@ -269,8 +270,6 @@ public class Bundle extends BaseBundle /* implements IElement */{
BundleEntry entry = addEntry();
entry.setResource(theResource);
entry.setResource(theResource);
RuntimeResourceDefinition def = theContext.getResourceDefinition(theResource);
String title = ResourceMetadataKeyEnum.TITLE.get(theResource);
@ -312,6 +311,24 @@ public class Bundle extends BaseBundle /* implements IElement */{
String qualifiedId = b.toString();
entry.getLinkSelf().setValue(qualifiedId);
// String resourceType = theContext.getResourceDefinition(theResource).getName();
String linkSearch = ResourceMetadataKeyEnum.LINK_SEARCH.get(theResource);
if (isNotBlank(linkSearch)) {
if (!UrlUtil.isAbsolute(linkSearch)) {
linkSearch = (theServerBase + "/" + linkSearch);
}
entry.getLinkSearch().setValue(linkSearch);
}
String linkAlternate = ResourceMetadataKeyEnum.LINK_ALTERNATE.get(theResource);
if (isNotBlank(linkAlternate)) {
if (!UrlUtil.isAbsolute(linkAlternate)) {
linkSearch = (theServerBase + "/" + linkAlternate);
}
entry.getLinkAlternate().setValue(linkSearch);
}
}
InstantDt published = ResourceMetadataKeyEnum.PUBLISHED.get(theResource);
@ -346,9 +363,9 @@ public class Bundle extends BaseBundle /* implements IElement */{
return entry;
}
public static Bundle withResources(ArrayList<IResource> theUploadBundle, FhirContext theContext, String theServerBase) {
public static Bundle withResources(List<IResource> theResources, FhirContext theContext, String theServerBase) {
Bundle retVal = new Bundle();
for (IResource next : theUploadBundle) {
for (IResource next : theResources) {
retVal.addResource(next, theContext, theServerBase);
}
return retVal;

View File

@ -197,6 +197,52 @@ public abstract class ResourceMetadataKeyEnum<T> {
}
};
/**
* If present and populated with a string, provides the "search link" (the link
* element in the bundle entry with <code>rel="search"</code>). Server implementations
* may populate this with a complete URL, in which case the URL will be
* placed as-is in the bundle. They may alternately specify a
* resource relative URL (e.g. "Patient?name=tester") in which case the
* server will convert this to an absolute URL at runtime.
* <p>
* Values for this key are of type <b>{@link String}</b>
* </p>
*/
public static final ResourceMetadataKeyEnum<String> LINK_SEARCH = new ResourceMetadataKeyEnum<String>("LINK_SEARCH") {
@Override
public String get(IResource theResource) {
return getStringFromMetadataOrNullIfNone(theResource.getResourceMetadata(), LINK_SEARCH);
}
@Override
public void put(IResource theResource, String theObject) {
theResource.getResourceMetadata().put(LINK_SEARCH, theObject);
}
};
/**
* If present and populated with a string, provides the "alternate link" (the link
* element in the bundle entry with <code>rel="alternate"</code>). Server implementations
* may populate this with a complete URL, in which case the URL will be
* placed as-is in the bundle. They may alternately specify a
* resource relative URL (e.g. "Patient/1243") in which case the
* server will convert this to an absolute URL at runtime.
* <p>
* Values for this key are of type <b>{@link String}</b>
* </p>
*/
public static final ResourceMetadataKeyEnum<String> LINK_ALTERNATE = new ResourceMetadataKeyEnum<String>("LINK_ALTERNATE") {
@Override
public String get(IResource theResource) {
return getStringFromMetadataOrNullIfNone(theResource.getResourceMetadata(), LINK_ALTERNATE);
}
@Override
public void put(IResource theResource, String theObject) {
theResource.getResourceMetadata().put(LINK_ALTERNATE, theObject);
}
};
private final String myValue;
public ResourceMetadataKeyEnum(String theValue) {

View File

@ -35,6 +35,18 @@ public class Tag extends BaseElement implements IElement {
*/
public static final String HL7_ORG_FHIR_TAG = "http://hl7.org/fhir/tag";
/**
* Convenience constant containing the "http://hl7.org/fhir/tag/security" scheme
* value
*/
public static final String HL7_ORG_SECURITY_TAG = "http://hl7.org/fhir/tag/security";
/**
* Convenience constant containing the "http://hl7.org/fhir/tag/profile" scheme
* value
*/
public static final String HL7_ORG_PROFILE_TAG = "http://hl7.org/fhir/tag/profile";
public static final String ATTR_TERM = "term";
public static final String ATTR_LABEL = "label";
public static final String ATTR_SCHEME = "scheme";

View File

@ -21,6 +21,7 @@ package ca.uhn.fhir.model.api;
*/
import java.util.ArrayList;
import java.util.List;
public class TagList extends ArrayList<Tag> {
@ -48,7 +49,7 @@ public class TagList extends ArrayList<Tag> {
return null;
}
public ArrayList<Tag> getTagsWithScheme(String theScheme) {
public List<Tag> getTagsWithScheme(String theScheme) {
ArrayList<Tag> retVal = new ArrayList<Tag>();
for (Tag next : this) {
if (theScheme.equals(next.getScheme())) {

View File

@ -35,7 +35,7 @@ public @interface ResourceDef {
/**
* The name of the resource (e.g. "Patient" or "DiagnosticReport")
*/
String name();
String name() default "";
/**
* Not currently used

View File

@ -34,6 +34,7 @@ import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.util.UrlUtil;
/**
* Represents the FHIR ID type. This is the actual resource ID, meaning the ID that will be used in RESTful URLs,
@ -253,6 +254,14 @@ public class IdDt extends BasePrimitive<String> {
return isNotBlank(getVersionIdPart());
}
/**
* Returns <code>true</code> if this ID contains an absolute URL (in other words, a URL starting with "http://" or
* "https://"
*/
public boolean isAbsolute() {
return UrlUtil.isAbsolute(getValue());
}
/**
* Returns <code>true</code> if the unqualified ID is a valid {@link Long} value (in other words, it consists only
* of digits)

View File

@ -474,6 +474,12 @@ class ParserState<T> {
metadata.put(ResourceMetadataKeyEnum.VERSION_ID, linkSelf);
}
}
if (!myEntry.getLinkAlternate().isEmpty()) {
ResourceMetadataKeyEnum.LINK_ALTERNATE.put(myEntry.getResource(), myEntry.getLinkAlternate().getValue());
}
if (!myEntry.getLinkSearch().isEmpty()) {
ResourceMetadataKeyEnum.LINK_SEARCH.put(myEntry.getResource(), myEntry.getLinkSearch().getValue());
}
}

View File

@ -20,8 +20,6 @@ package ca.uhn.fhir.rest.method;
* #L%
*/
import static org.apache.commons.lang3.StringUtils.isBlank;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
@ -39,7 +37,6 @@ import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.model.api.Tag;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
import ca.uhn.fhir.model.primitive.IdDt;
@ -54,9 +51,7 @@ import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<MethodOutcome> {
private static final String LABEL = "label=\"";
static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseOutcomeReturningMethodBinding.class);
private static final String SCHEME = "scheme=\"";
private boolean myReturnVoid;
@ -118,7 +113,7 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<Metho
TagList tagList = new TagList();
for (Enumeration<String> enumeration = theRequest.getServletRequest().getHeaders(Constants.HEADER_CATEGORY); enumeration.hasMoreElements();) {
String nextTagComplete = enumeration.nextElement();
parseTagValue(tagList, nextTagComplete);
MethodUtil.parseTagValue(tagList, nextTagComplete);
}
if (tagList.isEmpty() == false) {
resource.getResourceMetadata().put(ResourceMetadataKeyEnum.TAG_LIST, tagList);
@ -218,19 +213,25 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<Metho
// getMethod().in
}
static void parseTagValue(TagList tagList, String nextTagComplete) {
StringBuilder next = new StringBuilder(nextTagComplete);
parseTagValue(tagList, nextTagComplete, next);
public boolean isReturnVoid() {
return myReturnVoid;
}
/**
* @throws IOException
*/
protected IResource parseIncomingServerResource(Request theRequest) throws IOException {
EncodingEnum encoding = RestfulServer.determineRequestEncoding(theRequest);
IParser parser = encoding.newParser(getContext());
IResource resource = parser.parseResource(theRequest.getServletRequest().getReader());
return resource;
private void addLocationHeader(Request theRequest, HttpServletResponse theResponse, MethodOutcome response) {
StringBuilder b = new StringBuilder();
b.append(theRequest.getFhirServerBase());
b.append('/');
b.append(getResourceName());
b.append('/');
b.append(response.getId().getIdPart());
if (response.getId().hasVersionIdPart()) {
b.append("/" + Constants.PARAM_HISTORY + "/");
b.append(response.getId().getVersionIdPart());
} else if (response.getVersionId() != null && response.getVersionId().isEmpty() == false) {
b.append("/" + Constants.PARAM_HISTORY + "/");
b.append(response.getVersionId().getValue());
}
theResponse.addHeader(Constants.HEADER_LOCATION, b.toString());
}
/*
@ -257,99 +258,6 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<Metho
* encoding.newParser(getContext()); parser.encodeResourceToWriter(outcome, writer); } } finally { writer.close(); } // getMethod().in }
*/
public boolean isReturnVoid() {
return myReturnVoid;
}
private void addLocationHeader(Request theRequest, HttpServletResponse theResponse, MethodOutcome response) {
StringBuilder b = new StringBuilder();
b.append(theRequest.getFhirServerBase());
b.append('/');
b.append(getResourceName());
b.append('/');
b.append(response.getId().getIdPart());
if (response.getId().hasVersionIdPart()) {
b.append("/" + Constants.PARAM_HISTORY + "/");
b.append(response.getId().getVersionIdPart());
} else if (response.getVersionId() != null && response.getVersionId().isEmpty() == false) {
b.append("/" + Constants.PARAM_HISTORY + "/");
b.append(response.getVersionId().getValue());
}
theResponse.addHeader(Constants.HEADER_LOCATION, b.toString());
}
private static void parseTagValue(TagList theTagList, String theCompleteHeaderValue, StringBuilder theBuffer) {
int firstSemicolon = theBuffer.indexOf(";");
int deleteTo;
if (firstSemicolon == -1) {
firstSemicolon = theBuffer.indexOf(",");
if (firstSemicolon == -1) {
firstSemicolon = theBuffer.length();
deleteTo = theBuffer.length();
} else {
deleteTo = firstSemicolon;
}
} else {
deleteTo = firstSemicolon + 1;
}
String term = theBuffer.substring(0, firstSemicolon);
String scheme = null;
String label = null;
if (isBlank(term)) {
return;
}
theBuffer.delete(0, deleteTo);
while (theBuffer.length() > 0 && theBuffer.charAt(0) == ' ') {
theBuffer.deleteCharAt(0);
}
while (theBuffer.length() > 0) {
boolean foundSomething = false;
if (theBuffer.length() > SCHEME.length() && theBuffer.substring(0, SCHEME.length()).equals(SCHEME)) {
int closeIdx = theBuffer.indexOf("\"", SCHEME.length());
scheme = theBuffer.substring(SCHEME.length(), closeIdx);
theBuffer.delete(0, closeIdx + 1);
foundSomething = true;
}
if (theBuffer.length() > LABEL.length() && theBuffer.substring(0, LABEL.length()).equals(LABEL)) {
int closeIdx = theBuffer.indexOf("\"", LABEL.length());
label = theBuffer.substring(LABEL.length(), closeIdx);
theBuffer.delete(0, closeIdx + 1);
foundSomething = true;
}
// TODO: support enc2231-string as described in
// http://tools.ietf.org/html/draft-johnston-http-category-header-02
// TODO: support multiple tags in one header as described in
// http://hl7.org/implement/standards/fhir/http.html#tags
while (theBuffer.length() > 0 && (theBuffer.charAt(0) == ' ' || theBuffer.charAt(0) == ';')) {
theBuffer.deleteCharAt(0);
}
if (!foundSomething) {
break;
}
}
if (theBuffer.length() > 0 && theBuffer.charAt(0) == ',') {
theBuffer.deleteCharAt(0);
while (theBuffer.length() > 0 && theBuffer.charAt(0) == ' ') {
theBuffer.deleteCharAt(0);
}
theTagList.add(new Tag(scheme, term, label));
parseTagValue(theTagList, theCompleteHeaderValue, theBuffer);
} else {
theTagList.add(new Tag(scheme, term, label));
}
if (theBuffer.length() > 0) {
ourLog.warn("Ignoring extra text at the end of " + Constants.HEADER_CATEGORY + " tag '" + theBuffer.toString() + "' - Complete tag value was: " + theCompleteHeaderValue);
}
}
protected abstract void addParametersForServerRequest(Request theRequest, Object[] theParams);
/**
@ -366,6 +274,16 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<Metho
*/
protected abstract String getMatchingOperation();
/**
* @throws IOException
*/
protected IResource parseIncomingServerResource(Request theRequest) throws IOException {
EncodingEnum encoding = RestfulServer.determineRequestEncoding(theRequest);
IParser parser = encoding.newParser(getContext());
IResource resource = parser.parseResource(theRequest.getServletRequest().getReader());
return resource;
}
protected abstract Set<RequestType> provideAllowableRequestTypes();
/**
@ -425,4 +343,5 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<Metho
}
}
}

View File

@ -1,6 +1,6 @@
package ca.uhn.fhir.rest.method;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.apache.commons.lang3.StringUtils.*;
import java.io.IOException;
import java.io.PushbackReader;
@ -79,6 +79,8 @@ import ca.uhn.fhir.util.ReflectionUtil;
*/
public class MethodUtil {
private static final String LABEL = "label=\"";
private static final String SCHEME = "scheme=\"";
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(MethodUtil.class);
@ -132,8 +134,95 @@ public class MethodUtil {
String headerValue = clHeaders.get(0);
resource.getId().setValue(headerValue);
}
List<String> categoryHeaders = theHeaders.get(Constants.HEADER_CATEGORY_LC);
if (categoryHeaders != null && categoryHeaders.size() > 0 && StringUtils.isNotBlank(categoryHeaders.get(0))) {
TagList tagList = new TagList();
for (String header : categoryHeaders) {
parseTagValue(tagList, header);
}
ResourceMetadataKeyEnum.TAG_LIST.put(resource, tagList);
}
}
public static void parseTagValue(TagList tagList, String nextTagComplete) {
StringBuilder next = new StringBuilder(nextTagComplete);
parseTagValue(tagList, nextTagComplete, next);
}
private static void parseTagValue(TagList theTagList, String theCompleteHeaderValue, StringBuilder theBuffer) {
int firstSemicolon = theBuffer.indexOf(";");
int deleteTo;
if (firstSemicolon == -1) {
firstSemicolon = theBuffer.indexOf(",");
if (firstSemicolon == -1) {
firstSemicolon = theBuffer.length();
deleteTo = theBuffer.length();
} else {
deleteTo = firstSemicolon;
}
} else {
deleteTo = firstSemicolon + 1;
}
String term = theBuffer.substring(0, firstSemicolon);
String scheme = null;
String label = null;
if (isBlank(term)) {
return;
}
theBuffer.delete(0, deleteTo);
while (theBuffer.length() > 0 && theBuffer.charAt(0) == ' ') {
theBuffer.deleteCharAt(0);
}
while (theBuffer.length() > 0) {
boolean foundSomething = false;
if (theBuffer.length() > SCHEME.length() && theBuffer.substring(0, SCHEME.length()).equals(SCHEME)) {
int closeIdx = theBuffer.indexOf("\"", SCHEME.length());
scheme = theBuffer.substring(SCHEME.length(), closeIdx);
theBuffer.delete(0, closeIdx + 1);
foundSomething = true;
}
if (theBuffer.length() > LABEL.length() && theBuffer.substring(0, LABEL.length()).equals(LABEL)) {
int closeIdx = theBuffer.indexOf("\"", LABEL.length());
label = theBuffer.substring(LABEL.length(), closeIdx);
theBuffer.delete(0, closeIdx + 1);
foundSomething = true;
}
// TODO: support enc2231-string as described in
// http://tools.ietf.org/html/draft-johnston-http-category-header-02
// TODO: support multiple tags in one header as described in
// http://hl7.org/implement/standards/fhir/http.html#tags
while (theBuffer.length() > 0 && (theBuffer.charAt(0) == ' ' || theBuffer.charAt(0) == ';')) {
theBuffer.deleteCharAt(0);
}
if (!foundSomething) {
break;
}
}
if (theBuffer.length() > 0 && theBuffer.charAt(0) == ',') {
theBuffer.deleteCharAt(0);
while (theBuffer.length() > 0 && theBuffer.charAt(0) == ' ') {
theBuffer.deleteCharAt(0);
}
theTagList.add(new Tag(scheme, term, label));
parseTagValue(theTagList, theCompleteHeaderValue, theBuffer);
} else {
theTagList.add(new Tag(scheme, term, label));
}
if (theBuffer.length() > 0) {
ourLog.warn("Ignoring extra text at the end of " + Constants.HEADER_CATEGORY + " tag '" + theBuffer.toString() + "' - Complete tag value was: " + theCompleteHeaderValue);
}
}
static void addTagsToPostOrPut(IResource resource, BaseHttpClientInvocation retVal) {
TagList list = (TagList) resource.getResourceMetadata().get(ResourceMetadataKeyEnum.TAG_LIST);
if (list != null) {

View File

@ -48,6 +48,7 @@ public class Constants {
public static final String HEADER_ACCEPT_ENCODING = "Accept-Encoding";
public static final String HEADER_AUTHORIZATION = "Authorization";
public static final String HEADER_CATEGORY = "Category";
public static final String HEADER_CATEGORY_LC = HEADER_CATEGORY.toLowerCase();
public static final String HEADER_CONTENT_DISPOSITION = "Content-Disposition";
public static final String HEADER_CONTENT_ENCODING = "Content-Encoding";
public static final String HEADER_CONTENT_LOCATION = "Content-Location";
@ -96,9 +97,8 @@ public class Constants {
public static final int STATUS_HTTP_422_UNPROCESSABLE_ENTITY = 422;
public static final int STATUS_HTTP_500_INTERNAL_ERROR = 500;
public static final int STATUS_HTTP_501_NOT_IMPLEMENTED = 501;
public static final String URL_TOKEN_HISTORY = "_history";
public static final String TAG_SCHEME_PROFILE = "http://hl7.org/fhir/tag/profile ";
public static final String URL_TOKEN_HISTORY = "_history";
static {
Map<String, EncodingEnum> valToEncoding = new HashMap<String, EncodingEnum>();

View File

@ -866,7 +866,7 @@ public class RestfulServer extends HttpServlet {
}
private static void addProfileToBundleEntry(FhirContext theContext, IResource next, BundleEntry entry) {
ArrayList<Tag> profileTags = entry.getCategories().getTagsWithScheme(Constants.TAG_SCHEME_PROFILE);
List<Tag> profileTags = entry.getCategories().getTagsWithScheme(Constants.TAG_SCHEME_PROFILE);
if (profileTags.isEmpty()) {
RuntimeResourceDefinition nextDef = theContext.getResourceDefinition(next);
String profile = nextDef.getResourceProfile();

View File

@ -0,0 +1,10 @@
package ca.uhn.fhir.util;
public class UrlUtil {
public static boolean isAbsolute(String theValue) {
String value = theValue.toLowerCase();
return value.startsWith("http://") || value.startsWith("https://");
}
}

View File

@ -1,90 +0,0 @@
package example;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.client.IGenericClient;
import ca.uhn.fhir.rest.client.IRestfulClientFactory;
import ca.uhn.fhir.rest.client.api.IBasicClient;
import ca.uhn.fhir.rest.client.interceptor.BasicAuthInterceptor;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import ca.uhn.fhir.rest.server.EncodingEnum;
public class ClientExamples {
public interface IPatientClient extends IBasicClient {
// nothing yet
}
@SuppressWarnings("unused")
public void createProxy() {
//START SNIPPET: proxy
FhirContext ctx = new FhirContext();
ctx.getRestfulClientFactory().setProxy("example.com", 8888);
IGenericClient genericClient = ctx.newRestfulGenericClient("http://localhost:9999/fhir");
//START SNIPPET: end
}
@SuppressWarnings("unused")
public void createSecurity() {
//START SNIPPET: security
// Create a context and get the client factory so it can be configured
FhirContext ctx = new FhirContext();
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
//Create an HTTP basic auth interceptor
String username = "foobar";
String password = "boobear";
BasicAuthInterceptor authInterceptor = new BasicAuthInterceptor(username, password);
// Register the interceptor with your client (either style)
IPatientClient annotationClient = ctx.newRestfulClient(IPatientClient.class, "http://localhost:9999/fhir");
annotationClient.registerInterceptor(authInterceptor);
IGenericClient genericClient = ctx.newRestfulGenericClient("http://localhost:9999/fhir");
annotationClient.registerInterceptor(authInterceptor);
//END SNIPPET: security
}
@SuppressWarnings("unused")
public void createLogging() {
{
//START SNIPPET: logging
//Create a context and get the client factory so it can be configured
FhirContext ctx = new FhirContext();
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
//Create a logging interceptor
LoggingInterceptor loggingInterceptor = new LoggingInterceptor();
// Optionally you may configure the interceptor (by default only summary info is logged)
loggingInterceptor.setLogRequestSummary(true);
loggingInterceptor.setLogRequestBody(true);
//Register the interceptor with your client (either style)
IPatientClient annotationClient = ctx.newRestfulClient(IPatientClient.class, "http://localhost:9999/fhir");
annotationClient.registerInterceptor(loggingInterceptor);
IGenericClient genericClient = ctx.newRestfulGenericClient("http://localhost:9999/fhir");
genericClient.registerInterceptor(loggingInterceptor);
//END SNIPPET: logging
}
/******************************/
{
//START SNIPPET: clientConfig
//Create a client
FhirContext ctx = new FhirContext();
IPatientClient client = ctx.newRestfulClient(IPatientClient.class, "http://localhost:9999/");
// Request JSON encoding from the server (_format=json)
client.setEncoding(EncodingEnum.JSON);
// Request pretty printing from the server (_pretty=true)
client.setPrettyPrint(true);
//END SNIPPET: clientConfig
}
}
}

View File

@ -1,68 +0,0 @@
package example;
//START SNIPPET: client
import java.io.IOException;
import java.util.List;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.dstu.resource.Organization;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.rest.annotation.RequiredParam;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.client.api.IRestfulClient;
public class CompleteExampleClient {
/**
* This is a simple client interface. It can have many methods
* for various searches but in this case it has only 1.
*/
public static interface ClientInterface extends IRestfulClient
{
/**
* This is translated into a URL similar to the following:
* http://fhir.healthintersections.com.au/open/Patient?identifier=urn:oid:1.2.36.146.595.217.0.1%7C12345
*/
@Search
List<Patient> findPatientsForMrn(@RequiredParam(name=Patient.SP_IDENTIFIER) IdentifierDt theIdentifier);
}
/**
* The main method here will directly call an open FHIR server
* and retrieve a list of resources matching a given criteria,
* then load a linked resource.
*/
public static void main(String[] args) throws IOException {
// Create a client factory
FhirContext ctx = new FhirContext();
//Create the client
String serverBase = "http://fhir.healthintersections.com.au/open";
ClientInterface client = ctx.newRestfulClient(ClientInterface.class, serverBase);
// Invoke the client to search for patient
List<Patient> patients = client.findPatientsForMrn(new IdentifierDt("urn:oid:1.2.36.146.595.217.0.1", "12345"));
System.out.println("Found "+ patients.size() + " patients");
// Print a value from the loaded resource
Patient patient = patients.get(0);
System.out.println("Patient Last Name: " + patient.getName().get(0).getFamily().get(0).getValue());
// Load a referenced resource
ResourceReferenceDt managingRef = patient.getManagingOrganization();
Organization org = (Organization) managingRef.loadResource(client);
// Print organization name
System.out.println(org.getName().getValue());
}
}
//END SNIPPET: client

View File

@ -1,43 +0,0 @@
package example;
import java.io.IOException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.model.primitive.DateTimeDt;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.parser.MyPatient;
public class MyPatientUse {
@SuppressWarnings("unused")
public static void main(String[] args) throws DataFormatException, IOException {
//START SNIPPET: patientUse
MyPatient patient = new MyPatient();
patient.setPetName(new StringDt("Fido"));
patient.getImportantDates().add(new DateTimeDt("2010-01-02"));
patient.getImportantDates().add(new DateTimeDt("2014-01-26T11:11:11"));
patient.addName().addFamily("Smith").addGiven("John").addGiven("Quincy").addSuffix("Jr");
IParser p = new FhirContext().newXmlParser().setPrettyPrint(true);
String messageString = p.encodeResourceToString(patient);
System.out.println(messageString);
//END SNIPPET: patientUse
//START SNIPPET: patientParse
IParser parser = new FhirContext().newXmlParser();
MyPatient newPatient = parser.parseResource(MyPatient.class, messageString);
//END SNIPPET: patientParse
{
FhirContext ctx2 = new FhirContext();
RuntimeResourceDefinition def = ctx2.getResourceDefinition(patient);
System.out.println(ctx2.newXmlParser().setPrettyPrint(true).encodeResourceToString(def.toProfile()));
}
}
}

View File

@ -61,6 +61,7 @@
<item name="The Data Model" href="./doc_fhirobjects.html">
<item name="Extensions" href="./doc_extensions.html" />
<item name="Resource References" href="./doc_resource_references.html" />
<item name="Tags" href="./doc_tags.html" />
</item>
<item name="RESTful Client" href="./doc_rest_client.html" />
<item name="RESTful Server" href="./doc_rest_server.html" >

View File

@ -28,7 +28,7 @@
</p>
<macro name="snippet">
<param name="id" value="resourceExtension" />
<param name="file" value="src/site/example/java/example/Extensions.java" />
<param name="file" value="examples/src/main/java/example/Extensions.java" />
</macro>
<p>
@ -36,7 +36,7 @@
</p>
<macro name="snippet">
<param name="id" value="resourceStringExtension" />
<param name="file" value="src/site/example/java/example/Extensions.java" />
<param name="file" value="examples/src/main/java/example/Extensions.java" />
</macro>
<subsection name="Sub-Extensions">
@ -48,7 +48,7 @@
</p>
<macro name="snippet">
<param name="id" value="subExtension" />
<param name="file" value="src/site/example/java/example/Extensions.java" />
<param name="file" value="examples/src/main/java/example/Extensions.java" />
</macro>
</subsection>
@ -61,7 +61,7 @@
</p>
<macro name="snippet">
<param name="id" value="parseExtension" />
<param name="file" value="src/site/example/java/example/Extensions.java" />
<param name="file" value="examples/src/main/java/example/Extensions.java" />
</macro>
</subsection>
@ -78,7 +78,7 @@
<macro name="snippet">
<param name="id" value="patientDef" />
<param name="file" value="src/site/example/java/example/MyPatient.java" />
<param name="file" value="examples/src/main/java/example/MyPatient.java" />
</macro>
<p>
@ -88,7 +88,7 @@
<macro name="snippet">
<param name="id" value="patientUse" />
<param name="file" value="src/site/example/java/example/MyPatientUse.java" />
<param name="file" value="examples/src/main/java/example/MyPatientUse.java" />
</macro>
<p>
@ -121,7 +121,7 @@
<macro name="snippet">
<param name="id" value="patientParse" />
<param name="file" value="src/site/example/java/example/MyPatientUse.java" />
<param name="file" value="examples/src/main/java/example/MyPatientUse.java" />
</macro>
<subsection name="Documentation">

View File

@ -31,7 +31,7 @@
<macro name="snippet">
<param name="id" value="datatypes" />
<param name="file" value="src/site/example/java/example/FhirDataModel.java" />
<param name="file" value="examples/src/main/java/example/FhirDataModel.java" />
</macro>
<subsection name="Navigating Structures">
@ -45,7 +45,7 @@
<macro name="snippet">
<param name="id" value="nonNull" />
<param name="file" value="src/site/example/java/example/FhirDataModel.java" />
<param name="file" value="examples/src/main/java/example/FhirDataModel.java" />
</macro>
</subsection>
@ -65,7 +65,7 @@
<macro name="snippet">
<param name="id" value="codes" />
<param name="file" value="src/site/example/java/example/FhirDataModel.java" />
<param name="file" value="examples/src/main/java/example/FhirDataModel.java" />
</macro>
</subsection>
@ -87,7 +87,7 @@
<macro name="snippet">
<param name="id" value="namesHard" />
<param name="file" value="src/site/example/java/example/FhirDataModel.java" />
<param name="file" value="examples/src/main/java/example/FhirDataModel.java" />
</macro>
<p>
@ -97,7 +97,7 @@
<macro name="snippet">
<param name="id" value="namesEasy" />
<param name="file" value="src/site/example/java/example/FhirDataModel.java" />
<param name="file" value="examples/src/main/java/example/FhirDataModel.java" />
</macro>
</subsection>

View File

@ -70,7 +70,7 @@
<macro name="snippet">
<param name="id" value="creatingContext" />
<param name="file" value="src/site/example/java/example/FhirContextIntro.java" />
<param name="file" value="examples/src/main/java/example/FhirContextIntro.java" />
</macro>
</subsection>
@ -93,7 +93,7 @@
<macro name="snippet">
<param name="id" value="parseMsg" />
<param name="file" value="src/site/example/java/example/FhirContextIntro.java" />
<param name="file" value="examples/src/main/java/example/FhirContextIntro.java" />
</macro>
</subsection>
@ -107,7 +107,7 @@
<macro name="snippet">
<param name="id" value="encodeMsg" />
<param name="file" value="src/site/example/java/example/FhirContextIntro.java" />
<param name="file" value="examples/src/main/java/example/FhirContextIntro.java" />
</macro>
<!-- ****** The section below on fluent references the snippet above
@ -147,7 +147,7 @@
<macro name="snippet">
<param name="id" value="encodeMsgFluent" />
<param name="file" value="src/site/example/java/example/FhirContextIntro.java" />
<param name="file" value="examples/src/main/java/example/FhirContextIntro.java" />
</macro>
</subsection>
@ -160,7 +160,7 @@
<macro name="snippet">
<param name="id" value="encodeMsgJson" />
<param name="file" value="src/site/example/java/example/FhirContextIntro.java" />
<param name="file" value="examples/src/main/java/example/FhirContextIntro.java" />
</macro>
<p>

View File

@ -28,7 +28,7 @@
<macro name="snippet">
<param name="id" value="simple" />
<param name="file" value="src/site/example/java/example/Narrative.java" />
<param name="file" value="examples/src/main/java/example/Narrative.java" />
</macro>
</section>
@ -64,7 +64,7 @@
<macro name="snippet">
<param name="id" value="example1" />
<param name="file" value="src/site/example/java/example/Narrative.java" />
<param name="file" value="examples/src/main/java/example/Narrative.java" />
</macro>
<p>
@ -163,7 +163,7 @@ humanname.narrative=classpath:ca/uhn/fhir/narrative/HumanNameDt.html]]></source>
<macro name="snippet">
<param name="id" value="gen" />
<param name="file" value="src/site/example/java/example/NarrativeGenerator.java" />
<param name="file" value="examples/src/main/java/example/NarrativeGenerator.java" />
</macro>
</section>

View File

@ -47,7 +47,7 @@
<macro name="snippet">
<param name="id" value="simple" />
<param name="file"
value="src/site/example/java/example/GenericClientExample.java" />
value="examples/src/main/java/example/GenericClientExample.java" />
</macro>
<p>
@ -84,7 +84,7 @@
<macro name="snippet">
<param name="id" value="create" />
<param name="file"
value="src/site/example/java/example/GenericClientExample.java" />
value="examples/src/main/java/example/GenericClientExample.java" />
</macro>
</subsection>
@ -96,7 +96,7 @@
<macro name="snippet">
<param name="id" value="search" />
<param name="file"
value="src/site/example/java/example/GenericClientExample.java" />
value="examples/src/main/java/example/GenericClientExample.java" />
</macro>
<h4>Search - Multi-valued Parameters (ANY/OR)</h4>
@ -108,7 +108,7 @@
<macro name="snippet">
<param name="id" value="searchOr" />
<param name="file"
value="src/site/example/java/example/GenericClientExample.java" />
value="examples/src/main/java/example/GenericClientExample.java" />
</macro>
<h4>Search - Multi-valued Parameters (ALL/AND)</h4>
@ -120,7 +120,7 @@
<macro name="snippet">
<param name="id" value="searchOr" />
<param name="file"
value="src/site/example/java/example/GenericClientExample.java" />
value="examples/src/main/java/example/GenericClientExample.java" />
</macro>
<h4>Search - Paging</h4>
@ -131,7 +131,7 @@
<macro name="snippet">
<param name="id" value="searchPaging" />
<param name="file"
value="src/site/example/java/example/GenericClientExample.java" />
value="examples/src/main/java/example/GenericClientExample.java" />
</macro>
<h4>Search - Composite Parameters</h4>
@ -144,7 +144,7 @@
<macro name="snippet">
<param name="id" value="searchComposite" />
<param name="file"
value="src/site/example/java/example/GenericClientExample.java" />
value="examples/src/main/java/example/GenericClientExample.java" />
</macro>
<h4>Search - Other Query Options</h4>
@ -155,7 +155,7 @@
<macro name="snippet">
<param name="id" value="searchAdv" />
<param name="file"
value="src/site/example/java/example/GenericClientExample.java" />
value="examples/src/main/java/example/GenericClientExample.java" />
</macro>
<h4>Search - Using HTTP POST or GET with _search</h4>
@ -168,7 +168,7 @@
<macro name="snippet">
<param name="id" value="searchPost" />
<param name="file"
value="src/site/example/java/example/GenericClientExample.java" />
value="examples/src/main/java/example/GenericClientExample.java" />
</macro>
</subsection>
@ -181,7 +181,7 @@
<macro name="snippet">
<param name="id" value="delete" />
<param name="file"
value="src/site/example/java/example/GenericClientExample.java" />
value="examples/src/main/java/example/GenericClientExample.java" />
</macro>
</subsection>
@ -198,7 +198,7 @@
<macro name="snippet">
<param name="id" value="update" />
<param name="file"
value="src/site/example/java/example/GenericClientExample.java" />
value="examples/src/main/java/example/GenericClientExample.java" />
</macro>
</subsection>
@ -210,7 +210,7 @@
<macro name="snippet">
<param name="id" value="conformance" />
<param name="file"
value="src/site/example/java/example/GenericClientExample.java" />
value="examples/src/main/java/example/GenericClientExample.java" />
</macro>
</subsection>
@ -221,7 +221,7 @@
<macro name="snippet">
<param name="id" value="transaction" />
<param name="file"
value="src/site/example/java/example/GenericClientExample.java" />
value="examples/src/main/java/example/GenericClientExample.java" />
</macro>
</subsection>
@ -295,7 +295,7 @@
<macro name="snippet">
<param name="id" value="provider" />
<param name="file"
value="src/site/example/java/example/IRestfulClient.java" />
value="examples/src/main/java/example/IRestfulClient.java" />
</macro>
<p>
@ -321,7 +321,7 @@
<macro name="snippet">
<param name="id" value="client" />
<param name="file"
value="src/site/example/java/example/ExampleRestfulClient.java" />
value="examples/src/main/java/example/ExampleRestfulClient.java" />
</macro>
</subsection>
@ -343,7 +343,7 @@
<macro name="snippet">
<param name="id" value="clientConfig" />
<param name="file" value="src/site/example/java/example/ClientExamples.java" />
<param name="file" value="examples/src/main/java/example/ClientExamples.java" />
</macro>
</subsection>
@ -359,7 +359,7 @@
<macro name="snippet">
<param name="id" value="client" />
<param name="file"
value="src/site/example/java/example/CompleteExampleClient.java" />
value="examples/src/main/java/example/CompleteExampleClient.java" />
</macro>
</subsection>
@ -412,7 +412,7 @@
<macro name="snippet">
<param name="id" value="security" />
<param name="file" value="src/site/example/java/example/ClientExamples.java" />
<param name="file" value="examples/src/main/java/example/ClientExamples.java" />
</macro>
</subsection>
@ -429,7 +429,7 @@
<macro name="snippet">
<param name="id" value="logging" />
<param name="file" value="src/site/example/java/example/ClientExamples.java" />
<param name="file" value="examples/src/main/java/example/ClientExamples.java" />
</macro>
</subsection>
@ -443,7 +443,7 @@
<macro name="snippet">
<param name="id" value="logging" />
<param name="file" value="src/site/example/java/example/ClientExamples.java" />
<param name="file" value="examples/src/main/java/example/ClientExamples.java" />
</macro>
</subsection>

View File

@ -202,7 +202,7 @@
<macro name="snippet">
<param name="id" value="read" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -218,7 +218,7 @@
<macro name="snippet">
<param name="id" value="clientReadInterface" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<a name="instance_vread" />
@ -243,7 +243,7 @@
<macro name="snippet">
<param name="id" value="vread" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -294,7 +294,7 @@
<macro name="snippet">
<param name="id" value="update" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -311,7 +311,7 @@
<macro name="snippet">
<param name="id" value="updateClient" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<a name="instance_delete" />
@ -336,7 +336,7 @@
<macro name="snippet">
<param name="id" value="delete" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -407,7 +407,7 @@
<macro name="snippet">
<param name="id" value="create" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -424,7 +424,7 @@
<macro name="snippet">
<param name="id" value="createClient" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<a name="type_search" />
@ -456,7 +456,7 @@
<macro name="snippet">
<param name="id" value="searchAll" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -495,7 +495,7 @@
<macro name="snippet">
<param name="id" value="searchStringParam" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -517,7 +517,7 @@
<macro name="snippet">
<param name="id" value="searchIdentifierParam" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -550,7 +550,7 @@
<macro name="snippet">
<param name="id" value="dates" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -565,7 +565,7 @@
<macro name="snippet">
<param name="id" value="dateClient" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
</subsection>
@ -597,7 +597,7 @@
</p>
<macro name="snippet">
<param name="id" value="dateRange" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -612,7 +612,7 @@
<macro name="snippet">
<param name="id" value="dateClient" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<h4>Unbounded Ranges</h4>
@ -658,7 +658,7 @@
</p>
<macro name="snippet">
<param name="id" value="quantity" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -699,7 +699,7 @@
<macro name="snippet">
<param name="id" value="reference" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -722,7 +722,7 @@
<macro name="snippet">
<param name="id" value="referenceChain" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
</subsection>
@ -744,7 +744,7 @@
<macro name="snippet">
<param name="id" value="searchComposite" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -800,7 +800,7 @@
<macro name="snippet">
<param name="id" value="searchOptionalParam" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -878,7 +878,7 @@
<macro name="snippet">
<param name="id" value="searchMultiple" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -910,7 +910,7 @@
<macro name="snippet">
<param name="id" value="searchMultipleAnd" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<h4>AND Relationship Query Parameters for Dates</h4>
@ -940,7 +940,7 @@
<macro name="snippet">
<param name="id" value="pathSpec" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -957,7 +957,7 @@
<macro name="snippet">
<param name="id" value="pathSpecSimple" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
</subsection>
@ -979,7 +979,7 @@
<macro name="snippet">
<param name="id" value="searchNamedQuery" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -1016,7 +1016,7 @@
<macro name="snippet">
<param name="id" value="sort" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -1041,7 +1041,7 @@
<macro name="snippet">
<param name="id" value="searchWithDocs" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
</subsection>
@ -1108,7 +1108,7 @@
<macro name="snippet">
<param name="id" value="validate" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -1150,7 +1150,7 @@
</p>
<macro name="snippet">
<param name="id" value="metadataProvider" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -1160,7 +1160,7 @@
</p>
<macro name="snippet">
<param name="id" value="metadataClient" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -1171,7 +1171,7 @@
</p>
<macro name="snippet">
<param name="id" value="metadataClientUsage" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<a name="system_transaction" />
@ -1198,7 +1198,7 @@
</p>
<macro name="snippet">
<param name="id" value="transaction" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -1315,7 +1315,7 @@
<macro name="snippet">
<param name="id" value="history" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -1324,7 +1324,7 @@
<macro name="snippet">
<param name="id" value="historyClient" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<a name="exceptions" />
@ -1406,7 +1406,7 @@
<macro name="snippet">
<param name="id" value="readTags" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>
@ -1417,7 +1417,7 @@
<macro name="snippet">
<param name="id" value="clientReadTags" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
</subsection>
@ -1444,7 +1444,7 @@
<macro name="snippet">
<param name="id" value="createTags" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
</subsection>
@ -1464,7 +1464,7 @@
</p>
<macro name="snippet">
<param name="id" value="tagMethodProvider" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
<p>

View File

@ -57,7 +57,7 @@
<macro name="snippet">
<param name="id" value="provider" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProvider.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProvider.java" />
</macro>
</subsection>
@ -88,7 +88,7 @@
<macro name="snippet">
<param name="id" value="servlet" />
<param name="file" value="src/site/example/java/example/ExampleRestfulServlet.java" />
<param name="file" value="examples/src/main/java/example/ExampleRestfulServlet.java" />
</macro>
<a name="plain_providers"/>
@ -120,7 +120,7 @@
</p>
<macro name="snippet">
<param name="id" value="plainProvider" />
<param name="file" value="src/site/example/java/example/ExampleProviders.java" />
<param name="file" value="examples/src/main/java/example/ExampleProviders.java" />
</macro>
<p>
@ -136,7 +136,7 @@
</p>
<macro name="snippet">
<param name="id" value="plainProviderServer" />
<param name="file" value="src/site/example/java/example/ExampleProviders.java" />
<param name="file" value="examples/src/main/java/example/ExampleProviders.java" />
</macro>
</subsection>
@ -258,7 +258,7 @@
<macro name="snippet">
<param name="id" value="provider" />
<param name="file" value="src/site/example/java/example/PagingServer.java" />
<param name="file" value="examples/src/main/java/example/PagingServer.java" />
</macro>
</subsection>
@ -290,7 +290,7 @@
<macro name="snippet">
<param name="id" value="provider" />
<param name="file" value="src/site/example/java/example/PagingPatientProvider.java" />
<param name="file" value="examples/src/main/java/example/PagingPatientProvider.java" />
</macro>
</subsection>
@ -323,7 +323,7 @@
<macro name="snippet">
<param name="id" value="underlyingReq" />
<param name="file" value="src/site/example/java/example/RestfulPatientResourceProviderMore.java" />
<param name="file" value="examples/src/main/java/example/RestfulPatientResourceProviderMore.java" />
</macro>
@ -358,6 +358,41 @@
</section>
<section name="Populating Resource Metadata">
<p>
Server operations will often return a resource or a bundle of resources. These
types will contain one or more resource instances, but also specify a set of
metadata describing that resource.
</p>
<p>
For example, resources have a "published" and "updated" date, referring to
the date/time the resource was originally created and the date/time the
resource was last updated respectively. For operations which return a single
resource, these values are returned via HTTP headers. For operations which
return a bundle, these values are returned via elements within the
bundle's "entry" tag.
</p>
<p>
Bundles may also contain a set of links, such as an "alternate" link to
a resource, or a "search" link.
</p>
<p>
Populating these metadata elements is done via the
<code><a href="http://jamesagnew.github.io/hapi-fhir/apidocs/ca/uhn/fhir/model/api/IResource.html#getResourceMetadata()">IResource#getResourceMetadata()</a></code>
method. The following example shows how to set various metadata elements on
a resource being returned.
</p>
<macro name="snippet">
<param name="id" value="serverMethod" />
<param name="file" value="examples/src/main/java/example/ServerMetadataExamples.java" />
</macro>
</section>
<section name="A Complete Example">
<p>

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
<properties>
<title>Resource Tags - HAPI FHIR</title>
<author email="jamesagnew@users.sourceforge.net">James Agnew</author>
</properties>
<body>
<section name="Working With Tags">
<p>
FHIR defines a useful framework for adding/updating/removing
<a href="http://www.hl7.org/implement/standards/fhir/extras.html#tag">Tags</a>
against resource instances. A tag is a pair of URLs (a scheme, and a term) which
can optionally have a textual "label" as well.
</p>
<p>
A specific resource instance's tags can be found in the resource
<a href="http://jamesagnew.github.io/hapi-fhir/apidocs/ca/uhn/fhir/model/api/IResource.html#getResourceMetadata()">metadata</a>
map, using the key of
<a href="http://jamesagnew.github.io/hapi-fhir/apidocs/ca/uhn/fhir/model/api/ResourceMetadataKeyEnum.html#TAG_LIST">ResourceMetadataKeyEnum.TAG_LIST</a>.
The following example shows how to access the tags in a client
following a "read" operation:
</p>
<macro name="snippet">
<param name="id" value="getResourceTags" />
<param name="file" value="examples/src/main/java/example/TagsExamples.java" />
</macro>
<subsection name="Adding Tags to a Resource">
<p>
In a server implementation, you might want to
add tags to a resource being returned. This is done
by adding a TagList instance to the resource's
metadata, as shown in the example below.
</p>
<p>
The server will then do the "right thing" with the tags. If the method
is for a <code>search</code> operation, the tags will be added to the category
element in the
returned bundle. If the method is for a <code>read</code> operation, the
tags will be added to the response "Category" headers.
</p>
<macro name="snippet">
<param name="id" value="serverMethod" />
<param name="file" value="examples/src/main/java/example/TagsExamples.java" />
</macro>
</subsection>
</section>
</body>
</document>

View File

@ -5,7 +5,9 @@ import static org.junit.Assert.*;
import org.junit.Test;
import ca.uhn.fhir.model.dstu.resource.CarePlan;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.parser.MyPatient;
public class ModelScannerTest {
@ -15,6 +17,16 @@ public class ModelScannerTest {
new ModelScanner(CarePlan.class);
}
@Test
public void testExtendedClass() {
FhirContext ctx = new FhirContext();
ctx.getResourceDefinition(MyPatient.class);
ctx.getResourceDefinition(Patient.class);
RuntimeResourceDefinition patient = ctx.getResourceDefinition("Patient");
assertEquals(Patient.class, patient.getImplementingClass());
}
@Test
public void testScanExtensionTypes() throws DataFormatException {

View File

@ -3,7 +3,7 @@ package ca.uhn.fhir.parser;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.dstu.resource.Organization;
@ResourceDef(name="Organization")
@ResourceDef()
public class MyOrganization extends Organization {
}

View File

@ -12,7 +12,7 @@ import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.model.primitive.DateTimeDt;
import ca.uhn.fhir.model.primitive.StringDt;
@ResourceDef(name="Patient")
@ResourceDef()
public class MyPatient extends Patient {
@Child(name="petName")

View File

@ -1,9 +1,7 @@
package ca.uhn.fhir.rest.client;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@ -581,9 +579,11 @@ public class ClientTest {
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
Header[] headers = new Header[2];
headers[0] = new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT");
headers[1] = new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333");
Header[] headers = new Header[] {
new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"),
new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
new BasicHeader(Constants.HEADER_CATEGORY, "http://foo/tagdefinition.html; scheme=\"http://hl7.org/fhir/tag\"; label=\"Some tag\"")
};
when(httpResponse.getAllHeaders()).thenReturn(headers);
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
@ -603,6 +603,13 @@ public class ClientTest {
lm.setTimeZoneZulu(true);
assertEquals("1995-11-15T04:58:08.000Z", lm.getValueAsString());
TagList tags = ResourceMetadataKeyEnum.TAG_LIST.get(response);
assertNotNull(tags);
assertEquals(1,tags.size());
assertEquals("http://foo/tagdefinition.html", tags.get(0).getTerm());
assertEquals("http://hl7.org/fhir/tag",tags.get(0).getScheme());
assertEquals("Some tag",tags.get(0).getLabel());
}
@Test

View File

@ -270,9 +270,11 @@ public class GenericClientTest {
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
Header[] headers = new Header[2];
headers[0] = new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT");
headers[1] = new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333");
Header[] headers = new Header[] {
new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"),
new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
new BasicHeader(Constants.HEADER_CATEGORY, "http://foo/tagdefinition.html; scheme=\"http://hl7.org/fhir/tag\"; label=\"Some tag\"")
};
when(myHttpResponse.getAllHeaders()).thenReturn(headers);
IGenericClient client = myCtx.newRestfulGenericClient("http://example.com/fhir");
@ -289,6 +291,13 @@ public class GenericClientTest {
lm.setTimeZoneZulu(true);
assertEquals("1995-11-15T04:58:08.000Z", lm.getValueAsString());
TagList tags = ResourceMetadataKeyEnum.TAG_LIST.get(response);
assertNotNull(tags);
assertEquals(1,tags.size());
assertEquals("http://foo/tagdefinition.html", tags.get(0).getTerm());
assertEquals("http://hl7.org/fhir/tag",tags.get(0).getScheme());
assertEquals("Some tag",tags.get(0).getLabel());
}
@SuppressWarnings("unused")

View File

@ -14,7 +14,7 @@ public class BaseOutcomeReturningMethodBindingTest {
String headerString = "http://britsystems.com/fhir/tag/4567; scheme=\"http://britsystems.com/fhir\"; label=\"Tag-4567\",http://client/scheme/tag/123; scheme=\"http://client/scheme\"; label=\"tag 123\",http://client/scheme/tag/456; scheme=\"http://client/scheme\"; label=\"tag 456\",http://fhir.healthintersections.com.au/open/Patient/1; scheme=\"http://hl7.org/fhir/tag\"; label=\"GET <host>/<resourceType>/<id>\",http://hl7.fhir/example; scheme=\"http://hl7.org/fhir/tag\"; label=\"FHIR example\",http://hl7.org/fhir/sid/us-ssn; scheme=\"http://hl7.org/fhir/tag\"; label=\"POST <host>/<resourceType>\",http://hl7.org/fhir/tools/tag/test; scheme=\"http://hl7.org/fhir/tag\"; label=\"Test Tag\",http://hl7.org/implement/standards/fhir/v3/ActCode/InformationSensitivityPolicy#GDIS; scheme=\"http://hl7.org/fhir/tag\"; label=\"GDIS\",http://hl7.org/implement/standards/fhir/v3/Confidentiality#N; scheme=\"http://hl7.org/fhir/tag\"; label=\"N (Normal)\",http://hl7.org/implement/standards/fhir/v3/Confidentiality#R; scheme=\"http://hl7.org/fhir/tag\"; label=\"restricted\",http://nu.nl/testname; scheme=\"http://hl7.org/fhir/tag\"; label=\"TestCreateEditDelete\",http://readtag.nu.nl; scheme=\"http://hl7.org/fhir/tag\"; label=\"readTagTest\",http://spark.furore.com/fhir; scheme=\"http://hl7.org/fhir/tag\"; label=\"GET <host>/<resourceType>/<id>\",http://www.healthintersections.com.au/fhir/tags/invalid; scheme=\"http://hl7.org/fhir/tag\"; label=\"Non-conformant Resource\",urn:happytag; scheme=\"http://hl7.org/fhir/tag\"; label=\"This is a happy resource\",condition; scheme=\"http://hl7.org/fhir/tag/profile\"; label=\"Profile condition\",device; scheme=\"http://hl7.org/fhir/tag/profile\"; label=\"Profile device\",http://fhir.healthintersections.com.au/open/Profile/condition; scheme=\"http://hl7.org/fhir/tag/profile\"; label=\"Profile condition\",http://fhir.healthintersections.com.au/open/Profile/device; scheme=\"http://hl7.org/fhir/tag/profile\"; label=\"Profile device\",http://hl7.org/fhir/v3/ActCode#CEL; scheme=\"http://hl7.org/fhir/tag/security\"; label=\"Celebrity / VIP\",http://hl7.org/fhir/v3/ActCode#DEMO; scheme=\"http://hl7.org/fhir/tag/security\"; label=\"Contact/Employment Confidential\",http://hl7.org/fhir/v3/ActCode#DIA; scheme=\"http://hl7.org/fhir/tag/security\"; label=\"Diagnosis is/would be Confidential\",http://hl7.org/fhir/v3/ActCode#EMP; scheme=\"http://hl7.org/fhir/tag/security\"; label=\"Employee / Staff member\",http://hl7.org/fhir/v3/ActCode#ORCON; scheme=\"http://hl7.org/fhir/tag/security\"; label=\"Author only\",http://hl7.org/fhir/v3/ActCode#TABOO; scheme=\"http://hl7.org/fhir/tag/security\"; label=\"Patient/Carer Only\",http://hl7.org/fhir/v3/Confidentiality#L; scheme=\"http://hl7.org/fhir/tag/security\"; label=\"Confidentiality = Low\",http://hl7.org/fhir/v3/Confidentiality#M; scheme=\"http://hl7.org/fhir/tag/security\"; label=\"Confidentiality = Moderate\",http://hl7.org/fhir/v3/Confidentiality#N; scheme=\"http://hl7.org/fhir/tag/security\"; label=\"Confidentiality = Normal\",http://hl7.org/fhir/v3/Confidentiality#R; scheme=\"http://hl7.org/fhir/tag/security\"; label=\"Confidentiality = Restricted\",http://hl7.org/fhir/v3/Confidentiality#U; scheme=\"http://hl7.org/fhir/tag/security\"; label=\"Confidentiality = none\",http://hl7.org/fhir/v3/Confidentiality#V; scheme=\"http://hl7.org/fhir/tag/security\"; label=\"Confidentiality = Very Restricted\",http://term.com; scheme=\"http://scheme.com\"; label=\"Some good ole term\"";
TagList parsedFromHeader = new TagList();
BaseOutcomeReturningMethodBinding.parseTagValue(parsedFromHeader, headerString);
MethodUtil.parseTagValue(parsedFromHeader, headerString);
//@formatter:off
String resourceString = "{\n" +

View File

@ -63,7 +63,7 @@ public class CustomTypeTest {
assertEquals(1, bundle.getEntries().size());
BundleEntry entry = bundle.getEntries().get(0);
ArrayList<Tag> profileTags = entry.getCategories().getTagsWithScheme(Constants.TAG_SCHEME_PROFILE);
List<Tag> profileTags = entry.getCategories().getTagsWithScheme(Constants.TAG_SCHEME_PROFILE);
assertEquals(1, profileTags.size());
assertEquals("http://foo/profiles/Profile", profileTags.get(0).getTerm());

View File

@ -10,6 +10,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
@ -26,9 +27,11 @@ import org.junit.Test;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.model.dstu.composite.CodingDt;
import ca.uhn.fhir.model.dstu.resource.Observation;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.rest.annotation.OptionalParam;
import ca.uhn.fhir.rest.annotation.RequiredParam;
@ -149,6 +152,29 @@ public class SearchTest {
assertEquals("AAANamed", p.getIdentifierFirstRep().getValue().getValue());
}
@Test
public void testReturnLinks() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort+"/Patient?_query=findWithLinks");
CloseableHttpResponse status = ourClient.execute(httpGet);
String responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(1, bundle.getEntries().size());
Patient p = bundle.getResources(Patient.class).get(0);
assertEquals("AAANamed", p.getIdentifierFirstRep().getValue().getValue());
assertEquals("http://foo/Patient?_id=1", bundle.getEntries().get(0).getLinkSearch().getValue());
assertEquals("http://localhost:" + ourPort+"/Patient/9988", bundle.getEntries().get(0).getLinkAlternate().getValue());
assertEquals("http://foo/Patient?_id=1", ResourceMetadataKeyEnum.LINK_SEARCH.get(p));
assertEquals("http://localhost:" + ourPort+"/Patient/9988", ResourceMetadataKeyEnum.LINK_ALTERNATE.get(p));
}
@AfterClass
public static void afterClass() throws Exception {
ourServer.stop();
@ -241,6 +267,19 @@ public class SearchTest {
return retVal;
}
@Search(queryName="findWithLinks")
public List<Patient> findWithLinks() {
ArrayList<Patient> retVal = new ArrayList<Patient>();
Patient patient = new Patient();
patient.setId("1");
patient.addIdentifier("system", "AAANamed");
ResourceMetadataKeyEnum.LINK_SEARCH.put(patient, ("http://foo/Patient?_id=1"));
ResourceMetadataKeyEnum.LINK_ALTERNATE.put(patient, ("Patient/9988"));
retVal.add(patient);
return retVal;
}
@Override
public Class<? extends IResource> getResourceType() {
return Patient.class;

View File

@ -197,6 +197,8 @@ public class TransactionTest {
}
/**
* Created by dsotnikov on 2/25/2014.
*/

View File

@ -12,7 +12,7 @@
<dependent-module archiveName="hapi-fhir-base-0.6-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/hapi-fhir-base/hapi-fhir-base">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module deploy-path="/" handle="module:/overlay/prj/hapi-fhir-testpage-overlay?includes=**/**&amp;excludes=META-INF/MANIFEST.MF">
<dependent-module deploy-path="/" handle="module:/overlay/var/M2_REPO/ca/uhn/hapi/fhir/hapi-fhir-testpage-overlay/0.6-SNAPSHOT/hapi-fhir-testpage-overlay-0.6-SNAPSHOT.war?unpackFolder=target/m2e-wtp/overlays&amp;includes=**/**&amp;excludes=META-INF/MANIFEST.MF">
<dependency-type>consumes</dependency-type>
</dependent-module>
<dependent-module deploy-path="/" handle="module:/overlay/slf/?includes=**/**&amp;excludes=META-INF/MANIFEST.MF">

View File

@ -57,6 +57,7 @@
<modules>
<module>hapi-fhir-base</module>
<module>hapi-fhir-base/examples</module>
<module>hapi-tinder-plugin</module>
<module>hapi-tinder-test</module>
<module>hapi-fhir-structures-dstu</module>