ehrbase / openEHR_SDK

A SDK to facilitate the development of openEHR applications
Other
48 stars 28 forks source link

Null Pointer Exceptions #25

Closed birgerhaarbrandt closed 4 years ago

birgerhaarbrandt commented 4 years ago

Please find attached a Cornoa Anamnese template. When trying to create the instance:

  public static CoronaAnamneseComposition buildCoronaAnamnese(){

        CoronaAnamneseComposition composition = new CoronaAnamneseComposition();
        composition.setLanguage(Language.DE);
        composition.setTerritory(Territory.DE);
        composition.setCategoryDefiningcode(CategoryDefiningcode.EVENT);
        composition.setComposer(new PartyIdentified(null, "Test", null));
        composition.setStartTimeValue(OffsetDateTime.of(2020, 04, 02, 12, 00, 00, 00, ZoneOffset.UTC));
        composition.setSettingDefiningcode(SettingDefiningcode.NURSINGHOMECARE);

        AnzeichenObservation observation = new AnzeichenObservation();
        observation.setSubject(new PartySelf());
        observation.setLanguage(Language.DE);
        observation.setBezeichnungDesSymptomsOderAnzeichensValue("Husten");
        observation.setOriginValue(OffsetDateTime.of(2020, 04, 02, 12, 00, 00, 00, ZoneOffset.UTC));
        observation.setTimeValue(OffsetDateTime.of(2020, 04, 02, 12, 00, 00, 00, ZoneOffset.UTC));
        observation.setVorhandenDefiningcode(VorhandenDefiningcode.NICHTVORHANDEN);

        AdHocUberschriftSection symptomeSection = new AdHocUberschriftSection();
        symptomeSection.setAnzeichen(observation);

        composition.setAdHocUberschrift(symptomeSection);

        //Set patient history
        HistorieObservation historyObservation = new HistorieObservation();
        historyObservation.setOriginValue(OffsetDateTime.of(2020, 04, 02, 12, 00, 00, 00, ZoneOffset.UTC));
        historyObservation.setSubject(new PartySelf());
        historyObservation.setLanguage(Language.DE);

        GeschichteHistorieBeliebigesEreignisPointEvent event = new GeschichteHistorieBeliebigesEreignisPointEvent();
        event.setTimeValue(OffsetDateTime.of(2020, 04, 02, 12, 00, 00, 00, ZoneOffset.UTC));
        GeschichteHistorieGeschichteElement geschichteElement = new GeschichteHistorieGeschichteElement();
        geschichteElement.setValue("Patient fuhr zum Skifahren nach Ischgl und kam krank zurück");

        List<GeschichteHistorieGeschichteElement> geschichtEventListe = new ArrayList<>();
        geschichtEventListe.add(geschichteElement);
        event.setGeschichte(geschichtEventListe);

        List<GeschichteHistorieBeliebigesEreignisChoice> historyObservationList = new ArrayList<>();
        historyObservationList.add(event);
        historyObservation.setBeliebigesEreignis(historyObservationList);

        List<HistorieObservation> historyObservations = new ArrayList<>();
        historyObservations.add(historyObservation);

        composition.setHistorie(historyObservations);

        //Allgemeine Angaben

        AdHocUberschriftSection4 section4 = new AdHocUberschriftSection4();

        DiagnoseEvaluationProblem diagnose = new DiagnoseEvaluationProblem();
        diagnose.setDerDiagnoseValue("Freitextdiagnose");
        diagnose.setLanguage(Language.DE);
        diagnose.setSubject(new PartySelf());

        List<AdresseDiagnoseChoice> diagnoseEvaluationList = new ArrayList<>();
        diagnoseEvaluationList.add(diagnose);
        section4.setDiagnose(diagnoseEvaluationList);
        composition.setAdHocUberschrift(section4);

        return composition;
    }

I get the following exception:

java.lang.NullPointerException
    at org.ehrbase.client.flattener.Unflattener.setValueAtPath(Unflattener.java:102)
    at org.ehrbase.client.flattener.Unflattener.lambda$mapDtoToEntity$1(Unflattener.java:88)
    at java.base/java.util.HashMap.forEach(HashMap.java:1336)
    at org.ehrbase.client.flattener.Unflattener.mapDtoToEntity(Unflattener.java:88)
    at org.ehrbase.client.flattener.Unflattener.handleSingleValue(Unflattener.java:196)
    at org.ehrbase.client.flattener.Unflattener.setValueAtPath(Unflattener.java:113)
    at org.ehrbase.client.flattener.Unflattener.lambda$mapDtoToEntity$1(Unflattener.java:88)
    at java.base/java.util.HashMap.forEach(HashMap.java:1336)
    at org.ehrbase.client.flattener.Unflattener.mapDtoToEntity(Unflattener.java:88)
    at org.ehrbase.client.flattener.Unflattener.unflatten(Unflattener.java:82)
    at org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestCompositionEndpoint.mergeCompositionEntity(DefaultRestCompositionEndpoint.java:51)
    at org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestCompositionEndpointIT.testCoronaAnamnese(DefaultRestCompositionEndpointIT.java:192)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:27)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)

Corona_Anamnese.zip

birgerhaarbrandt commented 4 years ago

Resolved by latest updates