use of org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7ImmunizationFHIRConversionTest method testDoubleMultipleNestedEducation.
// The following creates education records which combine information from related OBX's, indicated by matching OBX.4 value
// There are three ORC/RXA/RXR/OBX* sections, two differ only by dates and other small differences; enough to ensure we
// are finding the correct matching publication and presentation dates for the correct siblings and there is no data bleed.
// Others have handle various cases of completeness of data, according to rules outlined in Immunization.yml.
// For each of RXA sections below, Immunization.education should be (dates & xx vary):
//
// "education": [
// {
// "documentType": "DTaP, xx UF",
// "publicationDate": "2007-05-17",
// "presentationDate": "2014-12-03"
// },
// {
// "documentType": "Hep B, xx UF",
// "publicationDate": "2012-02-02",
// "presentationDate": "2014-12-03"
// }
// ],
@Test
void testDoubleMultipleNestedEducation() throws IOException {
String hl7VUXmessageRep = "MSH|^~\\&|||||20160106165800070+0000||VXU^V04^VXU_V04|20210205NH0000 01|P|2.5.1|||||||||Z22^CDCPHPHINVS|||\n" + "PID|1||12345^^^^MR||TestPatient^Jane^^^^^L||||||\n" + "NK1|1|LASTNAME^FIRST^^^^^L|SPO^SPOUSE^HL70063||^PRN^PH^^^603^7772222\n" + // ----- FIRST IMMUNIZATION SET. ----- Descriptions have AA, and dates 2007.
"ORC|RE||2623980^EHR|||||||||^ORDERINGLASTNAME^FIRST^^^^^^^L^^^MD|\n" + "RXA|0|1|20160105||33^PNEUMOCOCCAL POLYSACCHARIDE PPV23^CVX|0.5|ML^^UCUM|||||||||||||||\n" + "RXR|C28161^Intramuscular^NCIT|LD^Left Deltoid^HL70163|\n" + // Reference will be used as DocumentType
"OBX|1|CE|30956-7^Vaccine Type^LN|2|107^DTaP, AA1 UF^CVX||||||F\n" + "OBX|2|DT|29768-9^Date Vaccine Information Statement Published^LN|2|20070517||||||F\n" + "OBX|3|DT|29769-7^Date Vaccine Information Statement Presented^LN|2|20071203||||||F\n" + // Random OBX to prove it doesn't confuse searching or group association.
"OBX|4|CWE|64994-7^funding pgm eligibility^LN||V01^Insured^HL70064||||||F||||||VXC40^per immunization^CDCPHINVS\n" + // Reference will be used as DocumentType
"OBX|5|CE|30956-7^Vaccine Type^LN|3|45^Hep B, AA2 UF^CVX||||||F\n" + "OBX|6|DT|29768-9^Date Vaccine Information Statement Published^LN|3|20070202||||||F\n" + "OBX|7|DT|29769-7^Date Vaccine Information Statement Presented^LN|3|20071203||||||F\n" + // 48767-8 record in group will be ignore.
"OBX|2|DT|69764-9^HIB Info Sheet^LN|8|20070505||||||F|||20130531\n" + "OBX|3|DT|29768-9^VIS Publication Date^LN|8|20070606||||||F|||20130531\n" + "OBX|4|DT|29769-7^VIS Presentation Date^LN|8|20070707||||||F|||20130531\n" + "OBX|5|ST|48767-8^Annotation^LN|8|Some text from doctor||||||F|||20130531\n" + // ----- SECOND IMMUNIZATION SET. ----- Descriptions have BB, and dates 2014.
"ORC|RE||2623980^EHR|||||||||^ORDERINGLASTNAME^FIRST^^^^^^^L^^^MD|\n" + "RXA|0|1|20160105||33^PNEUMOCOCCAL POLYSACCHARIDE PPV23^CVX|0.5|ML^^UCUM||||||||||||||||\n" + "RXR|C28161^Intramuscular^NCIT|LD^Left Deltoid^HL70163|\n" + // Random OBX to prove it doesn't confuse searching or group association.
"OBX|1|CWE|64994-7^funding pgm eligibility^LN||V01^Insured^HL70064||||||F||||||VXC40^per immunization^CDCPHINVS\n" + // Reference will be used as DocumentType
"OBX|2|CE|30956-7^Vaccine Type^LN|2|107^DTaP, BB1 UF^CVX||||||F\n" + "OBX|3|DT|29768-9^Date Vaccine Information Statement Published^LN|2|20140517||||||F\n" + "OBX|4|DT|29769-7^Date Vaccine Information Statement Presented^LN|2|20141203||||||F\n" + // Reference will be used as DocumentType
"OBX|5|CE|30956-7^Vaccine Type^LN|3|45^Hep B, BB2 UF^CVX||||||F\n" + "OBX|6|DT|29768-9^Date Vaccine Information Statement Published^LN|3|20140202||||||F\n" + "OBX|7|DT|29769-7^Date Vaccine Information Statement Presented^LN|3|20141203||||||F\n" + // 'unspecified' is used as DocumentType.
"OBX|32|DT|29768-9^Date Vaccine Information Statement Published^LN|6|20140503||||||F\n" + "OBX|33|DT|29769-7^Date Vaccine Information Statement Presented^LN|6|20140505||||||F\n" + // ----- THIRD IMMUNIZATION SET. ----- Descriptions have CC, and dates 2017.
"ORC|RE||2623980^EHR|||||||||^ORDERINGLASTNAME^FIRST^^^^^^^L^^^MD|\n" + "RXA|0|1|20160105||33^PNEUMOCOCCAL POLYSACCHARIDE PPV23^CVX|0.5|ML^^UCUM||||||||||||||||\n" + "RXR|C28161^Intramuscular^NCIT|LD^Left Deltoid^HL70163|\n" + // OBX times have type TS to prove that works
"OBX|8|CE|69764-9^Vaccine Type^LN|4|45^Hep B, CC3a UF^CVX||||||F\n" + "OBX|9|CE|30956-7^Vaccine Type^LN|4|45^Hep B, CC3b UF^CVX||||||F\n" + "OBX|10|TS|29768-9^Date Vaccine Information Statement Published^LN|4|20170303||||||F\n" + "OBX|11|TS|29769-7^Date Vaccine Information Statement Presented^LN|4|20170305||||||F\n" + // OBX times have type DTM to prove that works
"OBX|21|CE|69764-9^Vaccine Type^LN|5|45^Hep B, CC4 UF^CVX||||||F\n" + "OBX|22|DTM|29768-9^Date Vaccine Information Statement Published^LN|5|20170403011212000+0000||||||F\n" + "OBX|23|DTM|29769-7^Date Vaccine Information Statement Presented^LN|5|20170405011212000+0000||||||F\n" + // 'unspecified' is used as DocumentType.
"OBX|43|DT|29769-7^Date Vaccine Information Statement Presented^LN|7|20170605||||||F\n" + "ORC|RE||9999^EHR|||||||\n";
List<Bundle.BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7VUXmessageRep);
List<Resource> immunizations = ResourceUtils.getResourceList(e, ResourceType.Immunization);
assertThat(immunizations).hasSize(3);
// First immunization set. Descriptions have AA, and dates 2007.
Immunization immunization = (Immunization) immunizations.get(0);
assertThat(immunization.getEducation()).hasSize(3);
checkImmunizationEducation(immunization.getEducation().get(1), "DTaP, AA1 UF", "2007-05-17", "2007-12-03");
checkImmunizationEducation(immunization.getEducation().get(2), "Hep B, AA2 UF", "2007-02-02", "2007-12-03");
// Degenerate 69764-9 without CE/CWE data. DocumentType will default to "unspecified"
checkImmunizationEducation(immunization.getEducation().get(0), "unspecified", "2007-06-06", "2007-07-07");
// Second immunization set. Descriptions have BB, and dates 2014.
immunization = (Immunization) immunizations.get(1);
assertThat(immunization.getEducation()).hasSize(3);
// Reference used as DocumentType
checkImmunizationEducation(immunization.getEducation().get(0), "DTaP, BB1 UF", "2014-05-17", "2014-12-03");
// Reference used as DocumentType
checkImmunizationEducation(immunization.getEducation().get(1), "Hep B, BB2 UF", "2014-02-02", "2014-12-03");
// Has no DocumentType nor Reference record. 'unspecified' is used as DocumentType.
checkImmunizationEducation(immunization.getEducation().get(2), "unspecified", "2014-05-03", "2014-05-05");
// Second immunization set. Descriptions have CC, and dates 2017.
immunization = (Immunization) immunizations.get(2);
assertThat(immunization.getEducation()).hasSize(3);
// Has both DocumentType and Reference records. DocumentType will be used.
checkImmunizationEducation(immunization.getEducation().get(0), "Hep B, CC3a UF", "2017-03-03", "2017-03-05");
// Has only DocumentType record. DocumentType will be used.
checkImmunizationEducation(immunization.getEducation().get(1), "Hep B, CC4 UF", "2017-04-03", "2017-04-05");
// Has no DocumentType nor Reference record nor PublicationDate. 'unspecified' is used as DocumentType.
checkImmunizationEducation(immunization.getEducation().get(2), "unspecified", null, "2017-06-05");
}
use of org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet in project kindling by HL7.
the class ResourceNameConceptMapGenerator method genMap.
private static void genMap(String src, String srcV, String dst, String dstV, Sheet xls, String dstFolder, String name, Date date) throws FileNotFoundException, IOException {
ConceptMap cm = new ConceptMap();
cm.setId(name);
cm.setUrl("http://hl7.org/fhir/" + name);
cm.setName("ResourceNames" + src.toUpperCase() + "to" + dst.toUpperCase());
cm.setTitle("Resource Names " + src.toUpperCase() + " to " + dst.toUpperCase());
cm.setDescription("This map contains a mapping between resources from " + src + " to " + dst);
cm.setStatus(PublicationStatus.ACTIVE);
cm.setDate(date);
ConceptMapGroupComponent grp = cm.addGroup();
grp.setSource("http://hl7.org/fhir/" + srcV + "/resource-types");
grp.setTarget("http://hl7.org/fhir/" + dstV + "/resource-types");
for (int row = 0; row < xls.rows.size(); row++) {
String s = xls.getColumn(row, src);
String t = xls.getColumn(row, dst);
if (!Utilities.noString(s) && (Character.isAlphabetic(s.charAt(0)) || s.startsWith("->") || s.startsWith("("))) {
String c = s.startsWith("->") ? s.substring(2).trim() : s.startsWith("(") ? s.substring(1, s.length() - 1) : s;
SourceElementComponent map = elementForCode(grp, c);
if (Utilities.noString(t))
map.addTarget().setRelationship(ConceptMapRelationship.NOTRELATEDTO);
else if (t.startsWith("("))
map.addTarget().setCode(t.substring(1, t.length() - 1)).setRelationship(ConceptMapRelationship.RELATEDTO);
else if (t.startsWith("->"))
map.addTarget().setCode(t.substring(2).trim()).setRelationship(ConceptMapRelationship.SOURCEISBROADERTHANTARGET);
else if (t.startsWith(":"))
map.addTarget().setComment(t.substring(1).trim()).setRelationship(ConceptMapRelationship.NOTRELATEDTO);
else if (s.startsWith("-<"))
map.addTarget().setCode(t).setRelationship(ConceptMapRelationship.SOURCEISNARROWERTHANTARGET);
else if (s.startsWith("("))
map.addTarget().setCode(t).setRelationship(ConceptMapRelationship.RELATEDTO);
else
map.addTarget().setCode(t).setRelationship(ConceptMapRelationship.EQUIVALENT);
}
}
//
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dstFolder, "ConceptMap-" + name + ".json")), cm);
}
use of org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet in project kindling by HL7.
the class BindingsFixer method processCodes.
private static void processCodes(CodeSystem cs, Sheet sheet) throws Exception {
Map<String, ConceptDefinitionComponent> concepts = new HashMap<>();
for (int row = 0; row < sheet.rows.size(); row++) {
if (Utilities.noString(sheet.getColumn(row, "System"))) {
ConceptDefinitionComponent cc = new ConceptDefinitionComponent();
cc.setUserData("id", sheet.getColumn(row, "Id"));
cc.setCode(sheet.getColumn(row, "Code"));
concepts.put(cc.getCode(), cc);
cc.setDisplay(sheet.getColumn(row, "Display"));
if (sheet.getColumn(row, "Abstract").toUpperCase().equals("Y"))
CodeSystemUtilities.setNotSelectable(cs, cc);
if (cc.hasCode() && !cc.hasDisplay())
cc.setDisplay(Utilities.humanize(cc.getCode()));
cc.setDefinition(Utilities.appendPeriod(sheet.getColumn(row, "Definition")));
if (!Utilities.noString(sheet.getColumn(row, "Comment")))
ToolingExtensions.addCSComment(cc, sheet.getColumn(row, "Comment"));
String parent = sheet.getColumn(row, "Parent");
if (Utilities.noString(parent))
cs.addConcept(cc);
else {
concepts.get(parent).addConcept(cc);
}
}
}
}
use of org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet in project kindling by HL7.
the class BindingsFixer method processSheet.
private static void processSheet(XLSXmlParser xls, Sheet sheet, String dir, String sfx) throws Exception {
for (int row = 0; row < sheet.rows.size(); row++) {
String bindingName = sheet.getColumn(row, "Binding Name");
if (Utilities.noString(bindingName) || bindingName.startsWith("!"))
continue;
BindingMethod method = BindingsParser.readBinding(sheet.getColumn(row, "Binding"), "??");
String ref = sheet.getColumn(row, "Reference");
if (method == BindingMethod.CodeList) {
if (ref.startsWith("#valueset-"))
throw new Exception("don't start code list references with #valueset-");
String vfn = Utilities.path(dir, "valueset-" + sfx + ref.substring(1) + ".xml");
String cfn = Utilities.path(dir, "codesystem-" + sfx + ref.substring(1) + ".xml");
File vf = new File(vfn);
File cf = new File(cfn);
if (!vf.exists()) {
System.out.println("Produce " + vfn);
ValueSet vs = ValueSetUtilities.makeShareable(new ValueSet());
vs.setVersion(Constants.VERSION);
vs.setId(sfx + ref.substring(1));
vs.setUrl("http://hl7.org/fhir/ValueSet/" + sfx + ref.substring(1));
vs.setDescription(sheet.getColumn(row, "Description"));
vs.setName(bindingName);
vs.setStatus(PublicationStatus.fromCode(sheet.getColumn(row, "Status")));
vs.setCopyright(sheet.getColumn(row, "Copyright"));
Sheet css = xls.getSheets().get(ref.substring(1));
if (css == null) {
throw new Exception("Error parsing binding " + bindingName + ": code list reference '" + ref + "' not resolved");
}
CodeSystem cs = CodeSystemUtilities.makeShareable(new CodeSystem());
cs.setVersion(Constants.VERSION);
cs.setId(sfx + ref.substring(1));
cs.setUrl("http://hl7.org/fhir/" + sfx + ref.substring(1));
cs.setDescription(sheet.getColumn(row, "Description"));
cs.setName(bindingName);
cs.setStatus(PublicationStatus.fromCode(sheet.getColumn(row, "Status")));
cs.setCopyright(sheet.getColumn(row, "Copyright"));
vs.getCompose().addInclude().setSystem(cs.getUrl());
processCodes(cs, css);
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(vf), vs);
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(cf), cs);
}
}
}
}
use of org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet in project kindling by HL7.
the class BindingsFixer method checkBindings.
private static void checkBindings(File f) throws Exception {
System.out.println(f.getName());
XLSXmlParser xls = new XLSXmlParser(new FileInputStream(f), f.getName());
Sheet sheet = xls.getSheets().get("Bindings");
if (sheet != null) {
String sfx = "";
processSheet(xls, sheet, Utilities.getDirectoryForFile(f.getAbsolutePath()), sfx);
}
}
Aggregations