Search in sources :

Example 81 with Address

use of org.hl7.fhir.r4b.model.Address in project org.hl7.fhir.core by hapifhir.

the class ProfileUtilitiesTests method testSlicingTask8742.

private void testSlicingTask8742() throws EOperationOutcome, Exception {
    StructureDefinition focus = new StructureDefinition();
    StructureDefinition base = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Organization").copy();
    focus.setUrl(Utilities.makeUuidUrn());
    focus.setBaseDefinition(base.getUrl());
    focus.setType(base.getType());
    focus.setDerivation(TypeDerivationRule.CONSTRAINT);
    ElementDefinition id = focus.getDifferential().addElement();
    id.setPath("Organization.address");
    id.setMin(1);
    id.setMax("1");
    id.setMustSupport(true);
    id = focus.getDifferential().addElement();
    id.setPath("Organization.address.extension");
    id.setSliceName("USLabCountycodes");
    id.getSlicing().setOrdered(false).setRules(SlicingRules.OPEN).addDiscriminator().setPath("url").setType(DiscriminatorType.VALUE);
    id.setShort("County/Parish FIPS codes");
    id.setDefinition("County/Parish FIPS codes.");
    id.setRequirements("County/Parish Code SHALL use FIPS 6-4  ( INCITS 31:2009).");
    id.setMin(0);
    id.setMax("1");
    id.addType().setCode("Extension").setProfile("http://hl7.org/fhir/StructureDefinition/us-core-county");
    id.setMustSupport(true);
    id.getBinding().setStrength(BindingStrength.REQUIRED).setDescription("FIPS codes for US counties and county equivalent entities.").setValueSet(new Reference().setReference("http://hl7.org/fhir/ValueSet/fips-county"));
    List<ValidationMessage> messages = new ArrayList<ValidationMessage>();
    new ProfileUtilities(context, messages, null).generateSnapshot(base, focus, focus.getUrl(), "Simple Test");
    // 14 for address with one sliced extension
    boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size() - 13;
    if (!ok) {
        compareXml(base, focus);
        throw new FHIRException("Snap shot generation test 8742 failed");
    } else
        System.out.println("Snap shot generation test 8742 passed");
}
Also used : StructureDefinition(org.hl7.fhir.dstu3.model.StructureDefinition) ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) ProfileUtilities(org.hl7.fhir.dstu3.conformance.ProfileUtilities) Reference(org.hl7.fhir.dstu3.model.Reference) ArrayList(java.util.ArrayList) ElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 82 with Address

use of org.hl7.fhir.r4b.model.Address in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeRelatedPerson.

