OOP: Modelling class to match external file fields (e.g. fillable PDF) - oop

I'm currently working on a program that takes some measurements, adds them to a PDF and outputs it.
The user chooses which part of the equipment (e.g. X, Y and Z) is tested, and what test is done (e.g. a, b, c, d).
Each equipment has a different PDF form with fields. Each PDF form is split into 3 different sections, first being shared by all forms (e.g. userName, date). The last two are sections for tests.
In this example, X and Y both share a and b. Z has c and d, where d is a variation of a. All of these sections have some values that are in common, and some that are not.
The program is functional, and outputs the PDFs however an object representing the PDF has attribute names hardcoded in to match the PDF field names. There is one class, with attributes that all PDFs have, and also an attribute for the test component (i.e. can hold fields of a, b, etc). Several classes are defined to represent the test sections.
What would be the best way to model this, so it allows for future cases where someone might slightly change the standard? E.g. a new PDF form with different field names (but that still needs the same values filled in)

Related

ms access: Empty subform query causes empty parent control reference

The Problem
I have two continuous subforms A and B in a tabular layout on a main form C. The first has the names of some chemicals, the second has corresponding info on those chemicals. I have a field D on C that takes the value of the primary key [stoff_id] of A for the current record. B is linked to D, so it shows all corresponding records for the currently selected chemical. Here a quick overview of the database:
DB Relationships
The query for A [stoffe_abfrage subform]:
SELECT chemikalien_tabelle.stoff_id, chemikalien_tabelle.bezeichnung,
chemikalien_tabelle.einsatzgebiet, kategorie_tabelle.kategorie
FROM kategorie_tabelle INNER JOIN chemikalien_tabelle ON
kategorie_tabelle.[kategorie_id] = chemikalien_tabelle.[kategorie_id];
The query for B [tmb_abfrage subform]:
SELECT tmb_tabelle.version, tmb_tabelle.datum_aktualisiert,
tmb_tabelle.datum_upload, sprachen_tabelle.bezeichnung,
tmb_link.stoff_id, tmb_link.tmb_id, tmb_tabelle.datei.FileType,
tmb_tabelle.datei
FROM (sprachen_tabelle INNER JOIN tmb_tabelle ON sprachen_tabelle.
[sprache_id] = tmb_tabelle.[sprache_id]) INNER JOIN tmb_link ON
tmb_tabelle.[tmb_id] = tmb_link.[tmb_id];
The value of the control D [MainLinkStoff] on C:
=[stoffe_abfrage subform].[Formular]![stoff_id]
(B is linked from [stoff_id] on B, to D)
I want to use the primary key value on A in a button event on B, so I need a way to reference it. Unfortunately, referencing the primary key (stoff_id) on A from B only works if B is not empty. If there are no records on B, then the reference of stoff_id on A from B turns empty, event though the value of the control on A itself is nonempty.
What I have tried:
I tried getting [stoff_id] from A and I have
also tried getting the value from D,
but both have resulted in the same issue. When B
currently has no records, I get a runtime error because of an empty
value.
I was curious why this would be the case if getting the value
directly from D for example, since that field has a
value and is never empty. So I made a dummy textbox [dummyB] on
B where my button is located
in the header section and set the value to be equal to
D.
for the second test I tried 2 different approaches:
Get D from C via parent
=[Me].[Parent].[MainLinkStoff]
Get the D value manually from forms
=Formulare![HUB]![NavigationSubform].Formular![MainLinkStoff]
In both approaches, if the chemical already has records in B, the dummy and D both display the value of the primary key correctly and are identical. If the chemical has no current records in B, D on the parent form displays correctly but the dummy is suddenly empty too. Why is this? Here some images of what I mean. D is in the top middle of the form C, the dummy adjacent to it on the right subform B. A is on the left, B on the right. (invisible borders)
Existing records
No existing records
So, I found the issue. I was working on the project from 2 different computers. One used the German language version of Access, the other the English language one. Object references created by wizards and internal tools in those versions use different formulations ([Forms]=[Formulare] etc.). What ended up happening was that some object references in SQL queries, criteria etc. were in German, the objects themselves had further references that were in English, which in turn referenced others that were in German again. This worked most of the time, but quite often, especially in fringe cases, it resulted in Access messing up the references completely. For example in cases where queries or field values were returned empty. I am not entirely sure how Access manages the conversion of references in different language versions, but there seem to be issues with it when mixing them. The solution was to choose one language version to use for references, and stick with that formulation for the entire project. I tested both, and either German or English work fine, on either version of accesss. Mixing them up within the same project however, creates problems.

