public void Init(string formId, string encounterTypeId, string mode, string encounterId, string repmode)
        {
            //Load Form + Question Metadata

            if (null == Form)
            {
                Form = _encounterService.LoadForm(new Guid(formId));
                if (null != Form)
                {
                    var formJson = JsonConvert.SerializeObject(Form);
                    _settings.AddOrUpdateValue("client.form", formJson);
                }
            }


            //Load Client and Encounter Type

            var clientJson = _settings.GetValue("client.dto", "");

            if (!string.IsNullOrWhiteSpace(clientJson))
            {
                ClientDTO = JsonConvert.DeserializeObject <ClientDTO>(clientJson);

                // TODO: Partner Obs
                if (ClientDTO.HasPartners)
                {
                    var p = ClientDTO.Partners.First();
                    //b25fd62e-852f-11e7-bb31-be2e44b06b34
                    var pObst = _obsService.GetObs(p, new Guid("b2605964-852f-11e7-bb31-be2e44b06b34"));
                    if (null != pObst && pObst.Count > 0)
                    {
                        _settings.AddOrUpdateValue("client.partner.result",
                                                   pObst.FirstOrDefault().ValueCoded.ToString());
                    }
                    else
                    {
                        _settings.AddOrUpdateValue("client.partner.result", "");
                    }
                }
            }

            var clientEncounterJson = _settings.GetValue("client.encounter.dto", "");

            if (!string.IsNullOrWhiteSpace(clientEncounterJson))
            {
                ClientEncounterDTO = JsonConvert.DeserializeObject <ClientEncounterDTO>(clientEncounterJson);
            }


            //Load or Create Encounter

            if (mode == "new")
            {
                //  New Encounter
                _settings.AddOrUpdateValue("client.form.mode", "new");
                var visitType = repmode == "1" ? VisitType.Repeat : VisitType.Initial;
                Encounter = _encounterService.StartEncounter(ClientEncounterDTO.FormId,
                                                             ClientEncounterDTO.EncounterTypeId, ClientEncounterDTO.ClientId, AppProviderId, AppUserId,
                                                             AppPracticeId, AppDeviceId, null, visitType);
            }
            else
            {
                //  Load Encounter
                _settings.AddOrUpdateValue("client.form.mode", "open");
                Encounter = _encounterService.LoadEncounter(ClientEncounterDTO.FormId,
                                                            ClientEncounterDTO.EncounterTypeId, ClientEncounterDTO.ClientId, true);
            }

            if (null == Encounter)
            {
                throw new ArgumentException("Encounter has not been Initialized");
            }

            //Store Encounter

            var encounterJson = JsonConvert.SerializeObject(Encounter);

            _settings.AddOrUpdateValue("client.encounter", encounterJson);


            //Initialize and store Manifest

            _obsService.Initialize(Encounter);
            Manifest = _obsService.Manifest;
            Manifest.UpdateEncounter(Encounter);
            var manifestJson = JsonConvert.SerializeObject(Manifest);

            _settings.AddOrUpdateValue("client.manifest", manifestJson);



            //Load View

            LoadView();
        }