Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Normalize out resource type names into new hfj_resource_type table #6890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

YalingPeiS
Copy link
Collaborator

@YalingPeiS YalingPeiS commented Apr 22, 2025

Introduce a new hfj_resource_type table to normalize out the resource type name. These can be quite long (e.g. ExplanationOfBenefit is 20 bytes). These make for expensive indices. It increases the storage burden, and reduces performance.
This will be a 3 part migration, with each step 2 releases apart.

  1. Add new nullable res_type_id everywhere we currently use res_type. Start writing to it.
  2. Double check all rows are populated, make it not-null, and add indices to the various tables changed. Change runtime queries start using it.
  3. Stop writing the old column. Suggest dropping it in upgrade.md.

This ticket will only implement step 1.

  • new table with rows for every resource type.
  • new columns in the various hfj_res_* tables.
  • new rows write those columns

Implementation

  • Create entities and migrations roughly matching this schema.
  • Populate with names of all known types from all releases (DSTU2-R5).
  • Add an immortal cache of res_type->res_type_id.
  • Also support user-defined custom types on demand. If missing, add to table and cache.
create sequence seq_res_type;
create table hfj_resource_type (
	res_type_id	int2,
	res_type	varchar(100),
	CONSTRAINT res_type_pk PRIMARY KEY (res_type_id)
);
CREATE UNIQUE INDEX hfj_resource_type_type on hfj_resource_type using btree (res_type) INCLUDE (res_type_id);

insert into hfj_resource_type (res_type_id, res_type)
with spec_types as (select * from unnest(string_to_array('Account, ActivityDefinition, ActorDefinition, AdministrableProductDefinition, AdverseEvent, AllergyIntolerance, Appointment, AppointmentResponse, ArtifactAssessment, AuditEvent, Basic, Binary, BiologicallyDerivedProduct, BiologicallyDerivedProductDispense, BodySite, BodyStructure, Bundle, CapabilityStatement, CarePlan, CareTeam, CatalogEntry, ChargeItem, ChargeItemDefinition, Citation, Claim, ClaimResponse, ClinicalImpression, ClinicalUseDefinition, CodeSystem, Communication, CommunicationRequest, CompartmentDefinition, Composition, ConceptMap, Condition, ConditionDefinition, Conformance, Consent, Contract, Coverage, CoverageEligibilityRequest, CoverageEligibilityResponse, DataElement, DetectedIssue, Device, DeviceAssociation, DeviceComponent, DeviceDefinition, DeviceDispense, DeviceMetric, DeviceRequest, DeviceUsage, DeviceUseRequest, DeviceUseStatement, DiagnosticOrder, DiagnosticReport, DocumentManifest, DocumentReference, EffectEvidenceSynthesis, EligibilityRequest, EligibilityResponse, Encounter, EncounterHistory, Endpoint, EnrollmentRequest, EnrollmentResponse, EpisodeOfCare, EventDefinition, Evidence, EvidenceReport, EvidenceVariable, ExampleScenario, ExpansionProfile, ExplanationOfBenefit, FamilyMemberHistory, Flag, FormularyItem, GenomicStudy, Goal, GraphDefinition, Group, GuidanceResponse, HealthcareService, ImagingManifest, ImagingObjectSelection, ImagingSelection, ImagingStudy, Immunization, ImmunizationEvaluation, ImmunizationRecommendation, ImplementationGuide, Ingredient, InsurancePlan, InventoryItem, InventoryReport, Invoice, Library, Linkage, List, Location, ManufacturedItemDefinition, Measure, MeasureReport, Media, Medication, MedicationAdministration, MedicationDispense, MedicationKnowledge, MedicationOrder, MedicationRequest, MedicationStatement, MedicinalProduct, MedicinalProductAuthorization, MedicinalProductContraindication, MedicinalProductDefinition, MedicinalProductIndication, MedicinalProductIngredient, MedicinalProductInteraction, MedicinalProductManufactured, MedicinalProductPackaged, MedicinalProductPharmaceutical, MedicinalProductUndesirableEffect, MessageDefinition, MessageHeader, MolecularSequence, NamingSystem, NutritionIntake, NutritionOrder, NutritionProduct, Observation, ObservationDefinition, OperationDefinition, OperationOutcome, Order, OrderResponse, Organization, OrganizationAffiliation, PackagedProductDefinition, Parameters, Patient, PaymentNotice, PaymentReconciliation, Permission, Person, PlanDefinition, Practitioner, PractitionerRole, Procedure, ProcedureRequest, ProcessRequest, ProcessResponse, Provenance, Questionnaire, QuestionnaireResponse, ReferralRequest, RegulatedAuthorization, RelatedPerson, RequestGroup, RequestOrchestration, Requirements, ResearchDefinition, ResearchElementDefinition, ResearchStudy, ResearchSubject, RiskAssessment, RiskEvidenceSynthesis, Schedule, SearchParameter, Sequence, ServiceDefinition, ServiceRequest, Slot, Specimen, SpecimenDefinition, StructureDefinition, StructureMap, Subscription, SubscriptionStatus, SubscriptionTopic, Substance, SubstanceDefinition, SubstanceNucleicAcid, SubstancePolymer, SubstanceProtein, SubstanceReferenceInformation, SubstanceSourceMaterial, SubstanceSpecification, SupplyDelivery, SupplyRequest, Task, TerminologyCapabilities, TestPlan, TestReport, TestScript, Transport, ValueSet, VerificationResult, VisionPrescription', ', ')))
select nextval('seq_res_type'), * from spec_types;