Comparing two datasets in SSRS

I'm looking to compare two datasets with each other. In an ideal world, I'd like to have it to show a green item if the data matches between the two. I have created two different GDocs files to get the code out there, to prevent SO from dinging me on formatting.
The first dataset is from our program itself, it pulls everything from our application, and displays the information, based on company code. The second dataset is from an external source requiring validation. The main fields I am matching are "NPI Number (Type 1)" from DS1 vs. "NPI" from DS2. If there is a match to highlight in green the row from both sides of data.
Dataset 1
Dataset 2
You may need to use LookUp function and set that as a expression to fill the background color of a text box or row of a table
Sample Expression: =iif(Len(Lookup(Fields!NPI.Value, Fields!NPI.Value, Fields!ProviderName.Value, "DS1"))>0,"Green","Red")
I have created a sample here. Download entire content and run it.

Combining condition files

I am working on an experiment and have parts of it built using some coder and some builder, but am stuck on a spot. The experiment presents two different lists of words to people (list A and list B) and each word in it's respective list is randomly paired with a number at the beginning of the experiment. Psychopy shows both the word and the number to participants and it is important that after they are randomly paired the word-number pairs are then yoked for the remainder of the experiment. I have used coder to randomize the pairing and construct a conditions file for the two word lists on the fly. Builder then uses these constructed conditions files to present the stimuli (words and numbers).
This is the part where I'm stuck. After the two word lists and their paired numbers are presented, I need to present a subset of both lists A and B as well as a third list of word-number pairs that was not previously presented. So, for example, a person might see something like this during the experiment:
First presentation:
List A:
frank - 1, susan - 3
List B:
shoe - 2, dingy - 1
Second presentation:
frank - 1, shoe - 2, hotel - 4
The beginning of the experiment is where coder is used to create the word and number lists as well as write the two list's condition files. That code is below:
import random
import csv
studylista=["shoe","bear","balls","dingy"]
pointslista=[1,2,3,4]
listaRand=random.sample(studylista,len(studylista))
listapointsRand=random.sample(pointslista,len(pointslista))
with open('WordsandPointslista.csv','wb') as w:
writer=csv.writer(w)
writer.writerow(['studylista','pointslista'])
for i in range(len(listaRand)):
writer.writerow([listaRand[i],listapointsRand[i]])
studylistb=["frank","robert","daniel","susan"]
pointslistb=[1,2,3,4]
listbRand=random.sample(studylistb,len(studylistb))
listbpointsRand=random.sample(pointslistb,len(pointslistb))
with open('WordsandPointslistb.csv','wb') as w:
writer=csv.writer(w)
writer.writerow(['studylistb','pointslistb'])
for i in range(len(listbRand)):
writer.writerow([listbRand[i],listbpointsRand[i]])
I need a random subset of the two previously presented lists along with an additional list that has not been presented to be seen all together by the participant. The previous word-number pairings for the already seen lists also need to be preserved. I cannot seem to discover how to do this.
I currently have the two word-number lists presented in separate routines with loops around each one. I am trying to figure out how to create a third routine that will show only some of the previously seen word-number pairs along with some new word-number pairs.
Thanks.
In your code above, don't create two separate two-column CSV files, but combine them into a single four-column file. This file can be used in multiple loops. If I understand your design correctly, it would be used first in a loop to present all the 'A' word/number pairs, and then again in a second loop to present all the 'B' word/number pairs. Lastly, use it in a final loop to present just a subset of the 'A' & 'B' pairs. This subsetting is applied via the "Selected rows" field in the loop dialog. Randomisation is optional in the first two loops, as you have already shuffled the rows, but would likely be necessary in the third loop to avoid presenting rows in the same order as in the first two loops.
Then there is the question of how to handle the third set of word/number pairs. The easiest thing to do would be to simply create them at the same time as the A & B sets and stick them in the same CSV file. But in this case, you would need the same number of words and numbers, some of which wouldn't be presented due to only running through a subset in the final loop. The alternative is to have a second code component prior to the third loop which reads in the existing file, shuffles the rows, subsets it, and then adds the new columns. i.e. doing a lot of the things which the Builder loop would otherwise do for you, but allowing you not to 'waste' words, if that is important to you.
Lastly, I also simplified your code above. Builder already imports the numpy.radom.shuffle function, which is simpler than doing all the sampling and so on, and then you don't need to import the standard random library.

How to handle search for custom fields in form for FROM and TO fields?

I have just started implementing search module in a project, where I have a form with fixed fields consisting of combo box, text box, radio button etc (around 200 fields in multiple tabs), and later client should be able to add extra fields too. Once user fills the fields which he wants to search, that search criteria also he should be able to save. For all these reasons, for each field I am associating metadata in the following format.
"EntityName.attributeName": attributeValue
Once the user fills the form fields to search, I will validate form data and and only non empty fields metadata I am sending to server in JSON format. Everything is fine till now. But I am facing an issues now.
Using the metadata of each field I will create a new criteria for each field. but if there are fields where one field metadata depends on other field metadata I am struck.
In the form I have few special category fields in following format : for example DOB,
FROM DATE (meta data: entity1.dob)
TO DATE (meta data: entity1.dob)
both fields belongs to same entity and same column only field name in the UI is different
Like this I have around 20 fields which asks for FROM and TO to query the range (it need not be on date, for example no of bed rooms..it can be on integer, string etc)
My query formation should be in the following way depending on user search criteria. If user entered only FROM field of number of bed rooms then I have to query using EQUAL to operator in sql and if both mentioned then MORETHANEQUAL to for FROM field and LESSTHANEQUAL to for to field. So how I can handle this special case ?
like if he entered number of fields as 4 in TO field of number of bed rooms, then I have to query for houses having number of bed rooms equal to 4. but if in FROM he entered 3 and in To if he entered 7 then I have to query for houses having greater than or equal to 3 bed rooms and less than or equal to 7 bed rooms.
Since I have same metadata for these category fields also I am unable to proceed, to achieve this, what kind of metadata I need to prepare ?
How I can generalize this process to handle all the cases ?
my technology stack: ExtJs, Eclipse Link, spring.
and what are the best practices to follow to support custom fields adding feature in Forms in enterprise applications ?
Off of the top of my head, I would create wizards for these particular cases. So for example, have a custom wizard that allows the user to define a "from" field, a "to" field, and then the comparison operator in one action. This wizard could also be responsible for adding custom properties to the generated fields that could be used by your validation routine. So based on the combo of from, to, and operator, you could create a flexible validation mechanism for ensuring that correct values are entered, ranges are correct, whatever.
You might consider this "wizard" approach for all custom fields, in fact. I could see you predefining all the possible custom field types that could be used and create classes that can be used for those. The classes could be responsible not only for the field creation, but also for providing any custom validation, pre-submit transformation, etc. This approach would make adding new custom field types incredibly simple since all you'd have to do is follow the same implementation as the others that already exist, extend an existing one, etc.

Double data entry system using Infopath 2007 how to compare 2 infopath documents for differences?

How to compare 2 infopath documents craeted using double data entry system for
differences ?
We have a small project contains few infopath forms. Client is using double data entry system to reduce the errors. We are maintaining entry number in infopath form to seperate each entry.
Note: I know we can compare xml data
files of 2 documents. (xml data file
has field names like field1,field2 and
so on..while on form that field1
represent some meaninngful text) But
the question is we want to compare it
Visually side by side. Any difference
should highlight the field.
The easiest way I can think of is to use a different "comparison" form (instead of trying to alter the original). The new form can have two columns - two fields for each original field. You can load the two documents to compare into datasources (even make fields at the top which prompt for which two docs to compare). One shows in the left column and another in the right. Then just use conditional formatting to highlight where the first column doesn't match the second, or even hide the fields where they are identical so only the differences are visible.
If you want to get really fancy you can even let the user specify or change the values on the form and have them save back to the originals or create another new "merged" version.