From 92c4c945f773cffe0e2a65c6a5f8d239a860ead0 Mon Sep 17 00:00:00 2001 From: Adam Stevenson Date: Thu, 6 Jun 2024 10:04:15 -0600 Subject: [PATCH] Multiple eRSD Tranformer updates (#530) * Multiple eRSD Tranformer updates - releaseLabel extension added - date and effectivePeriod added to manifest library * Fixed test data --- .../transformer/ErsdTransformer.java | 36 +++++++++++++---- .../transformer/ErsdTransformerIT.java | 40 +++++++++++++++++++ .../transformer/eRSDv1bundle.json | 7 ++++ .../transformer/eRSDv1bundle.xml | 4 ++ 4 files changed, 80 insertions(+), 7 deletions(-) diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/casereporting/transformer/ErsdTransformer.java b/tooling/src/main/java/org/opencds/cqf/tooling/casereporting/transformer/ErsdTransformer.java index f03b7581c..48f6f6d75 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/casereporting/transformer/ErsdTransformer.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/casereporting/transformer/ErsdTransformer.java @@ -20,6 +20,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.ArrayList; +import java.util.Date; import java.util.HashSet; import java.util.List; @@ -35,10 +36,12 @@ public class ErsdTransformer extends Operation { private final String usPhTriggeringValueSetLibraryProfileUrl = "http://hl7.org/fhir/us/ecr/StructureDefinition/us-ph-triggering-valueset-library"; private final String usPhTriggeringValueSetProfileUrl = "http://hl7.org/fhir/us/ecr/StructureDefinition/us-ph-triggering-valueset"; private final String valueSetStewardExtensionUrl = "http://hl7.org/fhir/StructureDefinition/valueset-steward"; - + private final String artifactReleaseLabelExtensionUrl = "http://hl7.org/fhir/StructureDefinition/artifact-releaseLabel"; private PlanDefinition v2PlanDefinition; private String version; private Period effectivePeriod; + private Date artifactsDate; + private String releaseLabel; public ErsdTransformer() { ctx = FhirContext.forR4(); @@ -144,6 +147,10 @@ private PlanDefinition getV2PlanDefinition(String pathToPlanDefinition) { if (pathToPlanDefinition != null && !pathToPlanDefinition.isEmpty()) { planDef = (PlanDefinition)IOUtils.readResource(pathToPlanDefinition, ctx, true); planDef.setEffectivePeriod(this.effectivePeriod); + Extension releaseLabelExtension = new Extension(); + releaseLabelExtension.setUrl(artifactReleaseLabelExtensionUrl); + releaseLabelExtension.setValue(new StringType(this.releaseLabel)); + planDef.addExtension(releaseLabelExtension); } return planDef; @@ -192,6 +199,11 @@ else if (bundleFile.getName().endsWith("xml")) { && ((Library)x.getResource()).getUrl().equals(RCTCLIBRARYURL)).findFirst().get().getResource(); this.effectivePeriod = rctc.getEffectivePeriod(); + this.artifactsDate = rctc.getDate(); + Extension releaseLabelExtension = rctc.getExtensionByUrl(artifactReleaseLabelExtensionUrl); + if (releaseLabelExtension != null) { + this.releaseLabel = releaseLabelExtension.getValueAsPrimitive().getValueAsString(); + } if (rctc.hasVersion()) { this.version = rctc.getVersion(); @@ -204,19 +216,29 @@ else if (bundleFile.getName().endsWith("xml")) { private Library createSpecificationLibrary() { Library specificationLibrary = new Library(); - specificationLibrary.setId(new IdType("Library", "SpecificationLibrary", "1.0.0")); + specificationLibrary.setId(new IdType("Library", "SpecificationLibrary")); specificationLibrary.getMeta().addProfile(usPhSpecificationLibraryProfileUrl); + + Extension releaseLabelExtension = new Extension(); + releaseLabelExtension.setUrl(artifactReleaseLabelExtensionUrl); + releaseLabelExtension.setValue(new StringType(this.releaseLabel)); + specificationLibrary.addExtension(releaseLabelExtension); + + if (this.effectivePeriod != null) { + specificationLibrary.setEffectivePeriod(this.effectivePeriod); + } + specificationLibrary.setUrl("http://ersd.aimsplatform.org/fhir/Library/SpecificationLibrary"); + specificationLibrary.setVersion(this.version); specificationLibrary.setName("SpecificationLibrary"); specificationLibrary.setTitle("Specification Library"); - specificationLibrary.setVersion(this.version); - specificationLibrary.setDescription( - "Defines the asset-collection library containing the US Public Health specification assets."); specificationLibrary.setStatus(PublicationStatus.ACTIVE); specificationLibrary.setExperimental(false); - specificationLibrary.setPublisher(PUBLISHER); - specificationLibrary.setUrl("http://ersd.aimsplatform.org/fhir/Library/SpecificationLibrary"); specificationLibrary.setType(new CodeableConcept( new Coding("http://terminology.hl7.org/CodeSystem/library-type", "asset-collection", null))); + specificationLibrary.setDate(this.artifactsDate); + specificationLibrary.setPublisher(PUBLISHER); + specificationLibrary.setDescription( + "Defines the asset-collection library containing the US Public Health specification assets."); UsageContext reportingUsageContext = new UsageContext( diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/casereporting/transformer/ErsdTransformerIT.java b/tooling/src/test/java/org/opencds/cqf/tooling/casereporting/transformer/ErsdTransformerIT.java index f4217dc1e..6f5537d11 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/casereporting/transformer/ErsdTransformerIT.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/casereporting/transformer/ErsdTransformerIT.java @@ -4,6 +4,7 @@ import ca.uhn.fhir.parser.JsonParser; import ca.uhn.fhir.parser.XmlParser; import org.hl7.fhir.r4.model.Bundle; +import org.hl7.fhir.r4.model.Library; import org.hl7.fhir.r4.model.UsageContext; import org.hl7.fhir.r4.model.ValueSet; import org.opencds.cqf.tooling.parameter.TransformErsdParameters; @@ -149,4 +150,43 @@ public void testErsdTransformerEmergentPriorityUseContextPreserved() throws Exce logger.info("Transform"); } + + @Test + public void testErsdTransformerManifestElementPresence() throws Exception { + TransformErsdParameters params = new TransformErsdParameters(); + params.pathToBundle = "src/test/resources/casereporting/transformer/eRSDv1bundle.json"; + params.outputPath = "src/test/resources/casereporting/transformer/output"; + String outputBundleFileName = "rctc-release-2022-10-19-Bundle-rctc.json"; + params.pathToV2PlanDefinition = "src/test/resources/casereporting/transformer/eRSDv2PlanDefinition/plandefinition-us-ecr-specification.json"; + + Bundle outputBundle = transformBundle(params, outputBundleFileName); + + assertNotNull(outputBundle); + Library manifestLibrary; + manifestLibrary = (Library)outputBundle.getEntry().stream().filter(x -> x.hasResource() + && x.getResource().fhirType().equals("Library") + && x.getResource().getId().equals("http://ersd.aimsplatform.org/fhir/Library/SpecificationLibrary")).findFirst().get().getResource(); + + assertNotNull(manifestLibrary); + + List useContexts = manifestLibrary.getUseContext(); + UsageContext reportingUseContext = useContexts.stream().filter(x -> x.hasCode() + && x.getCode().getCode().equals("reporting") + && x.hasValueCodeableConcept() + && x.getValueCodeableConcept().getCodingFirstRep().getCode().equals("triggering")).findFirst().get(); + assertNotNull(reportingUseContext); + + UsageContext specificationTypeUseContext = useContexts.stream().filter(x -> x.hasCode() + && x.getCode().getCode().equals("reporting") + && x.hasValueCodeableConcept() + && x.getValueCodeableConcept().getCodingFirstRep().getCode().equals("triggering")).findFirst().get(); + assertNotNull(specificationTypeUseContext); + + assertNotNull(manifestLibrary.getDate()); + assertNotNull(manifestLibrary.getEffectivePeriod()); + assertNotNull(manifestLibrary.getEffectivePeriod().getStart()); + assertNotNull(manifestLibrary.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/artifact-releaseLabel")); + + logger.info("Transform"); + } } diff --git a/tooling/src/test/resources/casereporting/transformer/eRSDv1bundle.json b/tooling/src/test/resources/casereporting/transformer/eRSDv1bundle.json index 8212e6f1b..b1daa0640 100644 --- a/tooling/src/test/resources/casereporting/transformer/eRSDv1bundle.json +++ b/tooling/src/test/resources/casereporting/transformer/eRSDv1bundle.json @@ -512,6 +512,12 @@ "http://hl7.org/fhir/us/ecr/StructureDefinition/ersd-valueset-library" ] }, + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/artifact-releaseLabel", + "valueString": "2022-10-19" + } + ], "url": "http://ersd.aimsplatform.org/fhir/Library/rctc", "identifier": [ { @@ -531,6 +537,7 @@ } ] }, + "date": "2024-04-02T12:19:03-04:00", "description": "Release Description: This release includes code updates for the existing 132 conditions and adds codes for 41 new conditions: Agricultural Chemicals (Fertilizer) Poisoning Asbestosis Byssinosis Carbapenem-resistant Acinetobacter baumannii (CRAB) Carbapenem-resistant Pseudomonas aeruginosa (CRPA) Catheter-associated Urinary Tract Infection (CAUTI) Central Line-associated Bloodstream Infection (CLABSI) Chemical Pneumonitis Clostridium perfringens Infection Coal Workers Pneumoconiosis (CWP) Cysticercosis Drowning and Submersion Encephalitis Farmer's Lung Granuloma Inguinale (Donovanosis) Guillain-Barre Syndrome Gunshot Wound Head Injury Hepatitis G Virus Infection Herpes, Genital Herpes, Neonatal Leishmaniasis Louse-borne relapsing fever (LBRF) Lymphatic Filariasis Motor Vehicle Injury Multisystem Inflammatory Syndrome (MIS) Non-Polio Enterovirus Infection Nontuberculous Mycobacteria Infection, Pulmonary Ophthalmia Neonatorum Orthopoxvirus Disease Reye's Syndrome Rheumatic Fever Rotavirus Disease Scabies Staphylococcal Enterotoxin B Poisoning Suicide Surgical Site Infection (SSI) Taeniasis Toxoplasmosis Ventilator-associated Event (VAE) Vesicular Stomatitis", "purpose": "Triggers for initiating decision support for electronic case reports", "effectivePeriod": { diff --git a/tooling/src/test/resources/casereporting/transformer/eRSDv1bundle.xml b/tooling/src/test/resources/casereporting/transformer/eRSDv1bundle.xml index 823fd1ba7..0952bb295 100644 --- a/tooling/src/test/resources/casereporting/transformer/eRSDv1bundle.xml +++ b/tooling/src/test/resources/casereporting/transformer/eRSDv1bundle.xml @@ -1479,6 +1479,9 @@ + + + @@ -1494,6 +1497,7 @@ +