Closes #6889

@YalingPeiS YalingPeiS requested a review from a team as a code owner April 22, 2025 15:29
@YalingPeiS YalingPeiS linked an issue Apr 22, 2025 that may be closed by this pull request
@robogary
Copy link
Contributor

Formatting check succeeded!

@robogary
Copy link
Contributor

Formatting check succeeded!

@robogary
Copy link
Contributor

Formatting check succeeded!

…ormalize-out-resource-type-names-into-new-hfj_resource_type-table
@robogary
Copy link
Contributor

Formatting check succeeded!

@robogary
Copy link
Contributor

Formatting check succeeded!

…resource-type-names-into-new-hfj_resource_type-table
@robogary
Copy link
Contributor

Formatting check succeeded!

@robogary
Copy link
Contributor

This Pull Request has failed the formatting check

Please run mvn spotless:apply or mvn clean install -DskipTests to fix the formatting issues.

You can automate this auto-formatting process to execute on the git pre-push hook, by installing pre-commit and then calling pre-commit install --hook-type pre-push. This will cause formatting to run automatically whenever you push.

@robogary
Copy link
Contributor

Formatting check succeeded!

@robogary
Copy link
Contributor

Formatting check succeeded!

@robogary
Copy link
Contributor

Formatting check succeeded!

@robogary
Copy link
Contributor

This Pull Request has failed the formatting check

Please run mvn spotless:apply or mvn clean install -DskipTests to fix the formatting issues.

You can automate this auto-formatting process to execute on the git pre-push hook, by installing pre-commit and then calling pre-commit install --hook-type pre-push. This will cause formatting to run automatically whenever you push.

@robogary
Copy link
Contributor

Formatting check succeeded!

@hapifhir hapifhir deleted a comment from robogary Apr 29, 2025
@YalingPeiS YalingPeiS self-assigned this Apr 29, 2025
@YalingPeiS YalingPeiS requested review from fil512, tadgh and AD1306 as code owners May 6, 2025 23:12
@robogary
Copy link
Contributor

robogary commented May 6, 2025

Formatting check succeeded!

YalingPeiS added 2 commits May 6, 2025 19:12
…resource-type-names-into-new-hfj_resource_type-table

# Conflicts:
#	hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java
@robogary
Copy link
Contributor

robogary commented May 7, 2025

Formatting check succeeded!

@robogary
Copy link
Contributor

robogary commented May 7, 2025

Formatting check succeeded!

@robogary
Copy link
Contributor

robogary commented May 7, 2025

Formatting check succeeded!

Copy link

codecov bot commented May 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.40%. Comparing base (112cec3) to head (a7b6b80).
Report is 4 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6890      +/-   ##
============================================
- Coverage     83.41%   83.40%   -0.01%     
- Complexity    29193    29243      +50     
============================================
  Files          1843     1846       +3     
  Lines        113422   113658     +236     
  Branches      14251    14262      +11     
============================================
+ Hits          94608    94801     +193     
- Misses        12730    12764      +34     
- Partials       6084     6093       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@robogary
Copy link
Contributor

[spotless]: Formatting check succeeded!

@robogary
Copy link
Contributor

[spotless]: Formatting check succeeded!

@YalingPeiS YalingPeiS requested a review from jamesagnew May 20, 2025 15:34
@robogary
Copy link
Contributor

[spotless]: This Pull Request has failed the formatting check

Please run mvn spotless:apply or mvn clean install -DskipTests to fix the formatting issues.

You can automate this auto-formatting process to execute on the git pre-push hook, by installing pre-commit and then calling pre-commit install --hook-type pre-push. This will cause formatting to run automatically whenever you push.

@robogary
Copy link
Contributor

[spotless]: Formatting check succeeded!

@michaelabuckley michaelabuckley merged commit 22136a7 into master May 22, 2025
66 of 67 checks passed
@michaelabuckley michaelabuckley deleted the 6889-normalize-out-resource-type-names-into-new-hfj_resource_type-table branch May 22, 2025 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Normalize out resource type names into new hfj_resource_type table
6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.