Skip to content

Commit

Permalink
Multiple eRSD Tranformer updates (#530)
Browse files Browse the repository at this point in the history
* Multiple eRSD Tranformer updates

- releaseLabel extension added
- date and effectivePeriod added to manifest library

* Fixed test data
  • Loading branch information
sliver007 authored Jun 6, 2024
1 parent 3babcd0 commit 92c4c94
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -35,10 +36,12 @@ public class ErsdTransformer extends Operation {
private final String usPhTriggeringValueSetLibraryProfileUrl = "https://hl7.org/fhir/us/ecr/StructureDefinition/us-ph-triggering-valueset-library";
private final String usPhTriggeringValueSetProfileUrl = "https://hl7.org/fhir/us/ecr/StructureDefinition/us-ph-triggering-valueset";
private final String valueSetStewardExtensionUrl = "https://hl7.org/fhir/StructureDefinition/valueset-steward";

private final String artifactReleaseLabelExtensionUrl = "https://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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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("https://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("https://ersd.aimsplatform.org/fhir/Library/SpecificationLibrary");
specificationLibrary.setType(new CodeableConcept(
new Coding("https://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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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("https://ersd.aimsplatform.org/fhir/Library/SpecificationLibrary")).findFirst().get().getResource();

assertNotNull(manifestLibrary);

List<UsageContext> 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("https://hl7.org/fhir/StructureDefinition/artifact-releaseLabel"));

logger.info("Transform");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,12 @@
"https://hl7.org/fhir/us/ecr/StructureDefinition/ersd-valueset-library"
]
},
"extension": [
{
"url": "https://hl7.org/fhir/StructureDefinition/artifact-releaseLabel",
"valueString": "2022-10-19"
}
],
"url": "https://ersd.aimsplatform.org/fhir/Library/rctc",
"identifier": [
{
Expand All @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,9 @@
<meta>
<profile value="https://hl7.org/fhir/us/ecr/StructureDefinition/ersd-valueset-library"></profile>
</meta>
<extension url="https://hl7.org/fhir/StructureDefinition/artifact-releaseLabel">
<valueString value="2022-10-19"></valueString>
</extension>
<url value="https://ersd.aimsplatform.org/fhir/Library/rctc"></url>
<identifier>
<system value="urn:ietf:rfc:3986"></system>
Expand All @@ -1494,6 +1497,7 @@
<code value="asset-collection"></code>
</coding>
</type>
<date value="2024-04-02T12:19:03-04:00"></date>
<description value="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"></description>
<purpose value="Triggers for initiating decision support for electronic case reports"></purpose>
<effectivePeriod>
Expand Down

0 comments on commit 92c4c94

Please sign in to comment.