Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PT-3663: Modify Case Resolution and Diagnosis sections #2636

Merged
merged 14 commits into from Jul 24, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+1,157 −470
Diff settings

Always

Just for now

@@ -73,6 +73,11 @@
<artifactId>patient-data-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>patient-data-default-impl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>xwiki-platform-users-api</artifactId>
@@ -25,6 +25,7 @@
import org.phenotips.data.Patient;
import org.phenotips.data.PatientData;
import org.phenotips.data.PhenoTipsDate;
import org.phenotips.data.internal.SolvedData;
import org.phenotips.translation.TranslationManager;
import org.phenotips.vocabulary.internal.solr.SolrVocabularyTerm;

@@ -1363,23 +1364,32 @@ public DataSection isSolvedBody(Patient patient)
return null;
}
DataSection bodySection = new DataSection();
PatientData<String> patientData = patient.getData("solved");
PatientData<SolvedData> patientData = patient.getData("solved");
SolvedData data = patientData != null ? patientData.getValue() : null;

int x = 0;
if (present.contains("solved")) {
String solved = patientData != null ? patientData.get("solved") : null;
if (present.contains(SolvedData.STATUS_PROPERTY_NAME)) {
String solved = data != null ? data.getStatus() : null;

This comment has been minimized.

Copy link
@marta-

marta- May 16, 2018

Member

We're on Java 8, so now you can do String solved = data?.getStatus();

This comment has been minimized.

Copy link
@veronikaslc

veronikaslc May 16, 2018

Author Contributor

It doesn't compile..

This comment has been minimized.

Copy link
@marta-

marta- May 16, 2018

Member

Sorry, I meant to also give the link to the Optional documentation but forgot. Here's an article: http://www.oracle.com/technetwork/articles/java/java8-optional-2175753.html

This comment has been minimized.

Copy link
@veronikaslc

veronikaslc May 16, 2018

Author Contributor

Still don't see how to use data?.getStatus() syntax with Optional or anything that would be as easy as ?., it seems to be from another language. In general I personally find explicit null checks more readable.

This comment has been minimized.

Copy link
@allasm

allasm May 16, 2018

Member

?. syntax would be ideal in this case, but it seems to be a Groovy (?) and not Java construct? At the same time IMHO in simple cases like this Optional does not add much clarity or safety and is actually longer/harder to comprehend. IMHO it makes more sense for deep embedded values like in the example from the link above and/or when the optional value in question is used much further or much more in the code (so all those other places can benefit from the optional nature of the value or are forced to treat it as optional, even if by that line of code it is no longer obvious)

DataCell cell = new DataCell(solved != null ? ConversionHelpers.strIntegerToStrBool(solved) : "", x, 0);
bodySection.addCell(cell);
x++;
}
if (present.contains("solved__pubmed_id")) {
String pubmedId = patientData != null ? patientData.get("solved__pubmed_id") : null;
DataCell cell = new DataCell(pubmedId != null ? pubmedId : "", x, 0);
bodySection.addCell(cell);
x++;

if (present.contains(SolvedData.PUBMED_ID_PROPERTY_NAME)) {
List<String> pubmedIds = data != null ? data.getPubmedIds() : Collections.emptyList();
if (!pubmedIds.isEmpty()) {
int y = 0;
for (String id : pubmedIds) {
DataCell cell = new DataCell(StringUtils.isBlank(id) ? "" : id, x, y);
bodySection.addCell(cell);
y++;
}
x++;
}
}
if (present.contains("solved__notes")) {
String solvedNotes = patientData != null ? patientData.get("solved__notes") : null;

if (present.contains(SolvedData.NOTES_PROPERTY_NAME)) {
String solvedNotes = data != null ? data.getNotes() : null;
for (DataCell cell : ConversionHelpers.preventOverflow(solvedNotes, x, 0)) {
cell.setMultiline();
bodySection.addCell(cell);
@@ -44,14 +44,17 @@
// TODO: check what is the difference between 1.1 and 1.2
public static final String VERSION_1_2 = "1.2";

/** new gene status */
/** version 1.3: new tested negative gene status */
public static final String VERSION_1_3 = "1.3";

public static final String CURRENT_PUSH_PROTOCOL_VERSION = VERSION_1_3;
/** version 1.4: shift from single Pubmed ID value to multiple Pubmed IDs */
public static final String VERSION_1_4 = "1.4";

public static final String CURRENT_PUSH_PROTOCOL_VERSION = VERSION_1_4;

// list of protocol versions that the current server can read data from
public static final List<String> COMPATIBLE_CLIENT_PROTOCOL_VERSIONS =
Arrays.asList(VERSION_1, VERSION_1_1, VERSION_1_2, VERSION_1_3);
Arrays.asList(VERSION_1, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4);

// list of versions which can push even if required consents have not been checked
public static final List<String> ALLOW_NO_CONSENTS_PROTOCOL_VERSIONS = Arrays.asList(VERSION_1);
@@ -67,16 +70,21 @@

public static final Incompatibility GENE_STATUS_INCOMPAT = new Incompatibility("genes", "genes_v1");

public static final Incompatibility SOLVED_STATUS_INCOMPAT = new Incompatibility("solved", "solved_v1");

// a list of known (fixable) incompatibilities in the supported past versions of push protocol
public static final Map<String, List<Incompatibility>> INCOMPATIBILITIES_IN_OLD_PROTOCOL_VERSIONS =
new HashMap<String, List<Incompatibility>>();
static {
INCOMPATIBILITIES_IN_OLD_PROTOCOL_VERSIONS.put(VERSION_1,
Arrays.asList(BIRTH_DATE_INCOMPAT, DEATH_DATE_INCOMPAT, EXAM_DATE_INCOMPAT, GENE_STATUS_INCOMPAT));
Arrays.asList(BIRTH_DATE_INCOMPAT, DEATH_DATE_INCOMPAT, EXAM_DATE_INCOMPAT, GENE_STATUS_INCOMPAT,
SOLVED_STATUS_INCOMPAT));
INCOMPATIBILITIES_IN_OLD_PROTOCOL_VERSIONS.put(VERSION_1_1,
Arrays.asList(BIRTH_DATE_INCOMPAT, DEATH_DATE_INCOMPAT, EXAM_DATE_INCOMPAT, GENE_STATUS_INCOMPAT));
Arrays.asList(BIRTH_DATE_INCOMPAT, DEATH_DATE_INCOMPAT, EXAM_DATE_INCOMPAT, GENE_STATUS_INCOMPAT,
SOLVED_STATUS_INCOMPAT));
INCOMPATIBILITIES_IN_OLD_PROTOCOL_VERSIONS.put(VERSION_1_2,
Arrays.asList(GENE_STATUS_INCOMPAT));
Arrays.asList(GENE_STATUS_INCOMPAT, SOLVED_STATUS_INCOMPAT));
INCOMPATIBILITIES_IN_OLD_PROTOCOL_VERSIONS.put(VERSION_1_3, Arrays.asList(SOLVED_STATUS_INCOMPAT));
}

// list of old push protocol versions which are explicitly not supported. The idea is that clients are
@@ -88,7 +96,7 @@
// Those are listed explicitly because there is no way to tell if a version is old or new
// unless it is explicitly listed
public static final List<String> COMPATIBLE_OLD_SERVER_PROTOCOL_VERSIONS =
Arrays.asList(VERSION_1, VERSION_1_1, VERSION_1_2);
Arrays.asList(VERSION_1, VERSION_1_1, VERSION_1_2, VERSION_1_3);

// =========================================================================

Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.