protected void composeRelatedPerson(Complex parent, String parentType, String name, RelatedPerson element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "RelatedPerson", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "RelatedPerson", "identifier", element.getIdentifier().get(i), i);
    if (element.hasActiveElement())
        composeBoolean(t, "RelatedPerson", "active", element.getActiveElement(), -1);
    if (element.hasPatient())
        composeReference(t, "RelatedPerson", "patient", element.getPatient(), -1);
    for (int i = 0; i < element.getRelationship().size(); i++) composeCodeableConcept(t, "RelatedPerson", "relationship", element.getRelationship().get(i), i);
    for (int i = 0; i < element.getName().size(); i++) composeHumanName(t, "RelatedPerson", "name", element.getName().get(i), i);
    for (int i = 0; i < element.getTelecom().size(); i++) composeContactPoint(t, "RelatedPerson", "telecom", element.getTelecom().get(i), i);
    if (element.hasGenderElement())
        composeEnum(t, "RelatedPerson", "gender", element.getGenderElement(), -1);
    if (element.hasBirthDateElement())
        composeDate(t, "RelatedPerson", "birthDate", element.getBirthDateElement(), -1);
    for (int i = 0; i < element.getAddress().size(); i++) composeAddress(t, "RelatedPerson", "address", element.getAddress().get(i), i);
    for (int i = 0; i < element.getPhoto().size(); i++) composeAttachment(t, "RelatedPerson", "photo", element.getPhoto().get(i), i);
    if (element.hasPeriod())
        composePeriod(t, "RelatedPerson", "period", element.getPeriod(), -1);
    for (int i = 0; i < element.getCommunication().size(); i++) composeRelatedPersonRelatedPersonCommunicationComponent(t, "RelatedPerson", "communication", element.getCommunication().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 83 with Address

use of org.hl7.fhir.r4b.model.Address in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireBuilder method processDataType.

private void processDataType(StructureDefinition profile, QuestionnaireItemComponent group, ElementDefinition element, String path, TypeRefComponent t, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> answerGroups, List<ElementDefinition> parents) throws FHIRException {
    String tc = t.getWorkingCode();
    if (tc.equals("code"))
        addCodeQuestions(group, element, path, answerGroups);
    else if (Utilities.existsInList(tc, "string", "id", "oid", "uuid", "markdown"))
        addStringQuestions(group, element, path, answerGroups);
    else if (Utilities.existsInList(tc, "uri", "url", "canonical"))
        addUriQuestions(group, element, path, answerGroups);
    else if (tc.equals("boolean"))
        addBooleanQuestions(group, element, path, answerGroups);
    else if (tc.equals("decimal"))
        addDecimalQuestions(group, element, path, answerGroups);
    else if (tc.equals("dateTime") || tc.equals("date"))
        addDateTimeQuestions(group, element, path, answerGroups);
    else if (tc.equals("instant"))
        addInstantQuestions(group, element, path, answerGroups);
    else if (tc.equals("time"))
        addTimeQuestions(group, element, path, answerGroups);
    else if (tc.equals("CodeableConcept"))
        addCodeableConceptQuestions(group, element, path, answerGroups);
    else if (tc.equals("Period"))
        addPeriodQuestions(group, element, path, answerGroups);
    else if (tc.equals("Ratio"))
        addRatioQuestions(group, element, path, answerGroups);
    else if (tc.equals("HumanName"))
        addHumanNameQuestions(group, element, path, answerGroups);
    else if (tc.equals("Address"))
        addAddressQuestions(group, element, path, answerGroups);
    else if (tc.equals("ContactPoint"))
        addContactPointQuestions(group, element, path, answerGroups);
    else if (tc.equals("Identifier"))
        addIdentifierQuestions(group, element, path, answerGroups);
    else if (tc.equals("integer") || tc.equals("positiveInt") || tc.equals("unsignedInt"))
        addIntegerQuestions(group, element, path, answerGroups);
    else if (tc.equals("Coding"))
        addCodingQuestions(group, element, path, answerGroups);
    else if (Utilities.existsInList(tc, "Quantity", "Count", "Age", "Duration", "Distance", "Money"))
        addQuantityQuestions(group, element, path, answerGroups);
    else if (tc.equals("Money"))
        addMoneyQuestions(group, element, path, answerGroups);
    else if (tc.equals("Reference"))
        addReferenceQuestions(group, element, path, t.getTargetProfile(), answerGroups);
    else if (tc.equals("Duration"))
        addDurationQuestions(group, element, path, answerGroups);
    else if (tc.equals("base64Binary"))
        addBinaryQuestions(group, element, path, answerGroups);
    else if (tc.equals("Attachment"))
        addAttachmentQuestions(group, element, path, answerGroups);
    else if (tc.equals("Age"))
        addAgeQuestions(group, element, path, answerGroups);
    else if (tc.equals("Range"))
        addRangeQuestions(group, element, path, answerGroups);
    else if (tc.equals("Timing"))
        addTimingQuestions(group, element, path, answerGroups);
    else if (tc.equals("Annotation"))
        addAnnotationQuestions(group, element, path, answerGroups);
    else if (tc.equals("SampledData"))
        addSampledDataQuestions(group, element, path, answerGroups);
    else if (tc.equals("Extension")) {
        if (t.hasProfile())
            addExtensionQuestions(profile, group, element, path, t.getProfile().get(0).getValue(), answerGroups, parents);
    } else if (tc.equals("SampledData"))
        addSampledDataQuestions(group, element, path, answerGroups);
    else if (!tc.equals("Narrative") && !tc.equals("Resource") && !tc.equals("Meta") && !tc.equals("Signature")) {
        StructureDefinition sd = context.fetchTypeDefinition(tc);
        if (sd == null)
            throw new NotImplementedException("Unhandled Data Type: " + tc + " on element " + element.getPath());
        buildGroup(group, sd, sd.getSnapshot().getElementFirstRep(), parents, answerGroups);
    }
}
Also used : StructureDefinition(org.hl7.fhir.r4b.model.StructureDefinition) NotImplementedException(org.apache.commons.lang3.NotImplementedException)

Example 84 with Address

use of org.hl7.fhir.r4b.model.Address in project org.hl7.fhir.core by hapifhir.

the class StructureDefinitionSpreadsheetGenerator method configureSheet.

public void configureSheet(Sheet sheet, StructureDefinition sd) throws IOException {
    for (int i = 0; i < 34; i++) {
        sheet.autoSizeColumn(i);
    }
    sheet.setColumnHidden(2, true);
    sheet.setColumnHidden(3, true);
    sheet.setColumnHidden(30, true);
    sheet.setColumnHidden(31, true);
    sheet.setColumnHidden(32, true);
    sheet.setColumnWidth(9, columnPixels(20));
    sheet.setColumnWidth(11, columnPixels(100));
    sheet.setColumnWidth(12, columnPixels(100));
    sheet.setColumnWidth(13, columnPixels(100));
    sheet.setColumnWidth(15, columnPixels(20));
    sheet.setColumnWidth(16, columnPixels(20));
    sheet.setColumnWidth(17, columnPixels(20));
    sheet.setColumnWidth(18, columnPixels(20));
    sheet.setColumnWidth(34, columnPixels(100));
    int i = titles.length - 1;
    for (StructureDefinitionMappingComponent map : sd.getMapping()) {
        i++;
        sheet.setColumnWidth(i, columnPixels(50));
        sheet.autoSizeColumn(i);
    // sheet.setColumnHidden(i,  true);
    }
    sheet.createFreezePane(2, 1);
    if (hideMustSupportFalse) {
        SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
        String address = "A2:AI" + Math.max(Integer.valueOf(sheet.getLastRowNum()), 2);
        CellRangeAddress[] regions = { CellRangeAddress.valueOf(address) };
        ConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule("$G2<>\"Y\"");
        PatternFormatting fill1 = rule1.createPatternFormatting();
        fill1.setFillBackgroundColor(IndexedColors.GREY_25_PERCENT.index);
        fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
        ConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule("$Q2<>\"\"");
        FontFormatting font = rule2.createFontFormatting();
        font.setFontColorIndex(IndexedColors.GREY_25_PERCENT.index);
        font.setFontStyle(true, false);
        sheetCF.addConditionalFormatting(regions, rule1, rule2);
        sheet.setAutoFilter(new CellRangeAddress(0, sheet.getLastRowNum(), 0, titles.length + sd.getMapping().size() - 1));
        XSSFSheet xSheet = (XSSFSheet) sheet;
        CTAutoFilter sheetFilter = xSheet.getCTWorksheet().getAutoFilter();
        CTFilterColumn filterColumn1 = sheetFilter.addNewFilterColumn();
        filterColumn1.setColId(6);
        CTCustomFilters filters = filterColumn1.addNewCustomFilters();
        CTCustomFilter filter1 = filters.addNewCustomFilter();
        filter1.setOperator(STFilterOperator.NOT_EQUAL);
        filter1.setVal(" ");
        CTFilterColumn filterColumn2 = sheetFilter.addNewFilterColumn();
        filterColumn2.setColId(26);
        CTFilters filters2 = filterColumn2.addNewFilters();
        filters2.setBlank(true);
        // We have to apply the filter ourselves by hiding the rows:
        for (Row row : sheet) {
            if (row.getRowNum() > 0 && (!row.getCell(6).getStringCellValue().equals("Y") || !row.getCell(26).getStringCellValue().isEmpty())) {
                ((XSSFRow) row).getCTRow().setHidden(true);
            }
        }
    }
    sheet.setActiveCell(new CellAddress(sheet.getRow(1).getCell(0)));
}
Also used : StructureDefinitionMappingComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent) CTAutoFilter(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAutoFilter) ConditionalFormattingRule(org.apache.poi.ss.usermodel.ConditionalFormattingRule) FontFormatting(org.apache.poi.ss.usermodel.FontFormatting) PatternFormatting(org.apache.poi.ss.usermodel.PatternFormatting) CellAddress(org.apache.poi.ss.util.CellAddress) XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) CTFilterColumn(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFilterColumn) SheetConditionalFormatting(org.apache.poi.ss.usermodel.SheetConditionalFormatting) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow) Row(org.apache.poi.ss.usermodel.Row) CTCustomFilters(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCustomFilters) CTCustomFilter(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCustomFilter) CTFilters(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFilters)

