Skip to content

Commit

Permalink
application dev config changed with two profiles dev-r4 & dev-r5, Sup…
Browse files Browse the repository at this point in the history
…port for summary improved with custom organization/ author === Tenant, Summary restrained to Immunization, now supported with

R5
  • Loading branch information
cerbeor committed Aug 27, 2024
1 parent f94187e commit e52aaa8
Show file tree
Hide file tree
Showing 13 changed files with 187 additions and 114 deletions.
Binary file added data-h2/r4.mv.db
Binary file not shown.
Binary file added data-h2/r5.mv.db
Binary file not shown.
14 changes: 12 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -814,9 +814,19 @@
</properties>
</profile>
<profile>
<id>dev</id>
<id>dev-r4</id>
<properties>
<spring.profiles.active>dev</spring.profiles.active>
<spring.profiles.active>dev-r4</spring.profiles.active>
<IIS_MYSQL_URL>jdbc:mysql://localhost/iis_alongside_jpa</IIS_MYSQL_URL>
<!-- <mysql.hibernate.connection.url>jdbc:mysql://localhost/iis_alongside_jpa</mysql.hibernate.connection.url>-->
<jpa.properties.hibernate.dialect>ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect</jpa.properties.hibernate.dialect>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
<profile>
<id>dev-r5</id>
<properties>
<spring.profiles.active>dev-r5</spring.profiles.active>
<IIS_MYSQL_URL>jdbc:mysql://localhost/iis_alongside_jpa</IIS_MYSQL_URL>
<!-- <mysql.hibernate.connection.url>jdbc:mysql://localhost/iis_alongside_jpa</mysql.hibernate.connection.url>-->
<jpa.properties.hibernate.dialect>ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect</jpa.properties.hibernate.dialect>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class IpsConfig {
@Bean
@Conditional(OnR4Condition.class)
public IIpsGenerationStrategy ipsGenerationStrategyR4() {
return new DefaultIpsGenerationStrategy();
return new IpsGenerationStrategyR4();
}

@Bean
Expand All @@ -30,13 +30,11 @@ public IIpsGenerationStrategy ipsGenerationStrategyR5() {

@Bean
public IpsGeneratorSvcImpl ipsGeneratorSvc(FhirContext fhirContext, IIpsGenerationStrategy ipsGenerationStrategy,DaoRegistry daoRegistry) {
IpsGeneratorSvcImpl ipsGeneratorSvc = new IpsGeneratorSvcIIS(fhirContext, ipsGenerationStrategy, daoRegistry);
return ipsGeneratorSvc;
return new IpsGeneratorSvcIIS(fhirContext, ipsGenerationStrategy, daoRegistry);
}

@Bean
public IpsOperationProvider ipsOperationProvider(IIpsGeneratorSvc iIpsGeneratorSvc) {
IpsOperationProvider ipsOperationProvider = new IpsOperationProvider(iIpsGeneratorSvc);
return ipsOperationProvider;
return new IpsOperationProvider(iIpsGeneratorSvc);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.immregistries.iis.kernal.fhir.ips;

import ca.uhn.fhir.jpa.ips.api.SectionRegistry;
import ca.uhn.fhir.jpa.ips.strategy.DefaultIpsGenerationStrategy;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.Address;
import org.hl7.fhir.r4.model.IdType;
import org.hl7.fhir.r4.model.Organization;
import org.immregistries.iis.kernal.fhir.security.ServletHelper;
import org.immregistries.iis.kernal.mapping.forR4.OrganizationMapperR4;
import org.immregistries.iis.kernal.model.Tenant;
import org.springframework.beans.factory.annotation.Autowired;

public class IpsGenerationStrategyR4 extends DefaultIpsGenerationStrategy {

@Autowired
OrganizationMapperR4 organizationMapper;

/**
* Constructor
*/
public IpsGenerationStrategyR4() {
super();
this.setSectionRegistry(new SectionRegistryR4());
}

@Override
public IBaseResource createAuthor() {
Tenant tenant = ServletHelper.getTenant();

Organization organization = organizationMapper.getFhirResource(tenant);
return organization;
}

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package org.immregistries.iis.kernal.fhir.ips;

import ca.uhn.fhir.jpa.ips.api.IpsContext;
import ca.uhn.fhir.jpa.ips.api.SectionRegistry;
import ca.uhn.fhir.jpa.ips.strategy.DefaultIpsGenerationStrategy;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.model.api.Include;
import com.google.common.collect.Sets;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.r5.model.*;
import org.immregistries.iis.kernal.fhir.security.ServletHelper;
import org.immregistries.iis.kernal.mapping.forR5.OrganizationMapperR5;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
Expand All @@ -22,94 +24,23 @@
* prototype, unusable
*/
public class IpsGenerationStrategyR5 extends DefaultIpsGenerationStrategy {

@Autowired
OrganizationMapperR5 organizationMapper;
/**
* Constructor
*/
public IpsGenerationStrategyR5() {
super();
this.setSectionRegistry(new SectionRegistryR5());
}

@Override
public IBaseResource createAuthor() {
Organization organization = new Organization();
organization
.setName("eHealthLab - University of Cyprus")
.setId(IdType.newRandomUuid());
organization.addContact().setAddress(new Address()
.addLine("1 University Avenue")
.setCity("Nicosia")
.setPostalCode("2109")
.setCountry("CY"));
Organization organization = organizationMapper.getFhirResource(ServletHelper.getTenant());
return organization;
}

@Override
public String createTitle(IpsContext theContext) {
return "Patient Summary as of "
+ DateTimeFormatter.ofPattern("MM/dd/yyyy").format(LocalDate.now());
}

@Override
public IIdType massageResourceId(@Nullable IpsContext theIpsContext, @Nonnull IBaseResource theResource) {
return IdType.newRandomUuid();
}

@Override
public void massageResourceSearch(
IpsContext.IpsSectionContext theIpsSectionContext, SearchParameterMap theSearchParameterMap) {
switch (theIpsSectionContext.getSection()) {
case ALLERGY_INTOLERANCE:
case PROBLEM_LIST:
case IMMUNIZATIONS:
case PROCEDURES:
case MEDICAL_DEVICES:
case ILLNESS_HISTORY:
case FUNCTIONAL_STATUS:
default:
return;

}
// Shouldn't happen: This means none of the above switches handled the Section+resourceType combination
// assert false
// : "Don't know how to handle " + theIpsSectionContext.getSection() + "/"
// + theIpsSectionContext.getResourceType();
}

@Nonnull
@Override
public Set<Include> provideResourceSearchIncludes(IpsContext.IpsSectionContext theIpsSectionContext) {
switch (theIpsSectionContext.getSection()) {
case MEDICATION_SUMMARY:
if (ResourceType.MedicationStatement.name().equals(theIpsSectionContext.getResourceType())) {
return Sets.newHashSet(MedicationStatement.INCLUDE_MEDICATION);
}
if (ResourceType.MedicationRequest.name().equals(theIpsSectionContext.getResourceType())) {
return Sets.newHashSet(MedicationRequest.INCLUDE_MEDICATION);
}
if (ResourceType.MedicationAdministration.name().equals(theIpsSectionContext.getResourceType())) {
return Sets.newHashSet(MedicationAdministration.INCLUDE_MEDICATION);
}
if (ResourceType.MedicationDispense.name().equals(theIpsSectionContext.getResourceType())) {
return Sets.newHashSet(MedicationDispense.INCLUDE_MEDICATION);
}
break;
case MEDICAL_DEVICES:
case ALLERGY_INTOLERANCE:
case PROBLEM_LIST:
case IMMUNIZATIONS:
case PROCEDURES:
case DIAGNOSTIC_RESULTS:
case VITAL_SIGNS:
case ILLNESS_HISTORY:
case PREGNANCY:
case SOCIAL_HISTORY:
case FUNCTIONAL_STATUS:
case PLAN_OF_CARE:
case ADVANCE_DIRECTIVES:
break;
}
return Collections.emptySet();
}

@SuppressWarnings("EnhancedSwitchMigration")
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,36 @@ private String createSectionNarrative(
ResourceInclusionCollection theGlobalResourceCollection) {
CustomThymeleafNarrativeGenerator generator = newNarrativeGenerator(theGlobalResourceCollection);

org.hl7.fhir.r4.model.Bundle bundle = new org.hl7.fhir.r4.model.Bundle();
for (IBaseResource resource : theResources.getResources()) {
BundleEntrySearchModeEnum searchMode = ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.get(resource);
if (searchMode == BundleEntrySearchModeEnum.MATCH) {
bundle.addEntry().setResource((org.hl7.fhir.r4.model.Resource) resource);
if (myFhirContext.getVersion().getVersion().equals(FhirVersionEnum.R4)) {
org.hl7.fhir.r4.model.Bundle bundle = new org.hl7.fhir.r4.model.Bundle();
for (IBaseResource resource : theResources.getResources()) {
BundleEntrySearchModeEnum searchMode = ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.get(resource);
if (searchMode == BundleEntrySearchModeEnum.MATCH) {
bundle.addEntry().setResource((org.hl7.fhir.r4.model.Resource) resource);
}
}
String profile = theSection.getProfile();
bundle.getMeta().addProfile(profile);

// Generate the narrative
return generator.generateResourceNarrative(myFhirContext, bundle);
} else if (myFhirContext.getVersion().getVersion().equals(FhirVersionEnum.R5)) {
org.hl7.fhir.r5.model.Bundle bundle = new org.hl7.fhir.r5.model.Bundle();
for (IBaseResource resource : theResources.getResources()) {
BundleEntrySearchModeEnum searchMode = ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.get(resource);
if (searchMode == BundleEntrySearchModeEnum.MATCH) {
bundle.addEntry().setResource((org.hl7.fhir.r5.model.Resource) resource);
}
}
String profile = theSection.getProfile();
bundle.getMeta().addProfile(profile);

// Generate the narrative
return generator.generateResourceNarrative(myFhirContext, bundle);
} else {
return "";
}
String profile = theSection.getProfile();
bundle.getMeta().addProfile(profile);

// Generate the narrative
return generator.generateResourceNarrative(myFhirContext, bundle);
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.immregistries.iis.kernal.fhir.ips;

import ca.uhn.fhir.jpa.ips.api.SectionRegistry;

public class SectionRegistryR4 extends SectionRegistry {

@Override
/**
* Add the various sections to the registry in order. overridden for
* customization.
*/
protected void addSections() {
// addSectionAllergyIntolerance();
// addSectionMedicationSummary();
// addSectionProblemList();
addSectionImmunizations();
// addSectionProcedures();
// addSectionMedicalDevices();
// addSectionDiagnosticResults();
// addSectionVitalSigns();
// addSectionPregnancy();
// addSectionSocialHistory();
// addSectionIllnessHistory();
// addSectionFunctionalStatus();
// addSectionPlanOfCare();
// addSectionAdvanceDirectives();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.immregistries.iis.kernal.fhir.ips;

import ca.uhn.fhir.jpa.ips.api.SectionRegistry;

public class SectionRegistryR5 extends SectionRegistry {

@Override
/**
* Add the various sections to the registry in order. overridden for
* customization.
*/
protected void addSections() {
// addSectionAllergyIntolerance();
// addSectionMedicationSummary();
// addSectionProblemList();
addSectionImmunizations();
// addSectionProcedures();
// addSectionMedicalDevices();
// addSectionDiagnosticResults();
// addSectionVitalSigns();
// addSectionPregnancy();
// addSectionSocialHistory();
// addSectionIllnessHistory();
// addSectionFunctionalStatus();
// addSectionPlanOfCare();
// addSectionAdvanceDirectives();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
public class CustomSubscriptionCanonicalizer extends SubscriptionCanonicalizer {
private static final Logger ourLog = LoggerFactory.getLogger(SubscriptionCanonicalizer.class);

final FhirContext myFhirContext;
private final FhirContext myFhirContext;
@Autowired
public CustomSubscriptionCanonicalizer(FhirContext theFhirContext) {
super(theFhirContext);
Expand Down
Loading

0 comments on commit e52aaa8

Please sign in to comment.