Skip to content

Instantly share code, notes, and snippets.

@jkuester
Created January 25, 2024 21:27
Show Gist options
  • Save jkuester/d36f689b6884718302772168dfe6150d to your computer and use it in GitHub Desktop.
Save jkuester/d36f689b6884718302772168dfe6150d to your computer and use it in GitHub Desktop.
Editing (replacing) CHT contacts via an app form
type name label::en calculation appearance instance::db-doc instance::db-doc-ref relevant
begin_group inputs NO_LABEL   field-list     false()
begin_group contact NO_LABEL          
hidden _id            
end_group contact            
begin_group user NO_LABEL          
hidden facility_id            
hidden name            
hidden fullname            
end_group user            
end_group inputs            
               
begin_group page NO_LABEL   field-list      
begin_group current_favorites NO_LABEL   hidden      
string _id NO_LABEL concat(“favorite_things”, “:”, ../../../inputs/user/name) hidden select-contact type-person      
hidden _rev            
hidden type            
begin_group parent NO_LABEL          
hidden _id            
end_group parent            
hidden name            
hidden color            
hidden animal            
hidden song            
end_group              
begin_group new_favorites Record your new favorites     true    
calculate _id   ../../current_favorites/_id        
calculate _rev   ../../current_favorites/_rev        
calculate type   coalesce(../../current_favorites/type, “person”)        
calculate last_updated_by   .     /enketo_widgets  
begin_group parent NO_LABEL          
calculate _id   coalesce(../../../current_favorites/parent/_id, ${facility_id})        
end_group parent            
calculate name   coalesce(../../current_favorites/name, concat(../../../inputs/user/fullname, “’s Favorite Things”))        
string color What is your favorite color? coalesce(., ../../current_favorites/color)        
string animal What is your favorite animal? coalesce(., ../../current_favorites/animal)        
string song What is your favorite song? coalesce(., ../../current_favorites/song)        
end_group              
end_group page            
               
calculate updated_favorites_doc   .     ${new_favorites}  
calculate patient_uuid   ../inputs/contact/_id        
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment