Skip to content

Commit

Permalink
Throwing example Err 5, progess and testing
Browse files Browse the repository at this point in the history
  • Loading branch information
cerbeor committed Dec 23, 2024
1 parent 50cb983 commit b76550b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import org.hl7.fhir.instance.model.api.IDomainResource;

public interface IRecommendationForecastProvider<Parameters extends IBaseParameters, Patient extends IDomainResource, Immunization extends IDomainResource> {
public static final String $_IMMDS_FORECAST = "$immds-forecast";
public static final String ASSESSMENT_DATE = "assessmentDate";
public static final String PATIENT = "patient";
public static final String RECOMMENDATION = "recommendation";
public static final String IMMUNIZATION = "immunization";
public static final String IMM_DSFORECAST_CANONICAL_URL = "http://hl7.org/fhir/us/immds/OperationDefinition/ImmDSForecastOperation";
String $_IMMDS_FORECAST = "$immds-forecast";
String ASSESSMENT_DATE = "assessmentDate";
String PATIENT = "patient";
String RECOMMENDATION = "recommendation";
String IMMUNIZATION = "immunization";
String IMM_DSFORECAST_CANONICAL_URL = "http://hl7.org/fhir/us/immds/OperationDefinition/ImmDSForecastOperation";

// @Operation(name = $_IMMDS_FORECAST)
// @Operation(name = $_IMMDS_FORECAST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import org.immregistries.iis.kernal.fhir.annotations.OnR4Condition;
import org.immregistries.iis.kernal.fhir.security.ServletHelper;
import org.immregistries.iis.kernal.logic.ImmunizationRecommendationServiceR4;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Controller;
Expand All @@ -23,6 +25,7 @@
@Conditional(OnR4Condition.class)
public class RecommendationForecastProviderR4
implements IRecommendationForecastProvider<Parameters, Patient, Immunization> {
Logger logger = LoggerFactory.getLogger(RecommendationForecastProviderR4.class);

@Autowired
ImmunizationRecommendationServiceR4 immunizationRecommendationServiceR4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.immregistries.vfa.connect.ConnectFactory;
import org.immregistries.vfa.connect.ConnectorInterface;
import org.immregistries.vfa.connect.model.*;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -481,6 +482,9 @@ public String processQBP(Tenant tenant, HL7Reader reader, String messageReceived
PatientMaster singleMatch = null;

singleMatch = fhirRequester.matchPatient(multipleMatches, patientMasterForMatchQuery, cutoff);
if (singleMatch == null) {
throw new ProcessingException("Patient not found", "PID", 1, 1); // TODO position
}

return buildRSP(reader, messageReceived, singleMatch, tenant, multipleMatches, reportables);
}
Expand Down Expand Up @@ -1205,6 +1209,7 @@ public PatientReported processPatientFhirAgnostic(HL7Reader reader, List<IisRepo
if (patientBirthDate.after(new Date())) {
throw new ProcessingException("Patient is indicated as being born in the future, unable to record patients who are not yet born", "PID", 1, 7);
}

patientReported.setExternalLink(patientReportedExternalLink);
patientReported.setPatientReportedType(patientReportedType);
patientReported.setPatientNames(names);
Expand Down Expand Up @@ -1381,6 +1386,7 @@ public PatientReported processPatientFhirAgnostic(HL7Reader reader, List<IisRepo
}
reader.resetPostion();

doChecks(patientReported, iisReportableList);
verifyNoErrors(iisReportableList);

patientReported.setUpdatedDate(new Date());
Expand All @@ -1399,5 +1405,29 @@ public PatientReported processPatientFhirAgnostic(HL7Reader reader, List<IisRepo
return patientReported;
}

public void doChecks(PatientReported patientReported, List<IisReportable> iisReportableList) {
Date deathDate = patientReported.getDeathDate();
boolean isDead = deathDate != null || StringUtils.equals(patientReported.getDeathFlag(), "Y");
if (deathDate != null && deathDate.before(patientReported.getBirthDate())) {
IisReportable iisReportable = getIisReportable("2002", "Conflicting Date of Birth and Date of Death", List.of(new Hl7Location("PID-9"), new Hl7Location("PID-27")));
iisReportableList.add(iisReportable);
}
if (isDead && StringUtils.equals("A", patientReported.getRegistryStatusIndicator())) {
IisReportable iisReportable = getIisReportable("2007", "Conflicting Patient Status and Patient Death Information", List.of(new Hl7Location("PD1-16"), new Hl7Location("PID-29"), new Hl7Location("PID-30")));
iisReportableList.add(iisReportable);
}
}

private static @NotNull IisReportable getIisReportable(String number, String text, List<@NotNull Hl7Location> hl7LocationList) {
IisReportable iisReportable = new IisReportable();
iisReportable.setHl7LocationList(hl7LocationList);
CodedWithExceptions applicationErrorCode = new CodedWithExceptions("ERR-5");
applicationErrorCode.setIdentifier(number);
applicationErrorCode.setText(text);
iisReportable.setApplicationErrorCode(applicationErrorCode);
iisReportable.setHl7ErrorCode(applicationErrorCode);
iisReportable.setSeverity(IisReportableSeverity.WARN);
return iisReportable;
}

}

0 comments on commit b76550b

Please sign in to comment.