Skip to content

Commit

Permalink
Partitioninf fix, code cleaning, docker config change
Browse files Browse the repository at this point in the history
  • Loading branch information
cerbeor committed Aug 13, 2024
1 parent 2480ee3 commit c9f6fb8
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 297 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ services:
POSTGRES_USER: "hapi_iis_web"
POSTGRES_PASSWORD: "SicMundusCreatusEst"
healthcheck:
test: pg_isready -d hapi_fhir_iis -U $$POSTGRES_USER
test: pg_isready -d $$POSTGRES_DB -U $$POSTGRES_USER
interval: 8s
timeout: 10s
retries: 15
retries: 10
start_period: 5s
# volumes:
# - ./database/create-postgresql-for-hapi-fhir.sql:/docker-entrypoint-initdb.d/3.sql
Expand Down
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@
<!-- <groupId>org.springframework.security.oauth.boot</groupId>-->
<!-- <artifactId>spring-security-oauth2-autoconfigure</artifactId>-->
<!-- <version>2.6.8</version>-->
<!-- </dependency>-->

<!-- <dependency>-->
<!--&lt;!&ndash; https://github.com/usnistgov/fhirAdapter &ndash;&gt;-->
<!-- <groupId>gov.nist.fhir.adapter</groupId>-->
<!-- <artifactId>fhirAdapter</artifactId>-->
<!-- <version>1.0-SNAPSHOT</version>-->
<!-- </dependency>-->

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,11 @@ public Group groupInstanceMemberAdd(
if (memberId != null) {
logger.info("PATIENT ADD identifier {}", memberId.getValue());
// String patientId = identifierSolverInterceptor.solvePatientIdentifier(ServletHelper.requestDetailsWithPartitionName(), memberId);
String patientId = patientIFhirResourceDao.search(new SearchParameterMap("identifier", new TokenParam(memberId.getValue())),theRequestDetails).getAllResourceIds().get(0);
if (StringUtils.isBlank(patientId)) {
throw new InvalidRequestException("Patient with identifier " + memberId.getValue() + " is unknown");
}
IBundleProvider iBundleProvider = patientIFhirResourceDao.search(new SearchParameterMap("identifier", new TokenParam(memberId.getValue())),theRequestDetails);
if (iBundleProvider.isEmpty()) {
throw new InvalidRequestException("Patient with identifier " + memberId.getValue() + " is unknown"); // TODO proper exception
}
String patientId = iBundleProvider.getAllResourceIds().get(0);
Reference reference = new Reference("Patient/" + patientId).setIdentifier(memberId);
memberComponent = group.getMember().stream()
.filter(member -> reference.getReference().equals(member.getEntity().getReference()) || (memberId.getValue().equals(member.getEntity().getIdentifier().getValue()) && memberId.getSystem().equals(member.getEntity().getIdentifier().getSystem())))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.mdm.util.IdentifierUtil;
import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.param.TokenParam;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import com.github.jsonldjava.utils.Obj;
import org.hl7.fhir.r5.model.Group;
import org.hl7.fhir.r5.model.Immunization;
import org.hl7.fhir.r5.model.Organization;
import org.hl7.fhir.r5.model.Reference;
import org.immregistries.iis.kernal.InternalClient.FhirRequesterR5;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,18 @@ public class PartitionCreationInterceptor extends RequestTenantPartitionIntercep
public static final String PARTITION_NAME_SEPARATOR = "-"; // TEMP TODO find good url structure


@Hook(Pointcut.STORAGE_PARTITION_IDENTIFY_READ)
@Hook(value = Pointcut.SERVER_INCOMING_REQUEST_POST_PROCESSED)
public boolean partitionIdentifyPostProcessed(RequestDetails theRequestDetails) {
extractPartitionIdFromRequest(theRequestDetails);
return true;
}

@Hook(value = Pointcut.STORAGE_PARTITION_IDENTIFY_READ, order = -1000)
public RequestPartitionId partitionIdentifyRead(RequestDetails theRequestDetails) {
return extractPartitionIdFromRequest(theRequestDetails);
}

@Hook(Pointcut.STORAGE_PARTITION_IDENTIFY_CREATE)
@Hook(value = Pointcut.STORAGE_PARTITION_IDENTIFY_CREATE, order = -1000)
public RequestPartitionId partitionIdentifyCreate(RequestDetails theRequestDetails) {
return extractPartitionIdFromRequest(theRequestDetails);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java.util.*;

public interface IIncomingMessageHandler<Organization extends IBaseResource> {
public interface IIncomingMessageHandler {
public String process(String message, Tenant tenant, String facilityName);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.text.SimpleDateFormat;
import java.util.*;

public abstract class IncomingMessageHandler<Organization extends IBaseResource> implements IIncomingMessageHandler<Organization> {
public abstract class IncomingMessageHandler implements IIncomingMessageHandler {

protected final Logger logger = LoggerFactory.getLogger(IncomingMessageHandler.class);
@Autowired
Expand Down Expand Up @@ -727,16 +727,5 @@ public Date parseDateInternal(String dateString, boolean strict) throws ParseExc
}

protected static final Random random = new Random();
private static final char[] ID_CHARS =
{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9'};


public String generateId() {
StringBuilder patientRegistryId = new StringBuilder();
for (int i = 0; i < 12; i++) {
patientRegistryId.append(ID_CHARS[random.nextInt(ID_CHARS.length)]);
}
return patientRegistryId.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

@org.springframework.stereotype.Service()
@Conditional(OnR4Condition.class)
public class IncomingMessageHandlerR4 extends IncomingMessageHandler<Organization> {
public class IncomingMessageHandlerR4 extends IncomingMessageHandler {
private static final double MINIMAL_MATCHING_SCORE = 0.9;

public String process(String message, Tenant tenant, String sendingFacilityName) {
Expand Down Expand Up @@ -1741,30 +1741,6 @@ public List<VaccinationMaster> getVaccinationMasterList(PatientMaster patient) {
return vaccinationMasterList;
}

public String generatePatientExternalLink() {
IGenericClient fhirClient = getFhirClient();
boolean keepLooking = true;
int count = 0;
while (keepLooking) {
count++;
if (count > 1000) {
throw new RuntimeException("Unable to get a new id, tried 1000 times!");
}
String patientExternalLink = generateId();
try {
Bundle bundle = fhirClient.search().forResource(Patient.class)
.where(Patient.IDENTIFIER.exactly().code(patientExternalLink)).returnBundle(Bundle.class).execute();
if (!bundle.hasEntry()) {
return patientExternalLink;
}
} catch (ResourceNotFoundException e) {
return patientExternalLink;
// we found a unique id!
}
}
return null;
}

private Organization processSendingOrganization(HL7Reader reader) {
String organizationName = reader.getValue(4, 1);
Organization sendingOrganization = (Organization) fhirRequester.searchOrganization(
Expand Down
Loading

0 comments on commit c9f6fb8

Please sign in to comment.