Skip to content

Commit

Permalink
Merge branch 'tech-by-design:main' into jb-jb-feature-techbdspring-cs…
Browse files Browse the repository at this point in the history
…vfix-fourfilesmissinggroup
  • Loading branch information
jewelbonnie authored Dec 20, 2024
2 parents 0d703af + f5020b6 commit 9f038a2
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 57 deletions.
Binary file modified hub-prime/lib/techbd-udi-jooq-ingress.auto.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion hub-prime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>
<groupId>org.techbd</groupId>
<artifactId>hub-prime</artifactId>
<version>0.397.0</version>
<version>0.398.0</version>
<packaging>war</packaging>
<name>Tech by Design Hub (Prime)</name>
<description>Tech by Design Hub (Primary)</description>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.techbd.service.converters.shinny;

import java.util.List;
import java.util.UUID;

import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.CanonicalType;
Expand Down Expand Up @@ -30,7 +31,7 @@ public ResourceType getResourceType() {
*/
public Bundle generateEmptyBundle(String interactionId,String igVersion,DemographicData demographicData) {
Bundle bundle = new Bundle();
bundle.setId(CsvConversionUtil.sha256(demographicData.getPatientMrIdValue()));
bundle.setId(CsvConversionUtil.sha256(UUID.randomUUID().toString()));
bundle.setType(Bundle.BundleType.TRANSACTION);
Meta meta = new Meta();
meta.setLastUpdated(DateUtil.parseDate(demographicData.getPatientLastUpdated()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.hl7.fhir.r4.model.Attachment;
import org.hl7.fhir.r4.model.Bundle;
Expand Down Expand Up @@ -73,7 +74,7 @@ public List<BundleEntryComponent> convert(Bundle bundle,DemographicData demogra
Consent consent = new Consent();
setMeta(consent);

consent.setId(CsvConversionUtil.sha256(screeningProfileData.getEncounterId()));
consent.setId(CsvConversionUtil.sha256(UUID.randomUUID().toString()));

Meta meta = consent.getMeta();
meta.setLastUpdated(DateUtil.parseDate(screeningProfileData.getConsentLastUpdated()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public List<BundleEntryComponent> convert(Bundle bundle, DemographicData demogra

populatePatientReference(encounter, idsGenerated);

populateLocationReference(encounter, screeningProfileData, idsGenerated);
// populateLocationReference(encounter, screeningProfileData, idsGenerated);
Narrative text = new Narrative();
text.setStatus(NarrativeStatus.GENERATED);
encounter.setText(text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private static void populateOrganizationIdentifier(Organization organization, Qe
CodeableConcept type = new CodeableConcept();
type.addCoding(coding);
identifier.setType(type);
identifier.setSystem("http://www.scn.ny.gov/");
identifier.setSystem(data.getFacilityIdentifierTypeSystem());
LOG.info("Adding Identifier: Type Display - {}, Value - {}",
coding.getDisplay(), identifier.getValue());

Expand Down Expand Up @@ -166,7 +166,7 @@ private static void populateOrganizationAddress(Organization organization, QeAdm
}

private static void populateIsActive(Organization organization, QeAdminData qrAdminData) {
if (StringUtils.isNotEmpty("TRUE")) { //Static_Value
if (StringUtils.isNotEmpty("TRUE")) { //TODO : remove static reference
organization.setActive(Boolean.parseBoolean("TRUE"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.r4.model.Bundle.HTTPVerb;
import org.hl7.fhir.r4.model.CodeType;
import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.ContactPoint;
Expand All @@ -17,8 +18,6 @@
import org.hl7.fhir.r4.model.HumanName;
import org.hl7.fhir.r4.model.Identifier;
import org.hl7.fhir.r4.model.Meta;
import org.hl7.fhir.r4.model.Narrative;
import org.hl7.fhir.r4.model.Narrative.NarrativeStatus;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent;
import org.hl7.fhir.r4.model.Reference;
Expand Down Expand Up @@ -92,9 +91,6 @@ public List<BundleEntryComponent> convert(Bundle bundle, DemographicData demogra
populatePreferredLanguage(patient, demographicData);
populatePatientRelationContact(patient, demographicData);

Narrative text = new Narrative();
text.setStatus(NarrativeStatus.GENERATED);
patient.setText(text);
// populatePatientText(patient, demographicData);
BundleEntryComponent bundleEntryComponent = new BundleEntryComponent();
bundleEntryComponent.setFullUrl(fullUrl);
Expand Down Expand Up @@ -139,14 +135,14 @@ public static void populatePatientWithExtensions(Patient patient,DemographicData

if (demographicData.getExtensionSexAtBirthCodeValue() != null) {
Extension birthSexExtension = new Extension("http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex");
birthSexExtension.setValue(new StringType(demographicData.getExtensionSexAtBirthCodeValue()));
birthSexExtension.setValue(new CodeType(demographicData.getExtensionSexAtBirthCodeValue())); // Use CodeType for valueCode
patient.addExtension(birthSexExtension);
}

if (demographicData.getExtensionPersonalPronounsCode() != null) {
Extension pronounsExtension = new Extension("http://shinny.org/us/ny/hrsn/StructureDefinition/shinny-personal-pronouns");
pronounsExtension.setValue(new CodeableConcept().addCoding(new Coding()
.setSystem("http://loinc.org")
.setSystem(demographicData.getExtensionPersonalPronounsSystem())
.setCode(demographicData.getExtensionPersonalPronounsCode())
.setDisplay(demographicData.getExtensionPersonalPronounsDisplay())));
patient.addExtension(pronounsExtension);
Expand All @@ -155,7 +151,7 @@ public static void populatePatientWithExtensions(Patient patient,DemographicData
if (demographicData.getExtensionGenderIdentityCode() != null) {
Extension genderIdentityExtension = new Extension("http://shinny.org/us/ny/hrsn/StructureDefinition/shinny-gender-identity");
genderIdentityExtension.setValue(new CodeableConcept().addCoding(new Coding()
.setSystem("http://snomed.info/sct")
.setSystem(demographicData.getExtensionGenderIdentitySystem())
.setCode(demographicData.getExtensionGenderIdentityCode())
.setDisplay(demographicData.getExtensionGenderIdentityDisplay())));
patient.addExtension(genderIdentityExtension);
Expand Down Expand Up @@ -310,7 +306,7 @@ private void populatePreferredLanguage(Patient patient, DemographicData data) {
.filter(StringUtils::isNotEmpty)
.ifPresent(languageCode -> {
Coding coding = new Coding();
coding.setSystem("urn:ietf:bcp:47");
coding.setSystem(data.getPreferredLanguageCodeSystemName());
coding.setCode(languageCode);
CodeableConcept language = new CodeableConcept();
language.addCoding(coding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.DateTimeType;
import org.hl7.fhir.r4.model.Meta;
import org.hl7.fhir.r4.model.Narrative;
import org.hl7.fhir.r4.model.Narrative.NarrativeStatus;
import org.hl7.fhir.r4.model.Observation;
import org.hl7.fhir.r4.model.Reference;
import org.hl7.fhir.r4.model.ResourceType;
Expand Down Expand Up @@ -53,21 +51,40 @@ public List<BundleEntryComponent> convert(

for (ScreeningObservationData data : screeningObservationDataList) {
Observation observation = new Observation();
String observationId = CsvConversionUtil.sha256(data.getEncounterId()+data.getScreeningCode()); // Use screening code as ID'
String observationId = CsvConversionUtil.sha256(data.getQuestionCodeDisplay().replace(" ", "")+ data.getQuestionCode());
observation.setId(observationId);
String fullUrl = "http://shinny.org/us/ny/hrsn/Observation/%s%s"
.formatted(data.getQuestionCodeDisplay().replace(" ", ""), data.getQuestionCode());
String fullUrl = "http://shinny.org/us/ny/hrsn/Observation/"+observationId;
setMeta(observation);
Meta meta = observation.getMeta();
meta.setLastUpdated(DateUtil.parseDate(demographicData.getPatientLastUpdated())); // max date available in all
// screening records
observation.setLanguage("en");
Narrative narrative = new Narrative();
narrative.setStatus(NarrativeStatus.GENERATED);
observation.setText(narrative);
observation.setStatus(Observation.ObservationStatus.FINAL);
observation.addCategory(createCategory("http://hl7.org/fhir/us/sdoh-clinicalcare/CodeSystem/SDOHCC-CodeSystemTemporaryCodes",
"housing-instability", "Housing Instability"));
observation.setStatus(Observation.ObservationStatus.fromCode(screeningProfileData.getScreeningStatusCode()));
if (data.getObservationCategorySdohCode() != null && !data.getObservationCategorySnomedCode().equals("sdoh-category-unspecified")) {
observation.addCategory(createCategory("http://hl7.org/fhir/us/sdoh-clinicalcare/CodeSystem/SDOHCC-CodeSystemTemporaryCodes",
data.getObservationCategorySdohCode(), data.getObservationCategorySdohDisplay()));
} else {
observation.addCategory(createCategory("http://hl7.org/fhir/us/sdoh-clinicalcare/CodeSystem/SDOHCC-CodeSystemTemporaryCodes",
"sdoh-category-unspecified", "SDOH Category Unspecified"));

if (data.getObservationCategorySnomedCode() != null) {
observation.addCategory(createCategory("http://snomed.info/sct",
data.getObservationCategorySnomedCode(), data.getObservationCategorySnomedDisplay()));
}
}
if(data.getDataAbsentReasonCode() != null) {
CodeableConcept dataAbsentReason = new CodeableConcept();

dataAbsentReason.addCoding(
new Coding()
.setSystem("http://terminology.hl7.org/CodeSystem/data-absent-reason")
.setCode(data.getDataAbsentReasonCode())
.setDisplay(data.getDataAbsentReasonDisplay())
);
dataAbsentReason.setText(data.getDataAbsentReasonText());

observation.setDataAbsentReason(dataAbsentReason);
}
observation.addCategory(createCategory("http://terminology.hl7.org/CodeSystem/observation-category",
"social-history", null));
observation.addCategory(createCategory("http://terminology.hl7.org/CodeSystem/observation-category",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public List<BundleEntryComponent> convert(Bundle bundle,DemographicData demogr
LOG.info("SexualOrientationObservationConverter:: convert BEGIN for interaction id :{} ", interactionId);
Observation observation = new Observation();
setMeta(observation);
observation.setId("SexualOrientation-" +CsvConversionUtil.sha256(screeningProfileData.getEncounterId()));
observation.setId(CsvConversionUtil.sha256(screeningProfileData.getPatientMrIdValue()+screeningProfileData.getEncounterId()));
Meta meta = observation.getMeta();
String fullUrl = "http://shinny.org/us/ny/hrsn/Observation/" + observation.getId();
meta.setLastUpdated(DateUtil.parseDate(demographicData.getPatientLastUpdated()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ observation: http://shinny.org/us/ny/hrsn/StructureDefinition/shinny-observation
questionnaire: http://shinny.org/us/ny/hrsn/StructureDefinition/shinny-questionnaire
practitioner: http://shinny.org/us/ny/hrsn/StructureDefinition/shin-ny-practitioner
questionnaireResponse: http://shinny.org/us/ny/hrsn/StructureDefinition/shinny-questionnaire
observationSexualOrientation: http://shinny.org/us/ny/hrsn/StructureDefinition/shin-ny-observation-sexual-orientation
observationSexualOrientation: http://shinny.org/us/ny/hrsn/StructureDefinition/shinny-observation-sexual-orientation
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,14 @@ AS SELECT hub_interaction_id AS interaction_id,
WHEN 'Condition' = ANY(string_to_array(resource_type_set, ', '))
THEN 'Assessment'
ELSE NULL
END AS bundle_resource_type
END AS bundle_resource_type,
CASE
WHEN (source_type = 'CSV') then 'CSV'
WHEN (source_type = 'fhir') then 'FHIR'
WHEN (source_type = 'FHIR') then 'FHIR'
ELSE 'FHIR'
END as source_type,
source_hub_interaction_id
FROM techbd_udi_ingress.sat_interaction_fhir_request htt_req
WHERE uri != '/api/expect/fhir/bundle';

Expand Down Expand Up @@ -3772,28 +3779,44 @@ $$ LANGUAGE plpgsql;

DROP VIEW IF EXISTS techbd_udi_ingress.interaction_csv_http_stat CASCADE;
CREATE OR REPLACE VIEW techbd_udi_ingress.interaction_csv_http_stat AS
WITH fhir_summary AS (
SELECT
source_hub_interaction_id,
SUM(CASE WHEN nature = 'Forwarded HTTP Response' AND source_type = 'CSV' THEN 1 ELSE 0 END) AS fhir_count_success,
SUM(CASE WHEN nature = 'Forwarded HTTP Response Error' AND source_type = 'CSV' THEN 1 ELSE 0 END) AS fhir_count_failed,
COUNT(hub_interaction_id) AS fhir_count
FROM techbd_udi_ingress.sat_interaction_fhir_request
WHERE nature IN ('Forwarded HTTP Response', 'Forwarded HTTP Response Error')
AND source_type = 'CSV'
GROUP BY source_hub_interaction_id
)

SELECT
sizfr.tenant_id_lower,
sizfr.hub_interaction_id,
sizfr.created_at,
sizfr.tenant_id_lower,
sizfr.hub_interaction_id,
sizfr.created_at,
SUM(CASE WHEN siffcr.demographic_data_file_name IS NOT NULL THEN 1 ELSE 0 END) +
SUM(CASE WHEN siffcr.qe_admin_data_file_name IS NOT NULL THEN 1 ELSE 0 END) +
SUM(CASE WHEN siffcr.screening_observation_data_file_name IS NOT NULL THEN 1 ELSE 0 END) +
SUM(CASE WHEN siffcr.screening_profile_data_file_name IS NOT NULL THEN 1 ELSE 0 END)
AS file_count,
count(sifr.hub_interaction_id) as fhir_count,
SUM(CASE WHEN sifr.nature = 'Forwarded HTTP Response' THEN 1 ELSE 0 END) AS fhir_count_success,
SUM(CASE WHEN sifr.nature = 'Forwarded HTTP Response Error' THEN 1 ELSE 0 END) AS fhir_count_failed
SUM(CASE WHEN siffcr.screening_profile_data_file_name IS NOT NULL THEN 1 ELSE 0 END) AS file_count,
COALESCE(fhir_summary.fhir_count, 0) AS fhir_count,
COALESCE(fhir_summary.fhir_count_success, 0) AS fhir_count_success,
COALESCE(fhir_summary.fhir_count_failed, 0) AS fhir_count_failed
FROM
techbd_udi_ingress.sat_interaction_zip_file_request sizfr
JOIN
techbd_udi_ingress.sat_interaction_flat_file_csv_request siffcr
ON sizfr.hub_interaction_id = siffcr.zip_file_hub_interaction_id
ON sizfr.hub_interaction_id = siffcr.zip_file_hub_interaction_id
AND siffcr.nature = 'Original Flat File CSV'
LEFT JOIN
techbd_udi_ingress.sat_interaction_fhir_request sifr
ON sizfr.hub_interaction_id = sifr.source_hub_interaction_id AND (sifr.nature ='Forwarded HTTP Response' or sifr.nature='Forwarded HTTP Response Error') AND sifr.source_type ='CSV'
fhir_summary
ON sizfr.hub_interaction_id = fhir_summary.source_hub_interaction_id
GROUP BY
sizfr.hub_interaction_id,
sizfr.created_at,
sizfr.tenant_id_lower
ORDER BY sizfr.created_at DESC;
sizfr.tenant_id_lower,
fhir_summary.fhir_count,
fhir_summary.fhir_count_success,
fhir_summary.fhir_count_failed
ORDER BY
sizfr.created_at DESC;
Original file line number Diff line number Diff line change
Expand Up @@ -1162,21 +1162,6 @@ const migrateSP = pgSQLa.storedProcedure(
ALTER TABLE techbd_udi_ingress.sat_interaction_fhir_request
ADD COLUMN IF NOT EXISTS group_hub_interaction_id TEXT NULL;
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1
FROM information_schema.table_constraints
WHERE table_name = 'sat_interaction_fhir_request'
AND constraint_name = 'sat_interaction_fhir_request_group_interaction_id_fkey'
AND constraint_type = 'FOREIGN KEY'
) THEN
ALTER TABLE techbd_udi_ingress.sat_interaction_fhir_request
ADD CONSTRAINT sat_interaction_fhir_request_group_interaction_id_fkey
FOREIGN KEY (group_hub_interaction_id)
REFERENCES techbd_udi_ingress.hub_interaction(hub_interaction_id);
END IF;
END $$;
${dependenciesSQL}
Expand Down

0 comments on commit 9f038a2

Please sign in to comment.