Example 85 with Address

use of org.hl7.fhir.r4b.model.Address in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeCapabilityStatementCapabilityStatementMessagingEndpointComponent.

protected void composeCapabilityStatementCapabilityStatementMessagingEndpointComponent(Complex parent, String parentType, String name, CapabilityStatement.CapabilityStatementMessagingEndpointComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "endpoint", name, element, index);
    if (element.hasProtocol())
        composeCoding(t, "CapabilityStatement", "protocol", element.getProtocol(), -1);
    if (element.hasAddressElement())
        composeUrl(t, "CapabilityStatement", "address", element.getAddressElement(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Aggregations

Address (org.hl7.fhir.r4.model.Address)75 Test (org.junit.Test)47 Patient (org.hl7.fhir.r4.model.Patient)30 Test (org.junit.jupiter.api.Test)30 PersonAddress (org.openmrs.PersonAddress)27 HumanName (org.hl7.fhir.r4.model.HumanName)24 Identifier (org.hl7.fhir.r4.model.Identifier)23 ArrayList (java.util.ArrayList)22 Address (org.hl7.fhir.dstu3.model.Address)22 Path (javax.ws.rs.Path)20 Produces (javax.ws.rs.Produces)20 NotImplementedException (org.apache.commons.lang3.NotImplementedException)19 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)19 Location (org.hl7.fhir.r4.model.Location)13 Organization (org.hl7.fhir.r4.model.Organization)13 InputStream (java.io.InputStream)12 IdType (org.hl7.fhir.dstu3.model.IdType)12 Patient (org.hl7.fhir.dstu3.model.Patient)12 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)12 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)12