diff --git a/docs/cases/PMID_30012084.txt b/docs/cases/PMID_30012084.txt new file mode 100644 index 0000000..92e3d90 --- /dev/null +++ b/docs/cases/PMID_30012084.txt @@ -0,0 +1,19 @@ +[source] +pmid = PMID:30012084 +title = The most 5' truncating homozygous mutation of WNT1 in siblings with osteogenesis imperfecta with a variable degree of brain anomalies: a case report +[diagnosis] +disease_id = OMIM:615220 +disease_label = Osteogenesis imperfecta, type XV +[text] +A 14-year-old Thai girl was born via cesarean section due to premature rupture of the membrane with a birth weight of 2500 g. +She is the first child of a consanguineous (second-degree relatives) couple. Both parents are healthy and have never had fractures. +During her first year of life, she had delayed motor development and growth failure. At one year of age, she could not sit by +herself and weighed 7.5 kg (< 3rd centile). She presented to our hospital at 14 months of age with fractures of both femora +without a history of significant trauma. She was found to have ptosis of both eyes with normal teeth but no blue sclerae. +She was small for her age. Her weight was 7.8 kg (3rd centile) and her length was 68 cm (< 3rd centile). Skeletal survey +showed diffuse osteopenia, multiple healed fractures of the right humoral shaft, both tibiae and fibulae. Spine radiograph showed +flattening and indentation of vertebral bodies (Fig. 1). +Radiological features of the proband. Imaging of the thoracic and lumbar spines at 14 months of age, (a) the +antero-posterior and (b) lateral views revealed depressed multiple vertebrae. +Figures c-f showed imaging at 14 years of age of upper extremities (c-d) and lower extremities (e-f) revealing deformities +of humeri, left ulna and radius, right tibia and fibula, left tibia and fibula, respectively \ No newline at end of file diff --git a/docs/cases/PMID_30509212.txt b/docs/cases/PMID_30509212.txt new file mode 100644 index 0000000..e47dbbd --- /dev/null +++ b/docs/cases/PMID_30509212.txt @@ -0,0 +1,24 @@ +[source] +pmid = PMID:30509212 +title = Novel KDM6A splice-site mutation in kabuki syndrome with congenital hydrocephalus: a case report +[diagnosis] +disease_id = OMIM:300867 +disease_label = Kabuki syndrome 2 +[text] +A 2 months and 13 days old male was hospitalized in the neonatology department of our hospital for postnatal growth retardation +on 20 February, 2017. The infant was spontaneous breech delivery at the 36th week plus 1 day of gestation with a +weight of 2.8 kg and head circumference of 31 cm. The Apgar scores of the infant all were 8 at 1, 5, and 10 min. +The infant was the third child of a 29-year-old mother who had fewer dysmorphic features and had two unaffected older sisters. +Before the infant was born, magnetic resonance imaging (MRI) results showed that enlarged lateral ventricles (Fig. 1), +this indicated congenital hydrocephalus. +After admission to our hospital, physical examination showed that the patient’s growth and development level was of +below the normal range 3rd centiles at height (~52 cm), weight (~2.9 kg) and head circumference (~33.5 cm) in accordance +with the new WHO (2006) Child growth standards [13], suggesting postnatal onset of growth retardation. +The patient had an inability to lift the head and weak crying. The patient couldn’t amuse by physician, and couldn’t accomplish +the tests of audio and visual tracking. However, The patient presented with recognizable facial features, +including sparse eyebrows (Fig. 2a), a depressed nasal tip (Fig. 2b), long palpebral fissures with eversion of +the lateral part of the lower eyelid (Fig. 2c), large prominent ears with low set ears (Fig. 2d), micrognathia (Fig. 2e), +gingival thickening and a high palate with cleft (Fig. 2f). In addition, head computed tomography (CT) scan revealed +hydrocephalus (Fig. 3), ultrasonography showed developmental dysplasia of hip (Fig. 4). +The results of cardiopulmonary and hepatolienal examination were normal. The patient had hypotonia, no pathological reflex. +Liver and kidney functions, thyroid function, blood counts, electrolytes were normal. \ No newline at end of file diff --git a/docs/cases/PMID_30643655.txt b/docs/cases/PMID_30643655.txt new file mode 100644 index 0000000..7cb47d3 --- /dev/null +++ b/docs/cases/PMID_30643655.txt @@ -0,0 +1,10 @@ +[source] +pmid = PMID:30643655 +title = Exome Sequencing: Mutilating Sensory Neuropathy with Spastic Paraplegia due to a Mutation in FAM134B Gene +[diagnosis] +disease_id = OMIM:613115 +disease_label = Neuropathy, hereditary sensory and autonomic, type IIB +[text] +Family 2: A 15-year-old boy (F2: IV: 1) presented with a history of frequent falls, unsteadiness, and pain insensitivity from an early age of 4 years [Figure 1(a)]. During the 5-year follow-up, he was hospitalized multiple times due to skin ulcers and osteomyelitis affecting his feet and toes. There was mild spasticity in the lower limbs with minimal pyramidal weakness (MRC4). Tendon reflexes were exaggerated with negative extensor response. + +Touch, pinprick, temperature and vibration revealed mild impairment in the distal part of the lower extremities for all the affected’s from family 1 while it was normal for family 2. In both families, applying strong pressure to the Achilles tendon or touching the exposed bony areas was not followed by an adequate pain reflex. Neurophysiological findings were normal or mildly abnormal in family 1 in the early stages but follow-up studies revealed sensory axonal polyneuropathy predominantly in the lower limbs while it was normal for family 2. Sympathetic skin response and beat to beat variation were also found to be normal for family 2 but abnormal in family 1 indicating involvement of the autonomic nervous system. Cerebral MRI as well as other hematological and biochemical investigations was normal \ No newline at end of file diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/model/HpoOnsetAge.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/model/HpoOnsetAge.java index 8f45301..5da83df 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/model/HpoOnsetAge.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/model/HpoOnsetAge.java @@ -15,12 +15,19 @@ public final class HpoOnsetAge implements PhenopacketAge { private final int totalDays; - /** - * One of Antenatal onset HP:0030674; Fetal onset HP:0011461; Late first trimester onset HP:0034199; - * Third trimester onset HP:0034197; Second trimester onset HP:0034198; Embryonal onset HP:0011460 + + private final static TermId antenatalOnset = TermId.of("HP:0030674"); + private final static TermId fetalOnset = TermId.of("HP:0011461"); + private final static TermId lateFirstTrimesterOnset = TermId.of("HP:0034199"); + private final static TermId secondTrimesterOnset = TermId.of("HP:0034198"); + private final static TermId thirdTrimesterOnset = TermId.of("HP:0034197"); + + private final static TermId embryonalOnset = TermId.of("HP:0011460"); + /** Note we are including antenatal in fetal, because this is almost certainly what is meant if embryonal is not + * specifically indicated */ - private final static Set fetalIds = Set.of(TermId.of(" HP:0030674"), TermId.of("HP:0011461"), TermId.of("HP:0034199"), - TermId.of("HP:0034197"), TermId.of("HP:0034198"), TermId.of("HP:0011460*")); + private final static Set fetalIds = Set.of(antenatalOnset, fetalOnset, + lateFirstTrimesterOnset, secondTrimesterOnset, thirdTrimesterOnset); public static HpoOnsetAge congenital() { return new HpoOnsetAge(congenitalOnset.getValue(), "Congenital onset"); @@ -150,4 +157,10 @@ public boolean equals(Object obj) { return iso.totalDays() == totalDays(); } + + @Override + public String toString() { + return String.format("[HpoOnsetAge]: %s (%s)", this.label, this.tid.getValue()); + } + } diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/PPKtBuildingBlockGenerator.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/BuildingBlockGenerator.java similarity index 97% rename from src/main/java/org/monarchinitiative/phenopacket2prompt/output/PPKtBuildingBlockGenerator.java rename to src/main/java/org/monarchinitiative/phenopacket2prompt/output/BuildingBlockGenerator.java index 7202781..1dcadfb 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/PPKtBuildingBlockGenerator.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/BuildingBlockGenerator.java @@ -7,7 +7,7 @@ * Provide the "building blocks" (i.e., text fragments) needed to generate the * texts in the various languages. */ -public interface PPKtBuildingBlockGenerator { +public interface BuildingBlockGenerator { // days, months, years -- format singular and plural forms String days(int d); diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/english/PPKtEnglishBuildingBlocks.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/english/EnglishBuildingBlocks.java similarity index 97% rename from src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/english/PPKtEnglishBuildingBlocks.java rename to src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/english/EnglishBuildingBlocks.java index f597bfe..7864123 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/english/PPKtEnglishBuildingBlocks.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/english/EnglishBuildingBlocks.java @@ -1,12 +1,12 @@ package org.monarchinitiative.phenopacket2prompt.output.impl.english; import org.monarchinitiative.phenopacket2prompt.model.Iso8601Age; -import org.monarchinitiative.phenopacket2prompt.output.PPKtBuildingBlockGenerator; +import org.monarchinitiative.phenopacket2prompt.output.BuildingBlockGenerator; import java.util.ArrayList; import java.util.List; -public class PPKtEnglishBuildingBlocks implements PPKtBuildingBlockGenerator { +public class EnglishBuildingBlocks implements BuildingBlockGenerator { @Override diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/english/PpktIndividualEnglish.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/english/PpktIndividualEnglish.java index d521cba..f432dc0 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/english/PpktIndividualEnglish.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/english/PpktIndividualEnglish.java @@ -2,13 +2,12 @@ import org.monarchinitiative.phenol.base.PhenolRuntimeException; import org.monarchinitiative.phenopacket2prompt.model.*; -import org.monarchinitiative.phenopacket2prompt.output.PPKtBuildingBlockGenerator; +import org.monarchinitiative.phenopacket2prompt.output.BuildingBlockGenerator; import org.monarchinitiative.phenopacket2prompt.output.PPKtIndividualInfoGenerator; import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.Set; /** @@ -32,17 +31,17 @@ */ public class PpktIndividualEnglish implements PPKtIndividualInfoGenerator { - private final PPKtBuildingBlockGenerator buildBlocks; + private final BuildingBlockGenerator buildBlocks; public PpktIndividualEnglish() { - buildBlocks = new PPKtEnglishBuildingBlocks(); + buildBlocks = new EnglishBuildingBlocks(); } /** * We begin our description with a sentence * - * @param individual - * @return + * @param individual the individual for whom we are creating a diagnostic prompt + * @return complete prompt for an LLM */ public String getIndividualDescription(PpktIndividual individual) { if (individual.annotationCount() == 0) { @@ -117,10 +116,12 @@ private String nameOfLifeStage(HpoOnsetAge hpoOnsetTermAge) { return "an " +buildBlocks.adolescentChild(); } else if (hpoOnsetTermAge.isNeonate()) { return "a " +buildBlocks.newborn(); - } else if (hpoOnsetTermAge.isAdult()) { + } else if (hpoOnsetTermAge.isYoungAdult()) { + return "a young adult"; // +buildBlocks.asYoungAdult(); + } else if (hpoOnsetTermAge.isAdult()) { return "an " +buildBlocks.adult(); } else { - throw new PhenolRuntimeException("Could not identify life stage name for HpoOnsetAge " + hpoOnsetTermAge); + throw new PhenolRuntimeException("Could not identify life stage name for HpoOnsetAge " + hpoOnsetTermAge.toString()); } } @@ -295,4 +296,5 @@ public String atAgeForVignette(PhenopacketAge ppktAge) { } + } diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanBuildingBlocks.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanBuildingBlocks.java new file mode 100644 index 0000000..ac13110 --- /dev/null +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanBuildingBlocks.java @@ -0,0 +1,326 @@ +package org.monarchinitiative.phenopacket2prompt.output.impl.german; + +import org.monarchinitiative.phenopacket2prompt.model.Iso8601Age; +import org.monarchinitiative.phenopacket2prompt.output.BuildingBlockGenerator; + +import java.util.ArrayList; +import java.util.List; + +public class GermanBuildingBlocks implements BuildingBlockGenerator { + @Override + public String days(int d) { + return ""; + } + + @Override + public String months(int m) { + return ""; + } + + @Override + public String years(int y) { + return ""; + } + + @Override + public String yearsOld(int y) { + return String.format("%djährig", y); + } + + @Override + public String monthsOld(int m) { + return String.format("%d Monate alt", m); + } + + @Override + public String daysOld(int d) { + return String.format("%d Tage alt", d); + } + + @Override + public String monthDayOld(int m, int d) { + List components = new ArrayList<>(); + if (m > 0) { + components.add(String.format("%d %s", m, m > 1 ? "Monaten" : "Monat")); + } + if (d > 0) { + components.add(String.format("%d %s", d, d > 1 ? "Tagen" : "Tag")); + } + if (components.isEmpty()) { + return "am ersten Lebenstag"; + } else if (components.size() == 1) { + return components.get(0); + } else { + return String.format("im Alter von %s und %s", components.get(0), components.get(1)); + } + } + + @Override + public String yearsMonthsDaysOld(int y, int m, int d) { + List components = new ArrayList<>(); + if (y > 0) { + components.add(String.format("%d %s", y, y > 1 ? "Jahren" : "Jahr")); + } + if (m > 0) { + components.add(String.format("%d %s", m, m > 1 ? "Monaten" : "Monat")); + } + if (d > 0) { + components.add(String.format("%d %s", d, d > 1 ? "Tagen" : "Tag")); + } + if (components.isEmpty()) { + return "am ersten Lebenstag"; + } else if (components.size() == 1) { + return components.get(0); + } else if (components.size() == 2) { + return String.format("im Alter von %s und %s", components.get(0), components.get(1)); + } else { + // we must have y,m,d + return String.format("im Alter von %s, %s und %s", components.get(0), components.get(1), components.get(2)); + } + } + + @Override + public String asNewborn() { + return ""; + } + + @Override + public String atTheAgeOf() { + return ""; + } + + @Override + public String she() { + return ""; + } + + @Override + public String he() { + return ""; + } + + @Override + public String theProband() { + return ""; + } + + @Override + public String woman() { + return "Frau"; + } + + @Override + public String man() { + return "Mann"; + } + + @Override + public String individual() { + return "erwachsene Person unbekannten Geschlechtes"; + } + + @Override + public String theIndividual() { + return ""; + } + + @Override + public String girl() { + return "Mädchen"; + } + + @Override + public String boy() { + return "Junge"; + } + + @Override + public String child() { + return "Kind"; + } + + @Override + public String adolescentGirl() { + return ""; + } + + @Override + public String adolescentBoy() { + return ""; + } + + @Override + public String adolescentChild() { + return ""; + } + + @Override + public String maleInfant() { + return "männlicher Säugling"; + } + + @Override + public String femaleInfant() { + return "weiblicher Säugling"; + } + + @Override + public String infant() { + return "Säugling"; + } + + @Override + public String newbornBoy() { + return "männliches Neugeborenes"; + } + + @Override + public String newbornGirl() { + return "weibliches Neugeborenes"; + } + + @Override + public String newborn() { + return "Neugeborenes"; + } + + @Override + public String maleFetus() { + return "männlicher Fet"; + } + + @Override + public String femaleFetus() { + return "weiblicher Fet"; + } + + @Override + public String fetus() { + return "Fet"; + } + + @Override + public String female() { + return ""; + } + + @Override + public String male() { + return ""; + } + + @Override + public String adult() { + return ""; + } + + @Override + public String probandWasA() { + return "Der Proband war"; + } + + @Override + public String whoPresented() { + return ""; + } + + @Override + public String presented() { + return ""; + } + + @Override + public String probandNoAgePresented() { + return ""; + } + + @Override + public String probandNoAgePresentedWith() { + return ""; + } + + @Override + public String probandWasAMale() { + return "Der Proband war ein Mann"; + } + + @Override + public String probandWasAFemale() { + return "Die Probandin war eine Frau"; + } + + @Override + public String probandWasAnIndividual() { + return "Der Proband war ein Individuum ohne angegebenes Geschlecht"; + } + + @Override + public String presentedWith() { + return ""; + } + + @Override + public String with() { + return ""; + } + + @Override + public String inWhomManifestationsWereExcluded() { + return ""; + } + + @Override + public String duringFetal() { + return ""; + } + + @Override + public String asNeonate() { + return ""; + } + + @Override + public String atBirth() { + return ""; + } + + @Override + public String asInfant() { + return ""; + } + + @Override + public String inChildhood() { + return ""; + } + + @Override + public String asAdolescent() { + return ""; + } + + @Override + public String asAdult() { + return ""; + } + + @Override + public String asYoungAdult() { + return ""; + } + + @Override + public String asMiddleAge() { + return ""; + } + + @Override + public String asLateOnset() { + return ""; + } + + @Override + public String fromIso(Iso8601Age ppktAge) { + return ""; + } +} diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGenerator.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGenerator.java index b795fb2..5af55b7 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGenerator.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGenerator.java @@ -10,6 +10,7 @@ import org.monarchinitiative.phenopacket2prompt.output.PromptGenerator; import java.util.List; +import java.util.Map; import java.util.Set; public class GermanPromptGenerator implements PromptGenerator { @@ -53,12 +54,46 @@ public String getVignetteAtAge(PhenopacketAge page, PhenopacketSex psex, List "Er"; + case FEMALE -> "Sie"; + default -> "Die betroffene Person"; + }; + return this.ppktPhenotypicFeatureGenerator.featuresAtOnset(person, individual.getPhenotypicFeaturesAtOnset()); + } + + @Override public Set getMissingTranslations() { return this.ppktPhenotypicFeatureGenerator.getMissingTranslations(); } + /** + * The following structure should work for most other languages, but the function + * can be overridden if necessary. + * @param individual The individual for whom we are creating the prompt + * @return the prompt text + */ + @Override + public String createPrompt(PpktIndividual individual) { + String individualInfo = getIndividualInformation(individual); + // For creating the prompt, we first report the onset and the unspecified terms together, and then + String onsetDescription = getVignetteAtOnset(individual); + Map> pfMap = individual.extractSpecifiedAgePhenotypicFeatures(); + // We then report the rest, one for each specified time + //String onsetFeatures = formatFeatures(onsetTerms); + StringBuilder sb = new StringBuilder(); + sb.append(queryHeader()); + sb.append(individualInfo).append("\n").append(onsetDescription).append("\n"); + for (var entry: pfMap.entrySet()) { + String vignette = getVignetteAtAge(entry.getKey(), individual.getSex(), entry.getValue()); + sb.append(vignette).append("\n"); + } + return sb.toString(); + } diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/PpktIndividualGerman.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/PpktIndividualGerman.java index 552303a..3e0c96c 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/PpktIndividualGerman.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/PpktIndividualGerman.java @@ -2,6 +2,7 @@ import org.monarchinitiative.phenol.base.PhenolRuntimeException; import org.monarchinitiative.phenopacket2prompt.model.*; +import org.monarchinitiative.phenopacket2prompt.output.BuildingBlockGenerator; import org.monarchinitiative.phenopacket2prompt.output.PPKtIndividualInfoGenerator; import java.util.ArrayList; @@ -10,35 +11,106 @@ public class PpktIndividualGerman implements PPKtIndividualInfoGenerator { + private final BuildingBlockGenerator bbGenerator; + /** grammatical sex */ + private enum GrammatikalischesGeschlecht { + MAENNLICH, WEIBLICH, NEUTRUM + } + + public PpktIndividualGerman() { + bbGenerator = new GermanBuildingBlocks(); + } - private static final String FEMALE_INFANT = "ein weiblicher Säugling"; - private static final String MALE_INFANT = "ein männlicher Säugling"; - private static final String INFANT = "ein Säugling"; + @Override + public String getIndividualDescription(PpktIndividual individual) { + if (individual.annotationCount() == 0) { + throw new PhenolRuntimeException("No HPO annotations"); + } + Optional lastExamOpt = individual.getAgeAtLastExamination(); + Optional onsetOpt = individual.getAgeAtOnset(); + PhenopacketSex psex = individual.getSex(); + String individualDescription; + String onsetDescription; + if (lastExamOpt.isPresent()) { + var lastExamAge = lastExamOpt.get(); + if (lastExamAge.ageType().equals(PhenopacketAgeType.ISO8601_AGE_TYPE)) { + Iso8601Age isoAge = (Iso8601Age) lastExamAge; + individualDescription = iso8601individualDescription(psex, isoAge); + } else if (lastExamAge.ageType().equals(PhenopacketAgeType.HPO_ONSET_AGE_TYPE)) { + HpoOnsetAge hpoOnsetTermAge = (HpoOnsetAge) lastExamAge; + individualDescription = hpoOnsetIndividualDescription(psex, hpoOnsetTermAge); + } else { + // should never happen + throw new PhenolRuntimeException("Did not recognize last exam age type " + lastExamAge.ageType()); + } + } else { + individualDescription = switch (psex) { + case FEMALE -> bbGenerator.probandWasAFemale(); + case MALE -> bbGenerator.probandWasAMale(); + default -> bbGenerator.probandWasAnIndividual(); + }; + } + if (onsetOpt.isPresent()) { + var onsetAge = onsetOpt.get(); + if (onsetAge.ageType().equals(PhenopacketAgeType.ISO8601_AGE_TYPE)) { + Iso8601Age isoAge = (Iso8601Age) onsetAge; + onsetDescription = iso8601onsetDescription(isoAge); + } else if (onsetAge.ageType().equals(PhenopacketAgeType.HPO_ONSET_AGE_TYPE)) { + HpoOnsetAge hpoOnsetTermAge = (HpoOnsetAge) onsetAge; + onsetDescription = hpoOnsetDescription(hpoOnsetTermAge); + } else { + // should never happen + throw new PhenolRuntimeException("Did not recognize last exam age type " + onsetAge.ageType()); + } + } else { + onsetDescription = "Der Krankheitsbeginn wurde nicht angegeben"; + } + return String.format("%s. %s.", individualDescription, onsetDescription); + } - private static final String FEMALE_FETUS = "ein weiblicher Fet"; - private static final String MALE_FETUS = "ein männlicher Fet"; - private static final String FETUS = "ein Fet"; + private String hpoOnsetDescription(HpoOnsetAge hpoOnsetTermAge) { + return String.format("Der Krankheitsbeginn trat %s auf", + nameOfLifeStage(hpoOnsetTermAge)); + } - private static final String FEMALE_CHILD = "Mädchen"; - private static final String MALE_CHILD = "Junge"; - private static final String CHILD = "Kind"; + private String nameOfLifeStage(HpoOnsetAge hpoOnsetTermAge) { + if (hpoOnsetTermAge.isFetus()) { + return "während der Fetalperiode"; + } else if (hpoOnsetTermAge.isCongenital()) { + return "zum Zeitpunkt der Geburt"; + } else if (hpoOnsetTermAge.isInfant()) { + return "im Säuglingsalter"; + } else if (hpoOnsetTermAge.isChild()) { + return "im Kindesalter"; + } else if (hpoOnsetTermAge.isJuvenile()) { + return "im Jugendlichenalter"; + } else if (hpoOnsetTermAge.isNeonate()) { + return "im Neugeborenenalter"; // +bbGenerator.newborn(); + } else if (hpoOnsetTermAge.isYoungAdult()) { + return "im jungen Erwachsenenalter" ; + } else if (hpoOnsetTermAge.isMiddleAge()) { + return "im mittleren Erwachsenenalter" ; + } else if (hpoOnsetTermAge.isLateAdultAge()) { + return "im späten Erwachsenenalter" ; + } else if (hpoOnsetTermAge.isAdult()) { + // d.h. nicht weiter spezifiziert + return "im Erwachsenenalter" ; + } else { + throw new PhenolRuntimeException("Could not identify German life stage name for HpoOnsetAge " + hpoOnsetTermAge.toString()); + } + } - private static final String FEMALE_ADULT = "Frau"; - private static final String MALE_ADULT = "Mann"; - private static final String ADULT = "erwachsene Person unbekannten Geschlechtes"; - /** - * Equivalent of "The clinical - * @param individual - * @return - */ - public String ageAndSexAtOnset(PpktIndividual individual) { - Optional ageOpt = individual.getAgeAtOnset(); - return ""; + private String iso8601onsetDescription(Iso8601Age isoAge) { + return String.format("Der Krankheitsbeginn trat im Alter von %s auf", + bbGenerator.yearsMonthsDaysOld(isoAge.getYears(), isoAge.getMonths(), isoAge.getDays())); } + + + public String ageAndSexAtLastExamination(PpktIndividual individual) { PhenopacketSex psex = individual.getSex(); Optional ageOpt = individual.getAgeAtLastExamination(); @@ -47,9 +119,9 @@ public String ageAndSexAtLastExamination(PpktIndividual individual) { } String sex; switch (psex) { - case FEMALE -> sex = FEMALE_ADULT; - case MALE -> sex = MALE_ADULT; - default -> sex = ADULT; + case FEMALE -> sex = bbGenerator.woman(); + case MALE -> sex = bbGenerator.man(); + default -> sex = bbGenerator.adult(); } if (ageOpt.isEmpty()) { @@ -79,33 +151,34 @@ public String ageAndSexAtLastExamination(PpktIndividual individual) { } if (age.isChild()) { return switch (psex) { - case FEMALE -> FEMALE_CHILD; - case MALE -> MALE_CHILD; - default -> CHILD; + case FEMALE -> bbGenerator.girl(); + case MALE -> bbGenerator.boy(); + default -> bbGenerator.child(); }; } else if (age.isCongenital()) { return switch (psex) { - case FEMALE -> "ein weibliches Neugeborenes"; - case MALE -> "ein männliches Neugeborenes"; - default -> "ein Neugeborenes"; + case FEMALE -> bbGenerator.newbornGirl(); + case MALE -> bbGenerator.newbornBoy(); + default -> bbGenerator.newborn(); }; } else if (age.isFetus()) { return switch (psex) { - case FEMALE -> "ein weiblicher Fet"; - case MALE -> "ein männlicher Fet"; - default -> "ein Fet"; + case FEMALE -> bbGenerator.femaleFetus(); + case MALE -> bbGenerator.maleFetus(); + default -> bbGenerator.fetus(); }; } else if (age.isInfant()) { return switch (psex) { - case FEMALE -> FEMALE_INFANT; - case MALE -> MALE_INFANT; - default -> INFANT; + case FEMALE -> bbGenerator.femaleInfant(); + case MALE -> bbGenerator.maleInfant(); + default -> bbGenerator.infant(); }; } else { return switch (psex) { - case FEMALE -> FEMALE_ADULT; - case MALE -> MALE_ADULT; - default -> ADULT; + // TODO -- MORE GRANULARITY + case FEMALE -> bbGenerator.woman(); + case MALE -> bbGenerator.man(); + default -> bbGenerator.adult(); }; } } @@ -137,23 +210,98 @@ private String imAlterVonIsoAgeExact(PhenopacketAge ppktAge) { } - @Override - public String getIndividualDescription(PpktIndividual individual) { - if (individual.annotationCount() == 0) { - throw new PhenolRuntimeException("No HPO annotations"); + private String iso8601individualDescription(PhenopacketSex psex, Iso8601Age iso8601Age) { + int y = iso8601Age.getYears(); + int m = iso8601Age.getMonths(); + int d = iso8601Age.getDays(); + // if older + if (y > 17) { + return switch (psex) { + case FEMALE -> String.format("Die Probandin war eine %s Frau", + dAlter(iso8601Age, GrammatikalischesGeschlecht.WEIBLICH)); + case MALE -> String.format("Der Proband war ein %s Mann", + dAlter(iso8601Age, GrammatikalischesGeschlecht.MAENNLICH)); + default -> String.format("Der Proband war ein %s %s", + dAlter(iso8601Age, GrammatikalischesGeschlecht.NEUTRUM), + bbGenerator.individual()); + }; + } else if (y > 9) { + return switch (psex) { + case FEMALE -> String.format("%s %s %s", bbGenerator.probandWasA(), + dAlter(iso8601Age, GrammatikalischesGeschlecht.WEIBLICH), + bbGenerator.adolescentGirl()); + case MALE -> String.format("%s %s %s", bbGenerator.probandWasA(), + dAlter(iso8601Age, GrammatikalischesGeschlecht.MAENNLICH), + bbGenerator.adolescentBoy()); + default -> String.format("%s %s %s", bbGenerator.probandWasA(), + dAlter(iso8601Age, GrammatikalischesGeschlecht.NEUTRUM), bbGenerator.adolescentChild()); + }; + } else if (y > 0) { + return switch (psex) { + case FEMALE -> String.format("%s %s %s", bbGenerator.probandWasA(), + dAlter(iso8601Age, GrammatikalischesGeschlecht.NEUTRUM), // "das Mädchen" + bbGenerator.girl()); + case MALE -> String.format("%s %s %s", bbGenerator.probandWasA(), + dAlter(iso8601Age, GrammatikalischesGeschlecht.MAENNLICH), + bbGenerator.boy()); + default -> String.format("%s %s %s", bbGenerator.probandWasA(), + dAlter(iso8601Age, GrammatikalischesGeschlecht.NEUTRUM), // Das Individuum + bbGenerator.child()); + }; + } else if (m > 0 || d > 0) { + return switch (psex) { + case FEMALE -> String.format("%s ein %s %s", bbGenerator.probandWasA(), + dAlter(iso8601Age, GrammatikalischesGeschlecht.MAENNLICH), // "der weibliche Säungling", + bbGenerator.femaleInfant()); + case MALE -> String.format("%s ein %s %s", bbGenerator.probandWasA(), + dAlter(iso8601Age, GrammatikalischesGeschlecht.MAENNLICH), + bbGenerator.maleInfant()); + default -> String.format("%s %s %s", bbGenerator.probandWasA(), + dAlter(iso8601Age, GrammatikalischesGeschlecht.MAENNLICH), // "der Säugling + bbGenerator.infant()); + }; + } else { + return switch (psex) { + case FEMALE -> String.format("Die Probandin war ein %s", bbGenerator.probandWasA(), bbGenerator.newbornGirl()); + case MALE -> String.format("Der Proband war ein %s", bbGenerator.probandWasA(), bbGenerator.newbornBoy()); + default -> String.format("Der Proband war ein Neugeborenes ohne angegebenes Geschlecht"); + }; } - Optional lastExamOpt = individual.getAgeAtLastExamination(); - Optional onsetOpt = individual.getAgeAtOnset(); - PhenopacketSex psex = individual.getSex(); - if (lastExamOpt.isPresent() && onsetOpt.isPresent()) { - return onsetAndLastEncounterAvailable(psex, lastExamOpt.get(), onsetOpt.get()); - } else if (lastExamOpt.isPresent()) { - return latestEncounterAvailable(psex, lastExamOpt.get()); - } else if (onsetOpt.isPresent()) { - return onsetAvailable(psex, onsetOpt.get()); + } + + /** + * @param iso8601Age + * @return zB. "4 Jahre und 2 Monate alter" "3 Monate und 1 Tag altes" + */ + private String dAlter(Iso8601Age iso8601Age, GrammatikalischesGeschlecht geschlecht) { + int y = iso8601Age.getYears(); + int m = iso8601Age.getMonths(); + int d = iso8601Age.getDays(); + List components = new ArrayList<>(); + if (y > 0) { + components.add(String.format("%d %s", y, y > 1 ? "Jahre" : "Jahr")); + } + if (m > 0) { + components.add(String.format("%d %s", m, m > 1 ? "Monate" : "Monat")); + } + if (d > 0) { + components.add(String.format("%d %s", d, d > 1 ? "Tage" : "Tag")); + } + String ymd; + if (components.isEmpty()) { + ymd = ""; + } else if (components.size() == 1) { + ymd = components.get(0); + } else if (components.size() == 2) { + ymd = String.format("%s und %s", components.get(0), components.get(1)); } else { - return ageNotAvailable(psex); + ymd = String.format("%s, %s und %s", components.get(0), components.get(1), components.get(2)); } + return switch (geschlecht) { + case MAENNLICH -> String.format("%s alter", ymd); + case WEIBLICH -> String.format("%s alte", ymd); + case NEUTRUM -> String.format("%s altes", ymd); + }; } @@ -235,7 +383,7 @@ private String iso8601AtAgeOf(Iso8601Age isoAge) { " und " + components.get(2); } } - +/* private String onsetTermAtAgeOf(HpoOnsetAge hpoOnsetTermAge) { if (hpoOnsetTermAge.isFetus()) { return "in der Fetalperiode"; @@ -251,181 +399,52 @@ private String onsetTermAtAgeOf(HpoOnsetAge hpoOnsetTermAge) { return "im Erwachsenenalter"; } } +*/ - private String iso8601individualDescription(PhenopacketSex psex, Iso8601Age iso8601Age) { - int y = iso8601Age.getYears(); - int m = iso8601Age.getMonths(); - int d = iso8601Age.getDays(); - // if older - if (y>17) { - return switch (psex) { - case FEMALE -> String.format("Die Patientin war eine %d-jährige Frau", y); - case MALE -> String.format("Der Patient war ein %d-jähriger Mann", y); - default -> String.format("Der Patient war eine %d-jährige Person", y); - }; - } else if (y>9) { - return switch (psex) { - case FEMALE -> String.format("Die Patientin war eine %d-jährige Jugendliche", y); - case MALE -> String.format("Der Patient war ein %d-jähriger Jugendlicher", y); - default -> String.format("Der Patient war ein %d-jähriger Jugendlicher", y); - }; - } else if (y>0) { - return switch (psex) { - case FEMALE -> String.format("Die Patientin war %s", iso8601ToYearMonth(iso8601Age, psex)); - case MALE -> - String.format("Der Patient war %s", iso8601ToYearMonth(iso8601Age, psex)); - default -> String.format("Der Patient war %s", iso8601ToYearMonth(iso8601Age, psex)); - }; - } else if (m>0 || d> 0) { - return switch (psex) { - case FEMALE -> String.format("Die Patientin war ein %s alter weiblicher Säugling", iso8601ToMonthDay(iso8601Age)); - case MALE -> String.format("Der Patient war ein %s alter Säugling", iso8601ToMonthDay(iso8601Age)); - default -> String.format("Der Patient war ein %s alter Säugling", iso8601ToMonthDay(iso8601Age)); - }; - } else { - return switch (psex) { - case FEMALE -> "Die Patientin war ein weibliches Neugeborenes"; - case MALE -> "Der Patient war ein männliches Neugeborenes"; - default -> "Der Patient war ein Neugeborenes"; - }; - } - } - private String hpoOnsetIndividualDescription(PhenopacketSex psex, HpoOnsetAge hpoOnsetTermAge) { if (hpoOnsetTermAge.isFetus()) { return switch (psex) { - case FEMALE -> FEMALE_FETUS; - case MALE -> MALE_FETUS; - default -> FETUS; + case FEMALE -> String.format("%s %s", bbGenerator.probandWasAFemale(), bbGenerator.femaleFetus()); + case MALE -> String.format("%s %s", bbGenerator.probandWasAMale(), bbGenerator.maleFetus()); + default -> String.format("%s %s", bbGenerator.probandWasA(), bbGenerator.fetus()); }; } else if (hpoOnsetTermAge.isCongenital()) { return switch (psex) { - case FEMALE -> "Die Patientin war ein weibliches Neugeborenes, das sich"; - case MALE -> "Der Patient war ein männliches Neugeborenes, das sich"; - default -> "Der Patient war ein Neugeborenes, das sich"; + case FEMALE -> "Die Probandin war ein weibliches Neugeborenes"; + case MALE -> "Der Probandwar ein männliches Neugeborenes"; + default -> "Der Patient war ein Neugeborenes ohne angegebenes Geschelcht"; }; } else if (hpoOnsetTermAge.isInfant()) { return switch (psex) { - case FEMALE -> "Die Patientin war ein weiblicher Säugling, der sich "; - case MALE -> "Der Patient war ein männlicher Säugling, der sich"; - default -> "Der Patient war ein Säugling, der sich"; + case FEMALE -> "Die Probandin war ein weiblicher Säugling"; + case MALE -> "Der Proband war ein männlicher Säugling"; + default -> "Der Proband war ein Säugling ohne angegebenes Geschlecht"; }; } else if (hpoOnsetTermAge.isChild()) { return switch (psex) { - case FEMALE -> "Die Patientin war ein Mädchen, das sich "; - case MALE -> "Der Patient war ein Junge, der sich"; - default -> "Der Patient war ein Kind, das sich"; + case FEMALE -> "Die Probandin war ein Mädchen"; + case MALE -> "Der Proband war ein Junge"; + default -> "Der Proband war ein Kind ohne angegebenes Geschlecht"; }; } else if (hpoOnsetTermAge.isJuvenile()) { return switch (psex) { - case FEMALE -> "Die Patientin war eine Jugendliche, die sich"; - case MALE -> "Der Patient war ein Jugendlicher, der sich"; - default -> "Der Patient war ein Jugendlicher, der sich"; + case FEMALE -> "Die Probandin war eine Jugendliche"; + case MALE -> "Der Proband war ein Jugendlicher"; + default -> "Der Proband war ein Jugendlicher ohne angegebenes Geschlecht"; }; - }else { + } else if (hpoOnsetTermAge.isAdult()) { return switch (psex) { - case FEMALE -> "Die Patientin war eine Frau, die sich"; - case MALE -> "Der Patient war ein Mann, der sich"; - default -> "Der Patient war eine erwachsene Person nicht angegebenen Geschlechtes, die sich"; - }; - } - } - - /** - * A sentence such as The proband was a 39-year old woman who presented at the age of 12 years with - * HPO1, HPO2, and HPO3. HPO4 and HPO5 were excluded. This method returns the phrase that ends with "with" - * El sujeto era un niño de 1 año y 10 meses que se presentó como recién nacido con un filtrum largo. - * @param psex - * @param lastExamAge - * @param onsetAge - * @return - */ - private String onsetAndLastEncounterAvailable(PhenopacketSex psex, PhenopacketAge lastExamAge, PhenopacketAge onsetAge) { - String individualDescription; - String onsetDescription; - if (lastExamAge.ageType().equals(PhenopacketAgeType.ISO8601_AGE_TYPE)) { - Iso8601Age isoAge = (Iso8601Age) lastExamAge; - individualDescription = iso8601individualDescription(psex, isoAge); - } else if (lastExamAge.ageType().equals(PhenopacketAgeType.HPO_ONSET_AGE_TYPE)) { - HpoOnsetAge hpoOnsetTermAge = (HpoOnsetAge) lastExamAge; - individualDescription = hpoOnsetIndividualDescription(psex,hpoOnsetTermAge); - } else { - // should never happen - throw new PhenolRuntimeException("Did not recognize last exam age type " + lastExamAge.ageType()); - } - if (onsetAge.ageType().equals(PhenopacketAgeType.ISO8601_AGE_TYPE)) { - Iso8601Age isoAge = (Iso8601Age) onsetAge; - onsetDescription = iso8601AtAgeOf(isoAge); - } else if (onsetAge.ageType().equals(PhenopacketAgeType.HPO_ONSET_AGE_TYPE)) { - HpoOnsetAge hpoOnsetTermAge = (HpoOnsetAge) onsetAge; - onsetDescription = onsetTermAtAgeOf(hpoOnsetTermAge); - } else { - // should never happen - throw new PhenolRuntimeException("Did not recognize onset age type " + onsetAge.ageType()); - } - return switch (psex) { - case FEMALE -> String.format("%s, die sich %s mit den folgenden Symptomen vorgestellt hat: ", individualDescription, onsetDescription); - default -> String.format("%s, der sich %s mit den folgenden Symptomen vorgestellt hat: ", individualDescription, onsetDescription); - }; - } - - - /** - * Age at last examination available but age of onset not available - * The proband was a 39-year old woman who presented with HPO1, HPO2, and HPO3. HPO4 and HPO5 were excluded. - * @param psex - * @param lastExamAge - */ - private String latestEncounterAvailable(PhenopacketSex psex, PhenopacketAge lastExamAge) { - String individualDescription; - if (lastExamAge.ageType().equals(PhenopacketAgeType.ISO8601_AGE_TYPE)) { - Iso8601Age isoAge = (Iso8601Age) lastExamAge; - individualDescription = iso8601individualDescription(psex, isoAge); - } else if (lastExamAge.ageType().equals(PhenopacketAgeType.HPO_ONSET_AGE_TYPE)) { - HpoOnsetAge hpoOnsetTermAge = (HpoOnsetAge) lastExamAge; - individualDescription = hpoOnsetIndividualDescription(psex,hpoOnsetTermAge); - } else { - // should never happen - throw new PhenolRuntimeException("Did not recognize last exam age type " + lastExamAge.ageType()); - } - if (psex.equals(PhenopacketSex.FEMALE)) { - return String.format("%s, die sich mit den folgenden Symptomen vorgestellt hat: ", individualDescription); - } else { - return String.format("%s, der sich mit den folgenden Symptomen vorgestellt hat: ", individualDescription); - } + case FEMALE -> "Die Probandin war eine Frau"; + case MALE -> "Der Proband war ein Mann"; + default -> "Der Proband war eine erwachsene Person ohne angegebenes Geschlecht"; - } - - /** - * Age at last examination not available but age of onset available - * The proband presented at the age of 12 years with HPO1, HPO2, and HPO3. HPO4 and HPO5 were excluded. - * @param psex - * @param onsetAge - * @return - */ - private String onsetAvailable(PhenopacketSex psex, PhenopacketAge onsetAge) { - String onsetDescription; - if (onsetAge.ageType().equals(PhenopacketAgeType.ISO8601_AGE_TYPE)) { - Iso8601Age isoAge = (Iso8601Age) onsetAge; - onsetDescription = iso8601AtAgeOf(isoAge); - } else if (onsetAge.ageType().equals(PhenopacketAgeType.HPO_ONSET_AGE_TYPE)) { - HpoOnsetAge hpoOnsetTermAge = (HpoOnsetAge) onsetAge; - onsetDescription = onsetTermAtAgeOf(hpoOnsetTermAge); + }; } else { - // should never happen - throw new PhenolRuntimeException("Did not recognize onset age type " + onsetAge.ageType()); + throw new PhenolRuntimeException("Could not find HPO onset type " + hpoOnsetTermAge.toString()); } - return String.format("Der Patient stellte sich %s mit den folgenden Symptomen vor: ", onsetDescription); } - private String ageNotAvailable(PhenopacketSex psex) { - return switch (psex) { - case FEMALE -> "Die Patientin stellte sich mit den folgenden Symptomen vor: "; - case MALE -> "Der Patient stellte sich mit den folgenden Symptomen vor: "; - default -> "Der Patient stellte sich mit den folgenden Symptomen vor: "; - }; - } @Override public String heSheIndividual(PhenopacketSex psex) { @@ -458,53 +477,7 @@ public String atAgeForVignette(PhenopacketAge ppktAge) { } } - // @Override - public String ppktSex(PpktIndividual individual) { - PhenopacketSex psex = individual.getSex(); - Optional ageOpt = individual.getAgeAtLastExamination(); - if (ageOpt.isEmpty()) { - ageOpt = individual.getAgeAtOnset(); - } - if (ageOpt.isEmpty()) { - return switch (psex) { - case FEMALE -> "Frau"; - case MALE -> "Mann"; - default -> "Person"; - }; - } - PhenopacketAge age = ageOpt.get(); - if (age.isChild()) { - return switch (psex) { - case FEMALE -> "Mädchen"; - case MALE -> "Junge"; - default -> "Kind"; - }; - } else if (age.isCongenital()) { - return switch (psex) { - case FEMALE -> "weibliches Neugeborenes"; - case MALE -> "männliches Neugeborenes"; - default -> "Neugeborenes"; - }; - } else if (age.isFetus()) { - return switch (psex) { - case FEMALE -> FEMALE_FETUS; - case MALE -> MALE_FETUS; - default -> FETUS; - }; - } else if (age.isInfant()) { - return switch (psex) { - case FEMALE -> FEMALE_INFANT; - case MALE -> MALE_INFANT; - default -> INFANT; - }; - } else { - return switch (psex) { - case FEMALE -> "Frau"; - case MALE -> "Mann"; - default -> "Person"; - }; - } - } + } diff --git a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/PpktPhenotypicfeatureGerman.java b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/PpktPhenotypicfeatureGerman.java index c257aa8..4ac3cd7 100644 --- a/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/PpktPhenotypicfeatureGerman.java +++ b/src/main/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/PpktPhenotypicfeatureGerman.java @@ -5,6 +5,7 @@ import org.monarchinitiative.phenopacket2prompt.output.PpktPhenotypicFeatureGenerator; import java.util.*; +import java.util.stream.Collectors; public class PpktPhenotypicfeatureGerman implements PpktPhenotypicFeatureGenerator { @@ -35,6 +36,9 @@ private List getTranslations(List ontologyTerms) { private String getCommaList(List items) { + if (items.isEmpty()) { + return ""; // this will be filtered out later + } if (items.size() == 1) { return items.getFirst(); } @@ -43,11 +47,12 @@ private String getCommaList(List items) { // one item will work with the below code return String.join(" und ", items); } - String symList = String.join(", ", items); - int jj = symList.lastIndexOf(", "); - String end = symList.substring(jj+2); - symList = symList.substring(0, jj) + " und " + end; - return symList; + // if we have more than two, join all but the very last item with a comma + String penultimate = items.stream() + .limit(items.size() - 1) + .collect(Collectors.joining(",")); + String ultimate = items.get(items.size() - 1); + return penultimate + " und " + ultimate; } @Override @@ -75,4 +80,31 @@ public String formatFeatures(List ontologyTerms) { public Set getMissingTranslations() { return missingTranslations; } + + + + @Override + public String featuresAtOnset(String personString, List ontologyTerms) { + List observed = getObservedFeaturesAsStr(ontologyTerms); + List excluded = getExcludedFeaturesAsStr(ontologyTerms); + var observedStr = getCommaList(observed); + var excludedStr = getCommaList(excluded); + if (!observed.isEmpty() && ! excluded.isEmpty()) { + return String.format("%s präsentierte mit den folgenden Symptomen: %s. Im Gegensatz %s die folgenden Symptome ausgeschlossen: %s.", + personString, + observedStr, + excluded.size()>1? "wurden":"wurde", + excludedStr); + } else if (!observed.isEmpty()) { + return String.format("%s präsentierte mit den folgenden Symptomen: %s.", personString, observedStr); + } else if (!excluded.isEmpty()) { + return String.format("Beim Krankheitsbeginn %s die folgenden Symptome ausgeschlossen: %s.", + excluded.size()>1? "wurden":"wurde", excludedStr); + } else { + return "Keine phänotypischen Abnormalitäten wurden explizit zu Krankheitsbeginn beschrieben."; + } + } + + + } diff --git a/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/english/PPKtEnglishBuildingBlocksTest.java b/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/english/PPKtEnglishBuildingBlocksTest.java index 6fcc3df..d39ee04 100644 --- a/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/english/PPKtEnglishBuildingBlocksTest.java +++ b/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/english/PPKtEnglishBuildingBlocksTest.java @@ -2,13 +2,13 @@ import org.junit.jupiter.api.Test; import org.monarchinitiative.phenopacket2prompt.model.Iso8601Age; -import org.monarchinitiative.phenopacket2prompt.output.PPKtBuildingBlockGenerator; +import org.monarchinitiative.phenopacket2prompt.output.BuildingBlockGenerator; import static org.junit.jupiter.api.Assertions.assertEquals; public class PPKtEnglishBuildingBlocksTest { - public final static PPKtBuildingBlockGenerator generator = new PPKtEnglishBuildingBlocks(); + public final static BuildingBlockGenerator generator = new EnglishBuildingBlocks(); @Test public void oneMonth() { diff --git a/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGeneratorTest.java b/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGeneratorTest.java index 67f5fce..931cad0 100644 --- a/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGeneratorTest.java +++ b/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/GermanPromptGeneratorTest.java @@ -35,7 +35,9 @@ public class GermanPromptGeneratorTest { Ich habe Ihnen diese Anleitung auf English gegeben, aber ich bitte Sie, ihre Antwort ausschließlich auf English zu liefern. Hier ist der Fall: -Der Patient war ein 2jähriger Junge, der sich im Alter von 3 Tagen mit den folgenden Symptomen vorgestellt hat: Lymphopenie, Lungenentzündung und Verminderter zirkulierender IgA-Spiegel. Im Alter von 2 Jahren, präsentierte er mit den folgenden Symptomen: Verringertes zirkulierendes Gesamt-IgM."""; +Der Proband war 2 Jahre alter Junge. Der Krankheitsbeginn trat im Alter von 3 Tagen auf. +Er präsentierte mit den folgenden Symptomen: Lymphopenie, Lungenentzündung und Verminderter zirkulierender IgA-Spiegel. +Im Alter von 2 Jahren, präsentierte er mit den folgenden Symptomen: Verringertes zirkulierendes Gesamt-IgM."""; @Test public void testCase() { PpktIndividual i = twoYears(); diff --git a/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/PpktIndividualGermanTest.java b/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/PpktIndividualGermanTest.java index 2b33327..91ba30f 100644 --- a/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/PpktIndividualGermanTest.java +++ b/src/test/java/org/monarchinitiative/phenopacket2prompt/output/impl/german/PpktIndividualGermanTest.java @@ -1,5 +1,6 @@ package org.monarchinitiative.phenopacket2prompt.output.impl.german; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.monarchinitiative.phenol.base.PhenolRuntimeException; @@ -7,6 +8,7 @@ import org.monarchinitiative.phenopacket2prompt.model.PpktIndividual; import org.monarchinitiative.phenopacket2prompt.output.PPKtIndividualBase; import org.monarchinitiative.phenopacket2prompt.output.PPKtIndividualInfoGenerator; +import org.monarchinitiative.phenopacket2prompt.output.impl.english.PpktIndividualEnglish; import java.util.function.Supplier; import java.util.stream.Stream; @@ -21,18 +23,29 @@ public class PpktIndividualGermanTest extends PPKtIndividualBase{ private static Stream testGetIndividualDescription() { return Stream.of( new TestIndividual("46 year old female, infantile onset", - female46yearsInfantileOnset(), new TestOutcome.Ok("Die Patientin war eine 46-jährige Frau, die sich im Säuglingsalter mit den folgenden Symptomen vorgestellt hat: ")), + female46yearsInfantileOnset(), new TestOutcome.Ok("Die Probandin war eine 46 Jahre alte Frau. Der Krankheitsbeginn trat im Säuglingsalter auf.")), new TestIndividual("male 4 months, congenital onset", - male4monthsCongenitalOnset(), new TestOutcome.Ok("Der Patient war ein 4 Monate alter Säugling, der sich bei der Geburt mit den folgenden Symptomen vorgestellt hat: ")), + male4monthsCongenitalOnset(), new TestOutcome.Ok("Der Proband war ein 4 Monate alter männlicher Säugling. Der Krankheitsbeginn trat zum Zeitpunkt der Geburt auf.")), new TestIndividual("female, no onset", - femaleNoAge(), new TestOutcome.Ok("Die Patientin stellte sich mit den folgenden Symptomen vor: ")), + femaleNoAge(), new TestOutcome.Ok("Die Probandin war eine Frau. Der Krankheitsbeginn wurde nicht angegeben.")), new TestIndividual("female, no HPOs", femaleNoHPOs(), new TestOutcome.Error(() -> new PhenolRuntimeException("No HPO annotations"))), new TestIndividual("unknown sex, no 4yo", - unknownSex4YearsOnset(), new TestOutcome.Ok("Der Patient stellte sich in der Kindheit mit den folgenden Symptomen vor: ")) + unknownSex4YearsOnset(), new TestOutcome.Ok("Der Proband war ein Individuum ohne angegebenes Geschlecht. Der Krankheitsbeginn trat im Kindesalter auf.")) ); } + @Test + public void t1() { + PPKtIndividualInfoGenerator generator = new PpktIndividualGerman(); + + String expected = "Die Probandin war eine 46 Jahre alte Frau. Der Krankheitsbeginn trat im Säuglingsalter auf."; + PpktIndividual ppkti = female46yearsInfantileOnset(); + String desc = generator.getIndividualDescription(ppkti); + assertEquals(expected,desc); + } + + @ParameterizedTest